本文整理汇总了PHP中absint函数的典型用法代码示例。如果您正苦于以下问题:PHP absint函数的具体用法?PHP absint怎么用?PHP absint使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了absint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax_refresh_static_posts
function ajax_refresh_static_posts()
{
check_ajax_referer('refreshstaticposts');
if (isset($_POST['number'])) {
$number = absint($_POST['number']);
$action = sanitize_text_field($_POST['action']);
$name = sanitize_text_field($_POST['name']);
//Get the SRP widgets
$settings = get_option($name);
$widget = $settings[$number];
//Get the new post IDs
$widget = $this->build_posts(intval($widget['postlimit']), $widget);
$post_ids = $widget['posts'];
//Save the settings
$settings[$number] = $widget;
//Only save if user is admin
if (is_user_logged_in() && current_user_can('administrator')) {
update_option($name, $settings);
//Let's clean up the cache
//Update WP Super Cache if available
if (function_exists("wp_cache_clean_cache")) {
@wp_cache_clean_cache('wp-cache-');
}
}
//Build and send the response
die($this->print_posts($post_ids, false));
}
exit;
}
示例2: widget
function widget($args, $instance)
{
$title = $instance['title'];
$flickrid = $instance['flickrid'];
$number = $instance['number'];
echo ts_essentials_escape($args['before_widget']);
if (!empty($title)) {
echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']);
}
?>
<div class="flickr ts-mfp-gallery">
<ul id="<?php
echo esc_attr($args['widget_id']);
?>
-ul" class="flickr-widget clearfix"></ul>
<div><script type="text/javascript">jQuery(document).ready(function($){if ($.fn.jflickrfeed){jQuery('#<?php
echo esc_js($args['widget_id']);
?>
-ul').jflickrfeed({limit: <?php
echo absint($number);
?>
,qstrings: { id: '<?php
echo esc_js($flickrid);
?>
' }}, function(data){if(typeof(ts_magnificPopup)=="function"){ ts_magnificPopup()}})}});</script></div>
</div>
<?php
echo ts_essentials_escape($args['after_widget']);
}
示例3: get_cart_item_data
/**
* Process this field after being posted
* @return array on success, WP_ERROR on failure
*/
public function get_cart_item_data()
{
$cart_item_data = array();
foreach ($this->addon['options'] as $key => $option) {
$option_key = empty($option['label']) ? $key : sanitize_title($option['label']);
$posted = isset($this->value[$option_key]) ? $this->value[$option_key] : '';
if ($posted === '') {
continue;
}
$label = $this->get_option_label($option);
$price = $this->get_option_price($option);
switch ($this->addon['type']) {
case "custom_price":
$price = floatval(sanitize_text_field($posted));
if ($price >= 0) {
$cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price)));
}
break;
case "input_multiplier":
$posted = absint($posted);
$cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price);
break;
default:
$cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price);
break;
}
}
return $cart_item_data;
}
示例4: init
public static function init()
{
do_action('o2_read_api');
// Need a 'method' of some sort
if (empty($_GET['method'])) {
self::die_failure('no_method', __('No method supplied', 'o2'));
}
$method = strtolower($_GET['method']);
// ?since=unixtimestamp only return posts/comments since the specified time
global $o2_since;
$o2_since = false;
if (isset($_REQUEST['since'])) {
// JS Date.now() sends milliseconds, so just substr to be safe
// Also, substract two seconds to allow for differences in client and
// server clocks
$o2_since = absint(substr($_REQUEST['since'], 0, 10)) - 2;
}
// sanity check. don't allow arbitrarily low since values
// or we could end up serving all the posts and comments for the blog
// so, let's lower bound since to 1 day ago
$min_since = time() - 24 * 60 * 60;
if ($o2_since < $min_since) {
$o2_since = $min_since;
}
// Only allow whitelisted methods
if (in_array($method, apply_filters('o2_read_api_methods', array('poll', 'query', 'preview')))) {
// Handle different methods
if (method_exists('o2_Read_API', $method)) {
o2_Read_API::$method();
} else {
self::die_success('1');
}
}
self::die_failure('unknown_method', __('Unknown/unsupported method supplied', 'o2'));
}
示例5: get_data
/**
* Get the Export Data
*
* @access public
* @since 2.0
* @return array $data The data for the CSV file
*/
public function get_data()
{
$start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
$end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
$start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
$end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
$data = array();
$year = $start_year;
$stats = new EDD_Payment_Stats();
while ($year <= $end_year) {
if ($year == $start_year && $year == $end_year) {
$m1 = $start_month;
$m2 = $end_month;
} elseif ($year == $start_year) {
$m1 = $start_month;
$m2 = 12;
} elseif ($year == $end_year) {
$m1 = 1;
$m2 = $end_month;
} else {
$m1 = 1;
$m2 = 12;
}
while ($m1 <= $m2) {
$date1 = mktime(0, 0, 0, $m1, 1, $year);
$date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
$data[] = array('date' => date_i18n('F Y', $date1), 'sales' => $stats->get_sales(0, $date1, $date2, array('publish', 'revoked')), 'earnings' => edd_format_amount($stats->get_earnings(0, $date1, $date2)));
$m1++;
}
$year++;
}
$data = apply_filters('edd_export_get_data', $data);
$data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
return $data;
}
示例6: woo_enforce_defaults
function woo_enforce_defaults($instance)
{
$defaults = $this->woo_get_settings();
$instance = wp_parse_args($instance, $defaults);
if ($instance['limit'] < 1) {
$instance['limit'] = 1;
} elseif ($instance['limit'] > 10) {
$instance['limit'] = 10;
}
$instance['width'] = absint($instance['width']);
if ($instance['width'] < 1) {
$instance['width'] = $defaults['width'];
}
$instance['height'] = absint($instance['height']);
if ($instance['height'] < 1) {
$instance['height'] = $defaults['height'];
}
if ($instance['sorting'] != 'random') {
$instance['sorting'] = $defaults['sorting'];
}
if (!in_array($instance['size'], array('s', 'm', 't'))) {
$instance['size'] = $defaults['size'];
}
if ($instance['type'] != 'group') {
$instance['type'] = $defaults['type'];
}
return $instance;
}
示例7: 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;
}
if (!is_user_logged_in()) {
$message = apply_filters('woocommerce_my_account_message', '');
if (!empty($message)) {
wc_add_notice($message);
}
if (isset($wp->query_vars['lost-password'])) {
self::lost_password();
} else {
wc_get_template('myaccount/form-login.php');
}
} else {
if (!empty($wp->query_vars['view-order'])) {
self::view_order(absint($wp->query_vars['view-order']));
} elseif (isset($wp->query_vars['edit-account'])) {
self::edit_account();
} elseif (isset($wp->query_vars['edit-address'])) {
self::edit_address(wc_edit_address_i18n(sanitize_title($wp->query_vars['edit-address']), true));
} elseif (isset($wp->query_vars['add-payment-method'])) {
self::add_payment_method();
} else {
self::my_account($atts);
}
}
}
示例8: ninja_forms_register_form_settings_basic_metabox
function ninja_forms_register_form_settings_basic_metabox()
{
if (isset($_REQUEST['form_id'])) {
$form_id = absint($_REQUEST['form_id']);
$form_data = Ninja_Forms()->form($form_id)->get_all_settings();
} else {
$form_id = '';
$form_row = '';
$form_data = '';
}
$pages = get_pages();
$pages_array = array();
$append_array = array();
array_push($pages_array, array('name' => __('- None', 'ninja-forms'), 'value' => ''));
array_push($append_array, array('name' => __('- None', 'ninja-forms'), 'value' => ''));
foreach ($pages as $pagg) {
array_push($pages_array, array('name' => $pagg->post_title, 'value' => get_page_link($pagg->ID)));
array_push($append_array, array('name' => $pagg->post_title, 'value' => $pagg->ID));
}
if (isset($form_data['ajax'])) {
$ajax = $form_data['ajax'];
} else {
$ajax = 0;
}
$args = apply_filters('ninja_forms_form_settings_basic', array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'basic_settings', 'title' => __('Display', 'ninja-forms'), 'state' => 'closed', 'settings' => array(array('name' => 'form_title', 'type' => 'text', 'label' => __('Form Title', 'ninja-forms')), array('name' => 'show_title', 'type' => 'checkbox', 'label' => __('Display Form Title', 'ninja-forms')), array('name' => 'append_page', 'type' => 'select', 'desc' => '', 'label' => __('Add form to this page', 'ninja-forms'), 'display_function' => '', 'help' => '', 'options' => $append_array), array('name' => 'ajax', 'type' => 'checkbox', 'desc' => '', 'label' => __('Submit via AJAX (without page reload)?', 'ninja-forms'), 'display_function' => '', 'help' => ''), array('name' => 'clear_complete', 'type' => 'checkbox', 'desc' => '', 'label' => __('Clear successfully completed form?', 'ninja-forms'), 'display_function' => '', 'desc' => __('If this box is checked, Ninja Forms will clear the form values after it has been successfully submitted.', 'ninja-forms'), 'default_value' => 1), array('name' => 'hide_complete', 'type' => 'checkbox', 'desc' => '', 'label' => __('Hide successfully completed form?', 'ninja-forms'), 'display_function' => '', 'desc' => __('If this box is checked, Ninja Forms will hide the form after it has been successfully submitted.', 'ninja-forms'), 'default_value' => 1))));
ninja_forms_register_tab_metabox($args);
$args = apply_filters('ninja_forms_form_settings_restrictions', array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'restrictions', 'title' => __('Restrictions', 'ninja-forms'), 'state' => 'closed', 'settings' => array(array('name' => 'logged_in', 'type' => 'checkbox', 'desc' => '', 'label' => __('Require user to be logged in to view form?', 'ninja-forms'), 'display_function' => '', 'help' => ''), array('name' => 'not_logged_in_msg', 'type' => 'rte', 'label' => __('Not Logged-In Message', 'ninja-forms'), 'desc' => __('Message shown to users if the "logged in" checkbox above is checked and they are not logged-in.', 'ninja-forms'), 'tr_class' => ''), array('name' => 'sub_limit_number', 'type' => 'number', 'desc' => '', 'label' => __('Limit Submissions', 'ninja-forms'), 'display_function' => '', 'desc' => __('Select the number of submissions that this form will accept. Leave empty for no limit.', 'ninja-forms'), 'default_value' => '', 'tr_class' => '', 'min' => 0), array('name' => 'sub_limit_msg', 'type' => 'rte', 'label' => __('Limit Reached Message', 'ninja-forms'), 'desc' => __('Please enter a message that you want displayed when this form has reached its submission limit and will not accept new submissions.', 'ninja-forms'), 'tr_class' => ''))));
ninja_forms_register_tab_metabox($args);
}
示例9: display
public function display()
{
if (isset($_GET['form_id'])) {
if ('new' == $_GET['form_id']) {
$form_id = 'tmp-' . time();
} else {
$form_id = is_numeric($_GET['form_id']) ? absint($_GET['form_id']) : '';
}
/*
* FORM BUILDER
*/
Ninja_Forms::template('admin-menu-new-form.html.php');
$this->_enqueue_the_things($form_id);
delete_user_option(get_current_user_id(), 'nf_form_preview_' . $form_id);
if (!isset($_GET['ajax'])) {
$this->_localize_form_data($form_id);
$this->_localize_field_type_data();
$this->_localize_action_type_data();
$this->_localize_form_settings();
$this->_localize_merge_tags();
}
} else {
/*
* ALL FORMS TABLE
*/
$this->table->prepare_items();
Ninja_Forms::template('admin-menu-all-forms.html.php', array('table' => $this->table, 'add_new_url' => admin_url('admin.php?page=ninja-forms&form_id=new'), 'add_new_text' => __('Add New Form', 'ninja-forms')));
}
}
示例10: hoot_get_image_size_links
/**
* Returns a set of image attachment links based on size.
*
* @since 1.0.0
* @access public
* @return string
*/
function hoot_get_image_size_links()
{
/* If not viewing an image attachment page, return. */
if (!wp_attachment_is_image(get_the_ID())) {
return;
}
/* Set up an empty array for the links. */
$links = array();
/* Get the intermediate image sizes and add the full size to the array. */
$sizes = get_intermediate_image_sizes();
$sizes[] = 'full';
/* Loop through each of the image sizes. */
foreach ($sizes as $size) {
/* Get the image source, width, height, and whether it's intermediate. */
$image = wp_get_attachment_image_src(get_the_ID(), $size);
/* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */
if (!empty($image) && (true === $image[3] || 'full' == $size)) {
/* Translators: Media dimensions - 1 is width and 2 is height. */
$label = sprintf(__('%1$s × %2$s', 'chromatic'), number_format_i18n(absint($image[1])), number_format_i18n(absint($image[2])));
$links[] = sprintf('<a class="image-size-link">%s</a>', $label);
}
}
/* Join the links in a string and return. */
return join(' <span class="sep">/</span> ', $links);
}
示例11: jetpack_instagram_handler
function jetpack_instagram_handler($matches, $atts, $url)
{
global $content_width;
static $did_script;
// keep a copy of the passed-in URL since it's modified below
$passed_url = $url;
$max_width = 698;
$min_width = 320;
if (is_feed()) {
$media_url = sprintf('http://instagr.am/p/%s/media/?size=l', $matches[2]);
return sprintf('<a href="%s" title="%s"><img src="%s" alt="Instagram Photo" /></a>', esc_url($url), esc_attr__('View on Instagram', 'jetpack'), esc_url($media_url));
}
$atts = shortcode_atts(array('width' => isset($content_width) ? $content_width : $max_width, 'hidecaption' => false), $atts);
$atts['width'] = absint($atts['width']);
if ($atts['width'] > $max_width || $min_width > $atts['width']) {
$atts['width'] = $max_width;
}
// remove the modal param from the URL
$url = remove_query_arg('modal', $url);
// force .com instead of .am for https support
$url = str_replace('instagr.am', 'instagram.com', $url);
// The oembed endpoint expects HTTP, but HTTP requests 301 to HTTPS
$instagram_http_url = str_replace('https://', 'http://', $url);
$instagram_https_url = str_replace('http://', 'https://', $url);
$url_args = array('url' => $instagram_http_url, 'maxwidth' => $atts['width']);
if ($atts['hidecaption']) {
$url_args['hidecaption'] = 'true';
}
$url = esc_url_raw(add_query_arg($url_args, 'https://api.instagram.com/oembed/'));
// Don't use object caching here by default, but give themes ability to turn it on.
$response_body_use_cache = apply_filters('instagram_cache_oembed_api_response_body', false, $matches, $atts, $passed_url);
$response_body = false;
if ($response_body_use_cache) {
$cache_key = 'oembed_response_body_' . md5($url);
$response_body = wp_cache_get($cache_key, 'instagram_embeds');
}
if (!$response_body) {
// Not using cache (default case) or cache miss
$instagram_response = wp_remote_get($url, array('redirection' => 0));
if (is_wp_error($instagram_response) || 200 != $instagram_response['response']['code'] || empty($instagram_response['body'])) {
return "<!-- instagram error: invalid oratv resource -->";
}
$response_body = json_decode($instagram_response['body']);
if ($response_body_use_cache) {
// if caching it is short-lived since this is a "Cache-Control: no-cache" resource
wp_cache_set($cache_key, $response_body, 'instagram_embeds', HOUR_IN_SECONDS + mt_rand(0, HOUR_IN_SECONDS));
}
}
if (!empty($response_body->html)) {
if (!$did_script) {
$did_script = true;
add_action('wp_footer', 'jetpack_instagram_add_script');
}
// there's a script in the response, which we strip on purpose since it's added above
$ig_embed = preg_replace('@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html);
} else {
$ig_embed = jetpack_instagram_iframe_embed($instagram_https_url, $atts);
}
return $ig_embed;
}
示例12: delete_albums
function delete_albums($entries)
{
global $wpdb, $wp_photo_gallery;
$album_table = WPPG_TBL_ALBUM;
if (is_array($entries)) {
//Delete multiple records
$id_list = "(" . implode(",", $entries) . ")";
//Create comma separate list for DB operation
$delete_command = "DELETE FROM " . $album_table . " WHERE id IN " . $id_list;
$result = $wpdb->query($delete_command);
if ($result != NULL) {
$success_msg = '<div id="message" class="updated"><p><strong>';
$success_msg .= __('The selected entries were deleted successfully!', 'WPS');
$success_msg .= '</strong></p></div>';
_e($success_msg);
} else {
$wp_photo_gallery->debug_logger->log_debug("There was an error deleting one or more albums!", 4);
}
} elseif ($entries != NULL) {
//Delete single record
$delete_command = $wpdb->prepare("DELETE FROM " . $album_table . " WHERE id = %d", absint($entries));
$result = $wpdb->query($delete_command);
if ($result != NULL) {
$success_msg = '<div id="message" class="updated"><p><strong>';
$success_msg .= __('The selected entry was deleted successfully!', 'WPS');
$success_msg .= '</strong></p></div>';
_e($success_msg);
} else {
$wp_photo_gallery->debug_logger->log_debug("There was an error deleting album with ID: " . absint($entries), 4);
}
}
}
示例13: reactor_numeric_posts_nav
function reactor_numeric_posts_nav()
{
if (is_singular()) {
return;
}
global $wp_query;
$paginas = new WP_Query($args);
$html = '';
/** Stop execution if there's only 1 page */
if ($paginas->max_num_pages <= 1) {
return;
}
$paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1;
$max = intval($paginas->max_num_pages);
/** Add current page to the array */
if ($paged >= 1) {
$links[] = $paged;
}
/** Add the pages around the current page to the array */
if ($paged >= 3) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ($paged + 2 <= $max) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="navigation"><ul>' . "\n";
/** Previous Post Link */
if (get_previous_posts_link()) {
printf('<li>%s</li>' . "\n", get_previous_posts_link());
}
/** Link to first page, plus ellipses if necessary */
if (!in_array(1, $links)) {
$class = 1 == $paged ? ' class="active"' : '';
printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link(1)), '1');
if (!in_array(2, $links)) {
echo '<li>…</li>';
}
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort($links);
foreach ((array) $links as $link) {
$class = $paged == $link ? ' class="active"' : '';
printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($link)), $link);
}
/** Link to last page, plus ellipses if necessary */
if (!in_array($max, $links)) {
if (!in_array($max - 1, $links)) {
echo '<li>…</li>' . "\n";
}
$class = $paged == $max ? ' class="active"' : '';
printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($max)), $max);
}
/** Next Post Link */
if (get_next_posts_link()) {
printf('<li>%s</li>' . "\n", get_next_posts_link());
}
echo '</ul></div>' . "\n";
}
示例14: UM_Mail
function UM_Mail($user_id_or_email = 1, $subject_line = 'Email Subject', $template, $path = null, $args = array())
{
if (absint($user_id_or_email)) {
$user = get_userdata($user_id_or_email);
$email = $user->user_email;
} else {
$email = $user_id_or_email;
}
$headers = 'From: ' . um_get_option('mail_from') . ' <' . um_get_option('mail_from_addr') . '>' . "\r\n";
$attachments = null;
if (file_exists(get_stylesheet_directory() . '/ultimate-member/templates/email/' . get_locale() . '/' . $template . '.html')) {
$path_to_email = get_stylesheet_directory() . '/ultimate-member/templates/email/' . get_locale() . '/' . $template . '.html';
} else {
if (file_exists(get_stylesheet_directory() . '/ultimate-member/templates/email/' . $template . '.html')) {
$path_to_email = get_stylesheet_directory() . '/ultimate-member/templates/email/' . $template . '.html';
} else {
$path_to_email = $path . $template . '.html';
}
}
if (um_get_option('email_html')) {
$message = file_get_contents($path_to_email);
add_filter('wp_mail_content_type', 'um_mail_content_type');
} else {
$message = um_get_option('email-' . $template) ? um_get_option('email-' . $template) : 'Untitled';
}
$message = um_convert_tags($message, $args);
wp_mail($email, $subject_line, $message, $headers, $attachments);
}
示例15: unblock_ip_address
function unblock_ip_address($entries)
{
global $wpdb, $aio_wp_security;
if (is_array($entries)) {
if (isset($_REQUEST['_wp_http_referer'])) {
//Delete multiple records
$entries = array_filter($entries, 'is_numeric');
//discard non-numeric ID values
$id_list = "(" . implode(",", $entries) . ")";
//Create comma separate list for DB operation
$delete_command = "DELETE FROM " . AIOWPSEC_TBL_PERM_BLOCK . " WHERE id IN " . $id_list;
$result = $wpdb->query($delete_command);
if ($result != NULL) {
AIOWPSecurity_Admin_Menu::show_msg_record_deleted_st();
}
}
} elseif ($entries != NULL) {
$nonce = isset($_GET['aiowps_nonce']) ? $_GET['aiowps_nonce'] : '';
if (!isset($nonce) || !wp_verify_nonce($nonce, 'unblock_ip')) {
$aio_wp_security->debug_logger->log_debug("Nonce check failed for unblock IP operation!", 4);
die(__('Nonce check failed for unblock IP operation!', 'all-in-one-wp-security-and-firewall'));
}
//Delete single record
$delete_command = "DELETE FROM " . AIOWPSEC_TBL_PERM_BLOCK . " WHERE id = '" . absint($entries) . "'";
$result = $wpdb->query($delete_command);
if ($result != NULL) {
AIOWPSecurity_Admin_Menu::show_msg_record_deleted_st();
}
}
}