Skip to content

Commit

Permalink
Seperate Markup and Code (#176)
Browse files Browse the repository at this point in the history
* Move HTML Views out of the Logic

Move HTML Views out of the Logic

* WPCS Fixes

WPCS Fixes
  • Loading branch information
namithj authored Nov 12, 2024
1 parent 6bd7a0a commit f6e835d
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 83 deletions.
90 changes: 7 additions & 83 deletions includes/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,89 +314,13 @@ public function the_settings_page() {
],
network_admin_url( 'index.php?page=aspireupdate-settings' )
);
?>
<div class="wrap">
<h1><?php esc_html_e( 'AspireUpdate Settings', 'AspireUpdate' ); ?></h1>
<form id="aspireupdate-settings-form" method="post" action="index.php?page=aspireupdate-settings">
<?php
settings_fields( $this->option_group );
do_settings_sections( 'aspireupdate-settings' );
?>
<p class="submit">
<?php wp_nonce_field( 'aspireupdate-settings' ); ?>
<?php submit_button( '', 'primary', 'submit', false ); ?>

<a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary" ><?php esc_html_e( 'Reset', 'AspireUpdate' ); ?></a>
</p>
</form>
<pre id="voltron">
...................................................................................................:?%,.............................................................................
.................................................................................................,;*%:..............................................................................
...............................................................................................,++?+,...............................................................................
..............................................................................................;**?+.................................................................................
............................................................................................:*+;?;:++++:,...........................................................................
..........................................................................................:*+:;%*++::;;;+++:........................................................................
........................................................................................,+*:,+S*::+%#@#+.,*?........................................................................
......................................................................................,+*;,.,;:;?#@@@%;,;*+,........................................................................
....................................................................................,+*;:..,+?S@@@@@%,.+*,..........................................................................
...................................................................................:*+:*+,;:*#@@@@@@?.;*,...........................................................................
.................................................................................,+*:;?;:?*%.;S@@@@#+.++............................................................................
...............................................................................,*+::?S:;%:,%:,%@@@@#?.++............................................................................
.............................................................................,+*;,*@%,;%:.,%:,?@@@@@%.++............................................................................
............................................................................;*;,+#@?,+%:..,%::%@@@@@?.++............................................................................
..........................................................................:*+,;S@@*,*?,...,%,:S@@@@@?.++............................................................................
........................................................................,**::%@@#;,?%+;;;;+?.:S@@@@@?.;*:;;;:.......................................................................
......................................................................,+*::?##@S::%??;,::::,,;S#####?,,::;;;%;......................................................................
.....................................................................;*;,+S###%,:%??::?SSS%%SS#######SS%SS%:,?+.....................................................................
...................................................................:*;,+S####?,;%%*,+S#####################S;,*+....................................................................
.................................................................:*+::%##S##*,+%?+,*#SSSSSSSSSSSSSSSSSSSSSSSS+,**,..................................................................
...............................................................,+*::?#SSSS#+,*%%;,?#SSSSS?*?#SSSSSSS##%SSSSSSS*,+*,.................................................................
.............................................................,+*:,*SSSSSSS;,?S?::%SSSSSS*,.*@SSSSSSS@S.+SSSSSSS?,;?:.........................................................,;;;;;:
............................................................;*;,+SSSSSS#S::%S?,.???%??%+,.,%#%SSSSSS#S..+SSSSSSS%,:?:.......................................................:%;;;;;S
..........................................................:*+,;%#S%%%%#%,:%?%;:;;;;;:,,,:,,S#%%%%%%S@S,..,;++;;++;:;S;.....................................................,?+,?S+.%
++:::::::::::::::::::::::::::;;.........................:*+,:?SS%%%%%#?,;%:,::::::+%,.,%S,,@S%%%%%%S@#?+;,:+?%*+;;::;:.....................................................;S.+#S*,%
:?*,,,;+++++++++++++++++++++;,*+......................,+*:,*SS%%%%%S#*,*%,.......;?,+*,S%,;@S%%%%%%S@#%%S%?+;:;++;:.................................,+;...................,%;:%SS*,%
..+?;.:%#SSSSSSSSSSSSSSSSSSS%;,?;...................,;*;,*SS%%%%%%S#;,??,.......;?,+@S:;:,*@%%%%%%%S@#%%%%%%S%*;:;+*+;,................:*;..........;%S+..................+?.+#%S*,%
...,+*:.;SS%%%%%%%%%%%%%%%%%%%::?:.................;*;,;%S%%%%%%%SS:,%*........*?,+#SS;..,%#%%%%%%%S@#%%%%%%%%%S%?+;:;+*+:,..........:*+;?*,........;?:*?,...............,S::S%%S*,%
.....:*+,,*SS%%%%%%%%%%%%%%%%S?,+*,..............:*+,:%S%%%%%%%%#%::%+........+?,+#%%#+.,,##%%%%%%%S@#%%%%%%%%%%%%%%%*+::;++;:,....,+*:,;:+?;.......;?:.;%:..............?*,?S%%S*,%
.......+?;.:%#S%%%%%%%%%%%%%%%S*.*+............:++,:?#S%%%%%%%%#?,;%;........+*,+#%%%#?,.,@S%%%%%%%S@#%%%%%%%%%%%%%%%%%%?*;:;+*+::+*;,+%S%;:?*,.....;?:.::?+............;%,:#%%%S*,%
........,+*:.;SS%%%%%%%%%%%%%%%S+.?;.........,+*:,*SS%%%%%%%%S#*.+%:........+*,*#%%%%S%:.+@%%%%%%%%S@#%%%%%%%%%%%%%%%%%%%%S%?;::;;;,:%S%%%S*,+?;....;?:.#*,??,.........,%+,%S%%%S*,%
..........:**,,*SS%%%%%%%%%%%%%SS:,?:......,;*;,+SS%%%%%%%%%S#+,*%:.......,**,*#%%%%%%#;.*#%%%%%%%%S@#%%%%%%%%S@##S%%%%%%%%%%%%?*;;?S%%%%%%S%::?*,..;?:.#S?:+%;........+?,+#%%%%S+,%
...........,;*;.:?#%%%%%%%%%%%%%S%,:%,....;*;,;%S%%%%%%%%%%SS;,*+,.......,**,*#%%%%%%%@+.%#%%%%%%%%%@#%%%%%%%%S@@@@#%%%%%%%%%%%S@@S%????????%S+,+?;.;?:.#%%%;;%+......,%;,S%%%%%S+,%
.............,*?:.+S?????????????S?,;?,.:++,:?S%??????????S@;.;*.........**,*#%???????#?,#S?????????@#????????%@@S????????????S@#%????????????%?::?*;?:.#???%+:?*,....*?,*S?????S;.%
...............:%+.;S?************S*.+?**:,*S%***********SS%?:,?+......,**,*#?********%%;@?*********@#********?S?***********%@#%***************?%+,+S%:.#?***?*:*?:..:%;,S?*****S;.%
................,%+.+S*++++++++++++S;,+:,*S?*++++++++++*S%*+?%;,**....,?*.*#?+++++++++*S*#*++++++++*@#*+++++++++++++++++++?#@%*++++++++?*++++++++?*:;+,.#*++++*?:;%;.*?.??++++++S;.%
.................,%;.*%+;++++;;;;;;+S,.;%%+;;;;;;;;;;;*#?;++;+S+,**,.,?+.*#*;++++++++;;#SS++++++++++##+++++++++++++;;;;;*S@%+;;+++;;;+?@S*;;+++++;+?;...#+++++;+*+:?%%,;?+;;;;;;%;.%
..................:%:,*?;;;;;;;;;;;;*S?%+;;;;;;;;;;;;?S+;;;;;;;%*,**:?+.*#+;;;;;;;;;;;*#@%;;;;;;;;;+##;;;;;;;;;;;;;;;;;?#S*;;;;;;;;;?#@@@@*;;;;;;;;;?*,.#;;;;;;;;**:+;,?*;;;;;;;%;.%
...................;?:,??::::::::::::*+:::::::::::::%S;::::::::;?*,+%;.?#+::::::::::;%@@@*:::::::::+##;::::::::::::::*S#*:::::::::;S@@@@@@#*:::::::::+?:#:::::::::;*;.+?;:::::::%;.%
....................;?,,?*::::::::::::::::::::::::;%?:::::*%;::::??,..?#+::::::::::*#@@@@;:::::::::;#S:::::::::::::::%@*::::::::;?@@@@@@@@@@?::::::::::%@:::::::::::**%+::::::::%;.%
.....................+*,,%*::::::::::::::::::::::+S?:::::*@@%;::::*?:?#+:::::::::;%@@@@@@;:::::::::;##;:::::::::::::::?#?:::::::;S@@@@@@@@@@@+::::::::+#@::::::::::::*?:::::::::?;.%
.....................,**,,S+::::::::::::::::::::*S*:;;;:*#@@@S;;;;:*##+:::::::::*#@@@@@@S;:::::::::;##;::::;;;+::::::::?@S+::::::;?@@@@@@@@#*;;:::::;%%*@;::::::::::::::::::::::*:.%
.......................?+.:%*;;;;;;;;;;;;;;;;;+*SS;;;;;+#@@@@@*+++;*S*;;;;;;;;+S@@@@@@@@%+;;;;;;;;;+@#+;;;;;;+%?;;;;;;;;?@@?+;;;;;;*S@@@@@%+;;;;;;;?S*,:@+;;;;++;;;;;;;;;;;;;;;;?;.%
.......................,?;.:S?+++++++++++++*+*?;,?%*+***%@@@@%***+?S?+++++++*%@@@@@@@@@@?++++++++++*@#*++++++*S@?++++++++?#@S*++++++*%@@#?+++++++*S%:..:@*++++?S?+++++++++++++++%;.%
........................:%;.;S?*************??:,:.*S????*%@@%???*?#%*???????#@@@@@@####@?*??????????@#?*????*?S@#?*****?**?#@@%*????**?%?*??????%S+,**,:@???*%?:*%???***********%;.%
.........................:%:.;#%%%%%%%%%%%%%?,;%?+.;SS%%%%%%%%%%%#S%%%%%%%%SSS%%%%%%%?S#%%%%%%%%%%%%@@%%%%%%%%S@@#%%%%%%%%%%#@@S%%%%%%%%%%%%%%%#%::*%*,:@%%%S?,,,;S%%%%%%%%%%%%%S;.%
..........................:%:.+#SSSSSSSSSSS*,+?,,**,:%#SSSSSSSSS@#SSSSSSSSSS%SSSSSSSSS##SSSSSSSSSS%S@@SSSSSSSSS@@@#SSSSSSSSSS#@@@SS%SSSSSSS%S##+,+*,;*,:@SSSS:,%%::%SSSSSSSSSSSSS;.S
...........................:%,.*#SSSSSSSSS+,**,...+?:,?#SSSSSS#@#SSSSSSSSSSSSSSSSSSSS#@#SSSSSSSSSSS#@@SSSSSSSS#@@@@#SSSSSSSSSS#@@@@SSSSSSSS##?,:*+..;+,:@SS#;,%+;%;,?#SSSSSSSSSS#:.#
............................;?,.?@######S;,?+......:?;.+##S#S#@#S####################@@#S###########@@#SSSSSSS#@@@@@#SSSSSSSSSS#@@@@##S#S#@S;,+*:...;+,:@##*,?*,.,?*,+##SSSSSSS##:.#
.............................+?,,%@####%::?;........,*+.;S###@@#####################@@@#############@@#########@@@@@@############@@@@@###@?,:?+.....;+,:@@?,*?,....*?,;S#########:.#
.............................,**,,%@##?,;?:...........+*,,%@#%%%%%%%%%%%%%%%%%%%%%%%%S@#############@#########################@@@@@@@@@#S+,+?:......;+,,?*,+%,......;?::%########;.#
..............................,*+.,%@*,+*,.............;?:,+:.,,,,,,,,,,,,,,,,,,,,...;##############%,::::::::::::::::::::::::;;;;;;;;;:,:*+,.......;*+;;;+?:........;%+,?######S:.#
...............................,?+.,;,**,...............:?+.,*;;;;;;;;;;;;;;;;;;;+?,.*@@@@@@@@@@@@@@?..**;;;;;;;;;;;;;;;;::::::::::::::::+:.........,::::::,..........:?*,+#@@@@%:.#
................................,%;.,?+..................,**?;...................,#..+@@@@@@@@@@@@@@?..*+..............................................................,*?,:S@@@%:.#
.................................:%+?:.....................;:....................,++,.+#@@@@@@@@@@@@S..*;................................................................;%:,%@@%:.#
..................................:+,..............................................;?:.:S@@@@@@@@@@@%..*+.................................................................:%+,*@S:.#
....................................................................................:?;.,%@@@@@@@@@@+.:?:..................................................................,?*,+?:.#
.....................................................................................,?+.,?@@@@@@@@%,;?;....................................................................,*?:.,.#
......................................................................................,**,.+@@@@@@*,;?:.......................................................................;%;..#
........................................................................................;?:.;#@@#+.+?,.........................................................................:%+.#
.........................................................................................:?;.:S#;.*?,...........................................................................,?*#
..........................................................................................,**,,,,**..............................................................................,*S
............................................................................................+?,,?+.................................................................................,
.............................................................................................;?%;...................................................................................
</pre>
</div>
<?php
Utilities::include_file(
'page-admin-settings.php',
[
'reset_url' => $reset_url,
'option_group' => $this->option_group,
]
);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions includes/class-utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@ public static function get_top_level_domain() {
$domain_parts = explode( '.', $domain_name );
return sanitize_text_field( implode( '.', array_slice( $domain_parts, -2 ) ) );
}

