Exemplo n.º 1
0
 /**
  * Logs the given value to a file.
  * @since   2.0.6
  */
 public static function log($v, $sFilePath = null)
 {
     if (!defined('WP_DEBUG') || !WP_DEBUG) {
         return;
     }
     static $_iPageLoadID;
     // identifies the page load.
     static $_nGMTOffset;
     static $_fPreviousTimeStamp = 0;
     $_iPageLoadID = $_iPageLoadID ? $_iPageLoadID : uniqid();
     $_oCallerInfo = debug_backtrace();
     $_sCallerFunction = isset($_oCallerInfo[1]['function']) ? $_oCallerInfo[1]['function'] : '';
     $_sCallerClasss = isset($_oCallerInfo[1]['class']) ? $_oCallerInfo[1]['class'] : '';
     $sFilePath = !$sFilePath ? WP_CONTENT_DIR . DIRECTORY_SEPARATOR . get_class() . '_' . $_sCallerClasss . '_' . date("Ymd") . '.log' : (true === $sFilePath ? WP_CONTENT_DIR . DIRECTORY_SEPARATOR . get_class() . '_' . date("Ymd") . '.log' : $sFilePath);
     $_nGMTOffset = isset($_nGMTOffset) ? $_nGMTOffset : get_option('gmt_offset');
     $_fCurrentTimeStamp = microtime(true);
     $_nNow = $_fCurrentTimeStamp + $_nGMTOffset * 60 * 60;
     $_nMicroseconds = round(($_nNow - floor($_nNow)) * 10000);
     $_nMicroseconds = str_pad($_nMicroseconds, 4, '0');
     // $_nMicroseconds        = strlen( $_nMicroseconds ) === 4 ? $_nMicroseconds : str_pad( $_nMicroseconds, 4, '0' );
     $_nElapsed = round($_fCurrentTimeStamp - $_fPreviousTimeStamp, 3);
     $_aElapsedParts = explode(".", (string) $_nElapsed);
     $_sElapsedFloat = str_pad(isset($_aElapsedParts[1]) ? $_aElapsedParts[1] : 0, 3, '0');
     $_sElapsed = isset($_aElapsedParts[0]) ? $_aElapsedParts[0] : 0;
     $_sElapsed = strlen($_sElapsed) > 1 ? '+' . substr($_sElapsed, -1, 2) : ' ' . $_sElapsed;
     $_sHeading = date("Y/m/d H:i:s", $_nNow) . '.' . $_nMicroseconds . ' ' . $_sElapsed . '.' . $_sElapsedFloat . ' ' . "{$_iPageLoadID} {$_sCallerClasss}::{$_sCallerFunction} " . current_filter() . ' ' . self::getCurrentURL();
     file_put_contents($sFilePath, $_sHeading . PHP_EOL . print_r($v, true) . PHP_EOL . PHP_EOL, FILE_APPEND);
     $_fPreviousTimeStamp = $_fCurrentTimeStamp;
 }
 /**
  * Handle term changes.
  *
  * @wp-hook create_term
  * @wp-hook delete_term
  * @wp-hook edit_term
  *
  * @param int    $term_id          Term ID. Not used.
  * @param int    $term_taxonomy_id Term taxonomy ID.
  * @param string $taxonomy         Taxonomy slug.
  *
  * @return bool
  */
 public function change_term_relationships($term_id, $term_taxonomy_id, $taxonomy)
 {
     if (!$this->is_valid_request($taxonomy)) {
         return FALSE;
     }
     /**
      * This is a core bug!
      *
      * @see https://core.trac.wordpress.org/ticket/32876
      */
     $term_taxonomy_id = (int) $term_taxonomy_id;
     $success = FALSE;
     $current_filter = current_filter();
     if (is_callable(array($this, $current_filter))) {
         /**
          * Runs before the terms are changed.
          *
          * @param int    $term_taxonomy_id Term taxonomy ID.
          * @param string $taxonomy         Taxonomy name.
          * @param string $current_filter   Current filter.
          */
         do_action('mlp_before_term_synchronization', $term_taxonomy_id, $taxonomy, $current_filter);
         $success = call_user_func(array($this, $current_filter), $term_taxonomy_id);
         /**
          * Runs after the terms have been changed.
          *
          * @param int    $term_taxonomy_id Term taxonomy ID.
          * @param string $taxonomy         Taxonomy name.
          * @param string $current_filter   Current filter.
          * @param bool   $success          Denotes whether or not the database was changed.
          */
         do_action('mlp_after_term_synchronization', $term_taxonomy_id, $taxonomy, $current_filter, $success);
     }
     return $success;
 }
