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;
 }
Example #2
0
    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']);
    }
 /**
  * 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;
 }
Example #4
0
 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'));
 }
 /**
  * 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;
 }
 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;
 }
 /**
  * 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);
         }
     }
 }
Example #8
0
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);
}
 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')));
     }
 }
Example #10
0
/**
 * 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 &#215; %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);
}
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;
}
 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);
         }
     }
 }
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";
}
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);
}
 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();
         }
     }
 }
 public function prepare_items()
 {
     global $wpdb, $per_page;
     $per_page = $this->get_items_per_page('formidable_page_formidable_entries_per_page');
     $form_id = $this->params['form'];
     if (!$form_id) {
         $this->items = array();
         $this->set_pagination_args(array('total_items' => 0, 'per_page' => $per_page));
         return;
     }
     $default_orderby = 'id';
     $default_order = 'DESC';
     $s_query = array('it.form_id' => $form_id);
     $s = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
     if ($s != '' && FrmAppHelper::pro_is_installed()) {
         $fid = isset($_REQUEST['fid']) ? sanitize_title($_REQUEST['fid']) : '';
         $s_query = FrmProEntriesHelper::get_search_str($s_query, $s, $form_id, $fid);
     }
     $orderby = isset($_REQUEST['orderby']) ? sanitize_title($_REQUEST['orderby']) : $default_orderby;
     if (strpos($orderby, 'meta') !== false) {
         $order_field_type = FrmField::get_type(str_replace('meta_', '', $orderby));
         $orderby .= in_array($order_field_type, array('number', 'scale')) ? ' +0 ' : '';
     }
     $order = isset($_REQUEST['order']) ? sanitize_title($_REQUEST['order']) : $default_order;
     $order = ' ORDER BY ' . $orderby . ' ' . $order;
     $page = $this->get_pagenum();
     $start = (int) isset($_REQUEST['start']) ? absint($_REQUEST['start']) : ($page - 1) * $per_page;
     $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false);
     $total_items = FrmEntry::getRecordCount($s_query);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
 static function get_posts($args = array(), $current = 0)
 {
     $deff = array('post_type' => 'page', 'posts_per_page' => 40, 'post_status' => 'publish');
     if (empty($args)) {
         $args = $deff;
     } else {
         if (!isset($args['post_type'])) {
             $args['post_type'] = $deff['post_type'];
         }
         if (!isset($args['posts_per_page'])) {
             $args['posts_per_page'] = $deff['posts_per_page'];
         }
         if (!isset($args['post_status'])) {
             $args['post_status'] = $deff['post_status'];
         }
     }
     $query = new WP_Query($args);
     $rett = array(0 => __(' - Select from list - ', 'materialize'));
     if (count($query->posts)) {
         foreach ($query->posts as $p) {
             $rett[$p->ID] = esc_attr(get_the_title($p->ID));
         }
     }
     if (absint($current) > 0 && !isset($rett[$current])) {
         $p_ = get_post($current);
         if (isset($p_->ID)) {
             $rett[$p_->ID] = esc_attr(get_the_title($p_->ID));
         }
     }
     return $rett;
 }
Example #18
0
function excerpt($excerpt = '', $length = '')
{
    // Save a copy of the raw excerpt
    $raw_excerpt = $excerpt;
    // Excerpt length default
    if (empty($length)) {
        $length = absint(option('excerpt_length'));
    }
    // Generate an excerpt where none exists
    if (empty($excerpt)) {
        $post = get_post();
        if (empty($post)) {
            return;
        }
        // Don't return an excerpt for a protected post
        if (post_password_required($post->ID)) {
            return esc_html__('This post is protected.', 'ubik');
        }
        // Post contents will serve as the basis for generating the excerpt
        $excerpt = $post->post_content;
    }
    // Sanitize excerpt
    $excerpt = apply_filters('ubik_excerpt_sanitize', wptexturize(\Ubik\text_truncate($excerpt, $length, esc_html(option('excerpt_more')))));
    // Run the excerpt through a filter on the way out the door
    return apply_filters('ubik_excerpt', $excerpt, $raw_excerpt);
}
function so_remove_editor()
{
    // If not in the admin, return.
    if (!is_admin()) {
        return;
    }
    // Get the post ID on edit post with filter_input super global inspection.
    $current_post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT);
    // Get the post ID on update post with filter_input super global inspection.
    $update_post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT);
    // Check to see if the post ID is set, else return.
    if (isset($current_post_id)) {
        $post_id = absint($current_post_id);
    } else {
        if (isset($update_post_id)) {
            $post_id = absint($update_post_id);
        } else {
            return;
        }
    }
    // Don't do anything unless there is a post_id.
    if (isset($post_id)) {
        // Get the template of the current post.
        $template_file = get_post_meta($post_id, '_wp_page_template', true);
        // Example of removing page editor for page-your-template.php template.
        if ('page-your-template.php' === $template_file) {
            remove_post_type_support('page', 'editor');
            // Other features can also be removed in addition to the editor. See: https://codex.wordpress.org/Function_Reference/remove_post_type_support.
            remove_post_type_support('page', 'thumbnail');
        }
    }
}
Example #20
0
 /**
  * Previous Imports list
  */
 public function index()
 {
     $get = $this->input->get(array('s' => '', 'order_by' => 'registered_on', 'order' => 'DESC', 'pagenum' => 1, 'perPage' => 25));
     $get['pagenum'] = absint($get['pagenum']);
     extract($get);
     $this->data += $get;
     if (!in_array($order_by, array('registered_on', 'id', 'name'))) {
         $order_by = 'registered_on';
     }
     if (!in_array($order, array('DESC', 'ASC'))) {
         $order = 'DESC';
     }
     $list = new PMXI_Import_List();
     $post = new PMXI_Post_Record();
     $by = array('parent_import_id' => 0);
     if ('' != $s) {
         $like = '%' . preg_replace('%\\s+%', '%', preg_replace('/[%?]/', '\\\\$0', $s)) . '%';
         $by[] = array(array('name LIKE' => $like, 'type LIKE' => $like, 'path LIKE' => $like, 'friendly_name LIKE' => $like), 'OR');
     }
     $this->data['list'] = $list->join($post->getTable(), $list->getTable() . '.id = ' . $post->getTable() . '.import_id', 'LEFT')->setColumns($list->getTable() . '.*', 'COUNT(' . $post->getTable() . '.post_id' . ') AS post_count')->getBy($by, "{$order_by} {$order}", $pagenum, $perPage, $list->getTable() . '.id');
     $this->data['page_links'] = paginate_links(array('base' => add_query_arg('pagenum', '%#%', $this->baseUrl), 'add_args' => array('page' => 'pmxi-admin-manage'), 'format' => '', 'prev_text' => __('&laquo;', 'wp_all_import_plugin'), 'next_text' => __('&raquo;', 'wp_all_import_plugin'), 'total' => ceil($list->total() / $perPage), 'current' => $pagenum));
     //pmxi_session_unset();
     PMXI_Plugin::$session->clean_session();
     $this->render();
 }
 /**
  *    get_event
  *    attempts to retrieve an EE_Event object any way it can
  *
  * @access    public
  * @param    int $EVT_ID
  * @return    object
  */
 public static function get_event($EVT_ID = 0)
 {
     $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
     // do we already have the Event  you are looking for?
     if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
         return EEH_Event_View::$_event;
     }
     EEH_Event_View::$_event = NULL;
     // international newspaper?
     global $post;
     // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
     if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
         //			d( $post );
         // grab the event we're looking for
         if (isset($post->EE_Event) && ($EVT_ID == 0 || $EVT_ID == $post->ID)) {
             EEH_Event_View::$_event = $post->EE_Event;
             //				d( EEH_Event_View::$_event );
         }
         // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
         if (!EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
             // sigh... pull it from the db
             EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
             //				d( EEH_Event_View::$_event );
         }
     }
     return EEH_Event_View::$_event;
 }
 /**
  * Conditionally hook into WordPress.
  *
  * Theme must declare that they support this module by adding
  * add_theme_support( 'featured-content' ); during after_setup_theme.
  *
  * If no theme support is found there is no need to hook into WordPress.
  * We'll just return early instead.
  *
  * @static
  * @access public
  */
 public static function init()
 {
     $theme_support = get_theme_support('featured-content');
     // Return early if theme does not support Featured Content.
     if (!$theme_support) {
         return;
     }
     /*
      * An array of named arguments must be passed as the second parameter
      * of add_theme_support().
      */
     if (!isset($theme_support[0])) {
         return;
     }
     // Return early if "featured_content_filter" has not been defined.
     if (!isset($theme_support[0]['featured_content_filter'])) {
         return;
     }
     $filter = $theme_support[0]['featured_content_filter'];
     // Theme can override the number of max posts.
     if (isset($theme_support[0]['max_posts'])) {
         self::$max_posts = absint($theme_support[0]['max_posts']);
     }
     add_filter($filter, array(__CLASS__, 'get_featured_posts'));
     add_action('customize_register', array(__CLASS__, 'customize_register'), 9);
     add_action('admin_init', array(__CLASS__, 'register_setting'));
     add_action('switch_theme', array(__CLASS__, 'delete_transient'));
     add_action('save_post', array(__CLASS__, 'delete_transient'));
     add_action('delete_post_tag', array(__CLASS__, 'delete_post_tag'));
     add_action('customize_controls_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
     add_action('pre_get_posts', array(__CLASS__, 'pre_get_posts'));
     add_action('wp_loaded', array(__CLASS__, 'wp_loaded'));
 }
Example #23
0
function frl_get_related_ids($cpost, $tax = 'post_tag', $limit = 5)
{
    global $wpdb, $related_pt_rules;
    $related_ids = array();
    //params
    $related_pt_rules = frl_related_posts_rules();
    $post_type = isset($related_pt_rules[$cpost->post_type]) ? $related_pt_rules[$cpost->post_type] : '';
    $post_type = apply_filters('tst_related_post_types', $post_type, $cpost, $tax);
    //sometimes we need to alter it outside
    if (empty($post_type)) {
        return $related_ids;
    }
    $post_type = implode("','", $post_type);
    $limit = absint($limit);
    $post_id = absint($cpost->ID);
    //tags
    $relation_tags = get_the_terms($cpost, $tax);
    if (empty($relation_tags)) {
        return $related_ids;
    }
    $tag_ids = array();
    foreach ($relation_tags as $pt) {
        $tag_ids[] = (int) $pt->term_taxonomy_id;
    }
    $tag_ids = implode(',', $tag_ids);
    $sql = "SELECT p.ID, COUNT(t_r.object_id) AS cnt \nFROM {$wpdb->term_relationships} AS t_r, {$wpdb->posts} AS p\nWHERE t_r.object_id = p.id \nAND t_r.term_taxonomy_id IN({$tag_ids}) \nAND p.post_type IN('{$post_type}') \t\nAND p.id != {$post_id} \nAND p.post_status='publish' \nGROUP BY t_r.object_id \nORDER BY cnt DESC, p.post_date_gmt DESC \nLIMIT {$limit} ";
    $r_posts = $wpdb->get_results($sql);
    if (empty($r_posts)) {
        return $related_ids;
    }
    foreach ($r_posts as $p) {
        $related_ids[] = (int) $p->ID;
    }
    return $related_ids;
}
 /**
  * get_order function.
  *
  * @param bool $the_order (default: false)
  * @return WC_Order|bool
  */
 public function get_order($the_order = false)
 {
     global $post;
     if (false === $the_order) {
         $the_order = $post;
     } elseif (is_numeric($the_order)) {
         $the_order = get_post($the_order);
     }
     if (!$the_order || !is_object($the_order)) {
         return false;
     }
     $order_id = absint($the_order->ID);
     $post_type = $the_order->post_type;
     if ($order_type = wc_get_order_type($post_type)) {
         $classname = $order_type['class_name'];
     } else {
         $classname = false;
     }
     // Filter classname so that the class can be overridden if extended.
     $classname = apply_filters('woocommerce_order_class', $classname, $post_type, $order_id);
     if (!class_exists($classname)) {
         $classname = 'WC_Order';
     }
     return new $classname($the_order);
 }
 public function register_shortcode($atts, $content = null)
 {
     $atts = shortcode_atts(array('title' => __('Test Title', 'backend', 'vc-elements-pt'), 'number' => '299', 'icon' => 'fa fa-home'), $atts);
     $atts['number'] = absint($atts['number']);
     // The PHP_EOL is added so that it can be used as a separator between multiple counters
     return PHP_EOL . json_encode($atts);
 }
 /**
  * Sanitize widget form values as they are saved.
  *
  * @param array $new_instance The new options
  * @param array $old_instance The previous options
  */
 public function update($new_instance, $old_instance)
 {
     $instance = array();
     $instance['page_id'] = absint($new_instance['page_id']);
     $instance['layout'] = sanitize_key($new_instance['layout']);
     return $instance;
 }
Example #27
0
 function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     if (empty($instance['user_id']) || 'invalid' === $instance['user_id']) {
         if (current_user_can('edit_theme_options')) {
             echo $args['before_widget'];
             echo '<p>' . sprintf(__('You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s">Full instructions</a>.', 'jetpack'), esc_url(admin_url('widgets.php')), 'http://support.wordpress.com/widgets/goodreads-widget/#goodreads-user-id') . '</p>';
             echo $args['after_widget'];
         }
         return;
     }
     if (!array_key_exists($instance['shelf'], $this->shelves)) {
         return;
     }
     $instance['user_id'] = absint($instance['user_id']);
     // Set widget ID based on shelf.
     $this->goodreads_widget_id = $instance['user_id'] . '_' . $instance['shelf'];
     if (empty($title)) {
         $title = esc_html__('Goodreads', 'jetpack');
     }
     echo $args['before_widget'];
     echo $args['before_title'] . $title . $args['after_title'];
     $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode($instance['user_id']) . '.' . urlencode($instance['title']) . ':%20' . urlencode($instance['shelf']) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode($instance['shelf']) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr($this->goodreads_widget_id);
     echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr($this->goodreads_widget_id) . '"></div>' . "\n";
     echo '<script src="' . esc_url($goodreads_url) . '"></script>' . "\n";
     echo $args['after_widget'];
     do_action('jetpack_stats_extra', 'widget', 'goodreads');
 }
 /**
  * Register core taxonomies.
  */
 public static function register_taxonomies()
 {
     if (taxonomy_exists('product_type')) {
         return;
     }
     do_action('woocommerce_register_taxonomy');
     $permalinks = get_option('woocommerce_permalinks');
     register_taxonomy('product_type', apply_filters('woocommerce_taxonomy_objects_product_type', array('product')), apply_filters('woocommerce_taxonomy_args_product_type', array('hierarchical' => false, 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'rewrite' => false, 'public' => false)));
     register_taxonomy('product_cat', apply_filters('woocommerce_taxonomy_objects_product_cat', array('product')), apply_filters('woocommerce_taxonomy_args_product_cat', array('hierarchical' => true, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Categories', 'woocommerce'), 'labels' => array('name' => __('Product Categories', 'woocommerce'), 'singular_name' => __('Product Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Categories', 'woocommerce'), 'all_items' => __('All Product Categories', 'woocommerce'), 'parent_item' => __('Parent Product Category', 'woocommerce'), 'parent_item_colon' => __('Parent Product Category:', 'woocommerce'), 'edit_item' => __('Edit Product Category', 'woocommerce'), 'update_item' => __('Update Product Category', 'woocommerce'), 'add_new_item' => __('Add New Product Category', 'woocommerce'), 'new_item_name' => __('New Product Category Name', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['category_base']) ? _x('product-category', 'slug', 'woocommerce') : $permalinks['category_base'], 'with_front' => false, 'hierarchical' => true))));
     register_taxonomy('product_tag', apply_filters('woocommerce_taxonomy_objects_product_tag', array('product')), apply_filters('woocommerce_taxonomy_args_product_tag', array('hierarchical' => false, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Tags', 'woocommerce'), 'labels' => array('name' => __('Product Tags', 'woocommerce'), 'singular_name' => __('Product Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Tags', 'woocommerce'), 'all_items' => __('All Product Tags', 'woocommerce'), 'edit_item' => __('Edit Product Tag', 'woocommerce'), 'update_item' => __('Update Product Tag', 'woocommerce'), 'add_new_item' => __('Add New Product Tag', 'woocommerce'), 'new_item_name' => __('New Product Tag Name', 'woocommerce'), 'popular_items' => __('Popular Product Tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate Product Tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove Product Tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used Product tags', 'woocommerce'), 'not_found' => __('No Product Tags found', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['tag_base']) ? _x('product-tag', 'slug', 'woocommerce') : $permalinks['tag_base'], 'with_front' => false))));
     register_taxonomy('product_shipping_class', apply_filters('woocommerce_taxonomy_objects_product_shipping_class', array('product', 'product_variation')), apply_filters('woocommerce_taxonomy_args_product_shipping_class', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping Classes', 'woocommerce'), 'labels' => array('name' => __('Shipping Classes', 'woocommerce'), 'singular_name' => __('Shipping Class', 'woocommerce'), 'menu_name' => _x('Shipping Classes', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Shipping Classes', 'woocommerce'), 'all_items' => __('All Shipping Classes', 'woocommerce'), 'parent_item' => __('Parent Shipping Class', 'woocommerce'), 'parent_item_colon' => __('Parent Shipping Class:', 'woocommerce'), 'edit_item' => __('Edit Shipping Class', 'woocommerce'), 'update_item' => __('Update Shipping Class', 'woocommerce'), 'add_new_item' => __('Add New Shipping Class', 'woocommerce'), 'new_item_name' => __('New Shipping Class Name', 'woocommerce')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => false)));
     global $wc_product_attributes;
     $wc_product_attributes = array();
     if ($attribute_taxonomies = wc_get_attribute_taxonomies()) {
         foreach ($attribute_taxonomies as $tax) {
             if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
                 $tax->attribute_public = absint(isset($tax->attribute_public) ? $tax->attribute_public : 1);
                 $label = !empty($tax->attribute_label) ? $tax->attribute_label : $tax->attribute_name;
                 $wc_product_attributes[$name] = $tax;
                 $taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => false, 'query_var' => 1 === $tax->attribute_public, 'rewrite' => false, 'sort' => false, 'public' => 1 === $tax->attribute_public, 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
                 if (1 === $tax->attribute_public) {
                     $taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($tax->attribute_name), 'with_front' => false, 'hierarchical' => true);
                 }
                 register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
             }
         }
         do_action('woocommerce_after_register_taxonomy');
     }
 }
 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @since 4.4.0
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     $url = esc_url_raw(get_query_var('url'));
     $format = wp_oembed_ensure_format(get_query_var('format'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @since 4.4.0
      *
      * @param int $maxwidth Maximum allowed width. Default 600.
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = absint(get_query_var('maxwidth', $maxwidth));
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
 /**
  * Output widget.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
     $viewed_products = array_reverse(array_filter(array_map('absint', $viewed_products)));
     if (empty($viewed_products)) {
         return;
     }
     ob_start();
     $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std'];
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'post__in');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         $this->widget_start($args, $instance);
         echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">');
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo apply_filters('woocommerce_after_widget_product_list', '</ul>');
         $this->widget_end($args);
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }