phpQuery
13 years ago
wp-plugin-dev-classes
13 years ago
admin-external-links.php
13 years ago
class-admin-external-links.php
13 years ago
class-wp-external-links.php
13 years ago
phpQuery.php
13 years ago
admin-external-links.php
512 lines
| 1 | <?php defined( 'ABSPATH' ) OR die( 'No direct access.' ); |
| 2 | |
| 3 | /** |
| 4 | * Class Admin_External_Links |
| 5 | * @category WordPress Plugins |
| 6 | */ |
| 7 | final class Admin_External_Links { |
| 8 | |
| 9 | /** |
| 10 | * Used as text domain (for translations) |
| 11 | * @var string |
| 12 | */ |
| 13 | protected $domain = 'wp_external_links'; |
| 14 | |
| 15 | /** |
| 16 | * Options to be saved and their default values |
| 17 | * @var array |
| 18 | */ |
| 19 | protected $save_options = array( |
| 20 | 'general' => array( |
| 21 | 'target' => '_none', |
| 22 | 'use_js' => 1, |
| 23 | 'external' => 1, |
| 24 | 'nofollow' => 1, |
| 25 | 'title' => '%title%', |
| 26 | 'filter_page' => 1, |
| 27 | 'filter_posts' => 1, |
| 28 | 'filter_comments' => 1, |
| 29 | 'filter_widgets' => 1, |
| 30 | 'class_name' => 'ext-link', |
| 31 | 'filter_excl_sel' => '.excl-ext-link', |
| 32 | ), |
| 33 | 'style' => array( |
| 34 | 'icon' => 0, |
| 35 | 'no_icon_class' => 'no-ext-icon', |
| 36 | 'no_icon_same_window' => 0, |
| 37 | ), |
| 38 | 'screen' => array( |
| 39 | 'menu_position' => NULL, |
| 40 | ), |
| 41 | ); |
| 42 | |
| 43 | /** |
| 44 | * Meta box page object |
| 45 | * @var WP_Meta_Box_Page |
| 46 | */ |
| 47 | public $meta_box_page = NULL; |
| 48 | |
| 49 | /** |
| 50 | * Ajax form object |
| 51 | * @var WP_Ajax_Option_Form |
| 52 | */ |
| 53 | public $form = NULL; |
| 54 | |
| 55 | /** |
| 56 | * Location of the plugin file |
| 57 | * @var string |
| 58 | */ |
| 59 | protected $plugin_file = NULL; |
| 60 | |
| 61 | |
| 62 | /** |
| 63 | * Constructor |
| 64 | * @param string $file Location of the plugin file |
| 65 | */ |
| 66 | public function __construct( $plugin_file = NULL ) { |
| 67 | // set location of plugin file |
| 68 | $this->plugin_file = ( $plugin_file === NULL ) ? __FILE__ : $plugin_file; |
| 69 | |
| 70 | // set meta box page |
| 71 | $this->meta_box_page = new WP_Meta_Box_Page_01(); |
| 72 | |
| 73 | // set ajax forms (also used by front-end) |
| 74 | $this->form = new WP_Option_Forms_01( $this->domain, $this->save_options ); |
| 75 | |
| 76 | // init admin |
| 77 | if ( is_admin() ) |
| 78 | $this->init(); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Initialize Admin |
| 83 | */ |
| 84 | public function init() { |
| 85 | // load text domain for translations |
| 86 | load_plugin_textdomain( $this->domain, FALSE, dirname( plugin_basename( $this->plugin_file ) ) . '/lang/' ); |
| 87 | |
| 88 | // set activation hook |
| 89 | register_activation_hook( $this->plugin_file, array( $this, 'call_activation' ) ); |
| 90 | |
| 91 | // set deactivation hook |
| 92 | register_deactivation_hook( $this->plugin_file, array( $this, 'call_deactivation' ) ); |
| 93 | |
| 94 | // set options for add_page_method |
| 95 | $menu_pos = $this->form->set_current_option( 'screen' )->value( 'menu_position' ); |
| 96 | |
| 97 | // init meta box page |
| 98 | $this->meta_box_page->init( |
| 99 | // settings |
| 100 | array( |
| 101 | 'menu_title' => $this->__( 'External Links' ), |
| 102 | 'page_slug' => strtolower( $this->domain ), |
| 103 | 'add_page_method' => ( ! empty( $menu_pos ) AND $menu_pos != 'admin.php' ) ? 'add_submenu_page' : 'add_menu_page', |
| 104 | 'parent_slug' => ( ! empty( $menu_pos ) AND $menu_pos != 'admin.php' ) ? $menu_pos : NULL, |
| 105 | 'column_widths' => array( |
| 106 | 1 => array( 99 ), |
| 107 | 2 => array( 69, 29 ), |
| 108 | ), |
| 109 | 'icon_url' => plugins_url( 'images/icon-wp-external-links-16.png', $this->plugin_file ), |
| 110 | ), |
| 111 | // load callback |
| 112 | array( $this, 'call_load_meta_box' ) |
| 113 | ); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Translate text in current domain |
| 118 | * @param string $text |
| 119 | * @return string |
| 120 | */ |
| 121 | public function __( $text ) { |
| 122 | return translate( $text, $this->domain ); |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Translate text in current domain |
| 127 | * @param string $text |
| 128 | * @return string |
| 129 | */ |
| 130 | public function _e( $text ) { |
| 131 | echo translate( $text, $this->domain ); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Load meta box action |
| 136 | */ |
| 137 | public function call_load_meta_box( $meta_box ) { |
| 138 | // add filters |
| 139 | $meta_box->add_title_filter( array( $this, 'call_page_title' ) ) |
| 140 | ->add_screen_settings_filter( array( $this, 'call_screen_settings' ) ) |
| 141 | ->add_contextual_help_filter( array( $this, 'call_contextual_help' ) ); |
| 142 | |
| 143 | // add meta boxes |
| 144 | // add_meta_box( $title, $callback, $context = 'normal', $id = NULL, $priority = 'default', $callback_args = NULL ) |
| 145 | $meta_box->add_meta_box( $this->__( 'General Settings' ), array( $this, 'call_box_general_settings' ), 1 ) |
| 146 | ->add_meta_box( $this->__( 'Style Settings' ), array( $this, 'call_box_style_settings' ), 1 ) |
| 147 | ->add_meta_box( $this->__( 'About this Plugin' ), array( $this, 'call_box_about' ), 2 ) |
| 148 | ->add_meta_box( $this->__( 'Other Plugins' ), array( $this, 'call_box_other_plugins' ), 2 ); |
| 149 | |
| 150 | // stylesheets |
| 151 | wp_enqueue_style( 'jquery-tipsy', plugins_url( 'css/tipsy.css', $this->plugin_file ), FALSE, WP_EXTERNAL_LINKS_VERSION ); |
| 152 | |
| 153 | // scripts |
| 154 | wp_enqueue_script( 'jquery-tipsy', plugins_url( '/js/jquery.tipsy.js', $this->plugin_file ), array( 'jquery' ), WP_EXTERNAL_LINKS_VERSION ); |
| 155 | wp_enqueue_script( 'admin-external-links', plugins_url( '/js/admin-external-links.js', $this->plugin_file ), array( 'postbox', 'option-forms' ), WP_EXTERNAL_LINKS_VERSION ); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Screen settings |
| 160 | * @param string $content |
| 161 | * @return string |
| 162 | */ |
| 163 | public function call_screen_settings( $content ) { |
| 164 | $content .= '<h5>'. $this->__( 'Menu Setting' ) .'</h5>' . "\n"; |
| 165 | $content .= '<div class="extra-prfs">' . "\n"; |
| 166 | $content .= $this->__( 'Admin menu position' ) . ': ' . "\n"; |
| 167 | $content .= $this->form->open_screen_option( 'screen', 'menu_position' ); |
| 168 | $content .= $this->form->select( 'menu_position', array( |
| 169 | 'admin.php' => 'Main menu', |
| 170 | 'index.php' => $this->__( 'Subitem of Dashboard' ), |
| 171 | 'edit.php' => $this->__( 'Subitem of Posts' ), |
| 172 | 'upload.php' => $this->__( 'Subitem of Media' ), |
| 173 | 'link-manager.php' => $this->__( 'Subitem of Links' ), |
| 174 | 'edit.php?post_type=page' => $this->__( 'Subitem of Pages' ), |
| 175 | 'edit-comments.php' => $this->__( 'Subitem of Comments' ), |
| 176 | 'themes.php' => $this->__( 'Subitem of Appearance' ), |
| 177 | 'plugins.php' => $this->__( 'Subitem of Plugins' ), |
| 178 | 'users.php' => $this->__( 'Subitem of Users' ), |
| 179 | 'tools.php' => $this->__( 'Subitem of Tools' ), |
| 180 | 'options-general.php' => $this->__( 'Subitem of Settings' ), |
| 181 | )) . "\n"; |
| 182 | $content .= '</div>' . "\n"; |
| 183 | |
| 184 | return $content; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Contextual_help (callback) |
| 189 | * @param string $content |
| 190 | * @return string |
| 191 | */ |
| 192 | public function call_contextual_help( $content ) { |
| 193 | $help = ''; |
| 194 | $help .= $this->meta_box_page->get_ob_callback( array( $this, 'call_box_about' ) ); |
| 195 | $help .= $this->hr(); |
| 196 | $help .= '<h4><img src="'. plugins_url( 'images/icon-wp-16.gif', $this->plugin_file ) .'" width="16" height="16" /> ' |
| 197 | . $this->__( 'WordPress' ) .'</h4>'; |
| 198 | return $help . $content; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Add icon to page title |
| 203 | * @return string |
| 204 | */ |
| 205 | public function call_page_title( $title ) { |
| 206 | // when updated set update message |
| 207 | if ( $_GET[ 'settings-updated' ] == 'true' ) { |
| 208 | $title .= '<div class="updated settings-error" id="setting-error-settings_updated" style="display:none">' |
| 209 | . '<p><strong>' . __( 'Settings saved.' ) .'</strong></p>' |
| 210 | . '</div>'; |
| 211 | } |
| 212 | |
| 213 | $title = '<div class="icon32" id="icon-options-custom" style="background:url( '. plugins_url( 'images/icon-wp-external-links-32.png', $this->plugin_file ) .' ) no-repeat 50% 50%"><br></div>' |
| 214 | . $title; |
| 215 | |
| 216 | return $title; |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Meta Box: General Settings |
| 221 | */ |
| 222 | public function call_box_general_settings() { |
| 223 | echo $this->form->set_current_option( 'general' )->open_form(); |
| 224 | ?> |
| 225 | <fieldset class="options"> |
| 226 | <table class="form-table"> |
| 227 | <tr> |
| 228 | <th style="width:300px;"><?php $this->_e( 'Set <code>target</code> for external links' ) ?> |
| 229 | <?php echo $this->tooltip_help( 'Specify the target (window or tab) for opening external links.' ) ?></th> |
| 230 | <td class="target_external_links"> |
| 231 | <label><?php echo $this->form->radio( 'target', '_blank', array( 'class' => 'field_target' ) ); ?> |
| 232 | <span><?php $this->_e( '<code>_blank</code>, new window' ) ?></span></label> |
| 233 | <?php echo $this->tooltip_help( 'Open every external link in a new window or tab.' ) ?> |
| 234 | <br/> |
| 235 | <label><?php echo $this->form->radio( 'target', '_top', array( 'class' => 'field_target' ) ); ?> |
| 236 | <span><?php $this->_e( '<code>_top</code>, topmost frame' ) ?></span></label> |
| 237 | <?php echo $this->tooltip_help( 'Open in current window or tab, when framed in the topmost frame.' ) ?> |
| 238 | <br/> |
| 239 | <label><?php echo $this->form->radio( 'target', '_new', array( 'class' => 'field_target' ) ); ?> |
| 240 | <span><?php $this->_e( '<code>_new</code>, seperate window' ) ?></span></label> |
| 241 | <?php echo $this->tooltip_help( 'Open new window the first time and use this window for each external link.' ) ?> |
| 242 | <br/> |
| 243 | <label><?php echo $this->form->radio( 'target', '_none', array( 'class' => 'field_target' ) ); ?> |
| 244 | <span><?php $this->_e( '<code>_none</code>, current window' ) ?></span></label> |
| 245 | <?php echo $this->tooltip_help( 'Open in current window or tab, when framed in the same frame.' ) ?> |
| 246 | </td> |
| 247 | </tr> |
| 248 | <tr> |
| 249 | <th><?php $this->_e( 'Add to <code>rel</code>-attribute' ) ?> |
| 250 | <?php echo $this->tooltip_help( 'Set values for the "rel"-atribute of external links.' ) ?></th> |
| 251 | <td><label><?php echo $this->form->checkbox( 'external', 1 ); ?> |
| 252 | <span><?php $this->_e( 'Add <code>"external"</code>' ) ?></span></label> |
| 253 | <?php echo $this->tooltip_help( 'Add "external" to the "rel"-attribute of external links.' ) ?> |
| 254 | <br/><label><?php echo $this->form->checkbox( 'nofollow', 1 ); ?> |
| 255 | <span><?php $this->_e( 'Add <code>"nofollow"</code>' ) ?></span></label> |
| 256 | <?php echo $this->tooltip_help( 'Add "nofollow" to the "rel"-attribute of external links (unless link already has "follow").' ) ?> |
| 257 | </td> |
| 258 | </tr> |
| 259 | <tr> |
| 260 | <th><?php $this->_e( 'Add to <code>class</code>-attribute' ) ?> |
| 261 | <?php echo $this->tooltip_help( 'Add one or more extra classes to the external links, seperated by a space. It is optional, else just leave field blank.' ) ?></th> |
| 262 | <td><label><?php echo $this->form->text( 'class_name' ); ?></label></td> |
| 263 | </tr> |
| 264 | <tr> |
| 265 | <th><?php $this->_e( 'Set <code>title</code>-attribute' ) ?> |
| 266 | <?php echo $this->tooltip_help( 'Set title attribute for external links. Use %title% for the original title value.' ) ?></th> |
| 267 | <td><label><?php echo $this->form->text( 'title' ); ?> |
| 268 | <span class="description"><?php _e( 'Use <code>%title%</code> for the original title value.' ) ?></span></label></td> |
| 269 | </tr> |
| 270 | </table> |
| 271 | |
| 272 | <?php echo $this->hr(); ?> |
| 273 | |
| 274 | <table class="form-table"> |
| 275 | <tr> |
| 276 | <th style="width:300px;"><?php $this->_e( 'Valid XHTML Strict' ) ?> |
| 277 | <?php echo $this->tooltip_help( 'The "target"-attribute is not valid XHTML strict code. Enable this option to remove the target from external links and use the JavaScript method (built-in this plugin) for opening links.' ) ?></th> |
| 278 | <td> |
| 279 | <label><?php echo $this->form->checkbox( 'use_js', 1, array( 'class' => 'field_use_js' ) ); ?> |
| 280 | <span><?php $this->_e( 'Use JavaScript for opening links in given target, instead of setting <code>target</code>-attribute <em>(recommended)</em>' ) ?></span></label> |
| 281 | </td> |
| 282 | </tr> |
| 283 | </table> |
| 284 | |
| 285 | <?php echo $this->hr(); ?> |
| 286 | |
| 287 | <table class="form-table"> |
| 288 | <tr> |
| 289 | <th style="width:300px;"><?php $this->_e( 'Apply settings to external links on...' ) ?> |
| 290 | <?php echo $this->tooltip_help( 'Choose contents for applying settings to external links.' ) ?></th> |
| 291 | <td> |
| 292 | <label><?php echo $this->form->checkbox( 'filter_page', 1 ); ?> |
| 293 | <span><?php $this->_e( 'All contents' ) ?></span></label> |
| 294 | <br/> <label><?php echo $this->form->checkbox( 'filter_posts', 1 ); ?> |
| 295 | <span><?php $this->_e( 'Post contents' ) ?></span></label> |
| 296 | <br/> <label><?php echo $this->form->checkbox( 'filter_comments', 1 ); ?> |
| 297 | <span><?php $this->_e( 'Comments' ) ?></span></label> |
| 298 | <br/> <label><?php echo $this->form->checkbox( 'filter_widgets', 1 ); ?> |
| 299 | <span><?php |
| 300 | if ( self::check_widget_content_filter() ): |
| 301 | $this->_e( 'All widgets' ); |
| 302 | echo $this->tooltip_help( 'Applied to all widgets by using the "widget_content" filter of the Widget Logic plugin' ); |
| 303 | else: |
| 304 | $this->_e( 'All text widgets' ); |
| 305 | echo $this->tooltip_help( 'Only the text widget will be applied. To apply to all widget you should select "All contents" option.' ); |
| 306 | endif; |
| 307 | ?></span></label> |
| 308 | </td> |
| 309 | </tr> |
| 310 | <tr class="filter_excl_sel"> |
| 311 | <th><?php $this->_e( 'Do NOT apply settings on...' ) ?> |
| 312 | <?php echo $this->tooltip_help( 'The external links of these selection will be excluded for the settings of this plugin. Define the selection by using CSS selectors.' ) ?></th> |
| 313 | <td><label><?php echo $this->form->textarea( 'filter_excl_sel' ); ?> |
| 314 | <span class="description"><?php _e( 'Define selection by using CSS selectors, f.e.: <code>.excl-ext-link, .entry-title, #comments-title</code> (look <a href="http://code.google.com/p/phpquery/wiki/Selectors" target="_blank">here</a> for available selectors).' ) ?></span></label> |
| 315 | </td> |
| 316 | </tr> |
| 317 | </table> |
| 318 | </fieldset> |
| 319 | |
| 320 | <p style="position:absolute;"><a id="admin_menu_position" href="#"><?php _e( 'Change menu position in "Screen Options"' ) ?></a></p> |
| 321 | <?php |
| 322 | echo $this->form->submit(); |
| 323 | echo $this->form->close_form(); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Meta Box: Style Settings |
| 328 | */ |
| 329 | public function call_box_style_settings() { |
| 330 | echo $this->form->set_current_option( 'style' )->open_form(); |
| 331 | ?> |
| 332 | <fieldset class="options"> |
| 333 | <table class="form-table"> |
| 334 | <tr> |
| 335 | <th style="width:300px;"><?php $this->_e( 'Set icon for external link' ) ?> |
| 336 | <?php echo $this->tooltip_help( 'Set an icon that wll be shown for external links. See example on the right side.' ) ?></th> |
| 337 | <td> |
| 338 | <div> |
| 339 | <div style="width:15%;float:left"> |
| 340 | <label><?php echo $this->form->radio( 'icon', 0 ); ?> |
| 341 | <span><?php $this->_e( 'No icon' ) ?></span></label> |
| 342 | <?php for ( $x = 1; $x <= 20; $x++ ): ?> |
| 343 | <br/> |
| 344 | <label title="<?php echo sprintf( $this->__( 'Icon %1$s: choose this icon to show for all external links or add the class \'ext-icon-%1$s\' to a specific link.' ), $x ) ?>"> |
| 345 | <?php echo $this->form->radio( 'icon', $x ); ?> |
| 346 | <img src="<?php echo plugins_url( 'images/external-'. $x .'.png', $this->plugin_file ) ?>" /></label> |
| 347 | <?php if ( $x % 5 == 0 ): ?> |
| 348 | </div> |
| 349 | <div style="width:15%;float:left"> |
| 350 | <?php endif; ?> |
| 351 | <?php endfor; ?> |
| 352 | </div> |
| 353 | <div style="width:29%;float:left;"><span class="description"><?php $this->_e( 'Example:' ) ?></span> |
| 354 | <br/><img src="<?php echo plugins_url( 'images/link-icon-example.png', $this->plugin_file ) ?>" /> |
| 355 | </div> |
| 356 | <br style="clear:both" /> |
| 357 | </div> |
| 358 | </td> |
| 359 | </tr> |
| 360 | <tr> |
| 361 | <th style="width:300px;"><?php $this->_e( 'Set no-icon class' ) ?> |
| 362 | <?php echo $this->tooltip_help( 'Set this class for links, that should not have the external link icon.' ) ?></th> |
| 363 | <td><label><?php echo $this->form->text( 'no_icon_class', array( 'class' => '' ) ); ?></label> |
| 364 | <label><?php echo $this->form->checkbox( 'no_icon_same_window', 1 ); ?> |
| 365 | <span><?php $this->_e( 'Always open links with no-icon class in same window or tab' ) ?></span></label> |
| 366 | <?php echo $this->tooltip_help( 'When enabled external links containing the no-icon class will always be opened in the current window or tab. No matter which target is set.' ) ?> |
| 367 | </td> |
| 368 | </tr> |
| 369 | </table> |
| 370 | </fieldset> |
| 371 | <?php |
| 372 | echo $this->form->submit(); |
| 373 | echo $this->form->close_form(); |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Meta Box: About... |
| 378 | */ |
| 379 | public function call_box_about() { |
| 380 | ?> |
| 381 | <h4><img src="<?php echo plugins_url( 'images/icon-wp-external-links-16.png', $this->plugin_file ) ?>" width="16" height="16" /> <?php $this->_e( 'WP External Links' ) ?></h4> |
| 382 | <div> |
| 383 | <p><?php printf( $this->__( 'Current version: <strong>%1$s</strong>' ), WP_EXTERNAL_LINKS_VERSION ) ?></p> |
| 384 | <p><?php $this->_e( 'Manage external links on your site: open in new window/tab, set link icon, add "external", add "nofollow" and more.' ) ?></p> |
| 385 | <p><a href="http://www.freelancephp.net/contact/" target="_blank"><?php $this->_e( 'Questions or suggestions?' ) ?></a></p> |
| 386 | <p><?php $this->_e( 'If you like this plugin please send your rating at WordPress.org.' ) ?></p> |
| 387 | <p><?php _e( 'More info' ) ?>: <a href="http://wordpress.org/extend/plugins/wp-external-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-external-links-plugin/" target="_blank">FreelancePHP.net</a></p> |
| 388 | </div> |
| 389 | <?php |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Meta Box: Other Plugins |
| 394 | */ |
| 395 | public function call_box_other_plugins() { |
| 396 | ?> |
| 397 | <h4><img src="<?php echo plugins_url( 'images/icon-email-encoder-bundle-16.png', $this->plugin_file ); ?>" width="16" height="16" /> Email Encoder Bundle</h4> |
| 398 | <div> |
| 399 | <?php if ( is_plugin_active( 'email-encoder-bundle/email-encoder-bundle.php' ) ): ?> |
| 400 | <p><?php $this->_e( 'This plugin is already activated.' ) ?> <a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/options-general.php?page=email-encoder-bundle/email-encoder-bundle.php"><?php $this->_e( 'Settings' ) ?></a></p> |
| 401 | <?php elseif( file_exists( WP_PLUGIN_DIR . '/email-encoder-bundle/email-encoder-bundle.php' ) ): ?> |
| 402 | <p><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugins.php?plugin_status=inactive"><?php $this->_e( 'Activate this plugin.' ) ?></a></p> |
| 403 | <?php else: ?> |
| 404 | <p><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugin-install.php?tab=search&type=term&s=Email+Encoder+Bundle+freelancephp&plugin-search-input=Search+Plugins"><?php $this->_e( 'Get this plugin now' ) ?></a></p> |
| 405 | <?php endif; ?> |
| 406 | |
| 407 | <p><?php $this->_e( 'Protect email addresses on your site from spambots and being used for spamming by using one of the encoding methods.' ) ?></p> |
| 408 | <p><?php _e( 'More info' ) ?>: <a href="http://wordpress.org/extend/plugins/email-encoder-bundle/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/email-encoder-php-class-wp-plugin/" target="_blank">FreelancePHP.net</a></p> |
| 409 | </div> |
| 410 | |
| 411 | <?php echo $this->hr(); ?> |
| 412 | |
| 413 | <h4><img src="<?php echo plugins_url( 'images/icon-wp-mailto-links-16.png', $this->plugin_file ); ?>" width="16" height="16" /> WP Mailto Links</h4> |
| 414 | <div> |
| 415 | <?php if ( is_plugin_active( 'wp-mailto-links/wp-mailto-links.php' ) ): ?> |
| 416 | <p><?php $this->_e( 'This plugin is already activated.' ) ?> <a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/options-general.php?page=wp-mailto-links/wp-mailto-links.php"><?php $this->_e( 'Settings' ) ?></a></p> |
| 417 | <?php elseif( file_exists( WP_PLUGIN_DIR . '/wp-mailto-links/wp-mailto-links.php' ) ): ?> |
| 418 | <p><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugins.php?plugin_status=inactive"><?php $this->_e( 'Activate this plugin.' ) ?></a></p> |
| 419 | <?php else: ?> |
| 420 | <p><a href="<?php echo get_bloginfo( 'url' ) ?>/wp-admin/plugin-install.php?tab=search&type=term&s=WP+Mailto+Links+freelancephp&plugin-search-input=Search+Plugins"><?php $this->_e( 'Get this plugin now' ) ?></a></p> |
| 421 | <?php endif; ?> |
| 422 | |
| 423 | <p><?php $this->_e( 'Manage mailto links on your site and protect emails from spambots, set mail icon and more.' ) ?></p> |
| 424 | <p><?php _e( 'More info' ) ?>: <a href="http://wordpress.org/extend/plugins/wp-mailto-links/" target="_blank">WordPress.org</a> | <a href="http://www.freelancephp.net/wp-mailto-links-plugin/" target="_blank">FreelancePHP.net</a></p> |
| 425 | </div> |
| 426 | <?php |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Activation plugin callback |
| 431 | */ |
| 432 | public function call_activation() { |
| 433 | // check for upgrading saved options to v1.00 |
| 434 | $old_options = get_option( 'WP_External_Links_options' ); |
| 435 | |
| 436 | if ( ! empty( $old_options ) ) { |
| 437 | $new_options = $this->save_options; |
| 438 | |
| 439 | foreach ( $old_options AS $option ) { |
| 440 | $new_options[ 'general' ][ 'target' ] = $old_options[ 'target' ]; |
| 441 | $new_options[ 'general' ][ 'use_js' ] = $old_options[ 'use_js' ]; |
| 442 | $new_options[ 'general' ][ 'external' ] = $old_options[ 'external' ]; |
| 443 | $new_options[ 'general' ][ 'nofollow' ] = $old_options[ 'nofollow' ]; |
| 444 | $new_options[ 'general' ][ 'filter_page' ] = $old_options[ 'filter_whole_page' ]; |
| 445 | $new_options[ 'general' ][ 'filter_posts' ] = $old_options[ 'filter_posts' ]; |
| 446 | $new_options[ 'general' ][ 'filter_comments' ] = $old_options[ 'filter_comments' ]; |
| 447 | $new_options[ 'general' ][ 'filter_widgets' ] = $old_options[ 'filter_widgets' ]; |
| 448 | $new_options[ 'general' ][ 'class_name' ] = $old_options[ 'class_name' ]; |
| 449 | $new_options[ 'style' ][ 'icon' ] = $old_options[ 'icon' ]; |
| 450 | $new_options[ 'style' ][ 'no_icon_class' ] = $old_options[ 'no_icon_class' ]; |
| 451 | $new_options[ 'style' ][ 'no_icon_same_window' ] = $old_options[ 'no_icon_same_window' ]; |
| 452 | } |
| 453 | |
| 454 | // save new format option values |
| 455 | update_option( 'wp_external_links-general', $new_options[ 'general' ] ); |
| 456 | update_option( 'wp_external_links-style', $new_options[ 'style' ] ); |
| 457 | |
| 458 | // delete old format option values |
| 459 | delete_option( 'WP_External_Links_options' ); |
| 460 | unregister_setting( 'WP_External_Links', 'WP_External_Links_options' ); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Deactivation plugin callback |
| 466 | */ |
| 467 | public function call_deactivation() { |
| 468 | $this->form->delete_options(); |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Set tooltip help |
| 473 | * @param string $text |
| 474 | * @return string |
| 475 | */ |
| 476 | public function tooltip_help( $text ) { |
| 477 | $text = $this->__( $text ); |
| 478 | $text = htmlentities( $text ); |
| 479 | |
| 480 | $html = ''; |
| 481 | $html .= '<a href="#" class="tooltip-help" title="'. $text .'">'; |
| 482 | $html .= '<img alt="" title="" src="'. plugins_url( '/images/help-icon.png', $this->plugin_file ) .'" />'; |
| 483 | $html .= '</a>'; |
| 484 | return $html; |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * Get html seperator |
| 489 | * @return string |
| 490 | */ |
| 491 | protected function hr() { |
| 492 | return '<hr style="border:1px solid #FFF; border-top:1px solid #EEE;" />'; |
| 493 | } |
| 494 | |
| 495 | |
| 496 | /** |
| 497 | * Check if widget_content filter is available (Widget Logic Plugin) |
| 498 | * @return boolean |
| 499 | * @static |
| 500 | */ |
| 501 | public static function check_widget_content_filter() { |
| 502 | // set widget_content filter of Widget Logic plugin |
| 503 | $widget_logic_opts = get_option( 'widget_logic' ); |
| 504 | |
| 505 | if ( function_exists( 'widget_logic_expand_control' ) AND is_array( $widget_logic_opts ) AND key_exists( 'widget_logic-options-filter', $widget_logic_opts ) ) |
| 506 | return ( $widget_logic_opts[ 'widget_logic-options-filter' ] == 'checked' ); |
| 507 | |
| 508 | return FALSE; |
| 509 | } |
| 510 | |
| 511 | } // End Admin_External_Links Class |
| 512 |