function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { global $wp_filter, $merged_filters; $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); unset($merged_filters[$tag]); return true; }
public function test_not_has_filter_with_directly_removed_callback() { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; $priority = rand(1, 100); $accepted_args = rand(1, 100); $hook->add_filter($tag, $callback, $priority, $accepted_args); $function_key = _wp_filter_build_unique_id($tag, $callback, $priority); unset($hook->callbacks[$priority][$function_key]); $this->assertFalse($hook->has_filters()); }
public function test_add_filter_with_static_method() { $callback = array('MockAction', 'action'); $hook = new WP_Hook(); $tag = rand_str(); $priority = rand(1, 100); $accepted_args = rand(1, 100); $hook->add_filter($tag, $callback, $priority, $accepted_args); $function_index = _wp_filter_build_unique_id($tag, $callback, $priority); $this->assertEquals($callback, $hook->callbacks[$priority][$function_index]['function']); $this->assertEquals($accepted_args, $hook->callbacks[$priority][$function_index]['accepted_args']); }
/** * Ensure we're the last thing to run on blog creation. */ function blog_template_ensure_last_place() { global $wp_filter, $blog_templates; if (!$wp_filter || !$blog_templates) { return false; } $tag = 'wpmu_new_blog'; $method = 'set_blog_defaults'; $action_order = false; $bt_callback = array($blog_templates, $method); if (!is_callable($bt_callback)) { return false; } if (has_action($tag, $bt_callback)) { // This is all provided it's even bound $actions = !empty($wp_filter[$tag]) ? $wp_filter[$tag] : false; if (!$actions) { return false; } $highest = max(array_keys($actions)); if (!($idx = _wp_filter_build_unique_id($tag, $bt_callback, false))) { return false; } // Taken from core (`has_filter()`) foreach ($actions as $priority => $callbacks) { if (!isset($actions[$priority][$idx])) { continue; } $action_order = $priority; break; } if ($action_order >= $highest) { return true; } // We're the on the bottom, all good. // If we reached here, this is not good - we need to re-bind to highest position remove_action($tag, $bt_callback, $action_order, 6); $action_order = $highest + 10; } else { // No action bound, let's do our thing $action_order = defined('NBT_APPLY_TEMPLATE_ACTION_ORDER') && NBT_APPLY_TEMPLATE_ACTION_ORDER ? NBT_APPLY_TEMPLATE_ACTION_ORDER : 9999; $action_order = apply_filters('blog_templates-actions-action_order', $action_order); } add_action($tag, $bt_callback, $action_order, 6); return true; }
/** * Checks if a specific action has been registered for this hook. * * @since 4.7.0 * @access public * * @param callable|bool $function_to_check Optional. The callback to check for. Default false. * @param string $tag Optional. The name of the filter hook. Used for building * the callback ID when SPL is not available. Default empty. * @return bool|int The priority of that hook is returned, or false if the function is not attached. */ public function has_filter($tag = '', $function_to_check = false) { if (false === $function_to_check) { return $this->has_filters(); } $function_key = _wp_filter_build_unique_id($tag, $function_to_check, false); if (!$function_key) { return false; } foreach ($this->callbacks as $priority => $callbacks) { if (isset($callbacks[$function_key])) { return $priority; } } return false; }
public function getListenerPriority($eventName, $listener) { if (!isset($GLOBALS['wp_filter']) || !isset($GLOBALS['wp_filter'][$eventName])) { return null; } foreach ($GLOBALS['wp_filter'][$eventName] as $priority => $functions) { $function = _wp_filter_build_unique_id($eventName, $listener, $priority); if (isset($functions[$function])) { return $priority; } } return null; }
/** * * Check if any filter has been registered for a hook. * * @param string $tag The name of the filter hook. * @param callback|bool $function_to_check Optional. The callback to check for. Default false. * * @return false|int If $function_to_check is omitted, returns boolean for whether the hook has * anything registered. When checking a specific function, the priority of that * hook is returned, or false if the function is not attached. When using the * $function_to_check argument, this function may return a non-boolean value * that evaluates to false (e.g.) 0, so use the === operator for testing the * return value. */ public function has_filter($tag, $function_to_check = false) { // Don't reset the internal array pointer $filter = $this->filter; $has = !empty($filter[$tag]); // Make sure at least one priority has a filter callback if ($has) { $exists = false; foreach ($filter[$tag] as $callbacks) { if (!empty($callbacks)) { $exists = true; break; } } if (!$exists) { $has = false; } } if (false === $function_to_check || false === $has) { return $has; } if (!($idx = _wp_filter_build_unique_id($tag, $function_to_check, false))) { return false; } foreach ((array) array_keys($filter[$tag]) as $priority) { if (isset($filter[$tag][$priority][$idx])) { return $priority; } } return false; }
function the_content_filter($content) { global $post, $tempPost, $wp_filter, $save_wp_filter; // check the temporary $post reassignment for context specific $post data $the_post = isset($tempPost) ? $tempPost : $post; if (isset($save_wp_filter)) { $wp_filter['the_content'] = $save_wp_filter; } else { $save_wp_filter = $wp_filter['the_content']; } // active filters $the_content_filters = $wp_filter['the_content']; // get block options $disable = unserialize(get_theme_var('options,disable_wp_content')); if (isset($disable[$the_post->post_type])) { $disable = $disable[$the_post->post_type]; if (count($disable)) { foreach ($disable as $filter) { // check filter type (function or object) if (preg_match("/->/", $filter)) { // get class to block then generate current block id // and unset filter from apply list $filter = explode("->", $filter); $class = $filter[0]; $method = $filter[1]; foreach ($the_content_filters as $level => $_filters) { foreach ($_filters as $_filter_name => $_filter) { if (is_object($_filter['function'][0])) { if ($class == get_class($_filter['function'][0]) && $method == $_filter['function'][1]) { $object_filter = _wp_filter_build_unique_id('', array(&$_filter["function"][0], $method), 10); foreach ($wp_filter['the_content'] as $key => $val) { unset($wp_filter['the_content'][$key][$object_filter]); } } } } } } else { // unset function filter remove_filter('the_content', $filter); } } } } return $content; }
function add_filter($filter, $function = '', $priority = 10, $accepted_args = 1) { add_filter($filter, array(&$this, $function == '' ? $filter : $function), $priority, $accepted_args); $this->idx[$filter] = _wp_filter_build_unique_id($filter, array(&$this, $function == '' ? $filter : $function), $priority); /* unique id of this filter from object fixed 1.0.1 */ }
/** * Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional. The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). * @return boolean Whether the function is removed. */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { global $wp_filter, $merged_filters; unset($GLOBALS['wp_filter'][$tag][$priority][_wp_filter_build_unique_id($tag, $function_to_remove, $priority)]); unset( $merged_filters[ $tag ] ); return true; }
/** * put your comment there... * * @param mixed $name * @param mixed $callback * @param mixed $priority */ public static function getObserverKey($name, $callback, $priority = self::PRIORITY) { return _wp_filter_build_unique_id($name, $callback, $priority); }
/** * Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional. The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). * @return boolean Whether the function is removed. */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); unset($GLOBALS['merged_filters'][$tag]); return $r; }
/** * Performs an add_filter only once. Helpful for factory constructors where an action only * needs to be added once. Because of this, there will be no need to do a static variable that * will be set to true after the first run, ala $firstLoad * * @since 1.9 * * @param string $tag The name of the filter to hook the $function_to_add callback to. * @param callback $function_to_add The callback to be run when the filter is applied. * @param int $priority Optional. Used to specify the order in which the functions * associated with a particular action are executed. Default 10. * Lower numbers correspond with earlier execution, * and functions with the same priority are executed * in the order in which they were added to the action. * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. * * @return true */ function tf_add_filter_once($tag, $function_to_add, $priority = 10, $accepted_args = 1) { global $_gambitFiltersRan; if (!isset($_gambitFiltersRan)) { $_gambitFiltersRan = array(); } // Since references to $this produces a unique id, just use the class for identification purposes $idxFunc = $function_to_add; if (is_array($function_to_add)) { if (!is_string($function_to_add[0])) { $idxFunc[0] = get_class($function_to_add[0]); } } $idx = $tag . ':' . _wp_filter_build_unique_id($tag, $idxFunc, $priority); if (!in_array($idx, $_gambitFiltersRan)) { add_filter($tag, $function_to_add, $priority, $accepted_args); } $_gambitFiltersRan[] = $idx; return true; }
/** * Get a unique ID for a hook based on the internal method, hook, and priority. * * @param string $hook * @param string $method * @param int $priority * @return bool|string */ protected function get_wp_filter_id($hook, $method, $priority) { return _wp_filter_build_unique_id($hook, [$this, $method], $priority); }
function post_notification_admin_sub() { echo '<h3>' . __('Settings', 'post_notification') . '</h3>'; if ($_POST['updateSettings']) { if (!isset($_POST['the_content'])) { $_POST['the_content'] = array(); } //simple things first update_option('post_notification_read_more', $_POST['read_more']); update_option('post_notification_show_content', $_POST['show_content']); update_option('post_notification_send_default', $_POST['send_default']); update_option('post_notification_send_private', $_POST['send_private']); update_option('post_notification_send_page', $_POST['send_page']); update_option('post_notification_subject', $_POST['subject']); update_option('post_notification_from_name', $_POST['from_name']); update_option('post_notification_from_email', $_POST['from_email']); update_option('post_notification_page_name', $_POST['page_name']); update_option('post_notification_url', $_POST['pn_url']); update_option('post_notification_page_meta', $_POST['page_meta']); update_option('post_notification_filter_include', $_POST['filter_include']); update_option('post_notification_uninstall', $_POST['uninstall']); update_option('post_notification_debug', $_POST['debug']); update_option('post_notification_lock', $_POST['lock']); update_option('post_notification_the_content_exclude', serialize($_POST['the_content'])); update_option('post_notification_empty_cats', $_POST['empty_cats']); update_option('post_notification_show_cats', $_POST['show_cats']); update_option('post_notification_sendcheck', $_POST['sendcheck']); update_option('post_notification_saved_tmpl', $_POST['saved_tmpl']); update_option('post_notification_auto_subscribe', $_POST['auto_subscribe']); $p_captcha = $_POST['captcha']; if (is_numeric($p_captcha)) { if ($p_captcha >= 0) { update_option('post_notification_captcha', $p_captcha); } else { echo '<div class="error">' . __('Number of captcha-chars must be 0 or greater.', 'post_notification') . '</div>'; } } else { echo '<div class="error">' . __('Number of captcha-chars must be a number.', 'post_notification') . '</div>'; } $p_pause = $_POST['pause']; if (is_numeric($p_pause)) { if ($p_pause >= 0) { update_option('post_notification_pause', $p_pause); } else { echo '<div class="error">' . __('Pause must be zero or greater.', 'post_notification') . '</div>'; } } else { echo '<div class="error">' . __('Pause must be a number.', 'post_notification') . '</div>'; } $p_nervous = $_POST['nervous']; if (is_numeric($p_nervous)) { if ($p_nervous >= 0) { update_option('post_notification_nervous', $p_nervous); } else { echo '<div class="error">' . __('Nervous Finger must be zero or greater.', 'post_notification') . '</div>'; } } else { echo '<div class="error">' . __('Nervous Finger must be a number.', 'post_notification') . '</div>'; } $p_maxmail = $_POST['maxmails']; if (is_numeric($p_maxmail)) { if ($p_maxmail > 0) { update_option('post_notification_maxsend', $p_maxmail); } else { echo '<div class="error">' . __('Number of mails must be greater then zero.', 'post_notification') . '</div>'; } } else { echo '<div class="error">' . __('Number of mails must be a number', 'post_notification') . '</div>'; } if ($_POST['hdr_nl'] == "rn") { update_option('post_notification_hdr_nl', "rn"); } else { update_option('post_notification_hdr_nl', "n"); } // Check wheather the template exists in the Profile if (is_file(POST_NOTIFICATION_PATH . $_POST['en_profile'] . '/' . $_POST['en_template']) || is_file(POST_NOTIFICATION_DATA . $_POST['en_profile'] . '/' . $_POST['en_template'])) { update_option('post_notification_profile', $_POST['en_profile']); update_option('post_notification_template', $_POST['en_template']); } else { // Don't save any Profile / Template-inforamtion so we don't get in to an inconsisten state; echo '<div class="error">' . __('Could not find the template in this profile. Please select a template and save again.', 'post_notification') . '</diV>'; $profile = $_POST['en_profile']; } // Update default categories $categories = $_POST['pn_cats']; if (empty($categories)) { update_option('post_notification_selected_cats', ''); } else { $categoryList = ''; foreach ($categories as $category) { if (is_numeric($category)) { $categoryList .= ',' . $category; } } update_option('post_notification_selected_cats', substr($categoryList, 1)); } //Add the page if ($_POST['add_page'] == "add") { //Database change in 2.1 if (get_option('db_version') < 4772) { $post_status = "static"; } else { $post_type = "page"; $post_status = "publish"; } //Collect the Data if (get_option('post_notification_filter_include') == 'no') { $post_title = $_POST['page_name']; $post_content = __('If you can read this, something went wrong. :-(', 'post_notification'); } else { $post_title = '@@post_notification_header'; $post_content = '@@post_notification_body'; } $post_data = compact('post_content', 'post_title', 'post_status', 'post_type'); $post_data = add_magic_quotes($post_data); //Post $post_ID = wp_insert_post($post_data); //Add meta if we are using the Template. if (get_option('post_notification_filter_include') == 'no') { add_post_meta($post_ID, '_wp_page_template', 'post_notification_template.php', true); } //Add the ID to the URL update_option('post_notification_url', $post_ID); } echo '<H4>' . __('Data was updated.', 'post_notification') . '</H4>'; } //Try to install the theme in case we need it. There be no warning. Warnings are only on the info-page. post_notification_installtheme(); $selected = 'selected="selected"'; /** * @todo Move all this stuff down to where it is displayed, * having all this stuff up here was a good Idea while there were few settings. */ if (get_option('post_notification_hdr_nl') == 'rn') { $hdr_rn = $selected; } else { $hdr_n = $selected; } if (get_option('post_notification_show_content') == 'no') { $contentN = $selected; } else { $contentY = $selected; } if (get_option('post_notification_send_default') == 'no') { $sendN = $selected; } else { $sendY = $selected; } if (get_option('post_notification_send_private') == 'no') { $privateN = $selected; } else { $privateY = $selected; } if (get_option('post_notification_send_page') == 'no') { $pageN = $selected; } else { $pageY = $selected; } if (get_option('post_notification_page_meta') == 'no') { $metaN = $selected; } else { $metaY = $selected; } if (get_option('post_notification_filter_include') == 'no') { $filter_includeN = $selected; } else { $filter_includeY = $selected; } if (get_option('post_notification_uninstall') == 'yes') { //rather have No $uninstallY = $selected; } else { $uninstallN = $selected; } //Find Profiles if (!isset($profile)) { //If the profile is already set, dont change. $profile = get_option('post_notification_profile'); } $profile_list = array(); if (file_exists(POST_NOTIFICATION_DATA)) { $dir_handle = opendir(POST_NOTIFICATION_DATA); while (false !== ($file = readdir($dir_handle))) { if (@is_dir(POST_NOTIFICATION_DATA . $file) && $file[0] != '.' && $file[0] != '_') { if (post_notification_is_profile(POST_NOTIFICATION_DATA . $file)) { $profile_list[] = $file; } } } closedir($dir_handle); } else { echo '<div class = "error">' . __('Please save own Profiles in: ', 'post_notification') . ' ' . POST_NOTIFICATION_DATA . '<br/>'; echo __('Otherwise they may be deleted using autoupdate. ', 'post_notification') . '</div>'; } $dir_handle = opendir(POST_NOTIFICATION_PATH); while (false !== ($file = readdir($dir_handle))) { if (is_dir(POST_NOTIFICATION_PATH . $file) && $file[0] != '.' && $file[0] != '_') { if (post_notification_is_profile(POST_NOTIFICATION_PATH . $file)) { if (!in_array($file, $profile_list)) { $profile_list[] = $file; } } } } closedir($dir_handle); foreach ($profile_list as $profile_list_el) { $en_profiles .= "<option value=\"{$profile_list_el}\" "; if ($profile_list_el == $profile) { $en_profiles .= ' selected="selected"'; } $en_profiles .= ">{$profile_list_el}</option>"; } ///Find templates $template = get_option('post_notification_template'); $dir_handle = opendir(post_notification_get_profile_dir($profile)); while (false !== ($file = readdir($dir_handle))) { if (substr($file, -5) == '.html' or substr($file, -4) == '.txt') { $en_templates .= "<option value=\"{$file}\" "; if ($file == $template) { $en_templates .= ' selected="selected"'; } $en_templates .= ">{$file}</option>"; } } closedir($dir_handle); ?> <form id="update" method="post" action="admin.php?page=post_notification/admin.php&action=settings"> <h4> <?php _e('When to send', 'post_notification'); ?> </h4> <table width="100%"> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Send normal posts by default:', 'post_notification'); ?> </th> <td> <select name="send_default" > <option value="no" <?php echo $sendN; ?> > <?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $sendY; ?> > <?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Send private posts by default:', 'post_notification'); ?> </th> <td><select name="send_private"> <option value="no" <?php echo $privateN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $privateY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select></td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Send pages by default:', 'post_notification'); ?> </th> <td> <select name="send_page"> <option value="no" <?php echo $pageN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $pageY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Note:', 'post_notification'); ?> </th> <td> <?php echo '<b>' . __('You can always override the settings above when writing a post. There is a Post Notification box somewhere near the upload box when writing or editing a post.', 'post_notification') . '</b>'; ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Nervous finger wait:', 'post_notification'); ?> </th> <td> <input name="nervous" type="text" id="nervous" size="35" value="<?php echo get_option('post_notification_nervous'); ?> " /> <?php _e('seconds.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('This option sets the time to wait before sending an Email. So if you have an nervous finger you can unpublish your post quickly and no mails are sent.', 'post_notification'); ?> </td> </tr> </table> <h4> <?php _e('Look', 'post_notification'); ?> </h4> <table width="100%"> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Copy complete post in to the mail:', 'post_notification'); ?> </th> <td> <select name="show_content" > <option value="no" <?php if (get_option('post_notification_show_content') == 'no') { echo $selected; } ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php if (get_option('post_notification_show_content') == 'yes') { echo $selected; } ?> ><?php _e('Yes', 'post_notification'); ?> </option> <option value="more" <?php if (get_option('post_notification_show_content') == 'more') { echo $selected; } ?> ><?php _e('Up to the more-tag.', 'post_notification'); ?> </option> <option value="excerpt" <?php if (get_option('post_notification_show_content') == 'excerpt') { echo $selected; } ?> ><?php _e('The excerpt', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Read-more-text:', 'post_notification'); ?> </th> <td><input name="read_more" type="text" size="35" value="<?php echo get_option('post_notification_read_more'); ?> " /></td> </tr> <tr class="alternate"> <td /> <td><?php _e('This text is put behind the content in case the mail is truncated. E.g. because of the more-tag.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Profile:', 'post_notification'); ?> </th> <td> <select name="en_profile" > <?php echo $en_profiles; ?> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Template:', 'post_notification'); ?> </th> <td> <select name="en_template" > <?php echo $en_templates; ?> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('Templates with the extension .txt are sent as text-mails. Templates with the extension .html are sent as HTML-mails', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Subject:', 'post_notification'); ?> </th> <td><input name="subject" type="text" size="35" value="<?php echo get_option('post_notification_subject'); ?> " /></td> </tr> <tr class="alternate"> <td /> <td><?php _e('Use @@blogname as placeholder for the blog name.', 'post_notification'); ?> <?php _e('Use @@title as placeholder for the title of the post.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Sender-Name:', 'post_notification'); ?> </th> <td><input name="from_name" type="text" size="35" value="<?php echo get_option('post_notification_from_name'); ?> " /></td> </tr> <tr class="alternate"> <td /> <td><?php _e('Use @@blogname as placeholder for the blog name.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Sender-Email:', 'post_notification'); ?> </th> <td><input name="from_email" type="text" size="35" value="<?php echo get_option('post_notification_from_email'); ?> " /></td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Show "saved.tmpl" when saving frontend settings.', 'post_notification'); ?> </th> <?php if (get_option('post_notification_saved_tmpl') == 'yes') { $savedTmplY = $selected; } else { $savedTmplN = $selected; } ?> <td> <select name="saved_tmpl"> <option value="no" <?php echo $savedTmplN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $savedTmplY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('You can add an additional saved.tmpl file to your profile. If you select this option this file will be shown to the subscriber when he saves his settings.', 'post_notification'); ?> </td> </tr> </table> <h4> <?php _e('Technical', 'post_notification'); ?> </h4> <table width="100%"> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Number of mails to be sent in a burst:', 'post_notification'); ?> </th> <td><input name="maxmails" type="text" id="maxmail" size="35" value="<?php echo get_option('post_notification_maxsend'); ?> " /></td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Pause between transmission:', 'post_notification'); ?> </th> <td><input name="pause" type="text" id="pause" size="35" value="<?php echo get_option('post_notification_pause'); ?> " /> <?php _e('seconds.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Type of header line break:', 'post_notification'); ?> </th> <td> <select name="hdr_nl" > <option value="rn" <?php echo $hdr_rn; ?> >\r\n</option> <option value="n" <?php echo $hdr_n; ?> >\n</option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('According to the PHP-specification \\r\\n must be used. Never the less quite a few servers have trouble if they get a \\r\\n instead of \\n. You\'ll see part of the header in your mail if you have the wrong selection.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Locking:', 'post_notification'); ?> </th> <?php if (get_option('post_notification_lock') == 'db') { $lockDB = $selected; } else { $lockFILE = $selected; } ?> <td> <select name="lock" > <option value="file" <?php echo $lockFILE; ?> ><?php _e('File', 'post_notification'); ?> </option> <option value="db" <?php echo $lockDB; ?> ><?php _e('Database', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('Try using database locking if you are geting duplicate messages.', 'post_notification'); echo ' ' . '<a href="http://php.net/manual/function.flock.php">' . __('More information.', 'post_notification') . '</a>'; ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Filters to exclude from filtering "the_content":', 'post_notification'); ?> </th> <td> <?php global $wp_filter; $rem_filters = get_option('post_notification_the_content_exclude'); if (is_string($rem_filters) && strlen($rem_filters)) { $rem_filters = unserialize($rem_filters); } if (!is_array($rem_filters)) { $rem_filters = array(); } foreach ($wp_filter['the_content'] as $filter_level => $filters_in_level) { foreach ($filters_in_level as $filter) { if (function_exists('_wp_filter_build_unique_id')) { // If a function is passed the unique_id will return the function name. // Therefore there should be no problem with backward compatibilty // priority may/must be false as all functions should get an Id when being registered // As prio = false, $tag is not needed at all! $fn_name = _wp_filter_build_unique_id('the_content', $filter['function'], $filter_level); } else { $fn_name = $filter['function']; } if (!($fn_name === false)) { echo '<input type="checkbox" name="the_content[]" value="' . $fn_name . '" '; if (in_array($fn_name, $rem_filters)) { echo ' checked="checked" '; } echo '>' . $fn_name . '</input><br />'; } } } ?> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('Some plugins use filters to modify the content of a post. You might not want some of them modifying your mails. Finding the right filters might need some playing around.', 'post_notification'); ?> </td> </tr> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('When to send:', 'post_notification'); ?> </th> <?php if (get_option('post_notification_sendcheck') == 'head') { $sendhead = $selected; } else { if (get_option('post_notification_sendcheck') == 'footer') { $sendfoot = $selected; } else { $sendshutdown = $selected; } } ?> <td> <select name="sendcheck" > <option value="head" <?php echo $sendhead; ?> ><?php _e('Header', 'post_notification'); ?> </option> <option value="footer" <?php echo $sendfoot; ?> ><?php _e('Footer', 'post_notification'); ?> </option> <option value="shutdown" <?php echo $sendshutdown; ?> ><?php _e('Shutdown', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('By default PN sends mails after the page has been rendered and sent to the user (shutdown).' . ' Some hosters kill all scripts after the connection has been closed. ' . 'You can try sending mails before the page is rendered (header) or before creating the footer of the ' . 'page (footer).', 'post_notification'); ?> </td> </tr> <?php if (get_option('post_notification_auto_subscribe') == 'yes') { //rather have No $auto_subscribeY = $selected; } else { $auto_subscribeN = $selected; } ?> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Add user to PN when registering to WP:', 'post_notification'); ?> </th> <td> <select name="auto_subscribe" > <option value="no" <?php echo $auto_subscribeN; ?> > <?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $auto_subscribeY; ?> > <?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> </table> <h4> <?php _e('Frontend', 'post_notification'); ?> </h4> <table width="100%"> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Name of the Post Notification page:', 'post_notification'); ?> </th> <td><input name="page_name" type="text" id="page_name" size="60" value="<?php echo get_option('post_notification_page_name'); ?> " /></td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Allow selection of categories:', 'post_notification'); ?> </th> <td> <?php post_notification_select_yesno('show_cats'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Show empty categories:', 'post_notification'); ?> </th> <td> <?php post_notification_select_yesno('empty_cats'); ?> </td> </tr> <? $selected_cats_list = get_option('post_notification_selected_cats'); $selected_cats = explode(',', $selected_cats_list); ?> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Default categories:', 'post_notification'); ?> </th> <td><?php echo post_notification_get_catselect('', $selected_cats); ?> </td> </tr> <tr class="alternate"> <td /> <td><?php _e('The categories which will be automatically selected when a user subscribes, and which is also default for the Manage Addresses dialog. Choosing a category includes all subcategories.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"> <a href="<?php _e('http://en.wikipedia.org/wiki/Captcha', 'post_notification'); ?> "><?php _e('Captcha-chars:', 'post_notification'); ?> </a></th> <td><input name="captcha" type="text" size="60" value="<?php echo get_option('post_notification_captcha'); ?> " /></td> </tr> <tr class="alternate"> <td /> <td> <?php _e('Number of Captcha-chars. 0 is no Captcha', 'post_notification'); ?> <br /> <b><?php _e('Warning:', 'post_notification'); ?> </b> <?php _e('Your template must support Captchas.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Post Notification link in the meta-section:', 'post_notification'); ?> </th> <td> <select name="page_meta" > <option value="no" <?php echo $metaN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $metaY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Replacement in Posts:', 'post_notification'); ?> </th> <td> <select name="filter_include" > <option value="no" <?php echo $filter_includeN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $filter_includeY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('The Stings @@post_notification_header and @@post_notification_body will be replaced in your post.', 'post_notification'); ?> <br /> <?php _e('Also see the Instructions for this.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Add Post Notification page:', 'post_notification'); ?> </th> <td><input name="add_page" type="checkbox" id="add_page" value="add" /></td> </tr> <tr class="alternate"> <td /> <td> <?php _e('Adds a Post Notification page to your pages.', 'post_notification') . ' '; _e('The file "post_notification_template.php" has been copied into the active theme. You may want to edit this file to fit your needs. ', 'post_notification'); ?> <br /> <?php _e('This checkbox is cleared after execution.', 'post_notification'); ?> <br /> <?php _e('Also see the Instructions for this.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Link to the Post Notification page:', 'post_notification'); ?> </th> <td><input name="pn_url" type="text" id="pn_url" size="60" value="<?php echo get_option('post_notification_url'); ?> " /></td> </tr> <tr class="alternate"> <td /> <td> <?php _e('This must be the URL or the ID of the page on which you subscribe.', 'post_notification') . ' '; _e('If you pick "Add Post Notification page" this will be compleated automaticly.', 'post_notification') . ' '; _e('Also see the Instructions for this.', 'post_notification'); ?> </td> </tr> </table> <h4> <?php _e('Miscellaneous', 'post_notification'); ?> </h4> <table width="100%"> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Debug:', 'post_notification'); ?> </th> <?php if (get_option('post_notification_debug') != 'yes') { $debugN = $selected; } else { $debugY = $selected; } ?> <td> <select name="debug" > <option value="no" <?php echo $debugN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $debugY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <th style="text-align:right;padding-right:10px;"><?php _e('Uninstall:', 'post_notification'); ?> </th> <td> <select name="uninstall" > <option value="no" <?php echo $uninstallN; ?> ><?php _e('No', 'post_notification'); ?> </option> <option value="yes" <?php echo $uninstallY; ?> ><?php _e('Yes', 'post_notification'); ?> </option> </select> </td> </tr> <tr class="alternate"> <td /> <td> <?php _e('WARNING: If this option is set, all database entries are deleted upon deactivation. Of course all data is lost.', 'post_notification'); ?> </td> </tr> <tr class="alternate"> <td> </td> <td><input type="submit" name="updateSettings" value="<?php _e('save', 'post_notification'); ?> " /></td> </tr> </table> </form> <?php }
public static function include_user_profile_fields($arguments) { global $wp_filter; $tags = array('show_user_profile', 'edit_user_profile', 'personal_options_update', 'edit_user_profile_update'); if (isset($arguments['actions'])) { foreach ($tags as $tag) { foreach ($wp_filter[$tag] as $priority => $callback) { foreach ($callback as $id => $config) { foreach ($arguments['actions'] as $action) { if (strstr($id, $action)) { $idx = _wp_filter_build_unique_id($action, $id, $priority); if ($idx == $id) { array_push($arguments['actions'], $id); } } } if (!in_array($id, $arguments['actions']) && ($wp_filter[$tag][$priority][$id]['function'][0] != 'piklist_form' && $wp_filter[$tag][$priority][$id]['function'][0] != 'save_fields')) { unset($wp_filter[$tag][$priority][$id]); } } if (empty($wp_filter[$tag][$priority])) { unset($wp_filter[$tag][$priority]); } } if (empty($wp_filter[$tag])) { unset($wp_filter[$tag]); } } } if (isset($arguments['meta_boxes'])) { $count = count(self::$meta_boxes); for ($i = 0; $i < $count; $i++) { if (!in_array(self::$meta_boxes[$i]['config']['name'], $arguments['meta_boxes'])) { unset(self::$meta_boxes[$i]); } } } piklist('shared/admin-user-profile-fields', array('meta_boxes' => isset($arguments['meta_boxes']) ? $arguments['meta_boxes'] : array())); }
/** * Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * * To remove a hook, the $function_to_remove and $priority arguments must match * when the hook was added. This goes for both filters and actions. No warning * will be given on removal failure. * * @package MiniYun * @subpackage Plugin * @since 1.0 * * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority optional. The priority of the function (default: 10). * @param int $accepted_args optional. The number of arguments the function accepts (default: 1). * @return boolean Whether the function existed before it was removed. */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); $r = isset(Yii::app()->hook->wp_filter[$tag][$priority][$function_to_remove]); if (true === $r) { unset(Yii::app()->hook->wp_filter[$tag][$priority][$function_to_remove]); if (empty(Yii::app()->hook->wp_filter[$tag][$priority])) { unset(Yii::app()->hook->wp_filter[$tag][$priority]); } unset(Yii::app()->hook->merged_filters[$tag]); } return $r; }
/** * Removes a function from a specified filter hook. * * This function removes a function attached to a specified filter hook. This * method can be used to remove default functions attached to a specific filter * hook and possibly replace them with a substitute. * * To remove a hook, the $function_to_remove and $priority arguments must match * when the hook was added. This goes for both filters and actions. No warning * will be given on removal failure. * * @since 1.2.0 * * @global array $wp_filter Stores all of the filters * @global array $merged_filters Merges the filter hooks using this function. * * @param string $tag The filter hook to which the function to be removed is hooked. * @param callback $function_to_remove The name of the function which should be removed. * @param int $priority Optional. The priority of the function. Default 10. * @return bool Whether the function existed before it was removed. */ function remove_filter($tag, $function_to_remove, $priority = 10) { $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); if (true === $r) { unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); if (empty($GLOBALS['wp_filter'][$tag][$priority])) { unset($GLOBALS['wp_filter'][$tag][$priority]); } if (empty($GLOBALS['wp_filter'][$tag])) { $GLOBALS['wp_filter'][$tag] = array(); } unset($GLOBALS['merged_filters'][$tag]); } return $r; }
/** * @param $tag * @param string|array $callback * * @return false|string * @author Panagiotis Vagenas <*****@*****.**> * @since 0.0.2 */ public function alreadySet($tag, $callback) { return _wp_filter_build_unique_id($tag, $callback, false); }