Exemplo n.º 3
0
 public static function handle_deprecation($data)
 {
     // determine the current filter
     $current_filter = current_filter();
     // figure out if the current filter is actually in our map list
     if (isset(self::$map[$current_filter])) {
         // get a list of this function call's args, for use when calling deprecated filters
         $args = func_get_args();
         array_unshift($args, null);
         // get the list of all the potential old filters
         $old_filters = (array) self::$map[$current_filter];
         // for each matching old filter we have..
         foreach ($old_filters as $old_filter_info) {
             list($old_filter, $deprecation_version) = $old_filter_info;
             // if there is a register function on that old filter
             if (has_action($old_filter)) {
                 // then call those register functions
                 $args[0] = $old_filter;
                 $data = call_user_func_array('apply_filters', $args);
                 // pop the deprecation message
                 _deprecated_function(sprintf(__('The "%s" filter', 'opentickets-community-edition'), $old_filter), $deprecation_version, sprintf(__('The "%s" filter', 'opentickets-community-edition'), $current_filter));
             }
         }
     }
     return $data;
 }
    /**
     * The template displaying the front page featured page block.
     *
     *
     * @package Customizr
     * @since Customizr 3.0
     */
    function tc_fp_block_display()
    {
        //gets display options
        $tc_show_featured_pages = esc_attr(tc__f('__get_option', 'tc_show_featured_pages'));
        $tc_show_featured_pages_img = esc_attr(tc__f('__get_option', 'tc_show_featured_pages_img'));
        if (!apply_filters('tc_show_fp', 0 != $tc_show_featured_pages && tc__f('__is_home'))) {
            return;
        }
        //gets the featured pages array and sets the fp layout
        $fp_ids = apply_filters('tc_featured_pages_ids', TC_init::$instance->fp_ids);
        $fp_nb = count($fp_ids);
        $fp_per_row = apply_filters('tc_fp_per_line', 3);
        //defines the span class
        $span_array = array(1 => 12, 2 => 6, 3 => 4, 4 => 3, 5 => 2, 6 => 2, 7 => 2);
        $span_value = 4;
        $span_value = $fp_per_row > 7 ? 1 : $span_value;
        $span_value = isset($span_array[$fp_per_row]) ? $span_array[$fp_per_row] : $span_value;
        //save $args for filter
        $args = array($fp_ids, $fp_nb, $fp_per_row, $span_value);
        ?>

        <?php 
        ob_start();
        ?>



  			<div class="container marketing">


            <center><h1>
              Mavericks Classes<br>
            </h1></center>


          <?php 
        do_action('__before_fp');
        $j = 1;
        for ($i = 1; $i <= $fp_nb; $i++) {
            printf('%1$s<div class="span%2$s fp-%3$s">%4$s</div>%5$s', 1 == $j ? '<div class="row widget-area" role="complementary">' : '', $span_value, $fp_ids[$i - 1], $this->tc_fp_single_display($fp_ids[$i - 1], $tc_show_featured_pages_img), $j == $fp_per_row || $i == $fp_nb ? '</div>' : '');
            //set $j back to start value if reach $fp_per_row
            $j++;
            $j = $j == $fp_per_row + 1 ? 1 : $j;
        }
        do_action('__after_fp');
        ?>

  			</div><!-- .container -->

        <?php 
        echo !tc__f('__is_home_empty') ? apply_filters('tc_after_fp_separator', '<hr class="featurette-divider ' . current_filter() . '">') : '';
        ?>

       <?php 
        $html = ob_get_contents();
        if ($html) {
            ob_end_clean();
        }
        echo apply_filters('tc_fp_block_display', $html, $args);
    }
 public static function check_is_spam($lead_data)
 {
     $api_key = Inbound_Akismet::get_api_key();
     /* return true if akismet is not setup */
     if (!$api_key) {
         return false;
     }
     $params = Inbound_Akismet::prepare_params($lead_data);
     $is_spam = Inbound_Akismet::api_check($params);
     /* if not spam return false */
     if (!$is_spam) {
         return false;
     }
     /* Discover which filter is calling the spam check and react to spam accordingly */
     switch (current_filter()) {
         /* Kill ajax script if inbound_store_lead_pre hook */
         case 'inbound_store_lead_pre':
             exit;
             break;
             /* Return true to prevent email actions if form_actions_spam_check hook */
         /* Return true to prevent email actions if form_actions_spam_check hook */
         case 'form_actions_spam_check':
             return true;
             break;
     }
 }
        /**
         * Single post thumbnail view
         *
         * @package Customizr
         * @since Customizr 3.2.0
         */
        function tc_single_post_thumbnail_view()
        {
            $_exploded_location = explode('|', esc_attr(tc__f('__get_option', 'tc_single_post_thumb_location')));
            $_hook = isset($_exploded_location[0]) ? $_exploded_location[0] : '__before_content';
            $_size_to_request = '__before_main_wrapper' == $_hook ? 'slider-full' : 'slider';
            //get the thumbnail data (src, width, height) if any
            $thumb_data = TC_post_thumbnails::$instance->tc_get_thumbnail_data($_size_to_request);
            $_single_thumbnail_wrap_class = implode(" ", apply_filters('tc_single_post_thumb_class', array('row-fluid', 'tc-single-post-thumbnail-wrapper', current_filter())));
            ob_start();
            ?>
            <div class="<?php 
            echo $_single_thumbnail_wrap_class;
            ?>
">
              <?php 
            TC_post_thumbnails::$instance->tc_display_post_thumbnail($thumb_data, 'span12');
            ?>
            </div>
          <?php 
            $html = ob_get_contents();
            if ($html) {
                ob_end_clean();
            }
            echo apply_filters('tc_single_post_thumbnail_view', $html);
        }
