本文整理汇总了PHP中_doing_it_wrong函数的典型用法代码示例。如果您正苦于以下问题:PHP _doing_it_wrong函数的具体用法?PHP _doing_it_wrong怎么用?PHP _doing_it_wrong使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_doing_it_wrong函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($args = array())
{
// Load our helper function
require_once 'icit-helpers.php';
// notification helper
require_once 'icit-notices.php';
// Makes it easier to set default options on get_option.
require_once 'icit-defaults.php';
if (isset($args['dir'])) {
$this->dir = $args['dir'];
}
if (isset($args['url'])) {
$this->url = $args['url'];
}
// Set the folder for the core
$this->dir === null && ($this->dir = dirname(__FILE__));
// Load the translation stuff..
$locale = get_locale();
if (file_exists($this->dir . '/lang/' . self::DOM . '-' . $locale . '.mo')) {
load_textdomain(self::DOM, $this->dir . '/lang/' . self::DOM . '-' . $locale . '.mo');
}
// add core class autoloaders
spl_autoload_register(array($this, '__autoload'));
//spl_autoload_register( array( $this, '__autoload_psr0' ) );
spl_autoload_register(array($this, '__autoload_wp'));
if (did_action('init') && !(isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']))) {
_doing_it_wrong('icit_core', __('icit_core should be included at the top of your theme or plug-in file and should load before the init action.', self::DOM), 'icit_core:1.0');
} else {
if (!did_action('plugins_loaded') && !did_action('setup_theme') && $this->is_plugin == null) {
$this->is_plugin = true;
} elseif (did_action('plugins_loaded') && !did_action('setup_theme') && $this->is_plugin === null) {
$this->is_plugin = false;
}
}
}
示例2: tribe_is_recurring_event
function tribe_is_recurring_event($post_id = null)
{
$post_id = Tribe__Events__Main::postIdHelper($post_id);
if (!$post_id) {
_doing_it_wrong(__FUNCTION__, 'You need to pass a post ID or use it in the loop.', '3.10');
return false;
}
$post = get_post($post_id);
if ($post->post_type != Tribe__Events__Main::POSTTYPE) {
return false;
}
$recurring = false;
if ($post->post_parent > 0) {
$recurring = true;
} else {
$recurrence_meta = get_post_meta($post_id, '_EventRecurrence', true);
if (!empty($recurrence_meta['rules'])) {
foreach ($recurrence_meta['rules'] as &$recurrence) {
if ('None' !== $recurrence['type']) {
$recurring = true;
break;
}
}
}
}
return apply_filters('tribe_is_recurring_event', $recurring, $post_id);
}
示例3: create
/**
* Create an MS Object.
*
* @since 1.0.0
*
* @param string $class The class to create object from.
* @return object The created object.
*/
public static function create($class, $init_arg = null)
{
$singletons = array('MS_Model_Pages', 'MS_Model_Settings', 'MS_Model_Addon', 'MS_Model_Rule', 'MS_Model_Simulate');
$class = trim($class);
if (in_array($class, $singletons)) {
_doing_it_wrong('MS_Factory::create()', 'This class is a singleton and should be fetched via MS_Factory::load() -> ' . $class, '1.0.4.5');
}
if (class_exists($class)) {
if (null === $init_arg) {
$obj = new $class();
} else {
$obj = new $class($init_arg);
}
} else {
throw new Exception('Class ' . $class . ' does not exist.');
}
/*
* Assign a new unique-ID to the object right after loading it.
*
* Purpose:
* This helps us to spot duplicates of the same object.
* We can also identify objects that were not created by MS_Factory.
*/
$obj->_factory_id = uniqid('object-');
self::prepare_obj($obj);
return apply_filters('ms_factory_create_' . $class, $obj);
}
示例4: __set
/**
* __set function.
* @todo use set_* methods
* @param mixed $property
* @param mixed $key
*/
public function __set($key, $value)
{
_doing_it_wrong($key, 'Customer properties should not be set directly.', '2.7');
$key = $this->filter_legacy_key($key);
$this->_data[$key] = $value;
$this->_changed = true;
}
示例5: construct
/**
* Constructor
*/
public static function construct()
{
/**
* The auto-switch should always work
*/
self::_load_plugin_list();
self::_setup_automatic_switch();
/**
* The rest relies on user privileges, and therefore must wait until necessary WP functions are loaded
*/
if (!did_action('plugins_loaded')) {
_doing_it_wrong(__METHOD__, __('Must call in of after the "plugins_loaded" action.', 'redux-framework'), '14.03.19');
return;
}
/**
* Low-level users won't see anything
*/
if (!current_user_can(TIVWP_DM::MIN_CAPABILITY)) {
return;
}
/**
* The main actions happen in the admin area
*/
if (is_admin()) {
self::_setup_i18n();
self::_setup_plugin_composer();
self::_setup_admin_interface();
}
}
示例6: __construct
/**
* Class Constructor
*
* @since 1.0
* @param array $config the configuration required for the updater to work
* @see has_minimum_config()
* @return void
*/
public function __construct($config = array())
{
require_once plugin_dir_path(__FILE__) . "Parsedown.php";
$defaults = array('slug' => plugin_basename(__FILE__), 'proper_folder_name' => dirname(plugin_basename(__FILE__)), 'sslverify' => true, 'access_token' => '', 'changelog', 'githubAPIResult');
$this->config = wp_parse_args($config, $defaults);
//print_r($this->config);die();
// if the minimum config isn't set, issue a warning and bail
if (!$this->has_minimum_config()) {
$message = 'The GitHub Updater was initialized without the minimum required configuration, please check the config in your plugin. The following params are missing: ';
$message .= implode(',', $this->missing_config);
_doing_it_wrong(__CLASS__, $message, self::VERSION);
return;
}
$this->set_defaults();
add_filter('pre_set_site_transient_update_plugins', array($this, 'api_check'));
// Hook into the plugin details screen
if (strpos($_SERVER['SCRIPT_NAME'], 'plugin-install.php')) {
if (isset($_GET['tab']) && strpos($_GET['tab'], 'rapidology') > 0) {
add_filter('plugins_api', array($this, 'get_plugin_info'), 10, 3);
}
}
if (isset($_GET['tab'])) {
if (isset($_GET['plugin']) && $_GET['plugin'] == 'rapidology') {
add_filter('plugins_api', array($this, 'get_plugin_info'), 10, 3);
}
}
add_filter('upgrader_post_install', array($this, 'upgrader_post_install'), 10, 3);
// set timeout
add_filter('http_request_timeout', array($this, 'http_request_timeout'));
// set sslverify for zip download
add_filter('http_request_args', array($this, 'http_request_sslverify'), 10, 2);
}
示例7: set
/**
* Set key/value within an array, can set a key nested inside of a multidimensional array.
*
* Example: set( $a, [ 0, 1, 2 ], 'hi' ) sets $a[0][1][2] = 'hi' and returns $a.
*
* @param mixed $array The array containing the key this sets.
* @param string|array $key To set a key nested multiple levels deep pass an array
* specifying each key in order as a value.
* Example: array( 'lvl1', 'lvl2', 'lvl3' );
* @param mixed $value The value.
*
* @return array Full array with the key set to the specified value.
*/
public static function set(array $array, $key, $value)
{
// Convert strings and such to array.
$key = (array) $key;
// Setup a pointer that we can point to the key specified.
$key_pointer =& $array;
// Iterate through every key, setting the pointer one level deeper each time.
foreach ($key as $i) {
// Ensure current array depth can have children set.
if (!is_array($key_pointer)) {
// $key_pointer is set but is not an array. Converting it to an array
// would likely lead to unexpected problems for whatever first set it.
$error = sprintf('Attempted to set $array[%1$s] but %2$s is already set and is not an array.', implode($key, ']['), $i);
_doing_it_wrong(__FUNCTION__, esc_html($error), '4.3');
break;
} elseif (!isset($key_pointer[$i])) {
$key_pointer[$i] = array();
}
// Dive one level deeper into the nested array.
$key_pointer =& $key_pointer[$i];
}
// Set the value for the specified key
$key_pointer = $value;
return $array;
}
示例8: register_rest_route
/**
* Registers a REST API route.
*
* @since 4.4.0
*
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
*
* @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin.
* @param string $route The base URL for route you are adding.
* @param array $args Optional. Either an array of options for the endpoint, or an array of arrays for
* multiple methods. Default empty array.
* @param bool $override Optional. If the route already exists, should we override it? True overrides,
* false merges (with newer overriding if duplicate keys exist). Default false.
* @return bool True on success, false on error.
*/
function register_rest_route($namespace, $route, $args = array(), $override = false)
{
/** @var WP_REST_Server $wp_rest_server */
global $wp_rest_server;
if (empty($namespace)) {
/*
* Non-namespaced routes are not allowed, with the exception of the main
* and namespace indexes. If you really need to register a
* non-namespaced route, call `WP_REST_Server::register_route` directly.
*/
_doing_it_wrong('register_rest_route', __('Routes must be namespaced with plugin or theme name and version.'), '4.4.0');
return false;
} else {
if (empty($route)) {
_doing_it_wrong('register_rest_route', __('Route must be specified.'), '4.4.0');
return false;
}
}
if (isset($args['callback'])) {
// Upgrade a single set to multiple.
$args = array($args);
}
$defaults = array('methods' => 'GET', 'callback' => null, 'args' => array());
foreach ($args as $key => &$arg_group) {
if (!is_numeric($arg_group)) {
// Route option, skip here.
continue;
}
$arg_group = array_merge($defaults, $arg_group);
}
$full_route = '/' . trim($namespace, '/') . '/' . trim($route, '/');
$wp_rest_server->register_route($namespace, $full_route, $args, $override);
return true;
}
示例9: update_modules
/**
* Save module options.
*
* @return void
*/
public function update_modules()
{
check_admin_referer($this->nonce_action);
if (!current_user_can('manage_network_options')) {
wp_die('FU');
}
$this->set_module_activation_status();
/**
* Runs before the redirect.
*
* Process your fields in the $_POST superglobal here and then call update_site_option().
*
* @param array $_POST
*/
do_action('mlp_modules_save_fields', $_POST);
// backwards compatibility
if (has_action('mlp_settings_save_fields')) {
_doing_it_wrong('mlp_settings_save_fields', 'mlp_settings_save_fields is deprecated, use mlp_modules_save_fields instead.', '1.2');
/**
* @see mlp_modules_save_fields
* @deprecated
*/
do_action('mlp_settings_save_fields');
}
wp_safe_redirect(network_admin_url('settings.php?page=mlp&message=updated'));
exit;
}
示例10: offsetUnset
/**
* Unset a nav array value at the specified offset.
*
* @since 2.6.0
*
* @param mixed $offset Array offset.
*/
public function offsetUnset($offset)
{
_doing_it_wrong('bp_nav', __('These globals should not be used directly and are deprecated. Please use the BuddyPress nav functions instead.', 'buddypress'), '2.6.0');
$this->get_component_nav($offset)->delete_nav($offset, $this->get_parent_slug());
// Clear the cached nav.
unset($this->backcompat_nav[$offset]);
}
示例11: wc_doing_it_wrong
/**
* Wrapper for wc_doing_it_wrong.
*
* @since 2.7.0
* @param string $function
* @param string $version
* @param string $replacement
*/
function wc_doing_it_wrong($function, $message, $version)
{
if (is_ajax()) {
error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
} else {
_doing_it_wrong($function, $message, $version);
}
}
示例12: wc_get_order
/**
* Main function for returning orders, uses the WC_Order_Factory class.
*
* @since 2.2
* @param mixed $the_order Post object or post ID of the order.
* @return WC_Order
*/
function wc_get_order($the_order = false)
{
if (!did_action('woocommerce_init')) {
_doing_it_wrong(__FUNCTION__, __('wc_get_order should not be called before the woocommerce_init action.', 'woocommerce'), '2.5');
return false;
}
return WC()->order_factory->get_order($the_order);
}
示例13: __construct
public function __construct()
{
if (empty($this->type)) {
_doing_it_wrong('WP_JSON_Authentication::__construct', __('The type of authentication must be set'), 'WPAPI-0.9');
return;
}
add_filter('json_check_authentication', array($this, 'authenticate'), 0);
}
示例14: __set
/**
* __set function.
* @todo use set_* methods
* @param mixed $property
* @param mixed $key
*/
public function __set($key, $value)
{
_doing_it_wrong($key, 'Customer properties should not be set directly.', '2.7');
$key = $this->filter_legacy_key($key);
if (is_callable(array($this, "set_{$key}"))) {
$this->{"set_{$key}"}($value);
}
}
示例15: get_object
/**
* Return an object of type Charitable_Benefactor, given a benefactor record and an extension.
*
* @param Object $benefactor
* @param string $extension
* @return Charitable_Benefactor
* @access public
* @static
* @since 1.0.0
*/
public static function get_object($benefactor, $extension)
{
$class = apply_filters('charitable_benefactor_class_' . $extension, false);
if (!class_exists($class)) {
_doing_it_wrong(__METHOD__, __('Benefactor class does not exist for given extension.', '1.0.0'));
}
return new $class($benefactor);
}