本文整理汇总了PHP中wp_rand函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_rand函数的具体用法?PHP wp_rand怎么用?PHP wp_rand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_rand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: block
function block($instance)
{
extract($instance);
$unique = wp_rand(0, 1000);
echo '<div id="map-' . $unique . '-' . $block_id . '" class="map"></div>';
echo "<script type='text/javascript'>\n\t\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t'use strict';\n\t\t\t\t\n\t\t\t\t\tjQuery('#map-" . $unique . "-" . $block_id . "').goMap({ address: \"{$title}\",\n\t\t\t\t\t zoom: 14,\n\t\t\t\t\t mapTypeControl: false,\n\t\t\t\t draggable: false,\n\t\t\t\t scrollwheel: false,\n\t\t\t\t streetViewControl: true,\n\t\t\t\t maptype: 'ROADMAP',\n\t\t\t \t markers: [\n\t\t\t \t\t{ 'address' : \"{$title}\" }\n\t\t\t \t ],\n\t\t\t\t\t icon: '{$image}', \n\t\t\t\t\t addMarker: false\n\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\t});\n\t\t\t</script>";
}
开发者ID:misfist,项目名称:loom-theme,代码行数:7,代码来源:map_block.php
示例2: mm_ux_log
function mm_ux_log($args = array())
{
$url = "https://ssl.google-analytics.com/collect";
global $title;
if (empty($_SERVER['REQUEST_URI'])) {
return;
}
$path = explode('wp-admin', $_SERVER['REQUEST_URI']);
if (empty($path) || empty($path[1])) {
$path = array("", " ");
}
$defaults = array('v' => '1', 'tid' => 'UA-39246514-3', 't' => 'pageview', 'cid' => md5(get_option('siteurl')), 'uid' => md5(get_option('siteurl') . get_current_user_id()), 'cn' => 'mojo_wp_plugin', 'cs' => 'mojo_wp_plugin', 'cm' => 'plugin_admin', 'ul' => get_locale(), 'dp' => $path[1], 'sc' => '', 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dl' => $path[1], 'dh' => get_option('siteurl'), 'dt' => $title, 'ec' => '', 'ea' => '', 'el' => '', 'ev' => '');
if (isset($_SERVER['REMOTE_ADDR'])) {
$defaults['uip'] = $_SERVER['REMOTE_ADDR'];
}
$params = wp_parse_args($args, $defaults);
$test = get_transient('mm_test', '');
if (isset($test['key']) && isset($test['name'])) {
$params['cm'] = $params['cm'] . "_" . $test['name'] . "_" . $test['key'];
}
//use test account for testing
if (defined('WP_DEBUG') && WP_DEBUG) {
$params['tid'] = 'UA-19617272-27';
}
$z = wp_rand(0, 1000000000);
$query = http_build_query(array_filter($params));
$args = array('body' => $query, 'method' => 'POST', 'blocking' => false);
$url = add_query_arg(array('z' => $z), $url);
wp_remote_post($url, $args);
}
开发者ID:hyperhy,项目名称:hyperhy,代码行数:30,代码来源:user-experience-tracking.php
示例3: ebor_tabs_shortcode
/**
* The Shortcode
*/
function ebor_tabs_shortcode($atts, $content = null)
{
global $ebor_tabs_content;
global $ebor_tabs_count;
global $rand;
$rand = false;
$ebor_tabs_count = 0;
$ebor_tabs_content = false;
extract(shortcode_atts(array('type' => ''), $atts));
$output = false;
$rand = wp_rand(0, 10000);
$output .= '
<ul id="tab' . $rand . '" class="nav nav-tabs">' . do_shortcode($content) . '</ul><div id="myTabContent' . $rand . '" class="tab-content">' . $ebor_tabs_content . '</div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(\'#tab' . $rand . '\').tabCollapse({
tabsClass: \'hidden-sm hidden-xs\',
accordionClass: \'visible-sm visible-xs\'
});
jQuery(\'#tab' . $rand . '\').on(\'shown-accordion.bs.tabcollapse\', function(){
jQuery(\'.panel-group\').find(\'.panel-default:has(".in")\').addClass(\'panel-active\');
jQuery(\'.panel-group\').on(\'shown.bs.collapse\', function(e) {
jQuery(e.target).closest(\'.panel-default\').addClass(\' panel-active\');
}).on(\'hidden.bs.collapse\', function(e) {
jQuery(e.target).closest(\'.panel-default\').removeClass(\' panel-active\');
});
});
});
</script>
';
return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:35,代码来源:vc_tabs_block.php
示例4: set_verifyne_cookie
/**
* Set session cookie
*/
function set_verifyne_cookie()
{
global $pagenow;
# Only set session cookie on profile and login page
if ($pagenow === "profile.php" || $pagenow === "wp-login.php") {
# Check if session is set
if (isset($_COOKIE["vf_session_id"])) {
return;
}
# Generate a new session ID
$vf_session_id = '';
for ($i = 0; $i < 32; $i++) {
$vf_session_id .= chr(wp_rand(65, 90));
# A-Z
}
# Set cookie
setcookie("vf_session_id", $vf_session_id);
} else {
if (!isset($_COOKIE["vf_session_id"])) {
return;
}
# Delete cookie
unset($_COOKIE["vf_session_id"]);
setcookie("vf_session_id", "", time() - 86400);
return;
}
}
开发者ID:sruester,项目名称:wp-verifyne,代码行数:30,代码来源:wp-verifyne.php
示例5: ebor_progress_circle_shortcode
/**
* The Shortcode
*/
function ebor_progress_circle_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('title' => '', 'percent' => '0.4', 'color' => '#7bc4e6'), $atts));
$id = wp_rand(0, 1000);
$output = '
<div class="circle-progress-wrapper bm40 wow fadeIn" data-wow-duration="1s" data-wow-delay="0.0s">
<div class="circle-progress circle circle' . esc_attr($id) . '">
<h4>' . $title . '</h4>
</div>
</div>
<script type="text/javascript">
jQuery(window).load(function() {
var circle' . esc_attr($id) . ' = new ProgressBar.Circle(".circle.circle' . esc_attr($id) . '", {
color: "' . $color . '",
trailColor: "rgba(255,255,255,0.1)",
strokeWidth: 2,
trailWidth: 2,
duration: 4500,
easing: "easeInOut",
text: {
value: "' . esc_js($percent) . '"
},
step: function(state, bar) {
bar.setText((bar.value() * 100).toFixed(0));
}
});
circle' . esc_attr($id) . '.animate(' . esc_js($percent) . ');
});
</script>
';
return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:37,代码来源:vc_process_circle_block.php
示例6: xt_generate_guid
function xt_generate_guid()
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$password = '';
for ($i = 0; $i < 4; $i++) {
$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
}
// random_password filter was previously in random_password function which was deprecated
return apply_filters('random_password', $password);
}
开发者ID:aspirin,项目名称:wp-xintaoke,代码行数:10,代码来源:query-user.php
示例7: ebor_map_block_shortcode
/**
* The Shortcode
*/
function ebor_map_block_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('height' => '480', 'address' => '', 'image' => ''), $atts));
$block_id = wp_rand(0, 1000);
$image = wp_get_attachment_image_src($image, 'full');
if (!isset($image[0])) {
$image[0] = false;
}
$output = '<div class="map-wrapper"><div id="map" class="' . esc_attr($block_id) . '" style="height: ' . (int) esc_attr($height) . 'px;"> </div></div>';
$output .= "<script type='text/javascript'>\n\t\t\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t\t'use strict';\n\t\t\t\t\t\n\t\t\t\t\t\tjQuery('#map." . esc_attr($block_id) . "').goMap({ address: '" . esc_js($address) . "',\n\t\t\t\t\t\t zoom: 15,\n\t\t\t\t\t\t mapTypeControl: true,\n\t\t\t\t\t draggable: false,\n\t\t\t\t\t scrollwheel: false,\n\t\t\t\t\t streetViewControl: true,\n\t\t\t\t\t maptype: 'ROADMAP',\n\t\t\t\t \t markers: [\n\t\t\t\t \t\t{ 'address' : '" . esc_js($address) . "' }\n\t\t\t\t \t ],\n\t\t\t\t\t\t icon: '" . esc_url($image[0]) . "', \n\t\t\t\t\t\t addMarker: false,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar styles = [{stylers:[{saturation:-100},{gamma:1}]},{elementType:'labels.text.stroke',stylers:[{visibility:'off'}]},{featureType:'poi.business',elementType:'labels.text',stylers:[{visibility:'off'}]},{featureType:'poi.business',elementType:'labels.icon',stylers:[{visibility:'off'}]},{featureType:'poi.place_of_worship',elementType:'labels.text',stylers:[{visibility:'off'}]},{featureType:'poi.place_of_worship',elementType:'labels.icon',stylers:[{visibility:'off'}]},{featureType:'road',elementType:'geometry',stylers:[{visibility:'simplified'}]},{featureType:'water',stylers:[{visibility:'on'},{saturation:50},{gamma:0},{hue:'#50a5d1'}]},{featureType:'administrative.neighborhood',elementType:'labels.text.fill',stylers:[{color:'#333333'}]},{featureType:'road.local',elementType:'labels.text',stylers:[{weight:0.5},{color:'#333333'}]},{featureType:'transit.station',elementType:'labels.icon',stylers:[{gamma:1},{saturation:50}]}];\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery.goMap.setMap({styles: styles});\n\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t </script>";
return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:15,代码来源:vc_map_block.php
示例8: rand_string
function rand_string($length = 12, $special_chars = true)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if ($special_chars) {
$chars .= '!@#$%^&*()';
}
$password = '';
for ($i = 0; $i < $length; $i++) {
$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
}
return $password;
}
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:12,代码来源:class-scsa-functions.php
示例9: wps_deals_social_add_wp_user
/**
* Create User
*
* Function to add connected users to the WordPress users database
* and add the role subscriber
*
* @package Social Deals Engine
* @since 1.0.0
*/
public function wps_deals_social_add_wp_user($criteria)
{
global $wp_version;
$prefix = 'wps_user_';
$username = $prefix . wp_rand(100, 9999999);
while (username_exists($username)) {
// avoid duplicate user name
$username = $prefix . wp_rand(100, 9999999);
}
$name = $criteria['name'];
$first_name = $criteria['first_name'];
$last_name = $criteria['last_name'];
$password = wp_generate_password(12, false);
$email = $criteria['email'];
$wp_id = 0;
//create the WordPress user
if (version_compare($wp_version, '3.1', '<')) {
require_once ABSPATH . WPINC . '/registration.php';
}
//check user id is exist or not
if (email_exists($email) == false) {
$wp_id = wp_create_user($username, $password, $email);
if (!empty($wp_id)) {
//if user is created then update some data
$role = 'subscriber';
$user = new WP_User($wp_id);
$user->set_role($role);
wp_new_user_notification($wp_id, $password);
}
} else {
//get user from email
$userdata = get_user_by('email', $email);
if (!empty($userdata)) {
//check user is exit or not
$wp_id = $userdata->ID;
}
}
return $wp_id;
}
开发者ID:wppassion,项目名称:deals-engine,代码行数:48,代码来源:class-wps-deal-social-model.php
示例10: get_stock_feature_info
function get_stock_feature_info($size){
global $lastimg;
$id = 0;
while($id == 0){
$num = wp_rand(1, 8);
if($num == 1 && num != lastimg):
$id = 2220;
elseif($num == 2 && num != lastimg):
$id = 2214;
endif;
}
if($size == 'thumbnail'):
$info = wp_get_attachment_image_src($id);
elseif($size == 'medium'):
$info = wp_get_attachment_image_src($id, 'medium');
elseif($size == 'large'):
$info = wp_get_attachment_image_src($id, 'large');
else:
$info = wp_get_attachment_image_src($id, 'full');
endif;
$lastimg = $num;
return $info;
}
开发者ID:EssVeeEll,项目名称:users.opensciencegrid.org-main-php-and-css,代码行数:23,代码来源:functions.php
示例11: ebor_toggles_shortcode
/**
* The Shortcode
*/
function ebor_toggles_shortcode($atts, $content = null)
{
global $ebor_toggles_count;
global $rand;
$ebor_toggles_count = 0;
$rand = false;
$output = false;
$rand = wp_rand(0, 10000);
$output .= '
<div class="panel-group ebor-' . $rand . '" id="accordion-' . $rand . '">' . do_shortcode($content) . '</div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(\'.panel-group.ebor-' . $rand . '\').find(\'.panel-default:has(".in")\').addClass(\'panel-active\');
jQuery(\'.panel-group.ebor-' . $rand . '\').on(\'shown.bs.collapse\', function(e) {
jQuery(e.target).closest(\'.panel-default\').addClass(\' panel-active\');
}).on(\'hidden.bs.collapse\', function(e) {
jQuery(e.target).closest(\'.panel-default\').removeClass(\' panel-active\');
});
});
</script>
';
return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:27,代码来源:vc_toggles_block.php
示例12: generate_key
function generate_key($length = 40)
{
$keyset = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/';
$key = '';
for ($i = 0; $i < $length; $i++) {
$key .= substr($keyset, wp_rand(0, strlen($keyset) - 1), 1);
}
return $key;
}
开发者ID:netmagik,项目名称:netmagik,代码行数:9,代码来源:wpmdb-base.php
示例13: set_autosync_schedule
/**
* Set autosync schedule
*
* @since 1.0.0
*
* @param int $user_id [required]
* @param int $interval [required]
* @return string $hash
*/
public function set_autosync_schedule($user_id = null, $interval = 0)
{
/*
if ( ! in_array( $interval, array( 'hourly', 'twicedaily', 'daily' ) ) )
$interval = 'daily';
*/
$_timezone = get_option('timezone_string');
date_default_timezone_set($_timezone);
$_now = time();
$_hash = md5($user_id . $_now . wp_rand());
//wp_schedule_event( $_now, $interval, 'wpqt/autosync', array( $user_id, $_hash ) );
wp_schedule_single_event($_now + $interval, 'wpqt/autosync', array($user_id, $_hash));
return $_hash;
}
开发者ID:ka215,项目名称:wp-qiita,代码行数:23,代码来源:main.php
示例14: debug
function debug()
{
echo "<pre>\n";
var_dump(wp_rand(1, 100000));
die("debug: " . __METHOD__);
}
开发者ID:ngoctu006,项目名称:wd_project1,代码行数:6,代码来源:functions.php
示例15: wpcf7_generate_captcha
function wpcf7_generate_captcha($options = null)
{
if (!($captcha = wpcf7_init_captcha())) {
return false;
}
if (!is_dir($captcha->tmp_dir) || !wp_is_writable($captcha->tmp_dir)) {
return false;
}
$img_type = imagetypes();
if ($img_type & IMG_PNG) {
$captcha->img_type = 'png';
} elseif ($img_type & IMG_GIF) {
$captcha->img_type = 'gif';
} elseif ($img_type & IMG_JPG) {
$captcha->img_type = 'jpeg';
} else {
return false;
}
if (is_array($options)) {
if (isset($options['img_size'])) {
$captcha->img_size = $options['img_size'];
}
if (isset($options['base'])) {
$captcha->base = $options['base'];
}
if (isset($options['font_size'])) {
$captcha->font_size = $options['font_size'];
}
if (isset($options['font_char_width'])) {
$captcha->font_char_width = $options['font_char_width'];
}
if (isset($options['fg'])) {
$captcha->fg = $options['fg'];
}
if (isset($options['bg'])) {
$captcha->bg = $options['bg'];
}
}
$prefix = wp_rand();
$captcha_word = $captcha->generate_random_word();
return $captcha->generate_image($prefix, $captcha_word);
}
开发者ID:dracudakid,项目名称:WP_TrungTamTinHoc,代码行数:42,代码来源:really-simple-captcha.php
示例16: create_secret
/**
* Create a new random secret for the Google Authenticator app.
* 16 characters, randomly chosen from the allowed Base32 characters
* equals 10 bytes = 80 bits, as 256^10 = 32^16 = 2^80
*/
function create_secret()
{
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
// allowed characters in Base32
$secret = '';
for ($i = 0; $i < 16; $i++) {
$secret .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
}
return $secret;
}
开发者ID:kraczo,项目名称:pracowniapizzy,代码行数:15,代码来源:google-authenticator.php
示例17: wp_generate_password
/**
* * From WordPress !!!
*
* Generates a random password drawn from the defined set of characters.
*
* @since 2.5
*
* @param int $length The length of password to generate
* @param bool $special_chars Whether to include standard special characters. Default true.
* @param bool $extra_special_chars Whether to include other special characters. Used when
* generating secret keys and salts. Default false.
* @return string The random password
**/
function wp_generate_password($length = 12, $special_chars = true, $extra_special_chars = false)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if ($special_chars) {
$chars .= '!@#$%^&*()';
}
if ($extra_special_chars) {
$chars .= '-_ []{}<>~`+=,.;:/?|';
}
$password = '';
for ($i = 0; $i < $length; $i++) {
$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
}
return $password;
}
开发者ID:kodizant,项目名称:TemaTres-Vocabulary-Server,代码行数:28,代码来源:login.php
示例18: rtmb_generate_message_id
function rtmb_generate_message_id($post_id, $email_id, $type = 'post')
{
if ('comment' == $type) {
$comment = get_comment($post_id);
$post_id = $comment->comment_post_ID;
}
$domain_name = preg_replace('/^www\\./', '', $_SERVER['SERVER_NAME']);
$domain_name = '@' . $domain_name;
$post_date = current_time('mysql');
$unique_id = md5('rt_lib_' . get_post_type($post_id) . '_' . $post_date . '_' . $post_id . '-' . $email_id . '-' . wp_rand());
return '<' . $post_id . '-' . $unique_id . $domain_name . '>';
}
开发者ID:chandra-patel,项目名称:rtbiz,代码行数:12,代码来源:rt-mailbox-functions.php
示例19: edd_slg_create_username
/**
* Create User Name for VK.com / Instagram
*
* Function to check type is vk/instagram then create user name based on user id.
*
* @package Easy Digital Downloads - Social Login
* @since 1.3.0
*/
public function edd_slg_create_username($criteria)
{
global $edd_options;
//Initilize username
$username = '';
//Get base of username
$edd_user_base = isset($edd_options['edd_slg_base_reg_username']) ? $edd_options['edd_slg_base_reg_username'] : '';
switch ($edd_user_base) {
case 'realname':
//Get first name
$first_name = isset($criteria['first_name']) ? strtolower($criteria['first_name']) : '';
//Get last name
$last_name = isset($criteria['last_name']) ? strtolower($criteria['last_name']) : '';
//Get username using fname and lname
$username = $this->edd_slg_username_by_fname_lname($first_name, $last_name);
break;
case 'emailbased':
//Get user email
$user_email = isset($criteria['email']) ? $criteria['email'] : '';
//Create username using email
$username = $this->edd_slg_username_by_email($user_email);
break;
default:
break;
}
if (empty($username)) {
//If username get empty
//Get username prefix
$prefix = EDD_SLG_USER_PREFIX;
if ($criteria['type'] == 'vk' || $criteria['type'] == 'instagram') {
// if service is vk.com OR instagram then create username with unique id
$username = $prefix . $criteria['id'];
} else {
// else create create username with random string
$username = $prefix . wp_rand(100, 9999999);
}
}
//Apply filter to modify username logic
$username = apply_filters('edd_slg_social_username', $username, $criteria);
//Assign username to temporary variable
$temp_user_name = $username;
//Make sure the name is unique: if we've already got a user with this name, append a number to it.
$counter = 1;
if (username_exists($temp_user_name)) {
//If username is exist
do {
$username = $temp_user_name;
$counter++;
$username = $username . $counter;
} while (username_exists($username));
} else {
$username = $temp_user_name;
}
return $username;
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:63,代码来源:class-edd-slg-model.php
示例20: nonce_field
/**
* Prints a hidden form field to prevent multiple form submits during checkout
*
* @return string
*/
public static function nonce_field()
{
$user = wp_get_current_user();
$uid = (int) $user->ID;
$nonce = wp_hash(wp_rand() . 'pstsnonce' . $uid, 'nonce');
ProSites_Helper_Session::session('_psts_nonce', $nonce);
return '<input type="hidden" name="_psts_nonce" value="' . $nonce . '" />';
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:13,代码来源:gateway-paypal-express-pro.php
注:本文中的wp_rand函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论