/** * init() * * @return void **/ function init() { $opts = sem_external_links::get_options(); // more stuff: register actions and filters // after shortcodes add_filter('the_content', array($this, 'filter'), 12); add_filter('the_excerpt', array($this, 'filter'), 12); if (isset($opts['text_widgets']) && $opts['text_widgets']) { add_filter('widget_text', array($this, 'filter'), 12); } }
/** * init() * * @return void **/ function init() { // more stuff: register actions and filters $this->opts = sem_external_links::get_options(); $this->exclude_domains = array(); if (isset($this->opts['exclude_domains'])) { $this->exclude_domains = preg_split("/[\\s,]+/", $this->opts['exclude_domains']); } if (!is_admin()) { $inc_text_widgets = false; if (isset($this->opts['text_widgets']) && $this->opts['text_widgets']) { $inc_text_widgets = true; } if ($this->opts['icon']) { add_action('wp_enqueue_scripts', array($this, 'styles'), 5); } if ($this->opts['autolinks']) { if (!class_exists('sem_autolink_uri')) { include $this->plugin_path . '/sem-autolink-uri.php'; } } if ($this->opts['global']) { if (!class_exists('external_links_anchor_utils')) { include $this->plugin_path . '/external-links-anchor-utils.php'; } $this->anchor_utils = new external_links_anchor_utils($this); } else { add_filter('the_content', array($this, 'process_content_content'), 100000); // add_filter('the_excerpt', array($this, 'process_content_excerpt'), 100000); add_filter('comment_text', array($this, 'process_content_comment'), 100000); if ($inc_text_widgets) { add_filter('widget_text', array($this, 'process_content_widget'), 100000); } } } else { add_action('admin_menu', array($this, 'admin_menu')); add_action('load-settings_page_external-links', array($this, 'external_links_admin')); } }
/** * edit_options() * * @return void **/ static function edit_options() { echo '<div class="wrap">' . "\n" . '<form method="post" action="">'; wp_nonce_field('sem_external_links'); $options = sem_external_links::get_options(); if ($options['nofollow'] && (function_exists('strip_nofollow') || class_exists('sem_dofollow'))) { echo "<div class=\"error\">\n" . "<p>" . __('Note: Your rel=nofollow preferences is being ignored because the dofollow plugin is enabled on your site.', 'sem-external-links') . "</p>\n" . "</div>\n"; } echo '<h2>' . __('External Links Settings', 'sem-external-links') . '</h2>' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Apply Globally', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="global"' . checked($options['global'], true, false) . ' />' . ' ' . __('Apply these settings to all outbound links on the site except those in scripts, styles and the html head section.', 'sem-external-links') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Apply to Text Widgets', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="text_widgets"' . checked($options['text_widgets'], true, false) . ' />' . ' ' . __('Apply these settings to any text widgets in addition to post, page and comments content.', 'sem-external-links') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Treat Subdomains as Local', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="subdomains_local"' . checked($options['subdomains_local'], true, false) . ' />' . ' ' . __('Treat any subdomains for this site as a local link.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Example: If your site is at domain.com and you also have store.domain.com, any link to store.domain.com will be treated as local.', 'sem-external-links') . '<i>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Auto Convert Text Urls', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="autolinks"' . checked($options['autolinks'], true, false) . ' />' . ' ' . __('Automatically converts text urls into clickable urls.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Note: If this option is enabled then if www.example.com is found in your text, it will be converted to an html <a> link."', 'sem-external-links') . '<br />' . "\n" . __('This conversion will occur first so external link treatment for nofollow, icon and target will be applied to this auto links.', 'sem-external-links') . '</i>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Add No Follow', 'sem-sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="nofollow"' . checked($options['nofollow'], true, false) . ' />' . ' ' . __('Add a rel="nofollow" attribute to outbound links.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Note: You can override this behavior by adding the attribute rel="follow" to individual links.', 'sem-external-links') . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Add Icons', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="icon"' . checked($options['icon'], true, false) . ' />' . ' ' . __('Mark outbound links with an icon.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Note: You can override this behavior by adding a class="no_icon" or "noicon" to individual links.', 'sem-external-links') . '</i>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Open in New Windows', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="target"' . checked($options['target'], true, false) . ' />' . ' ' . __('Open outbound links in new windows.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Note: Some usability experts discourage this, claiming that <a href="http://www.useit.com/alertbox/9605.html">this can damage your visitors\' trust</a> towards your site. Others highlight that computer-illiterate users do not always know how to use the back button, and encourage the practice for that reason.', 'sem-external-links') . '</i>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Exclude HTML Code Blocks', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="exclude_code_blocks"' . checked($options['exclude_code_blocks'], true, false) . ' />' . ' ' . __('Do not process links in html code blocks.', 'sem-external-links') . '</label>' . '<br />' . "\n" . '<i>' . __('Links found inside either <code> or <pre> html tags will be ignored.', 'sem-external-links') . '</i>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Domains to Exclude', 'sem-external-links') . '</th>' . "\n" . '<td>' . '<label>' . __('External site domains that should be excluded from processing:', 'sem-external-links') . '<textarea name="exclude_domains" cols="58" rows="4" class="widefat">' . esc_html($options['exclude_domains']) . '</textarea>' . "\n" . __('Domains and subdomains should be separated by a comma, space or carriage return. http://, https://, www. should not be included and will be stripped off.', 'sem-external-links') . '</label> ' . '<i>' . __('Example: domain.com, domain.net, sub.domain.com, somesite.com, external.org.', 'sem-external-links') . '</i>' . '<br />' . "\n" . '</td>' . '</tr>' . "\n"; echo '</table>' . "\n"; echo '<p class="submit">' . '<input type="submit"' . ' value="' . esc_attr(__('Save Changes', 'sem-external-links')) . '"' . ' />' . '</p>' . "\n"; echo '</form>' . "\n" . '</div>' . "\n"; }