/**
 * Handle each of our LearnDash triggers
 *
 * @since 1.0.0
 */
function badgeos_learndash_trigger_event()
{
    // Setup all our important variables
    global $blog_id, $wpdb;
    // Setup args
    $args = func_get_args();
    $userID = get_current_user_id();
    if (is_array($args) && isset($args['user'])) {
        if (is_object($args['user'])) {
            $userID = (int) $args['user']->ID;
        } else {
            $userID = (int) $args['user'];
        }
    }
    if (empty($userID)) {
        return;
    }
    $user_data = get_user_by('id', $userID);
    if (empty($user_data)) {
        return;
    }
    // Grab the current trigger
    $this_trigger = current_filter();
    // Update hook count for this user
    $new_count = badgeos_update_user_trigger_count($userID, $this_trigger, $blog_id);
    // Mark the count in the log entry
    badgeos_post_log_entry(null, $userID, null, sprintf(__('%1$s triggered %2$s (%3$dx)', 'badgeos'), $user_data->user_login, $this_trigger, $new_count));
    // Now determine if any badges are earned based on this trigger event
    $triggered_achievements = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT post_id\n\t\tFROM   {$wpdb->postmeta}\n\t\tWHERE  meta_key = '_badgeos_learndash_trigger'\n\t\t\t\tAND meta_value = %s\n\t\t", $this_trigger));
    foreach ($triggered_achievements as $achievement) {
        badgeos_maybe_award_achievement_to_user($achievement->post_id, $userID, $this_trigger, $blog_id, $args);
    }
}
 public function handle_comment_log($comment_ID, $comment = null)
 {
     if (is_null($comment)) {
         $comment = get_comment($comment_ID);
     }
     $action = 'created';
     switch (current_filter()) {
         case 'wp_insert_comment':
             $action = 1 === (int) $comment->comment_approved ? 'approved' : 'pending';
             break;
         case 'edit_comment':
             $action = 'updated';
             break;
         case 'delete_comment':
             $action = 'deleted';
             break;
         case 'trash_comment':
             $action = 'trashed';
             break;
         case 'untrash_comment':
             $action = 'untrashed';
             break;
         case 'spam_comment':
             $action = 'spammed';
             break;
         case 'unspam_comment':
             $action = 'unspammed';
             break;
     }
     $this->_add_comment_log($comment_ID, $action, $comment);
 }
Exemplo n.º 9
0
 static function do_hook()
 {
     global $wp_filter;
     $current_hook = current_filter();
     if (!isset(self::$hooks[$current_hook])) {
         return;
     }
     $hook = self::$hooks[$current_hook];
     $hook_args = func_get_args();
     if ('filter' == $hook['hook_type']) {
         $value = $hook_args[0];
     }
     if (has_filter($hook['old_hook'])) {
         self::_deprecated_hook($current_hook);
         if ('filter' == $hook['hook_type']) {
             $type = 'apply_filters';
         } else {
             $type = 'do_action';
         }
         $value = call_user_func_array($type, array_merge(array($hook['old_hook']), array_slice($hook_args, 0, $hook['args'])));
     }
     if ('filter' == $hook['hook_type']) {
         return $value;
     }
 }
Exemplo n.º 10
0
 /**
  * Primary class constructor.
  *
  * @since 2.0.0
  */
 public function __construct()
 {
     // Load the base class object.
     $this->base = Optin_Monster::get_instance();
     // Possibly prepare the preview customizer frame.
     add_action(current_filter(), array($this, 'maybe_prepare_preview'));
 }
Exemplo n.º 11
0
 /**
  * Filter TinyMCE buttons (Visual tab).
  *
  * @param  array $buttons
  *
  * @return array
  */
 public function mce_buttons(array $buttons = [])
 {
     if ($new = papi_to_array($this->get_setting(current_filter(), []))) {
         return $new;
     }
     return $buttons;
 }
 /**
  * Outputs user selected Smartpost terminal in different locations (admin screen, email, orders)
  *
  * @param  mixed $order Order (ID or WC_Order)
  * @return void
  */
 function show_selected_terminal($order)
 {
     if ($order->has_shipping_method($this->id)) {
         // Fetch selected terminal ID
         $window_value = $this->get_order_terminal($order->id);
         $time_windows = $this->get_courier_time_windows();
         $window_name = isset($time_windows[$window_value]) ? $time_windows[$window_value] : reset($time_windows);
         // Output selected terminal to user customer details
         if (current_filter() == 'woocommerce_order_details_after_customer_details') {
             if (version_compare(WC_VERSION, '2.3.0', '<')) {
                 $terminal = '<dt>' . $this->i18n_selected_terminal . ':</dt>';
                 $terminal .= '<dd>' . $window_name . '</dd>';
             } else {
                 $terminal = '<tr>';
                 $terminal .= '<th>' . $this->i18n_selected_terminal . ':</th>';
                 $terminal .= '<td data-title="' . $this->i18n_selected_terminal . '">' . $window_name . '</td>';
                 $terminal .= '</tr>';
             }
         } elseif (current_filter() == 'woocommerce_email_customer_details') {
             $terminal = '<h2>' . $this->i18n_selected_terminal . '</h2>';
             $terminal .= '<p>' . $terminal_name . '</p>';
         } else {
             $terminal = '<div class="selected_terminal">';
             $terminal .= '<div><strong>' . $this->i18n_selected_terminal . '</strong></div>';
             $terminal .= $window_name;
             $terminal .= '</div>';
         }
         // Allow manipulating output
         echo apply_filters('wc_shipping_' . $this->id . '_selected_terminal', $terminal, $window_value, $window_name, current_filter());
     }
 }
Exemplo n.º 13
0
 function shortcode_route()
 {
     if (!EPL_IS_ADMIN && 'the_content' == current_filter()) {
         $resource = 'epl_front';
         return $this->_route($resource);
     }
 }
Exemplo n.º 14
0
 public static function register_buttons($buttons)
 {
     switch (current_filter()) {
         case 'mce_buttons':
             $cur_lvl = 1;
             break;
         case 'mce_buttons_2':
             $cur_lvl = 2;
             break;
         case 'mce_buttons_4':
             $cur_lvl = 4;
             break;
         default:
             $cur_lvl = 3;
     }
     // if there is no buttons for current level - return
     if (isset(self::$buttons[$cur_lvl])) {
         $cur_lvl_btns = self::$buttons[$cur_lvl];
     } else {
         return $buttons;
     }
     // add buttons
     foreach ($cur_lvl_btns as $plugin_name => $plugin_buttons) {
         $buttons = array_merge($buttons, $plugin_buttons);
     }
     return $buttons;
 }
Exemplo n.º 15
0
/**
 * [bootswatch_hook_callback description]
 */
function bootswatch_hook_callback()
{
    $hook = preg_replace('/^bootswatch_/', '', current_filter());
    $content = TitanFramework::getInstance('bootswatch')->getOption($hook);
    printf('<div class="%s">%s</div>', 'bootswatch_' . $hook, do_shortcode($content));
    // WPCS: XSS OK.
}
 public static function inspect()
 {
     self::$_current_filter = current_filter();
     if (in_array(self::$_current_filter, array_keys(self::$_user_meta_action_args))) {
         $arg_list = func_get_args();
         foreach (self::$_user_meta_action_args[self::$_current_filter] as $arg_key => $var_name) {
             ${$var_name} = $arg_list[$arg_key];
         }
         if (strpos($meta_key, '_capabilities')) {
             if (!is_super_admin($object_id)) {
                 $new_caps = array_filter((array) $meta_value);
                 if ("delete_user_meta" == self::$_current_filter || !empty($new_caps)) {
                     self::_log_capability_change($object_id, $new_caps);
                 }
             } else {
                 self::_log_super_user_cap_change($object_id);
             }
         }
     }
     if (in_array(self::$_current_filter, array_keys(self::$_super_user_action_args))) {
         $arg_list = func_get_args();
         foreach (self::$_super_user_action_args[self::$_current_filter] as $arg_key => $var_name) {
             ${$var_name} = $arg_list[$arg_key];
         }
         self::_log_super_user_priv_change($user_id);
     }
 }
 /**
  * Allow previewing and updating of a standalone collection
  */
 public function action_customize_save_collection()
 {
     // current_filter() is for backwards compat even though these are actions
     if (0 === strpos(current_filter(), 'customize_update_')) {
         $action = 'update';
         $collection_name = str_replace('customize_update_collection_setting_', '', current_filter());
     } else {
         if (0 === strpos(current_filter(), 'customize_preview_')) {
             $action = 'preview';
             $collection_name = str_replace('customize_preview_collection_setting_', '', current_filter());
         } else {
             return;
         }
     }
     $collection = Post_Collection::get_by_name($collection_name);
     if (!$collection) {
         $collection = Post_Collection::create($collection_name);
     }
     $posted_items = json_decode(wp_unslash($_POST['customized']), true);
     $key = 'collection_setting_' . $collection_name;
     $values = !empty($posted_items[$key]) ? array_map('intval', $posted_items[$key]) : array();
     if ('update' == $action) {
         $collection->set_customizer_item_ids($values);
         $collection->set_published_item_ids($values);
     } else {
         if ('preview' == $action) {
             $collection->set_customizer_item_ids($values);
         }
     }
 }
 /**
  * Activate the addon. 
  *
  * @return  void
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function activate()
 {
     if ('charitable_activate_addon' !== current_filter()) {
         return false;
     }
     self::load();
 }
Exemplo n.º 19
0
/**
 * Handle each of our activity triggers
 *
 * @since 1.0.0
 * @return mixed
 */
function badgeos_trigger_event()
{
    // Setup all our globals
    global $user_ID, $blog_id, $wpdb;
    $site_id = $blog_id;
    $args = func_get_args();
    // Grab our current trigger
    $this_trigger = current_filter();
    // Grab the user ID
    $user_id = badgeos_trigger_get_user_id($this_trigger, $args);
    $user_data = get_user_by('id', $user_id);
    // Sanity check, if we don't have a user object, bail here
    if (!is_object($user_data)) {
        return $args[0];
    }
    // If the user doesn't satisfy the trigger requirements, bail here
    if (!apply_filters('badgeos_user_deserves_trigger', true, $user_id, $this_trigger, $site_id, $args)) {
        return $args[0];
    }
    // Update hook count for this user
    $new_count = badgeos_update_user_trigger_count($user_id, $this_trigger, $site_id, $args);
    // Mark the count in the log entry
    badgeos_post_log_entry(null, $user_id, null, sprintf(__('%1$s triggered %2$s (%3$dx)', 'badgeos'), $user_data->user_login, $this_trigger, $new_count));
    // Now determine if any badges are earned based on this trigger event
    $triggered_achievements = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT post_id\n\t\tFROM   {$wpdb->postmeta}\n\t\tWHERE  meta_key = '_badgeos_trigger_type'\n\t\t       AND meta_value = %s\n\t\t", $this_trigger));
    foreach ($triggered_achievements as $achievement) {
        badgeos_maybe_award_achievement_to_user($achievement->post_id, $user_id, $this_trigger, $site_id, $args);
    }
    return $args[0];
}
Exemplo n.º 20
0
/**
 * Display pged navigation for posts loop when applicable.
 *
 * @since  4.0.0
 */
function cherry_paging_nav()
{
    $current_hook = current_filter();
    $position = cherry_get_option('pagination-position', 'after');
    // if position in option set only 'before' and this is not 'cherry_loop_before' hook - do anything
    if ('before' == $position && 'cherry_loop_before' != $current_hook) {
        return;
    }
    // if position in option set only 'after' and this is not 'cherry_loop_after' hook - do anything
    if ('after' == $position && 'cherry_loop_after' != $current_hook) {
        return;
    }
    // Don't print empty markup if there's only one page.
    if ($GLOBALS['wp_query']->max_num_pages < 2) {
        return;
    }
    $prev_next = cherry_get_option('pagination-next-previous');
    $show_all = cherry_get_option('pagination-show-all');
    $prev_next = 'true' == $prev_next ? true : false;
    $show_all = 'true' == $show_all ? true : false;
    // get slider args from options
    $options_args = array('prev_next' => $prev_next, 'prev_text' => cherry_get_option('pagination-previous-page'), 'next_text' => cherry_get_option('pagination-next-page'), 'screen_reader_text' => cherry_get_option('pagination-label'), 'show_all' => $show_all, 'end_size' => cherry_get_option('pagination-end-size', 1), 'mid_size' => cherry_get_option('pagination-mid-size', 2));
    // get additional pagination args
    $custom_args = apply_filters('cherry_pagination_custom_args', array('add_fragment' => '', 'add_args' => false));
    $args = array_merge($options_args, $custom_args);
    if (function_exists('the_posts_pagination')) {
        // Previous/next page navigation.
        the_posts_pagination($args);
    }
}
 /**
  * Action to add link to the plugin settings page to the Settings menu.
  *
  * This needs to be be run from the `admin_menu` hook
  */
 public static function the_menu_item()
 {
     if (current_filter() !== 'admin_menu') {
         return;
     }
     add_options_page(static::OPTIONS_PAGE_TITLE, static::OPTIONS_MENU_TITLE, static::OPTIONS_PAGE_PERMS, static::OPTIONS_MENU_SLUG, array(get_called_class(), 'the_options_page'));
 }
 /**
  * Field callback methods - for field definitions that require heavy tasks should be defined with the callback methods.
  *
  * @callback    filter      field_definition_{instantiated class name}_{section id}_{field_id}
  * @return      array
  */
 public function replyToRedefineExampleField($aField)
 {
     $aField['title'] = __('Post Titles', 'admin-page-framework-loader');
     $aField['description'] = sprintf(__('This description is inserted with the filter, named: <code>%1$s</code>.', 'admin-page-framework-loader'), current_filter());
     $aField['label'] = $this->_getPostTitles();
     return $aField;
 }
 /**
  * Logs the given variable output to a file.
  * 
  * @remark      The alias of the `logArray()` method.
  * @since       1.2.0
  **/
 public static function log($vValue, $sFilePath = null)
 {
     static $_iPageLoadID;
     // identifies the page load.
     static $_nGMTOffset;
     static $_fPreviousTimeStamp = 0;
     $_iPageLoadID = $_iPageLoadID ? $_iPageLoadID : uniqid();
     $_oCallerInfo = debug_backtrace();
     $_sCallerFunction = isset($_oCallerInfo[1]['function']) ? $_oCallerInfo[1]['function'] : '';
     $_sCallerClasss = isset($_oCallerInfo[1]['class']) ? $_oCallerInfo[1]['class'] : '';
     $sFilePath = !$sFilePath ? WP_CONTENT_DIR . DIRECTORY_SEPARATOR . get_class() . '_' . $_sCallerClasss . '_' . date("Ymd") . '.log' : (true === $sFilePath ? WP_CONTENT_DIR . DIRECTORY_SEPARATOR . get_class() . '_' . date("Ymd") . '.log' : $sFilePath);
     $_nGMTOffset = isset($_nGMTOffset) ? $_nGMTOffset : get_option('gmt_offset');
     $_fCurrentTimeStamp = microtime(true);
     $_nNow = $_fCurrentTimeStamp + $_nGMTOffset * 60 * 60;
     $_nMicroseconds = round(($_nNow - floor($_nNow)) * 10000);
     $_nMicroseconds = str_pad($_nMicroseconds, 4, '0');
     $_nElapsed = round($_fCurrentTimeStamp - $_fPreviousTimeStamp, 3);
     $_aElapsedParts = explode(".", (string) $_nElapsed);
     $_sElapsedFloat = str_pad(isset($_aElapsedParts[1]) ? $_aElapsedParts[1] : 0, 3, '0');
     $_sElapsed = isset($_aElapsedParts[0]) ? $_aElapsedParts[0] : 0;
     $_sElapsed = strlen($_sElapsed) > 1 ? '+' . substr($_sElapsed, -1, 2) : ' ' . $_sElapsed;
     $_sHeading = date("Y/m/d H:i:s", $_nNow) . '.' . $_nMicroseconds . ' ' . $_sElapsed . '.' . $_sElapsedFloat . ' ' . $_iPageLoadID . ' ' . ResponsiveColumnWidgets_Registry::VERSION . ' ' . "{$_sCallerClasss}::{$_sCallerFunction} " . current_filter() . ' ' . self::getCurrentURL() . ' ';
     $_sType = gettype($vValue);
     $_iLengths = is_string($vValue) || is_integer($vValue) ? strlen($vValue) : (is_array($vValue) ? count($vValue) : null);
     $vValue = is_object($vValue) ? method_exists($vValue, '__toString') ? (string) $vValue : (array) $vValue : $vValue;
     $vValue = is_array($vValue) ? self::getSliceByDepth($vValue, 5) : $vValue;
     file_put_contents($sFilePath, $_sHeading . PHP_EOL . '(' . $_sType . (null !== $_iLengths ? ', length: ' . $_iLengths : '') . ') ' . print_r($vValue, true) . PHP_EOL . PHP_EOL, FILE_APPEND);
     $_fPreviousTimeStamp = $_fCurrentTimeStamp;
 }
 public static function schedule_inspections($schedules = array())
 {
     global $wp_filter;
     $return_schedules = false;
     if ('cron_schedules' == current_filter()) {
         remove_filter('cron_schedules', array(__CLASS__, __FUNCTION__), 999);
     }
     if (!is_array($schedules) || count($schedules) <= 0) {
         $schedules = wp_get_schedules();
     } else {
         $return_schedules = true;
         self::unschedule_inspections();
     }
     foreach (array_keys($schedules) as $schedule) {
         if (!wp_next_scheduled('ac_inspection_' . $schedule)) {
             wp_schedule_event(time(), $schedule, 'ac_inspection_' . $schedule);
         }
         if (!has_action('ac_inspection_' . $schedule, array(__CLASS__, 'inspection_complete'))) {
             add_action('ac_inspection_' . $schedule, array(__CLASS__, 'inspection_complete'), 999, 0);
         }
     }
     if (!has_action('ac_inspection_now', array(__CLASS__, 'inspection_complete'))) {
         add_action('ac_inspection_now', array(__CLASS__, 'inspection_complete'), 999, 0);
     }
     if ('cron_schedules' == current_filter()) {
         add_filter('cron_schedules', array(__CLASS__, __FUNCTION__), 999, 1);
     }
     if ($return_schedules) {
         return $schedules;
     }
 }
 /**
  * Records current memory usage at specific hooks
  *
  * @since 6.0
  * @access public
  */
 function record_memory_usage()
 {
     $current_filter = current_filter();
     if (in_array($current_filter, $this->core_hooks) || substr($current_filter, 0, 4) == 'tml_') {
         $this->core_hook_usage[$current_filter] = memory_get_usage();
     }
 }
