本文整理汇总了PHP中c_ws_plugin__s2member_utils_strings::like_escape方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_strings::like_escape方法的具体用法?PHP c_ws_plugin__s2member_utils_strings::like_escape怎么用?PHP c_ws_plugin__s2member_utils_strings::like_escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c_ws_plugin__s2member_utils_strings
的用法示例。
在下文中一共展示了c_ws_plugin__s2member_utils_strings::like_escape方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users_list_query
/**
* Modifies the search query.
*
* Affects searches performed in the list of Users.
*
* @package s2Member\Users_List
* @since 3.5
*
* @attaches-to ``add_action("pre_user_query");``
*
* @param WP_User_Query $query Expects a `WP_User_Query` object, by reference.
*/
public static function users_list_query(&$query = NULL)
{
global $wpdb;
/** @var $wpdb wpdb */
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_before_users_list_search", get_defined_vars());
unset($__refs, $__v);
if (is_admin() && !empty($GLOBALS['pagenow']) && $GLOBALS['pagenow'] === 'users.php') {
if (isset($query->query_vars) && !is_network_admin()) {
// NOT in Network admin panels.
if (is_array($qv = $query->query_vars) && ($s = trim($qv["search"], "* \t\n\r\v")) && ($s = "%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape($s)) . "%")) {
$query->query_fields = "SQL_CALC_FOUND_ROWS DISTINCT(`" . $wpdb->users . "`.`ID`)";
$query->query_from = " FROM `" . $wpdb->users . "`, `" . $wpdb->usermeta . "`";
// Include meta table also.
$query->query_where = " WHERE `" . $wpdb->users . "`.`ID` = `" . $wpdb->usermeta . "`.`user_id`";
// Join w/ meta table.
$query->query_where .= " AND (" . apply_filters("ws_plugin__s2member_before_users_list_search_where_or_before", "", get_defined_vars());
$query->query_where .= " (`" . $wpdb->users . "`.`user_login` LIKE '" . $s . "' OR `" . $wpdb->users . "`.`user_nicename` LIKE '" . $s . "' OR `" . $wpdb->users . "`.`display_name` LIKE '" . $s . "' OR `" . $wpdb->users . "`.`user_email` LIKE '" . $s . "' OR `" . $wpdb->users . "`.`user_url` LIKE '" . $s . "')";
$query->query_where .= " OR ((`" . $wpdb->usermeta . "`.`meta_key` = 'first_name' OR `" . $wpdb->usermeta . "`.`meta_key` = 'last_name') AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->base_prefix . "s2member_subscr_id' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->base_prefix . "s2member_custom' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->base_prefix . "s2member_custom_fields' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
if (apply_filters("ws_plugin__s2member_users_list_search_admin_notes", FALSE, get_defined_vars())) {
// Off by default; this can get very slow on large sites.
$query->query_where .= " OR (`" . $wpdb->usermeta . "`.`meta_key` = '" . $wpdb->base_prefix . "s2member_notes' AND `" . $wpdb->usermeta . "`.`meta_value` LIKE '" . $s . "')";
}
$query->query_where .= apply_filters("ws_plugin__s2member_before_users_list_search_where_or_after", "", get_defined_vars()) . ")";
// Leaving room for additional searches here.
if (is_multisite()) {
// On a Multisite Network we need to make sure we're searching only users w/ capabilities on this blog.
$query->query_where .= " AND `" . $wpdb->users . "`.`ID` IN(SELECT DISTINCT(`user_id`) FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "capabilities')";
}
$query->query_from = apply_filters("ws_plugin__s2member_before_users_list_search_from", $query->query_from, get_defined_vars());
$query->query_where = apply_filters("ws_plugin__s2member_before_users_list_search_where", $query->query_where, get_defined_vars());
}
}
}
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_after_users_list_search", get_defined_vars());
unset($__refs, $__v);
}
示例2: export_users
/**
* Handles the exportation of Users/Members.
*
* @package s2Member\Exports
* @since 140724
*
* @return null Or exits script execution after issuing file download prompt with CSV file.
*/
public static function export_users()
{
if (!empty($_POST['ws_plugin__s2member_pro_export_users']) && ($nonce = $_POST['ws_plugin__s2member_pro_export_users']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-pro-export-users') && current_user_can('create_users')) {
global $wpdb;
// Global database object reference.
/** @var \wpdb $wpdb This line for IDEs that need a reference. */
global $current_site, $current_blog;
// Multisite Networking.
@set_time_limit(0);
@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
@ini_set('zlib.output_compression', 0);
if (function_exists('apache_setenv')) {
@apache_setenv('no-gzip', '1');
}
while (@ob_end_clean()) {
}
$format = !empty($_POST['ws_plugin__s2member_pro_export_users_format']) ? $_POST['ws_plugin__s2member_pro_export_users_format'] : '';
$utf8_bom = isset($_POST['ws_plugin__s2member_pro_export_users_utf8_bom']) ? (int) $_POST['ws_plugin__s2member_pro_export_users_utf8_bom'] : 0;
$start = !empty($_POST['ws_plugin__s2member_pro_export_users_start']) ? (int) $_POST['ws_plugin__s2member_pro_export_users_start'] : 1;
$limit = !empty($_POST['ws_plugin__s2member_pro_export_users_limit']) ? (int) $_POST['ws_plugin__s2member_pro_export_users_limit'] : apply_filters('ws_plugin__s2member_pro_export_users_limit', 1000);
// Back compatibility; and for blog farms.
$start = $start >= 1 ? $start : 1;
// Must be 1 or higher.
$sql_s = $start === 1 ? 0 : $start;
// 1 should be 0.
$export = '';
// Initialize the export file variable.
$user_keys = array();
// Initialize array of user keys.
if (is_object($_user_row = $wpdb->get_row("SELECT * FROM `" . $wpdb->users . "` LIMIT 1"))) {
foreach (array_keys((array) $_user_row) as $_user_key) {
if (!in_array($_user_key, array('user_pass'), TRUE)) {
$user_keys[] = $_user_key;
}
}
}
unset($_user_row, $_user_key);
// Housekeeping.
$user_keys = array_unique($user_keys);
// Only unique keys please.
$user_permission_keys = array('role', 'ccaps');
$user_meta_keys = $wpdb->get_col("SELECT DISTINCT `meta_key` FROM `" . $wpdb->usermeta . "` WHERE (`" . $wpdb->usermeta . "`.`meta_key` NOT LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape($wpdb->base_prefix)) . "%' OR `" . $wpdb->usermeta . "`.`meta_key` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape($wpdb->prefix)) . "%')");
$user_meta_keys = is_array($user_meta_keys) ? $user_meta_keys : array();
foreach ($user_meta_keys as $_index => $_meta_key) {
if ($_meta_key === $wpdb->prefix . 's2member_custom_fields') {
unset($user_meta_keys[$_index]);
}
}
if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
foreach ($user_meta_keys as $_index => $_meta_key) {
if (strpos($_meta_key, $wpdb->prefix) !== 0) {
if (!in_array($_meta_key, array('first_name', 'last_name', 'nickname', 'description'), TRUE)) {
unset($user_meta_keys[$_index]);
}
}
}
}
unset($_index, $_meta_key);
// Housekeeping.
$user_meta_keys = array_unique($user_meta_keys);
// Only unique keys please.
$user_custom_field_keys = array();
// Initialize this array.
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $_field) {
$custom_field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($_field['id']));
$user_custom_field_keys[] = $custom_field_var;
}
}
unset($_field);
// Housekeeping.
$user_custom_field_keys = array_unique($user_custom_field_keys);
// Only unique keys please.
sort($user_custom_field_keys, SORT_STRING);
// Sort these also; just to give them some order.
$export_headers = '';
// Initialize export headers.
foreach ($user_keys as $_user_key) {
// Include all of the user fields first.
$export_headers .= ',"' . c_ws_plugin__s2member_utils_strings::esc_dq($_user_key, 1, '"') . '"';
}
unset($_user_key);
// Housekeeping.
foreach ($user_permission_keys as $_user_permission_key) {
// Include permission keys now.
$export_headers .= ',"' . c_ws_plugin__s2member_utils_strings::esc_dq($_user_permission_key, 1, '"') . '"';
}
unset($_user_permission_key);
// Housekeeping.
foreach ($user_meta_keys as $_user_meta_key) {
// Next comes all of the user meta fields.
$export_headers .= ',"meta_key__' . c_ws_plugin__s2member_utils_strings::esc_dq($_user_meta_key, 1, '"') . '"';
//.........这里部分代码省略.........
示例3: delete_reset_all_ip_restrictions
/**
* Resets/deletes all IP Restrictions.
*
* @package s2Member\IP_Restrictions
* @since 3.5
*
* @return bool Always returns a `true` value.
*
* @todo Make return value conditional, based on success.
*/
public static function delete_reset_all_ip_restrictions()
{
global $wpdb;
do_action("ws_plugin__s2member_before_delete_reset_all_ip_restrictions", get_defined_vars());
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape("_transient_s2m_ipr_")) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape("_transient_timeout_s2m_ipr_")) . "%'");
do_action("ws_plugin__s2member_after_delete_reset_all_ip_restrictions", get_defined_vars());
return apply_filters("ws_plugin__s2member_delete_reset_all_ip_restrictions", true, get_defined_vars());
}
示例4: uninstall
/**
* Uninstall routines for s2Member.
*
* @package s2Member\Installation
* @since 3.5
*/
public static function uninstall()
{
global $wpdb;
/** @var $wpdb wpdb */
global $current_site, $current_blog;
// Multisite.
do_action('ws_plugin__s2member_before_uninstall', get_defined_vars());
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['run_uninstall_routines']) {
c_ws_plugin__s2member_roles_caps::unlink_roles();
c_ws_plugin__s2member_files::remove_no_gzip_from_root_htaccess();
if (is_dir($files_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir'])) {
if (file_exists($htaccess = $files_dir . '/.htaccess')) {
if (is_writable($htaccess)) {
unlink($htaccess);
}
}
@rmdir($files_dir) . @rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir));
}
if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) {
foreach (scandir($logs_dir) as $log_file) {
if (is_file($log_file = $logs_dir . '/' . $log_file)) {
if (is_writable($log_file)) {
unlink($log_file);
}
}
}
@rmdir($logs_dir) . @rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir));
}
delete_option('ws_plugin__s2member_cache');
delete_option('ws_plugin__s2member_notices');
delete_option('ws_plugin__s2member_options');
delete_option('ws_plugin__s2member_configured');
delete_option('ws_plugin__s2member_activated_levels');
delete_option('ws_plugin__s2member_activated_version');
delete_option('ws_plugin__s2member_activated_mms_version');
if (is_multisite() && is_main_site()) {
delete_site_option('ws_plugin__s2member_options');
}
$wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->usermeta . "` WHERE `meta_key` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_')) . "%'");
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_')) . "%'");
do_action('ws_plugin__s2member_during_uninstall', get_defined_vars());
}
do_action('ws_plugin__s2member_after_uninstall', get_defined_vars());
}
示例5: user_login_email_exists
/**
* Determines whether or not a Username/Email is already in the database.
*
* Returns the WordPress User ID if they exist.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param string $user_login A User's Username.
* @param string $user_email A User's Email Address.
*
* @return int|bool If exists, a WordPress User ID, else false.
*/
public static function user_login_email_exists($user_login = '', $user_email = '')
{
global $wpdb;
/** @var wpdb $wpdb */
if ($user_login && $user_email) {
// Only if we have both of these.
if ($user_id = $wpdb->get_var("SELECT `ID` FROM `" . $wpdb->users . "` WHERE `user_login` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape($user_login)) . "' AND `user_email` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape($user_email)) . "' LIMIT 1")) {
return $user_id;
}
}
// Return the associated WordPress ID.
return FALSE;
// Otherwise, return false.
}
示例6: cleanup_expired_s2m_transients
/**
* Removes expired Transients inserted into the database by s2Member.
*
* @since 3.5
* @package s2Member\Utilities
*
* @param bool $stagger Defaults to a `TRUE` value.
*
* @return bool Always returns a `TRUE` value.
*/
public static function cleanup_expired_s2m_transients($stagger = TRUE)
{
global $wpdb;
/** @var wpdb $wpdb */
if ($stagger && !is_float($stagger = time() / 2)) {
return TRUE;
}
// Bypass this time.
if ($expired_s2m_transients = $wpdb->get_results("SELECT * FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_transient_timeout_s2m_')) . "%' AND `option_value` < '" . esc_sql(time()) . "' LIMIT 5")) {
foreach ($expired_s2m_transients as $_expired_s2m_transient) {
// Delete the _timeout, and also the transient entry name itself.
if (($_id = $_expired_s2m_transient->option_id) && ($_name = preg_replace('/_transient_timeout_/i', '_transient_', $_expired_s2m_transient->option_name, 1))) {
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE (`option_id` = '" . esc_sql($_id) . "' OR `option_name` = '" . esc_sql($_name) . "')");
}
}
}
return TRUE;
// Always returns a `TRUE` value.
}
示例7: shortcode
/**
* [s2Member-Gift-Codes] Shortcode.
*
* @package s2Member\Shortcodes
* @since 150203
*
* @attaches-to ``add_shortcode('s2Member-Gift-Codes');``
*
* @param array $attr An array of Attributes.
* @param string $content Content inside the Shortcode.
* @param string $shortcode The actual Shortcode name itself.
*
* @return string List of Gift Codes.
*/
public static function shortcode($attr = array(), $content = '', $shortcode = '')
{
global $wpdb;
// Global DB object reference.
/** @var $wpdb wpdb Reference for IDEs. */
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('c_ws_plugin__s2member_pro_before_sc_gift_codes', get_defined_vars());
unset($__refs, $__v);
c_ws_plugin__s2member_no_cache::no_cache_constants(true);
$default_attr = array('quantity' => '1', 'discount' => '100%', 'directive' => '', 'singulars' => '', 'one_click' => '');
if (isset($attr['singular']) && !isset($attr['singulars'])) {
$attr['singulars'] = $attr['singular'];
}
$attr = shortcode_atts($default_attr, $attr, $shortcode);
$attr['quantity'] = (string) min($attr['quantity'], apply_filters('ws_plugin__s2member_pro_gifts_max_quantity', 1000));
$hashable_attr = $attr;
unset($hashable_attr['one_click']);
$post_id = is_singular() ? get_the_ID() : 0;
$user = wp_get_current_user();
// Current user.
$sp_access_value = $post_id ? c_ws_plugin__s2member_sp_access::sp_access($post_id, 'read-only') : '';
if ($post_id && ($sp_access_value && is_string($sp_access_value) || $user->ID)) {
$gifts = array();
// Initialize.
$coupons_class = new c_ws_plugin__s2member_pro_coupons();
if ($sp_access_value && is_string($sp_access_value)) {
$sp_hash = md5($sp_access_value);
$attr_hash = hash('crc32b', serialize($hashable_attr));
$option_key_for_gifts = 's2m_gcs_' . $post_id . '_' . $sp_hash . '_' . $attr_hash;
if (!is_array($gifts = get_option($option_key_for_gifts))) {
$gifts = $coupons_class->generate_gifts($attr);
// Generate new gifts.
$wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_gcs_' . $post_id . '_' . $sp_hash . '_')) . "%'");
add_option($option_key_for_gifts, $gifts, '', 'no');
// Store the new gifts.
}
} else {
if ($user->ID) {
$attr_hash = md5(serialize($hashable_attr));
$user_option_key_for_gifts = 's2m_gcs_' . $post_id . '_' . $attr_hash;
if (!is_array($gifts = get_user_option($user_option_key_for_gifts, $user->ID))) {
$gifts = $coupons_class->generate_gifts($attr);
// Generate new gifts.
$wpdb->query("DELETE FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . esc_sql($user->ID) . "' AND `meta_key` LIKE '%" . esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_gcs_' . $post_id . '_')) . "%'");
update_user_option($user->ID, $user_option_key_for_gifts, $gifts);
// Store the new gifts.
}
}
}
if ($gifts) {
$content = '<table class="ws-plugin--s2member-gift-codes table table-condensed table-striped table-hover">' . "\n";
$content .= '<thead>' . "\n";
$content .= '<tr>' . '<th class="-code">' . _x('Redemption Code', 's2member-front', 's2member') . '</th>' . '<th class="-status">' . _x('Status', 's2member-front', 's2member') . '</th>' . '</tr>' . "\n";
$content .= '</thead>' . "\n";
$content .= '<tbody>' . "\n";
foreach ($gifts as $_gift) {
if ($coupons_class->get_uses($_gift['code'])) {
$content .= '<tr class="-status-used">' . '<td class="-code"><s>' . esc_html($_gift['code']) . '</s></td>' . '<td class="-status">' . _x('used', 's2member-front', 's2member') . '</td>' . '</tr>' . "\n";
} else {
$_one_click_url = $attr['one_click'] ? add_query_arg('s2p-coupon', urlencode($_gift['code']), $attr['one_click']) : '';
$content .= '<tr class="-status-unused">' . '<td class="-code">' . ($attr['one_click'] && $_one_click_url ? '<a href="' . esc_attr($_one_click_url) . '" target="_blank" title="' . _x('Click to Redeem', 's2member-front', 's2member') . '" data-toggle="tooltip">' . esc_html($_gift['code']) . '</a>' : esc_html($_gift['code'])) . '</td>' . '<td class="-status">' . _x('unused', 's2member-front', 's2member') . '</td>' . '</tr>' . "\n";
}
}
unset($_gift, $_one_click_url);
// Housekeeping.
$content .= '<tbody>' . "\n";
$content .= '</table>';
}
}
return apply_filters('c_ws_plugin__s2member_pro_sc_gift_codes_content', $content, get_defined_vars());
}