/**
* Return the content of the File after processing.
*
* @param string $file File name.
* @param array $args Data to pass to the file.
*/
public static function include_file( $file, $args = [] ) {
$file_path = __DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $file;
if ( ( '' !== $file ) && file_exists( $file_path ) ) {
//phpcs:disable
// Usage of extract() is necessary in this content to simulate templating functionality.
extract( $args );
//phpcs:enable
include $file_path;
}
}
}
21 changes: 21 additions & 0 deletions includes/views/page-admin-settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace AspireUpdate;

$reset_url = $args['reset_url'] ?? '';
$option_group = $args['option_group'] ?? '';
?>
<div class="wrap">
<h1><?php esc_html_e( 'AspireUpdate Settings', 'AspireUpdate' ); ?></h1>
<form id="aspireupdate-settings-form" method="post" action="index.php?page=aspireupdate-settings">
<?php
settings_fields( $option_group );
do_settings_sections( 'aspireupdate-settings' );
?>
<p class="submit">
<?php wp_nonce_field( 'aspireupdate-settings' ); ?>
<?php submit_button( '', 'primary', 'submit', false ); ?>
<a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary" ><?php esc_html_e( 'Reset', 'AspireUpdate' ); ?></a>
</p>
</form>
<?php Utilities::include_file( 'voltron.txt' ); ?>
</div>
Loading

0 comments on commit f6e835d

Please sign in to comment.