Exemplo n.º 26
0
 /**
  * Get meta type so we know where the data should be saved.
  *
  * @return string
  */
 protected function get_meta_type()
 {
     if ($current_filter = current_filter()) {
         return papi_get_meta_type(explode('_', $current_filter)[1]);
     }
     return papi_get_meta_type();
 }
Exemplo n.º 27
0
 /**
  * Handle term changes.
  *
  * @wp-hook create_term
  * @wp-hook delete_term
  * @wp-hook edit_term
  * @param   int    $term_id  Term ID. Not used.
  * @param   int    $term_taxonomy_id  Term taxonomy ID.
  * @param   string $taxonomy Taxonomy slug.
  * @return  bool
  */
 public function change_term_relationships($term_id, $term_taxonomy_id, $taxonomy)
 {
     if (!$this->is_valid_request($taxonomy)) {
         return FALSE;
     }
     $success = FALSE;
     $filter = current_filter();
     if (is_callable(array($this, $filter))) {
         /**
          * Called in Mlp_Term_Connector::change_term_relationships before
          * terms are changed.
          *
          * @param int    $term_taxonomy_id
          * @param string $taxonomy
          * @param string $filter
          */
         do_action('mlp_before_term_synchronization', $term_taxonomy_id, $taxonomy, $filter);
         $success = call_user_func(array($this, $filter), $term_taxonomy_id);
         /**
          * Called in Mlp_Term_Connector::change_term_relationships after
          * terms are changed.
          *
          * @param int    $term_taxonomy_id
          * @param string $taxonomy
          * @param string $filter
          * @param bool   $success Whether or not the database was changed.
          */
         do_action('mlp_after_term_synchronization', $term_taxonomy_id, $taxonomy, $filter, $success);
     }
     return $success;
 }
