/** * Installs the blog * * {@internal Missing Long Description}} * * @since 2.1.0 * * @param string $blog_title Blog title. * @param string $user_name User's username. * @param string $user_email User's email. * @param bool $public Whether blog is public. * @param string $deprecated Optional. Not used. * @param string $user_password Optional. User's chosen password. Will default to a random password. * @param string $language Optional. Language chosen. * @return array Array keys 'url', 'user_id', 'password', 'password_message'. */ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.6'); } wp_check_mysql_version(); wp_cache_flush(); make_db_current_silent(); populate_options(); populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); if ($language) { update_option('WPLANG', $language); } $guessurl = wp_guess_url(); update_option('siteurl', $guessurl); // If not a public blog, don't ping. if (!$public) { update_option('default_pingback_flag', 0); } /* * Create default user. If the user already exists, the user tables are * being shared among blogs. Just set the role in that case. */ $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if (!$user_id && empty($user_password)) { $user_password = wp_generate_password(12, false); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = wp_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } else { if (!$user_id) { // Password has been provided $message = '<em>' . __('Your chosen password.') . '</em>'; $user_id = wp_create_user($user_name, $user_password, $user_email); } else { $message = __('User already exists. Password inherited.'); } } $user = new WP_User($user_id); $user->set_role('administrator'); wp_install_defaults($user_id); flush_rewrite_rules(); wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.')); wp_cache_flush(); /** * Fires after a site is fully installed. * * @since 3.9.0 * * @param WP_User $user The site owner. */ do_action('wp_install', $user); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
/** * Parse default arguments for the editor instance. * * @param string $editor_id ID for the current editor instance. * @param array $settings { * Array of editor arguments. * * @type bool $wpautop Whether to use wpautop(). Default true. * @type bool $media_buttons Whether to show the Add Media/other media buttons. * @type string $default_editor When both TinyMCE and Quicktags are used, set which * editor is shown on page load. Default empty. * @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false. * Requires the media modal. * @type string $textarea_name Give the textarea a unique name here. Square brackets * can be used here. Default $editor_id. * @type int $textarea_rows Number rows in the editor textarea. Default 20. * @type string|int $tabindex Tabindex value to use. Default empty. * @type string $tabfocus_elements The previous and next element ID to move the focus to * when pressing the Tab key in TinyMCE. Defualt ':prev,:next'. * @type string $editor_css Intended for extra styles for both Visual and Text editors. * Should include <style> tags, and can use "scoped". Default empty. * @type string $editor_class Extra classes to add to the editor textarea elemen. Default empty. * @type bool $teeny Whether to output the minimal editor config. Examples include * Press This and the Comment editor. Default false. * @type bool $dfw Whether to replace the default fullscreen with "Distraction Free * Writing". DFW requires specific DOM elements and css). Default false. * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to * TinyMCE using an array. Default true. * @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to * Quicktags using an array. Default true. * } * @return array Parsed arguments array. */ public static function parse_settings($editor_id, $settings) { $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'default_editor' => '', 'drag_drop_upload' => false, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)); self::$this_tinymce = $set['tinymce'] && user_can_richedit(); if (self::$this_tinymce) { if (false !== strpos($editor_id, '[')) { self::$this_tinymce = false; _deprecated_argument('wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.'); } } self::$this_quicktags = (bool) $set['quicktags']; if (self::$this_tinymce) { self::$has_tinymce = true; } if (self::$this_quicktags) { self::$has_quicktags = true; } if (empty($set['editor_height'])) { return $set; } if ('content' === $editor_id) { // A cookie (set when a user resizes the editor) overrides the height. $cookie = (int) get_user_setting('ed_size'); if ($cookie) { $set['editor_height'] = $cookie; } } if ($set['editor_height'] < 50) { $set['editor_height'] = 50; } elseif ($set['editor_height'] > 5000) { $set['editor_height'] = 5000; } return $set; }
/** * Add a new custom field to the ticket. * * @param string $name Option name * @param array $args Field arguments * * @return bool Whether or not the field was added * * @since 3.0.0 */ public function add_field($name = '', $args = array()) { /* Option name is mandatory */ if (empty($name)) { return false; } $name = sanitize_text_field($name); /* Default arguments */ $defaults = WPAS_Custom_Field::get_field_defaults(); /* Merge args */ $arguments = wp_parse_args($args, $defaults); /* Convert the callback for backwards compatibility */ if (!empty($arguments['callback'])) { _deprecated_argument('WPAS_Custom_Fields::add_field()', '3.2', sprintf(__('Please use %s to register your custom field type', 'wpas'), '<code>field_type</code>')); switch ($arguments['callback']) { case 'taxonomy': $arguments['field_type'] = 'taxonomy'; $arguments['callback'] = ''; break; case 'text': $arguments['field_type'] = 'text'; $arguments['callback'] = ''; break; } } /* Field with args */ $option = array('name' => $name, 'args' => $arguments); $this->options[$name] = apply_filters('wpas_add_field', $option); return true; }
/** * Output the shortcode. * * @access public * @param array $atts * @return void */ public static function output($atts) { global $wp; // Check cart class is loaded or abort if (is_null(WC()->cart)) { return; } // Backwards compat with old pay and thanks link arguments if (isset($_GET['order']) && isset($_GET['key'])) { _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.'); // Get the order to work out what we are showing $order_id = absint($_GET['order']); $order = wc_get_order($order_id); if ($order->has_status('pending')) { $wp->query_vars['order-pay'] = absint($_GET['order']); } else { $wp->query_vars['order-received'] = absint($_GET['order']); } } // Handle checkout actions if (!empty($wp->query_vars['order-pay'])) { self::order_pay($wp->query_vars['order-pay']); } elseif (isset($wp->query_vars['order-received'])) { self::order_received($wp->query_vars['order-received']); } else { self::checkout(); } }
public function __construct($label, $params = array(), $_deprecated = null) { if (is_bool($params)) { _deprecated_argument(get_class($this) . '::' . __FUNCTION__, '5.1.1', 'Use $params array instead.'); $params = array('self_closing' => $params); if (is_bool($_deprecated)) { $params['visibility'] = $_deprecated ? self::VISIBILITY_ALL : self::VISIBILITY_NONE; } else { if (is_int($_deprecated)) { $params['visibility'] = $_deprecated; } } } if (!is_null($this->tag)) { _deprecated_argument(get_class($this) . '::' . __FUNCTION__, '5.1.1', 'Use $params array instead.'); $params['tag'] = $this->tag; } $this->domain = Theme::getInstance()->domain; $this->label = $label; foreach (array_intersect_key($params, array_flip(array('tag', 'self_closing', 'parent', 'visibility'))) as $name => $value) { $this->{$name} = $value; } if ($this->tag === null) { $class = explode('\\', get_class($this)); $this->tag = Func::stringID(array_pop($class), '_'); } if ($this->parent !== null && !$this->parent instanceof self) { $this->parent = self::getInstance($params['parent']); } self::$instances[$this->tag] = $this; $this->register(); }
public function __construct($name, $title, array $values, $args = array()) { $this->id = $name; $this->name = $name . '[]'; $this->title = $title; $this->args = wp_parse_args($args, array('repeatable' => false, 'std' => '', 'default' => '', 'show_label' => false, 'taxonomy' => '', 'hide_empty' => false, 'data_delegate' => null, 'options' => array(), 'cols' => '12', 'style' => '', 'class' => '', 'readonly' => false, 'disabled' => false)); if (!empty($this->args['std']) && empty($this->args['default'])) { $this->args['default'] = $this->args['std']; _deprecated_argument('CMB_Field', "'std' is deprecated, use 'default instead'", '0.9'); } if (!empty($this->args['options']) && is_array(reset($this->args['options']))) { $re_format = array(); foreach ($this->args['options'] as $option) { $re_format[$option['value']] = $option['name']; } // TODO this is incorrect _deprecated_argument('CMB_Field', "'std' is deprecated, use 'default instead'", '0.9'); $this->args['options'] = $re_format; } // If the field has a custom value populator callback if (!empty($args['values_callback'])) { $this->values = call_user_func($args['values_callback'], get_the_id()); } else { $this->values = $values; } $this->value = reset($this->values); $this->description = !empty($this->args['desc']) ? $this->args['desc'] : ''; }
/** * Parses the plugin contents to retrieve plugin's metadata. * * The metadata of the plugin's data searches for the following in the plugin's * header. All plugin data must be on its own line. For plugin description, it * must not have any newlines or only parts of the description will be displayed * and the same goes for the plugin data. The below is formatted for printing. * * /* * Plugin Name: Name of Plugin * Plugin URI: Link to plugin information * Description: Plugin Description * Author: Plugin author's name * Author URI: Link to the author's web site * Version: Must be set in the plugin for WordPress 2.3+ * Text Domain: Optional. Unique identifier, should be same as the one used in * load_plugin_textdomain() * Domain Path: Optional. Only useful if the translations are located in a * folder above the plugin's base path. For example, if .mo files are * located in the locale folder then Domain Path will be "/locale/" and * must have the first slash. Defaults to the base folder the plugin is * located in. * Network: Optional. Specify "Network: true" to require that a plugin is activated * across all sites in an installation. This will prevent a plugin from being * activated on a single site when Multisite is enabled. * * / # Remove the space to close comment * * Some users have issues with opening large files and manipulating the contents * for want is usually the first 1kiB or 2kiB. This function stops pulling in * the plugin contents when it has all of the required plugin data. * * The first 8kiB of the file will be pulled in and if the plugin data is not * within that first 8kiB, then the plugin author should correct their plugin * and move the plugin data headers to the top. * * The plugin file is assumed to have permissions to allow for scripts to read * the file. This is not checked however and the file is only opened for * reading. * * @since 1.5.0 * * @param string $plugin_file Path to the plugin file * @param bool $markup Optional. If the returned data should have HTML markup applied. * Default true. * @param bool $translate Optional. If the returned data should be translated. Default true. * @return array { * Plugin data. Values will be empty if not supplied by the plugin. * * @type string $Name Name of the plugin. Should be unique. * @type string $Title Title of the plugin and link to the plugin's site (if set). * @type string $Description Plugin description. * @type string $Author Author's name. * @type string $AuthorURI Author's website address (if set). * @type string $Version Plugin version. * @type string $TextDomain Plugin textdomain. * @type string $DomainPath Plugins relative directory path to .mo files. * @type bool $Network Whether the plugin can only be activated network-wide. * } */ function get_plugin_data($plugin_file, $markup = true, $translate = true) { $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only'); $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin'); // Site Wide Only is the old header for Network if (!$plugin_data['Network'] && $plugin_data['_sitewide']) { /* translators: 1: Site Wide Only: true, 2: Network: true */ _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The %1$s plugin header is deprecated. Use %2$s instead.'), '<code>Site Wide Only: true</code>', '<code>Network: true</code>')); $plugin_data['Network'] = $plugin_data['_sitewide']; } $plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']); unset($plugin_data['_sitewide']); // If no text domain is defined fall back to the plugin slug. if (!$plugin_data['TextDomain']) { $plugin_slug = dirname(plugin_basename($plugin_file)); if ('.' !== $plugin_slug && false === strpos($plugin_slug, '/')) { $plugin_data['TextDomain'] = $plugin_slug; } } if ($markup || $translate) { $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate); } else { $plugin_data['Title'] = $plugin_data['Name']; $plugin_data['AuthorName'] = $plugin_data['Author']; } return $plugin_data; }
/** * We use the blogfilter function to define all the page urls * * @params the name of the page * @params 'display' * @return string url * */ function hma_blogfilter($arg, $arg2) { switch ($arg2) { case 'login_url': return apply_filters('hma_login_url', home_url(trailingslashit(hma_get_login_rewrite_slug()))); break; case 'login_inline_url': return apply_filters('hma_login_inline_url', home_url(trailingslashit(hma_get_login_inline_rewrite_slug()))); break; case 'register_url': return apply_filters('hma_register_url', home_url(trailingslashit(hma_get_register_rewrite_slug()))); break; case 'register_inline_url': return apply_filters('hma_register_inline_url', home_url(trailingslashit(hma_get_lost_password_inline_rewrite_slug()))); break; case 'lost_password_url': return apply_filters('hma_lost_password_url', home_url(trailingslashit(hma_get_lost_password_rewrite_slug()))); break; case 'lost_password_inline_url': return apply_filters('hma_lot_password_inline_url', home_url(trailingslashit(hma_get_lost_password_inline_rewrite_slug()))); break; case 'my_profile_url': _deprecated_argument(__FUNCTION__, '2.0', 'Use edit_profile_url instead of my_profile_url'); return apply_filters('hma_my_profile_url', home_url(trailingslashit(hma_get_edit_profile_rewrite_slug()))); break; case 'edit_profile_url': return apply_filters('hma_edit_profile_url', home_url(trailingslashit(hma_get_edit_profile_rewrite_slug()))); break; case 'logout_url': // TODO couldn't this just add action = logout to the current url? return add_query_arg('action', 'logout', hma_get_login_url()); break; } return $arg; }
/** * BP_Groups_Invite_Template constructor. * * @since 1.5.0 * * @param array $args */ public function __construct($args = array()) { // Backward compatibility with old method of passing arguments. if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '2.0.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__)); $old_args_keys = array(0 => 'user_id', 1 => 'group_id'); $func_args = func_get_args(); $args = bp_core_parse_args_array($old_args_keys, $func_args); } $r = wp_parse_args($args, array('page' => 1, 'per_page' => 10, 'page_arg' => 'invitepage', 'user_id' => bp_loggedin_user_id(), 'group_id' => bp_get_current_group_id())); $this->pag_arg = sanitize_key($r['page_arg']); $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']); $this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']); $iquery = new BP_Group_Member_Query(array('group_id' => $r['group_id'], 'type' => 'first_joined', 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'is_confirmed' => false, 'inviter_id' => $r['user_id'])); $this->invite_data = $iquery->results; $this->total_invite_count = $iquery->total_users; $this->invites = array_values(wp_list_pluck($this->invite_data, 'ID')); $this->invite_count = count($this->invites); // If per_page is set to 0 (show all results), don't generate // pag_links. if (!empty($this->pag_num)) { $this->pag_links = paginate_links(array('base' => add_query_arg($this->pag_arg, '%#%'), 'format' => '', 'total' => ceil($this->total_invite_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1, 'add_args' => array())); } else { $this->pag_links = ''; } }
function wp_new_user_notification($user_id, $deprecated = null, $notify = '') { if ($deprecated !== null) { _deprecated_argument(__FUNCTION__, '4.3.1'); } // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notifcation. if ('admin' === $notify || empty($deprecated) && empty($notify)) { return; } global $wpdb, $wp_hasher; $user = get_userdata($user_id); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // Generate something random for a password reset key. $key = wp_generate_password(20, false); /** This action is documented in wp-login.php */ do_action('retrieve_password_key', $user->user_login, $key); // Now insert the key, hashed, into the DB. if (empty($wp_hasher)) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash(8, true); } $hashed = time() . ':' . $wp_hasher->HashPassword($key); $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login)); $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; $message .= __('To set your password, visit the following address:') . "\r\n\r\n"; $message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login="******">\r\n\r\n"; $message .= wp_login_url() . "\r\n"; wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message); }
/** * Retrieve list of category objects. * * If you change the type to 'link' in the arguments, then the link categories * will be returned instead. Also all categories will be updated to be backwards * compatible with pre-2.3 plugins and themes. * * @since 2.1.0 * @see get_terms() Type of arguments that can be changed. * @link https://codex.wordpress.org/Function_Reference/get_categories * * @param string|array $args Optional. Change the defaults retrieving categories. * @return array List of categories. */ function get_categories($args = '') { $defaults = array('taxonomy' => 'category'); $args = wp_parse_args($args, $defaults); $taxonomy = $args['taxonomy']; /** * Filter the taxonomy used to retrieve terms when calling {@see get_categories()}. * * @since 2.7.0 * * @param string $taxonomy Taxonomy to retrieve terms from. * @param array $args An array of arguments. See {@see get_terms()}. */ $taxonomy = apply_filters('get_categories_taxonomy', $taxonomy, $args); // Back compat if (isset($args['type']) && 'link' == $args['type']) { _deprecated_argument(__FUNCTION__, '3.0', ''); $taxonomy = $args['taxonomy'] = 'link_category'; } $categories = (array) get_terms($taxonomy, $args); foreach (array_keys($categories) as $k) { _make_cat_compat($categories[$k]); } return $categories; }
public function __construct( $name, $title, array $values, $args = array() ) { $this->id = $name; $this->name = $name . '[]'; $this->title = $title; $this->args = wp_parse_args( $args, $this->get_default_args() ); // Deprecated argument: 'std' if ( ! empty( $this->args['std'] ) && empty( $this->args['default'] ) ) { $this->args['default'] = $this->args['std']; _deprecated_argument( 'CMB_Field', '0.9', "field argument 'std' is deprecated, use 'default' instead" ); } if ( ! empty( $this->args['options'] ) && is_array( reset( $this->args['options'] ) ) ) { $re_format = array(); foreach ( $this->args['options'] as $option ) { $re_format[$option['value']] = $option['name']; } $this->args['options'] = $re_format; } // If the field has a custom value populator callback if ( ! empty( $args['values_callback'] ) ) $this->values = call_user_func( $args['values_callback'], get_the_id() ); else $this->values = $values; $this->value = reset( $this->values ); }
/** * Retrieve list of category objects. * * If you change the type to 'link' in the arguments, then the link categories * will be returned instead. Also all categories will be updated to be backward * compatible with pre-2.3 plugins and themes. * * @since 2.1.0 * @see get_terms() Type of arguments that can be changed. * * @param string|array $args { * Optional. Arguments to retrieve categories. See get_terms() for additional options. * * @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'. * } * @return array List of categories. */ function get_categories($args = '') { $defaults = array('taxonomy' => 'category'); $args = wp_parse_args($args, $defaults); $taxonomy = $args['taxonomy']; /** * Filters the taxonomy used to retrieve terms when calling get_categories(). * * @since 2.7.0 * * @param string $taxonomy Taxonomy to retrieve terms from. * @param array $args An array of arguments. See get_terms(). */ $taxonomy = apply_filters('get_categories_taxonomy', $taxonomy, $args); // Back compat if (isset($args['type']) && 'link' == $args['type']) { /* translators: 1: "type => link", 2: "taxonomy => link_category" alternative */ _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('%1$s is deprecated. Use %2$s instead.'), '<code>type => link</code>', '<code>taxonomy => link_category</code>')); $taxonomy = $args['taxonomy'] = 'link_category'; } $categories = get_terms($taxonomy, $args); if (is_wp_error($categories)) { $categories = array(); } else { $categories = (array) $categories; foreach (array_keys($categories) as $k) { _make_cat_compat($categories[$k]); } } return $categories; }
function custom_new_user_notification($user_id, $deprecated = null, $notify = '', $password = null) { if ($deprecated !== null) { _deprecated_argument(__FUNCTION__, '4.3.1'); } global $wpdb, $wp_hasher; $user = get_userdata($user_id); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n"; @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if ('admin' === $notify || empty($notify)) { return; } if ($password === null) { $password = wp_generate_password(12, false); } // change the URL below to actual page with [adverts_manage] shortcode. $manage_url = home_url() . "/adverts/manage/"; $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; $message .= sprintf(__('Password: %s'), $password) . "\r\n"; $message .= 'To manage your Ads please use the following address ' . $manage_url . "\r\n"; wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); }
/** * Echoes or returns a pages or categories menu. * * Now only used for backwards-compatibility (genesis_vestige). * * The array of menu arguments (and their defaults) are: * - theme_location => '' * - type => 'pages' * - sort_column => 'menu_order, post_title' * - menu_id => false * - menu_class => 'nav' * - echo => true * - link_before => '' * - link_after => '' * * Themes can short-circuit the function early by filtering on 'genesis_pre_nav' or * on the string of list items via 'genesis_nav_items. They can also filter the * complete menu markup via 'genesis_nav'. The $args (merged with defaults) are * available for all filters. * * @category Genesis * @package Structure * @subpackage Menus * * @since 0.2.3 * * @uses genesis_get_seo_option() * @uses genesis_rel_nofollow() * * @see genesis_do_nav() * @see genesis_do_subnav() * * @param array $args Menu arguments * @return string HTML for menu (unless genesis_pre_nav returns something truthy) */ function genesis_nav($args = array()) { if (isset($args['context'])) { _deprecated_argument(__FUNCTION__, '1.2', __('The argument, "context", has been replaced with "theme_location" in the $args array.', 'genesis')); } /** Default arguments */ $defaults = array('theme_location' => '', 'type' => 'pages', 'sort_column' => 'menu_order, post_title', 'menu_id' => false, 'menu_class' => 'nav', 'echo' => true, 'link_before' => '', 'link_after' => ''); $defaults = apply_filters('genesis_nav_default_args', $defaults); $args = wp_parse_args($args, $defaults); /** Allow child theme to short-circuit this function */ $pre = apply_filters('genesis_pre_nav', false, $args); if ($pre) { return $pre; } $menu = ''; $list_args = $args; /** Show Home in the menu (mostly copied from WP source) */ if (isset($args['show_home']) && !empty($args['show_home'])) { if (true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home']) { $text = apply_filters('genesis_nav_home_text', __('Home', 'genesis'), $args); } else { $text = $args['show_home']; } $class = ''; if (is_front_page() && !is_paged()) { $class = 'class="home current_page_item"'; } else { $class = 'class="home"'; } $home = '<li ' . $class . '><a href="' . trailingslashit(home_url()) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; $menu .= genesis_get_seo_option('nofollow_home_link') ? genesis_rel_nofollow($home) : $home; /** If the front page is a page, add it to the exclude list */ if ('page' == get_option('show_on_front') && 'pages' == $args['type']) { $list_args['exclude'] .= $list_args['exclude'] ? ',' : ''; $list_args['exclude'] .= get_option('page_on_front'); } } $list_args['echo'] = false; $list_args['title_li'] = ''; /** Add menu items */ if ('pages' == $args['type']) { $menu .= str_replace(array("\r", "\n", "\t"), '', wp_list_pages($list_args)); } elseif ('categories' == $args['type']) { $menu .= str_replace(array("\r", "\n", "\t"), '', wp_list_categories($list_args)); } /** Apply filters to the nav items */ $menu = apply_filters('genesis_nav_items', $menu, $args); $menu_class = $args['menu_class'] ? ' class="' . esc_attr($args['menu_class']) . '"' : ''; $menu_id = $args['menu_id'] ? ' id="' . esc_attr($args['menu_id']) . '"' : ''; if ($menu) { $menu = '<ul' . $menu_id . $menu_class . '>' . $menu . '</ul>'; } /** Apply filters to the final nav output */ $menu = apply_filters('genesis_nav', $menu, $args); if ($args['echo']) { echo $menu; } else { return $menu; } }
/** * WooCommerce Dropdown categories * * Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258 * We use a custom walker, just like WordPress does * * @param int $show_counts (default: 1) * @param int $hierarchical (default: 1) * @param int $show_uncategorized (default: 1) * @return string */ function wc_product_dropdown_categories($args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '') { global $wp_query, $woocommerce; if (!is_array($args)) { _deprecated_argument('wc_product_dropdown_categories()', '2.1', 'show_counts, hierarchical, show_uncategorized and orderby arguments are invalid - pass a single array of values instead.'); $args['show_counts'] = $args; $args['hierarchical'] = $deprecated_hierarchical; $args['show_uncategorized'] = $deprecated_show_uncategorized; $args['orderby'] = $deprecated_orderby; } $defaults = array('pad_counts' => 1, 'show_counts' => 1, 'hierarchical' => 1, 'hide_empty' => 1, 'show_uncategorized' => 1, 'orderby' => 'name', 'selected' => isset($wp_query->query['product_cat']) ? $wp_query->query['product_cat'] : '', 'menu_order' => false); $args = wp_parse_args($args, $defaults); if ($args['orderby'] == 'order') { $r['menu_order'] = 'asc'; } $terms = get_terms('product_cat', $args); if (!$terms) { return; } $output = "<select name='product_cat' id='dropdown_product_cat'>"; $output .= '<option value="" ' . selected(isset($_GET['product_cat']) ? $_GET['product_cat'] : '', '', false) . '>' . __('Select a category', 'woocommerce') . '</option>'; $output .= wc_walk_category_dropdown_tree($terms, 0, $args); if ($args['show_uncategorized']) { $output .= '<option value="0" ' . selected(isset($_GET['product_cat']) ? $_GET['product_cat'] : '', '0', false) . '>' . __('Uncategorized', 'woocommerce') . '</option>'; } $output .= "</select>"; echo $output; }
/** * Installs the blog * * {@internal Missing Long Description}} * * @since 2.1.0 * * @param string $blog_title Blog title. * @param string $user_name User's username. * @param string $user_email User's email. * @param bool $public Whether blog is public. * @param null $deprecated Optional. Not used. * @param string $user_password Optional. User's chosen password. Will default to a random password. * @return array Array keys 'url', 'user_id', 'password', 'password_message'. */ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.6'); } wp_check_mysql_version(); wp_cache_flush(); make_db_current_silent(); if (!is_file(ABSPATH . 'wp-admin/install.sql')) { //[ysd]如果有install.sql不设置默认options数据 populate_options(); } else { validate_active_plugins(); //[ysd] 禁用 不可用的插件 } populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); $guessurl = isset($_SERVER['HTTP_APPNAME']) ? 'http://' . substr($_SERVER['HTTP_APPNAME'], 5) . '.1kapp.com' : wp_guess_url(); //[ysd] 固定了guessurl update_option('siteurl', $guessurl); update_option('home', $guessurl); get_option('siteurl'); // If not a public blog, don't ping. if (!$public) { update_option('default_pingback_flag', 0); } // Create default user. If the user already exists, the user tables are // being shared among blogs. Just set the role in that case. $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if (!$user_id && empty($user_password)) { $user_password = wp_generate_password(12, false); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = wp_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } else { if (!$user_id) { // Password has been provided $message = '<em>' . __('Your chosen password.') . '</em>'; $user_id = wp_create_user($user_name, $user_password, $user_email); } else { $message = __('User already exists. Password inherited.'); } } $user = new WP_User($user_id); $user->set_role('administrator'); if (!file_exists(ABSPATH . 'wp-admin/without_default')) { wp_install_defaults($user_id); } //[ysd],如果打包时设置了默认数据,才会设置默认数据 flush_rewrite_rules(); wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.')); wp_cache_flush(); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
/** * Wrapper for deprecated arguments so we can apply some extra logic. * * @since 2.7.0 * @param string $argument * @param string $version * @param string $replacement */ function wc_deprecated_argument($argument, $version, $message = null) { if (is_ajax()) { error_log("The {$argument} argument is deprecated since version {$version}. {$message}"); } else { _deprecated_argument($argument, $version, $message); } }
/** * Create a thumbnail from an Image given a maximum side size. * * This function can handle most image file formats which PHP supports. If PHP * does not have the functionality to save in a file of the same format, the * thumbnail will be created as a jpeg. * * @since 1.2.0 * * @param mixed $file Filename of the original image, Or attachment id. * @param int $max_side Maximum length of a single side for the thumbnail. * @param mixed $deprecated Never used. * @return string Thumbnail path on success, Error string on failure. */ function wp_create_thumbnail($file, $max_side, $deprecated = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '1.2'); } $thumbpath = image_resize($file, $max_side, $max_side); return apply_filters('wp_create_thumbnail', $thumbpath); }
/** * Get Venue * * Returns the event venue name * * @param int $postId Can supply either event id or venue id, if none specified, current post is used * @param bool $with_link (deprecated in 2.0.1) * @return string Venue Name * @since 2.0 */ function tribe_get_venue($postId = null, $with_link = false) { if ($with_link) { _deprecated_argument(__FUNCTION__, '2.0.1'); } $postId = tribe_get_venue_id($postId); $venue = $postId > 0 ? esc_html(get_post($postId)->post_title) : null; return $venue; }
public function __set($property, $value) { if ($property == 'id') { _deprecated_argument('id', '0.0.2', "Property 'id' is deprecated. Please use 'ID'."); $this->ID = $value; } else { $this->{$property} = $value; } }
/** * Get Venue * * Returns the event venue name * * @param int $postId Can supply either event id or venue id, if none specified, current post is used * @param bool $with_link (deprecated in 2.0.1) * * @return string Venue Name */ function tribe_get_venue($postId = null, $with_link = false) { if ($with_link) { _deprecated_argument(__FUNCTION__, '2.0.1'); } $postId = tribe_get_venue_id($postId); $venue = $postId > 0 ? esc_html(get_the_title($postId)) : null; return apply_filters('tribe_get_venue', $venue); }
public function tax($args) { if (is_string($args)) { _deprecated_argument(__FUNCTION__, 'Deprecated since version 3.1 in favor of `tax_query`'); $this->tax = $args; } elseif (is_array($args)) { $this->args['tax_query'][] = $args; } return $this; }
/** * This function overrides wp_install() in wp-admin/includes/upgrade.php */ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') { if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.6'); } wp_check_mysql_version(); wp_cache_flush(); /* changes */ require_once PDODIR . 'schema.php'; make_db_sqlite(); /* changes */ populate_options(); populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); $guessurl = wp_guess_url(); update_option('siteurl', $guessurl); if (!$public) { update_option('default_pingback_flag', 0); } $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if (!$user_id && empty($user_password)) { $user_password = wp_generate_password(12, false); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = wp_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } else { if (!$user_id) { $message = '<em>' . __('Your chosen password.') . '</em>'; $user_id = wp_create_user($user_name, $user_password, $user_email); } } $user = new WP_User($user_id); $user->set_role('administrator'); wp_install_defaults($user_id); flush_rewrite_rules(); wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.')); wp_cache_flush(); if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) { // Your server is Apache. Nothing to do more. } else { $server_message = sprintf('Your webserver doesn\'t seem to be Apache. So the database directory access restriction by the .htaccess file may not function. We strongly recommend that you should restrict the access to the directory %s in some other way.', FQDBDIR); echo '<div style="position: absolute; margin-top: 350px; width: 700px; border: .5px dashed rgb(0, 0, 0);"><p style="margin: 10px;">'; echo $server_message; echo '</p></div>'; } return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
/** * Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms. returns -1 if no page is found. * * @param string $page * @return int */ function wc_get_page_id($page) { if ($page == 'pay' || $page == 'thanks') { _deprecated_argument(__FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the WC_Order::get_checkout_payment_url() or WC_Order::get_checkout_order_received_url() methods instead.'); $page = 'checkout'; } if ($page == 'change_password' || $page == 'edit_address' || $page == 'lost_password') { _deprecated_argument(__FUNCTION__, '2.1', 'The "change_password", "edit_address" and "lost_password" pages are no-longer used - an endpoint is added to the my-account instead. To get a valid link use the wc_customer_edit_account_url() function instead.'); $page = 'myaccount'; } $page = apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id')); return $page ? absint($page) : -1; }
/** * trigger function. * * @access public * @return void */ function trigger($subscription) { $this->object = $subscription; if (!is_object($subscription)) { _deprecated_argument(__METHOD__, '2.0', 'The subscription key is deprecated. Use a subscription post ID'); $subscription = wcs_get_subscription_from_key($subscription); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } update_post_meta($subscription->id, '_cancelled_email_sent', 'true'); $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Searches for all matching country/state/postcode tax rates. * * @access public * @param string $args (default: '') * @return array */ public function find_rates($args = array(), $deprecated_state = null, $deprecated_postcode = null, $deprecated_class = null) { global $wpdb; // Make sure the arguments match the WC 2.0 structure if (is_string($args)) { _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["country"] instead. Deprecated argument will be removed in WC 2.1.'); $args = array('country' => $args); } if (func_num_args() > 1) { if (null !== $deprecated_state) { _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["state"] instead. Deprecated argument will be removed in WC 2.1.'); $args['state'] = $deprecated_state; } if (null !== $deprecated_postcode) { _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["postcode"] instead. Deprecated argument will be removed in WC 2.1.'); $args['postcode'] = $deprecated_postcode; } if (null !== $deprecated_class) { _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["tax_class"] instead. Deprecated argument will be removed in WC 2.1.'); $args['tax_class'] = $deprecated_class; } } $defaults = array('country' => '', 'state' => '', 'city' => '', 'postcode' => '', 'tax_class' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); if (!$country) { return array(); } // Handle postcodes $valid_postcodes = array('*', strtoupper(woocommerce_clean($postcode))); // Work out possible valid wildcard postcodes $postcode_length = strlen($postcode); $wildcard_postcode = strtoupper(woocommerce_clean($postcode)); for ($i = 0; $i < $postcode_length; $i++) { $wildcard_postcode = substr($wildcard_postcode, 0, -1); $valid_postcodes[] = $wildcard_postcode . '*'; } // Run the query $found_rates = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT tax_rates.* FROM\n\t\t\t\t{$wpdb->prefix}woocommerce_tax_rates as tax_rates\n\t\t\tLEFT OUTER JOIN\n\t\t\t\t{$wpdb->prefix}woocommerce_tax_rate_locations as locations ON tax_rates.tax_rate_id = locations.tax_rate_id\n\t\t\tWHERE\n\t\t\t\ttax_rate_country IN ( %s, '' )\n\t\t\t\tAND tax_rate_state IN ( %s, '' )\n\t\t\t\tAND tax_rate_class = %s\n\t\t\t\tAND (\n\t\t\t\t\t(\n\t\t\t\t\t\tlocations.location_type = 'postcode' AND locations.location_code IN ('" . implode("','", $valid_postcodes) . "')\n\t\t\t\t\t)\n\t\t\t\t\tOR\n\t\t\t\t\t(\n\t\t\t\t\t\tlocations.location_type = 'city' AND locations.location_code = %s\n\t\t\t\t\t)\n\t\t\t\t\tOR locations.location_type IS null\n\t\t\t\t)\n\t\t\tGROUP BY\n\t\t\t\ttax_rate_priority\n\t\t\tORDER BY\n\t\t\t\ttax_rate_priority, tax_rate_order\n\t\t\t", strtoupper($country), strtoupper($state), sanitize_title($tax_class), strtoupper($city))); // Put results into array $matched_tax_rates = array(); foreach ($found_rates as $found_rate) { $matched_tax_rates[$found_rate->tax_rate_id] = array('rate' => $found_rate->tax_rate, 'label' => $found_rate->tax_rate_name, 'shipping' => $found_rate->tax_rate_shipping ? 'yes' : 'no', 'compound' => $found_rate->tax_rate_compound ? 'yes' : 'no'); } /* echo '<pre>' . __( 'Matched tax rates:', 'woocommerce' ); var_dump( $matched_tax_rates ); echo '</pre>'; */ return apply_filters('woocommerce_matched_tax_rates', $matched_tax_rates, $country, $state, $postcode, $city, $tax_class); }
/** * Pluggable - Email login credentials to a newly-registered user * * A new user registration notification is also sent to admin email. * * @since 2.0.0 * * @param int $user_id User ID. * @param string $plaintext_pass Optional. The user's plaintext password. Default empty. */ function wp_new_user_notification($user_id, $deprecated = null, $notify = '') { if ($deprecated !== null) { _deprecated_argument(__FUNCTION__, '4.3.1'); } global $wpdb, $wp_hasher; $user = get_userdata($user_id); $userEmail = $user->user_email; $logoUrl = plugin_dir_url(__FILE__) . '/rw-new.jpg'; // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your site %s:'), $blogname); $message .= "\r\n\r\n" . sprintf(__('Username: %s'), $user->user_login); $message .= "\r\n\r\n" . sprintf(__('E-mail: %s'), $user->user_email) . "\r\n"; @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if ('admin' === $notify || empty($notify)) { return; } // Generate something random for a password reset key. $key = wp_generate_password(20, false); /** This action is documented in wp-login.php */ do_action('retrieve_password_key', $user->user_login, $key); // Now insert the key, hashed, into the DB. if (empty($wp_hasher)) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash(8, true); } $hashed = time() . ':' . $wp_hasher->HashPassword($key); $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login)); $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = '<html><body>'; $message .= '<img src="' . $logoUrl . '" />'; $message .= '<h1>Hello, Welcome to RetailWire!</h1>'; $message .= '<h3>Thanks for registering. Just three quick steps, and you"re all done:</h3>'; $message .= '<h3>1. Set your password by clicking this link:</h3>'; $message .= '<p>' . network_site_url("wp-login.php?action=rp&key={$key}&login="******"</p>"; $message .= '<h3>2. After setting your password, you’ll be taken to a page to complete your profile. Please take a moment to complete the form.</h3>'; $message .= '<h3>3. And be sure to subscribe to our newsletters so we can keep you informed. Click here to join our list:</h3>'; $message .= '<p>' . network_site_url("subscribe") . "</p>"; $message .= '<h3>If you have any problems, please contact us at</h3>'; $message .= get_option('admin_email'); $message .= '</body></html>'; // $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; // $message .= __('Thanks for registering with RetailWire! To set your password, visit the following address:') . "\r\n"; // $message .= '' . network_site_url("wp-login.php?action=rp&key=$key&login="******"\r\n"; // $message .= sprintf( __('Login, update your password and take a moment to fill in your profile. Then continue on and read the latest in retail news and discussions. If you have any problems, please contact us at %s.'), get_option('admin_email') ) . "\n\n"; // $message .= __('Thank You!') . "\n"; wp_mail($user->user_email, sprintf(__('[%s] Welcome! Please complete your RetailWire profile.'), $blogname), $message, $headers); }
/** * Parse default arguments for the editor instance. * * @param string $editor_id ID for the current editor instance. * @param array $settings { * Array of editor arguments. * * @type bool $wpautop Whether to use wpautop(). Default true. * @type bool $media_buttons Whether to show the Add Media/other media buttons. * @type string $default_editor When both TinyMCE and Quicktags are used, set which * editor is shown on page load. Default empty. * @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false. * Requires the media modal. * @type string $textarea_name Give the textarea a unique name here. Square brackets * can be used here. Default $editor_id. * @type int $textarea_rows Number rows in the editor textarea. Default 20. * @type string|int $tabindex Tabindex value to use. Default empty. * @type string $tabfocus_elements The previous and next element ID to move the focus to * when pressing the Tab key in TinyMCE. Defualt ':prev,:next'. * @type string $editor_css Intended for extra styles for both Visual and Text editors. * Should include `<style>` tags, and can use "scoped". Default empty. * @type string $editor_class Extra classes to add to the editor textarea elemen. Default empty. * @type bool $teeny Whether to output the minimal editor config. Examples include * Press This and the Comment editor. Default false. * @type bool $dfw Whether to replace the default fullscreen with "Distraction Free * Writing". DFW requires specific DOM elements and css). Default false. * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to * TinyMCE using an array. Default true. * @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to * Quicktags using an array. Default true. * } * @return array Parsed arguments array. */ public static function parse_settings($editor_id, $settings) { /** * Filter the wp_editor() settings. * * @since 4.0.0 * * @see _WP_Editors()::parse_settings() * * @param array $settings Array of editor arguments. * @param string $editor_id ID for the current editor instance. */ $settings = apply_filters('wp_editor_settings', $settings, $editor_id); $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'default_editor' => '', 'drag_drop_upload' => false, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, '_content_editor_dfw' => false, 'tinymce' => true, 'quicktags' => true)); self::$this_tinymce = $set['tinymce'] && user_can_richedit(); if (self::$this_tinymce) { if (false !== strpos($editor_id, '[')) { self::$this_tinymce = false; _deprecated_argument('wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.'); } } self::$this_quicktags = (bool) $set['quicktags']; if (self::$this_tinymce) { self::$has_tinymce = true; } if (self::$this_quicktags) { self::$has_quicktags = true; } if (empty($set['editor_height'])) { return $set; } if ('content' === $editor_id && empty($set['tinymce']['wp_autoresize_on'])) { // A cookie (set when a user resizes the editor) overrides the height. $cookie = (int) get_user_setting('ed_size'); // Upgrade an old TinyMCE cookie if it is still around, and the new one isn't. if (!$cookie && isset($_COOKIE['TinyMCE_content_size'])) { parse_str($_COOKIE['TinyMCE_content_size'], $cookie); $cookie = $cookie['ch']; } if ($cookie) { $set['editor_height'] = $cookie; } } if ($set['editor_height'] < 50) { $set['editor_height'] = 50; } elseif ($set['editor_height'] > 5000) { $set['editor_height'] = 5000; } return $set; }
/** * These functions are taken from the WORDPRESS 3.6-BETA3-24432 release and heavily modified to work for us in the frontend. * * @package BuddyForms * @since 0.1 beta */ function buddyforms_wp_list_post_revisions($post_id = 0, $type = 'all') { if (!($post = get_post($post_id))) { return; } // $args array with (parent, format, right, left, type) deprecated since 3.6 if (is_array($type)) { $type = !empty($type['type']) ? $type['type'] : $type; _deprecated_argument(__FUNCTION__, '3.6'); } if (!($revisions = buddyforms_wp_get_post_revisions($post->ID))) { return; } $rows = ''; foreach ($revisions as $revision) { if (!current_user_can('read_post', $revision->ID)) { continue; } $is_autosave = wp_is_post_autosave($revision); if ('revision' === $type && $is_autosave || 'autosave' === $type && !$is_autosave) { continue; } $rows .= "\t<li>" . buddyforms_wp_post_revision_title_expanded($revision, $post_id) . "</li>\n"; } echo '<div class="revision">'; echo '<h3>' . __('Revision', 'buddyforms') . '</h3>'; echo "<ul class='post-revisions'>\n"; echo $rows; // if the post was previously restored from a revision // show the restore event details if ($restored_from_meta = get_post_meta($post->ID, '_post_restored_from', true)) { $author = get_user_by('id', $restored_from_meta['restored_by_user']); /* translators: revision date format, see http://php.net/date */ $datef = _x('j F, Y @ G:i:s', 'revision date format'); $date = date_i18n($datef, strtotime($restored_from_meta['restored_time'])); $time_diff = human_time_diff($restored_from_meta['restored_time']); ?> <hr /> <div id="revisions-meta-restored"> <?php printf(__('Previously restored by %1$s %2$s, %3$s ago (%4$s)'), get_avatar($author->ID, 24), $author->display_name, $time_diff, $date); ?> </div> <?php } echo "</ul>"; echo "</div>"; }