Changeset 1855480
- Timestamp:
- 04/10/2018 01:59:41 AM (8 years ago)
- Location:
- seo-image-alt-tags/trunk
- Files:
-
- 4 edited
-
classes/class-sit-scripts.php (modified) (1 diff)
-
classes/class-sit-settings.php (modified) (12 diffs)
-
readme.txt (modified) (1 diff)
-
seo-image-alt-tags.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seo-image-alt-tags/trunk/classes/class-sit-scripts.php
r1650354 r1855480 4 4 5 5 class ScriptHandler { 6 /**7 * Enqueue scripts8 */6 /** 7 * Enqueue scripts 8 */ 9 9 10 10 11 public function __construct() { 12 add_action('wp_footer', array($this,'sit_scripts'),5); 13 } 14 public function sit_scripts() { ?> 11 public function __construct() { 12 add_action( 'wp_footer', [ $this, 'sit_scripts' ], 5 ); 13 } 15 14 16 <?php15 public function sit_scripts() { ?> 17 16 18 global $sit_settings; 19 $sit_settings = (array) get_option('sit_settings'); 20 $key = 'disable_clientside_script'; 21 $name = $_SERVER['SERVER_NAME']; 22 //var_dump($name); 23 //var_dump($sit_settings[$key]);//$var = get_option('wc_bom_option'); ?> 17 <?php 24 18 25 <?php if (is_null($sit_settings[$key])) ://$ke//if (is_null($sit_settings[$key])) { echo 'is_null';?> 26 <script type="text/javascript"> 27 28 //jQuery(document).ready(function($) { 29 jQuery(document).ready(function($){ 30 var count = 0; 31 var pathname = window.location.pathname; // Returns path only 32 var url = window.location.href; 33 var pdf; 19 global $sit_settings; 20 $sit_settings = (array) get_option( 'sit_settings' ); 21 $key = 'disable_clientside_script'; 22 $name = $_SERVER['SERVER_NAME']; 23 //var_dump($name); 24 //var_dump($sit_settings[$key]);//$var = get_option('wc_bom_option'); ?> 34 25 35 $("a").each(function() { 26 <?php if ( null === $sit_settings[ $key ] ) ://$ke//if (is_null($sit_settings[$key])) { echo 'is_null';?> 27 <script type="text/javascript"> 36 28 37 29 //jQuery(document).ready(function($) { 30 jQuery(document).ready(function ($) { 31 var count = 0; 32 var pathname = window.location.pathname; // Returns path only 33 var url = window.location.href; 34 var pdf; 38 35 39 if ( ( $(this).attr('href') != '#' ) && ( $(this).attr('href') != null ) ) { 40 41 var url = $(this).attr('href'); 42 43 <?php $key2 = 'enable_pdf_ext'; 44 45 if (!(is_null($sit_settings[$key2]))): ?> 46 47 var pos = url.indexOf('.pdf'); 48 //console.log(pos); 49 if (pos !== -1) { 50 $(this).attr('target', '_blank'); 51 } 52 53 54 <?php endif; 55 56 $key3 = 'enable_seo_links'; 57 58 if (!(is_null($sit_settings[$key3]))): ?> 59 60 var host = window.location.host; 61 var pos = url.indexOf(host); 62 //console.log(host); 63 if (pos === -1) { 64 $(this).attr('target', '_blank'); 65 } 66 67 <?php endif; ?> 68 69 } 70 71 }); //each 72 73 74 <?php $key4 = 'dab_af'; 75 76 if (!(is_null($sit_settings[$key4]))) : ?> 77 if ($.browser.chrome) { 78 //autcomplete_false(); 79 80 $("input").each(function() { 81 82 $(this).attr('autocomplete', 'false'); //FALSE AS OF 2015 83 84 }); // .each 85 86 $("form").each(function() { 87 88 $(this).attr('autocomplete', 'false'); //FALSE AS OF 2015 89 90 }); // .each 91 92 } else { 93 94 $("input").each(function() { 95 96 $(this).attr('autocomplete', 'off'); 36 $("a").each(function () { 97 37 98 38 99 }); // .each 39 if (($(this).attr('href') !== '#') && ($(this).attr('href') != null)) { 100 40 101 $("form").each(function() { 41 var url = $(this).attr('href'); 102 42 103 $(this).attr('autocomplete', 'off');43 <?php $key2 = 'enable_pdf_ext'; 104 44 105 }); // .each45 if (! ( null === $sit_settings[ $key2 ] )): ?> 106 46 107 } // end if 108 <?php endif; ?> 47 var pos = url.indexOf('.pdf'); 48 //console.log(pos); 49 if (pos !== -1) { 50 $(this).attr('target', '_blank'); 51 } 109 52 110 });111 53 112 </script>54 <?php endif; 113 55 114 <?php endif; 56 $key3 = 'enable_seo_links'; 57 58 if (! ( null === $sit_settings[ $key3 ] )): ?> 59 60 var host = window.location.host; 61 var pos = url.indexOf(host); 62 //console.log(host); 63 if (pos === -1) { 64 $(this).attr('target', '_blank'); 65 } 66 67 <?php endif; ?> 68 69 } 70 71 }); //each 72 73 74 }); 75 76 </script> 77 78 <?php endif; 115 79 } 116 80 } 81 117 82 $ss = new ScriptHandler(); -
seo-image-alt-tags/trunk/classes/class-sit-settings.php
r1844418 r1855480 5 5 6 6 } 7 8 7 /** 9 8 * PLUGIN SETTINGS PAGE … … 14 13 */ 15 14 public $sit_settings; 16 17 15 /** 18 16 * Start up 19 17 */ 20 public function __construct() {21 add_action( 'admin_menu', [ $this, 'add_sit_menu_page' ] );22 add_action( 'admin_ init', [ $this, 'page_init' ]);23 24 } 25 18 public function __construct() 19 { 20 add_action( 'admin_menu', array( $this, 'add_sit_menu_page' ) ); 21 add_action( 'admin_init', array( $this, 'page_init' ) ); 22 23 } 26 24 /** 27 25 * Add options page … … 35 33 'manage_options', 36 34 'seo-image-tags', 37 [ $this, 'create_sit_menu_page' ]//,35 array( $this, 'create_sit_menu_page' )//, 38 36 ); 39 37 } … … 73 71 'sit_settings_group', // Option group 74 72 'sit_settings', // Option name 75 [ $this, 'sanitize' ]// Sanitize73 array( $this, 'sanitize' ) // Sanitize 76 74 ); 77 75 … … 79 77 'sit_settings_section', // ID 80 78 '', // Title 81 [ $this, 'sit_info' ], // Callback79 array( $this, 'sit_info' ), // Callback 82 80 'sit-options-admin' // Page 83 81 ); … … 86 84 'sit_option', // ID 87 85 '', // Title 88 [ $this, 'sit_option_callback' ], // Callback86 array( $this, 'sit_option_callback' ), // Callback 89 87 'sit-options-admin', // Page 90 88 'sit_settings_section' // Section … … 92 90 93 91 } 94 95 92 /** 96 93 * Sanitize each setting field as needed … … 99 96 */ 100 97 public function sanitize( $input ) { 101 $new_input = [];102 if ( isset( $input['sit_settings'] ) ) {98 $new_input = array(); 99 if( isset( $input['sit_settings'] ) ) 103 100 $new_input['sit_settings'] = absint( $input['sit_settings'] ); 104 }105 101 106 102 return $input; … … 110 106 public function sit_info() { 111 107 112 $sit_settings = get_option( 'sit_settings' ); 113 114 if ( $sit_settings['update'] == true ) { 115 116 $count = []; 117 $count = batch_update_image_tags( true ); 108 if ($this->sit_settings['update']) { 109 110 $count = array(); 111 $count = batch_update_image_tags(true); 118 112 119 113 echo '<div id="setting-error-settings_updated" class="updated settings-error notice is-dismissible"><p>'; 120 114 121 foreach ( $count as $key => $value ) {122 echo '<strong>' . $key . ':</strong> ' . $value .'<br>';115 foreach( $count as $key => $value ) { 116 echo '<strong>'.$key.':</strong> '.$value.'<br>'; 123 117 } 124 update_option( $sit_settings['update'], true);118 update_option($sit_settings['update'], ''); 125 119 echo '</p></div>'; 126 120 127 } elseif ( $sit_settings['delete']) {128 $count = [];129 $count = batch_update_image_tags( false);121 } elseif ($this->sit_settings['delete']) { 122 $count = array(); 123 $count = batch_update_image_tags(false); 130 124 echo '<div id="setting-error-settings_updated" class="updated settings-error notice is-dismissible"><p>'; 131 125 132 foreach ( $count as $key => $value ) {133 echo '<strong>' . $key . ':</strong> ' . $value .'<br>';126 foreach( $count as $key => $value ) { 127 echo '<strong>'.$key.':</strong> '.$value.'<br>'; 134 128 } 135 update_option( $sit_settings['delete'], true);129 update_option($sit_settings['delete'], ''); 136 130 137 131 echo '</p></div>'; … … 168 162 <fieldset><?php $key = 'update'; ?> 169 163 170 <input class="button button-primary" id='sit_settings[<?php echo $key; ?>]' 171 name="sit_settings[<?php echo $key; ?>]" type="submit" value="Update Empty Tags"/> 164 <input class="button button-primary" id='sit_settings[<?php echo $key; ?>]' name="sit_settings[<?php echo $key; ?>]" type="submit" value="Update Tags" /> 172 165 173 166 174 167 <?php $key = 'delete'; ?> 175 168 176 <input class="button-secondary delete" id='sit_settings[<?php echo $key; ?>]' 177 name="sit_settings[<?php echo $key; ?>]" type="submit" value="Delete All Tags"/> 169 <input class="button-secondary delete" id='sit_settings[<?php echo $key; ?>]' name="sit_settings[<?php echo $key; ?>]" type="submit" value="Delete Tags" /> 178 170 179 171 </fieldset> … … 183 175 184 176 <tr> 185 <th> <?php submit_button( 'Save Settings' ); ?></th> 177 <th scope="row"> 178 Link Targetting 179 </th> 180 <td> 181 <fieldset><?php $key = 'enable_seo_links'; ?> 182 <label for="sit_settings[<?php echo $key; ?>]"> 183 <input id='sit_settings[<?php echo $key; ?>]' name="sit_settings[<?php echo $key; ?>]" type="checkbox" value="1" <?php checked(1, $sit_settings[$key], true ); ?> /> 184 Open external links in new tab. 185 </label> 186 </fieldset> 187 <fieldset><?php $key = 'enable_pdf_ext'; ?> 188 189 <label for="sit_settings[<?php echo $key; ?>]"> 190 <input id='sit_settings[<?php echo $key; ?>]' name="sit_settings[<?php echo $key; ?>]" type="checkbox" value="1" <?php checked(1, $sit_settings[$key], true ); ?> /> 191 Open internal PDFs in a new tab. 192 </label> 193 194 </fieldset> 195 196 197 198 </td> 199 </tr> 200 201 <tr> 202 <th> <?php submit_button('Save Settings'); ?></th> 186 203 187 204 </tr> … … 198 215 } 199 216 200 if ( is_admin() ) {217 if( is_admin() ) 201 218 $sit = new SitSettings(); 202 } 203 204 219 220 -
seo-image-alt-tags/trunk/readme.txt
r1844577 r1855480 4 4 Donate link: andrewgunn.org 5 5 Requires at least: 3.0 6 Tested up to: 4.9. 47 Stable tag: 3.3 6 Tested up to: 4.9.5 7 Stable tag: 3.3.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
seo-image-alt-tags/trunk/seo-image-alt-tags.php
r1844418 r1855480 9 9 * Description: THIS WILL SAVE YOU HOURS. Alt tags are dynamically generated and saved to the database automatically any time an image is uploaded, and improves your SEO score by optimizing image data. 10 10 11 * Version: 3.3 11 * Version: 3.3.1 12 12 * 13 13 * Author: Andrew M. Gunn … … 31 31 include_once( 'classes/class-sit-settings.php' ); 32 32 33 //include_once ('classes/class-sit-scripts.php');33 include_once ('classes/class-sit-scripts.php'); 34 34 35 35 add_filter( 'plugin_action_links', 'sit_settings_link', 10, 5 );
Note: See TracChangeset
for help on using the changeset viewer.