Exemplo n.º 28
0
 /**
  * Add language translations to update_plugins or update_themes transients.
  *
  * @param $transient
  *
  * @return mixed
  */
 public function pre_set_site_transient($transient)
 {
     $locales = get_available_languages();
     $locales = !empty($locales) ? $locales : array(get_locale());
     $repos = array();
     if (!isset($transient->translations)) {
         return $transient;
     }
     if ('pre_set_site_transient_update_plugins' === current_filter()) {
         $repos = Plugin::instance()->get_plugin_configs();
         $translations = wp_get_installed_translations('plugins');
     }
     if ('pre_set_site_transient_update_themes' === current_filter()) {
         $repos = Theme::instance()->get_theme_configs();
         $translations = wp_get_installed_translations('themes');
     }
     $repos = array_filter($repos, function ($e) {
         return isset($e->language_packs);
     });
     foreach ($repos as $repo) {
         foreach ($locales as $locale) {
             $lang_pack_mod = isset($repo->language_packs->{$locale}) ? strtotime($repo->language_packs->{$locale}->updated) : 0;
             $translation_mod = isset($translations[$repo->repo][$locale]) ? strtotime($translations[$repo->repo][$locale]['PO-Revision-Date']) : 0;
             if ($lang_pack_mod > $translation_mod) {
                 $transient->translations[] = (array) $repo->language_packs->{$locale};
             }
         }
     }
     $transient->translations = array_unique($transient->translations, SORT_REGULAR);
     return $transient;
 }
Exemplo n.º 29
0
/**
 * Add contextual help to the Themes and Post edit screens.
 *
 * @since Twenty Fourteen 1.0
 */
function twentyfourteen_contextual_help()
{
    if ('admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow']) {
        return;
    }
    get_current_screen()->add_help_tab(array('id' => 'twentyfourteen', 'title' => __('Twenty Fourteen', 'twentyfourteen'), 'content' => '<ul>' . '<li>' . sprintf(__('The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance &rarr; Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen'), esc_url(add_query_arg('tag', _x('featured', 'featured content default tag slug', 'twentyfourteen'), admin_url('edit.php'))), admin_url('customize.php'), admin_url('edit.php?show_sticky=1')) . '</li>' . '<li>' . sprintf(__('Enhance your site design by using <a href="%s">Featured Images</a> for posts you&rsquo;d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages&mdash;above the title&mdash;and in the Featured Content area on the home page.', 'twentyfourteen'), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail') . '</li>' . '<li>' . sprintf(__('For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen'), 'https://codex.wordpress.org/Twenty_Fourteen') . '</li>' . '</ul>'));
}
Exemplo n.º 30
0
 public function collect()
 {
     if (!defined('WP_ADMIN')) {
         return;
     }
     // Toggle script for Arrays/Objects
     if ('admin_init' === current_filter()) {
         add_action("admin_print_footer_scripts", array($this, 'toggle_script'));
     }
     foreach ($this->globals as $key => $var) {
         // Check availability in global context
         if (!empty($GLOBALS[$var])) {
             $global = $GLOBALS[$var];
             // Object/Array handling
             !is_scalar($global) and $global = $this->scalar_helper($global);
             // Add to result
             $this->data[get_class()][] = sprintf("<td><var>\$%s</var></td><td>%s</td><td>%s</td>", $var, $global, current_filter());
             // Don't loop this one the next time
             unset($this->globals[$key]);
         }
         // We're done: Remove callback & Return
         if (empty($this->globals) or 'contextual_help' === current_filter()) {
             return remove_filter(current_filter(), __FUNCTION__);
         }
     }
 }