-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from positiwise/dev
ADD: Admin Settings + Plugin Functionalities
- Loading branch information
Showing
9 changed files
with
484 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,86 @@ | ||
/** | ||
* All of the CSS for your admin-specific functionality should be | ||
* included in this file. | ||
*/ | ||
*/ | ||
|
||
.wp_sil_options_fields { | ||
padding: 2rem; | ||
} | ||
|
||
.wp_sil_nevigation_links { | ||
background: #fff; | ||
} | ||
|
||
.wp_sil_setting_row { | ||
max-height: 25rem; | ||
overflow: auto; | ||
} | ||
|
||
.wp_sil_nevigation_links .navigation_link_wrap { | ||
display: inline-block; | ||
padding: 1rem; | ||
border-right: thin solid #e2e2e2; | ||
} | ||
|
||
.wp_sil_nevigation_links a, | ||
.wp_sil_nevigation_links a:active, | ||
.wp_sil_nevigation_links a:focus { | ||
text-decoration: none; | ||
box-shadow: none; | ||
} | ||
|
||
.wp_sil_options_fields { | ||
background: #f4f4f4; | ||
} | ||
|
||
.wp_sil_options_fields .wp_sil_options_save_button { | ||
margin-top: 1rem; | ||
} | ||
|
||
.wp_sil_add_row { | ||
padding: 1rem 0; | ||
} | ||
|
||
.wp_sil_setting_rows { | ||
margin-top: 1rem; | ||
} | ||
|
||
.wp_sil_add_row a, | ||
.wp_sil_add_row a:active | ||
.wp_sil_add_row a:focus { | ||
text-decoration: none; | ||
box-shadow: none; | ||
cursor: pointer; | ||
} | ||
|
||
.wp_sil_keyword{ | ||
width: 20rem; | ||
} | ||
|
||
.wp_sil_link{ | ||
width: 45rem; | ||
} | ||
|
||
.wp_sil_priority { | ||
margin: 0 2em !important; | ||
} | ||
|
||
.wp_sil_setting_table th { | ||
text-align: left; | ||
} | ||
|
||
.wp_sil_info_help { | ||
display: inline-table; | ||
color: #fff; | ||
background-color: #000; | ||
border-radius: 100%; | ||
height: 20px; | ||
width: 20px; | ||
text-align: center; | ||
cursor: pointer; | ||
} | ||
|
||
.wp_sil_core_settings td select, | ||
.wp_sil_core_settings td input[type=number] { | ||
width: 15rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
admin/partials/wordpress-seo-internal-linking-admin-settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
class Wordpress_Seo_Internal_Linking_Admin_Settings { | ||
|
||
private $wp_sil_nevigation_links; | ||
|
||
public function __construct(){ | ||
|
||
$page_link = "?page=wp-seo-internal-linking-plugin"; | ||
|
||
$this->wp_sil_nevigation_links = [ | ||
"Settings" => $page_link, | ||
"Keywords" => $page_link . "&tab=keywords-links", | ||
"Import / Export" => $page_link . "&tab=import-export", | ||
]; | ||
|
||
} | ||
|
||
public function addAdminSettings(){ | ||
add_options_page( | ||
'WP SEO Internal Linking Settings', | ||
'WP SEO Internal Linking Settings', | ||
'manage_options', | ||
'wp-seo-internal-linking-plugin', | ||
array( $this, 'renderPluginSettings' ) | ||
); | ||
} | ||
|
||
public function renderPluginSettings(){ | ||
?> | ||
<div class="wrap wp_sil_options_head_wrap"> | ||
<h2><?php _e( "WordPress SEO Internal Linking Settings", "wordpress-seo-internal-linking" ); ?></h2> | ||
<p>Configure Plugin Settings Here</p> | ||
<div class="wp_sil_nevigation_links"> | ||
<?php | ||
foreach( $this->wp_sil_nevigation_links as $nevigation_link => $nevigation_url ){ | ||
echo "<a href='" . $nevigation_url . "'><div class='navigation_link_wrap'>" . $nevigation_link . "</div></a>"; | ||
} | ||
?> | ||
</div> | ||
</div> | ||
<?php | ||
if ( isset( $_GET['tab'] ) && 'import-export' == $_GET['tab'] ) { | ||
|
||
require_once 'wordpress-seo-internal-linking-settings-import-export.php'; | ||
$import_export_page = new Wordpress_Seo_Internal_Linking_Settings_Import_Export(); | ||
$import_export_page->renderImportExport(); | ||
|
||
} else if ( isset( $_GET['tab'] ) && 'keywords-links' == $_GET['tab'] ) { | ||
|
||
require_once 'wordpress-seo-internal-linking-keywords.php'; | ||
$import_export_page = new WordpressSeoInternalLinkingKeywords(); | ||
$import_export_page->renderKeywordsSettings(); | ||
|
||
} else { | ||
|
||
require_once 'wordpress-seo-internal-linking-core-settings.php'; | ||
$import_export_page = new WordpressSeoInternalLinkingCoreSettings(); | ||
$import_export_page->renderCoreSettings(); | ||
|
||
} | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
admin/partials/wordpress-seo-internal-linking-core-settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
class WordpressSeoInternalLinkingCoreSettings | ||
{ | ||
private $wp_sil_core_options; | ||
|
||
public function __construct() { | ||
if( isset( $_POST['wp_sil_core_settings'] ) ) { | ||
$this->saveWpSilOptions( $_POST['wp_sil_core_settings'] ); | ||
} | ||
|
||
$this->wp_sil_core_options = get_option( 'wp_sil_plugin_core_options' ); | ||
|
||
} | ||
|
||
public function renderCoreSettings() { | ||
|
||
$trubleshoot = ( isset( $this->wp_sil_core_options['trubleshoot'] ) ) ? $this->wp_sil_core_options['trubleshoot'] : ""; | ||
$target = ( isset( $this->wp_sil_core_options['target'] ) ) ? $this->wp_sil_core_options['target'] : ""; | ||
$count = ( isset( $this->wp_sil_core_options['count'] ) ) ? $this->wp_sil_core_options['count'] : "2"; | ||
|
||
?> | ||
<div class="wrap"> | ||
|
||
<form action="" method="post"> | ||
<div class="wp_sil_options_fields" data-key="<?php echo $last_key ?? 0; ?>"> | ||
<table class="wp_sil_setting_table wp_sil_core_settings"> | ||
|
||
<tr class="wp_sil_setting_row"> | ||
<th> | ||
<div>Enable Trubleshooting?</div> | ||
</th> | ||
<td> | ||
<input type="checkbox" name="wp_sil_core_settings[trubleshoot]" <?php echo ( "on" == $trubleshoot ) ? 'checked="checked"' : "" ; ?> /> | ||
<span class="wp_sil_info_help" title="This will temporarily remove all linkings until unchecked and saved.">?</span> | ||
</td> | ||
</tr> | ||
|
||
<tr class="wp_sil_setting_row"> | ||
<th> | ||
<div>Target</div> | ||
</th> | ||
<td> | ||
<select name="wp_sil_core_settings[target]"> | ||
<option value="" <?php echo ( "" == $target ) ? 'selected="selected"' : ''; ?>>Same Window</option> | ||
<option value="_blank" <?php echo ( "_blank" == $target ) ? 'selected="selected"' : ''; ?>>New Window</option> | ||
</select> | ||
</td> | ||
</tr> | ||
<tr class="wp_sil_setting_row"> | ||
<th> | ||
<div>Number of Target Keywords</div> | ||
</th> | ||
<td> | ||
<input type="number" name="wp_sil_core_settings[count]" placeholder="Number of Target Keywords" value="<?php echo $count; ?>" name="wp_sil_core_settings" /> | ||
<span class="wp_sil_info_help" title="Maximum how many keywords do you want to target in each paragraph?">?</span> | ||
</td> | ||
</tr> | ||
|
||
</table> | ||
<div class="wp_sil_options_save_button"> | ||
<input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save Core Settings' ); ?>" /> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
|
||
public function saveWpSilOptions( $coreOptions ) { | ||
if( update_option( 'wp_sil_plugin_core_options', $coreOptions ) ) { | ||
add_action( 'admin_notices', function() { | ||
?> | ||
<div class="notice notice-success is-dismissible"> | ||
<p><?php _e( 'Settings Saved Successfully!', 'wordpress-seo-internal-linking' ); ?></p> | ||
</div> | ||
<?php | ||
} ); | ||
} | ||
} | ||
|
||
} |
83 changes: 83 additions & 0 deletions
83
admin/partials/wordpress-seo-internal-linking-keywords.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
class WordpressSeoInternalLinkingKeywords | ||
{ | ||
|
||
private $wp_sil_options; | ||
|
||
public function __construct() { | ||
if( isset( $_POST['wp_sil_plugin_options'] ) ) { | ||
$this->saveWpSilOptions( $_POST['wp_sil_plugin_options'] ); | ||
} | ||
|
||
$this->wp_sil_options = get_option( 'wp_sil_plugin_options' ); | ||
} | ||
|
||
public function renderKeywordsSettings() { | ||
$options = $this->wp_sil_options; | ||
$keywords = ( isset( $options['keyword'] ) && !empty( $options['keyword'] ) ) ? $options['keyword'] : []; | ||
$links = ( isset( $options['link'] ) && !empty( $options['link'] ) ) ? $options['link'] : []; | ||
$priority = ( isset( $options['priority'] ) && !empty( $options['priority'] ) ) ? $options['priority'] : []; | ||
|
||
$last_key = array_key_last( $keywords ); | ||
|
||
?> | ||
<div class="wrap"> | ||
|
||
<form action="" method="post"> | ||
<div class="wp_sil_options_fields" data-key="<?php echo $last_key ?? 0; ?>"> | ||
<table class="wp_sil_setting_table"> | ||
<tr> | ||
<td>Keyword</td> | ||
<td>URL</td> | ||
<td>Priority?</td> | ||
</tr> | ||
<?php if( "" === $options ){ ?> | ||
<tr class="wp_sil_setting_row"> | ||
<td> | ||
<input class='wp_sil_keyword' name='wp_sil_plugin_options[keyword][0]' type='text' placeholder='Keyword' /> | ||
</td> | ||
<td> | ||
<input class='wp_sil_link' name='wp_sil_plugin_options[link][0]' type='url' placeholder='Link URL' /> | ||
</td> | ||
<td> | ||
<input class='wp_sil_priority' name='wp_sil_plugin_options[priority][0]' type='checkbox' /> | ||
</td> | ||
</tr> | ||
<?php } ?> | ||
<?php foreach( $keywords as $key => $word ) { ?> | ||
<tr class="wp_sil_setting_row" id="<?php echo $key; ?>"> | ||
<td> | ||
<input class='wp_sil_keyword' name='wp_sil_plugin_options[keyword][<?php echo $key; ?>]' type='text' placeholder='Keyword' value='<?php echo $keywords[$key]; ?>' /> | ||
</td> | ||
<td> | ||
<input class='wp_sil_link' name='wp_sil_plugin_options[link][<?php echo $key; ?>]' type='url' placeholder='Link URL' value='<?php echo $links[$key]; ?>' /> | ||
</td> | ||
<td> | ||
<input class='wp_sil_priority' name='wp_sil_plugin_options[priority][<?php echo $key; ?>]' type='checkbox' <?php echo ( isset( $priority[$key] ) && "on" == $priority[$key] ) ? 'checked=checked' : ''; ?> /> | ||
</td> | ||
<?php if( 0 !== $key ) { ?> | ||
<td> | ||
<a class='wp_sil_remove_row button button-secondary' data-rem-id='<?php echo $key; ?>'>- Remove</a> | ||
</td> | ||
<?php } ?> | ||
</tr> | ||
<?php } ?> | ||
|
||
</table> | ||
<div class="wp_sil_add_row"> | ||
<a class='button button-secondary'>+ Add Row</a> | ||
</div> | ||
<div class="wp_sil_options_save_button"> | ||
<input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save Keywords Settings' ); ?>" /> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
|
||
public function saveWpSilOptions( $options ){ | ||
update_option( 'wp_sil_plugin_options', $options ); | ||
} | ||
} |
Oops, something went wrong.