本文整理汇总了PHP中_deprecated_argument函数的典型用法代码示例。如果您正苦于以下问题:PHP _deprecated_argument函数的具体用法?PHP _deprecated_argument怎么用?PHP _deprecated_argument使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_deprecated_argument函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_settings
/**
* 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;
}
示例2: add_field
/**
* 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;
}
示例3: output
/**
* 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();
}
}
示例4: custom_new_user_notification
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);
}
示例5: __construct
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();
}
示例6: get_plugin_data
/**
* 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;
}
示例7: wc_product_dropdown_categories
/**
* 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;
}
示例8: __construct
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 );
}
示例9: genesis_nav
/**
* 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;
}
}
示例10: get_categories
/**
* 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;
}
示例11: __construct
/**
* 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 = '';
}
}
示例12: get_categories
/**
* 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;
}
示例13: wp_new_user_notification
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=" . rawurlencode($user->user_login), '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);
}
示例14: hma_blogfilter
/**
* 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;
}
示例15: wp_install
/**
* 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);
}