Пример #1
17
/**
 * Get theme update information from the PMPro server.
 *
 * @since  2.0
 */
function memberlite_getUpdateInfo()
{
    //check if forcing a pull from the server
    $update_info = get_option("memberlite_update_info", false);
    $update_info_timestamp = get_option("memberlite_update_info_timestamp", 0);
    //if no update_infos locally, we need to hit the server
    if (empty($update_info) || !empty($_REQUEST['force-check']) || current_time('timestamp') > $update_info_timestamp + 86400) {
        /**
         * Filter to change the timeout for this wp_remote_get() request.
         *
         * @since 2.0.1
         *
         * @param int $timeout The number of seconds before the request times out
         */
        $timeout = apply_filters("memberlite_get_update_info_timeout", 5);
        //get em
        $remote_info = wp_remote_get(PMPRO_LICENSE_SERVER . "/themes/memberlite", $timeout);
        //test response
        if (is_wp_error($remote_info) || empty($remote_info['response']) || $remote_info['response']['code'] != '200') {
            //error
            pmpro_setMessage("Could not connect to the PMPro License Server to get update information. Try again later.", "error");
        } else {
            //update update_infos in cache
            $update_info = json_decode(wp_remote_retrieve_body($remote_info), true);
            delete_option('memberlite_update_info');
            add_option("memberlite_update_info", $update_info, NULL, 'no');
        }
        //save timestamp of last update
        delete_option('memberlite_update_info_timestamp');
        add_option("memberlite_update_info_timestamp", current_time('timestamp'), NULL, 'no');
    }
    return $update_info;
}
Пример #2
0
function get_timespan_most_viewed($mode = '', $limit = 10, $days = 7, $display = true)
{
    global $wpdb, $post;
    $limit_date = current_time('timestamp') - $days * 26400;
    $limit_date = date("Y-m-d H:i:s", $limit_date);
    $where = '';
    $temp = '';
    if (!empty($mode) && $mode != 'both') {
        $where = "post_type = '{$mode}'";
    } else {
        $where = '1=1';
    }
    $most_viewed = $wpdb->get_results("SELECT {$wpdb->posts}.*, (meta_value+0) AS views FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID WHERE post_date < '" . current_time('mysql') . "' AND post_date > '" . $limit_date . "' AND {$where} AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER  BY views DESC LIMIT {$limit}");
    if ($most_viewed) {
        foreach ($most_viewed as $post) {
            $post_title = get_the_title();
            $post_views = intval($post->views);
            $post_views = number_format($post_views);
            $temp .= "<li><a href=\"" . get_permalink() . "\">{$post_title}</a>" . __('', 'wp-postviews') . "</li>";
        }
    } else {
        $temp = '<li>' . __('N/A', 'wp-postviews') . '</li>' . "\n";
    }
    if ($display) {
        echo $temp;
    } else {
        return $temp;
    }
}
Пример #3
0
    function sf_custom_comments($comment, $args, $depth)
    {
        $GLOBALS['comment'] = $comment;
        $GLOBALS['comment_depth'] = $depth;
        ?>
		    <li id="comment-<?php 
        comment_ID();
        ?>
" <?php 
        comment_class('clearfix');
        ?>
>
		        <div class="comment-wrap clearfix">
		            <div class="comment-avatar">
		            	<?php 
        if (function_exists('get_avatar')) {
            echo get_avatar($comment, '100');
        }
        ?>
		            	<?php 
        if ($comment->comment_author_email == get_the_author_meta('email')) {
            ?>
		            	<span class="tooltip"><?php 
            _e("Author", "swiftframework");
            ?>
<span class="arrow"></span></span>
		            	<?php 
        }
        ?>
		            </div>
		    		<div class="comment-content">
		            	<div class="comment-meta">
	            			<?php 
        printf('<span class="comment-author">%1$s</span> <span class="comment-date">%2$s</span>', get_comment_author_link(), human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ' . __("ago", "swiftframework"));
        ?>
			            	<div class="comment-meta-actions">
		            			<?php 
        edit_comment_link(__('Edit', 'swiftframework'), '<span class="edit-link">', '</span><span class="meta-sep"> |</span>');
        ?>
		                        <?php 
        if ($args['type'] == 'all' || get_comment_type() == 'comment') {
            comment_reply_link(array_merge($args, array('reply_text' => __('Reply', 'swiftframework'), 'login_text' => __('Log in to reply.', 'swiftframework'), 'depth' => $depth, 'before' => '<span class="comment-reply">', 'after' => '</span>')));
        }
        ?>
			                </div>
						</div>
		      			<?php 
        if ($comment->comment_approved == '0') {
            _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'swiftframework');
        }
        ?>
		            	<div class="comment-body">
		                	<?php 
        comment_text();
        ?>
		            	</div>
		    		</div>
		        </div>
	<?php 
    }
 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     if ('shop_subscription' == $post->post_type && !empty($_POST['woocommerce_meta_nonce']) && wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
         if (isset($_POST['_billing_interval'])) {
             update_post_meta($post_id, '_billing_interval', $_POST['_billing_interval']);
         }
         if (!empty($_POST['_billing_period'])) {
             update_post_meta($post_id, '_billing_period', $_POST['_billing_period']);
         }
         $subscription = wcs_get_subscription($post_id);
         $dates = array();
         foreach (wcs_get_subscription_date_types() as $date_key => $date_label) {
             if ('last_payment' == $date_key) {
                 continue;
             }
             $utc_timestamp_key = $date_key . '_timestamp_utc';
             // A subscription needs a start date, even if it wasn't set
             if (isset($_POST[$utc_timestamp_key])) {
                 $datetime = $_POST[$utc_timestamp_key];
             } elseif ('start' === $date_key) {
                 $datetime = current_time('timestamp', true);
             } else {
                 // No date to set
                 continue;
             }
             $dates[$date_key] = date('Y-m-d H:i:s', $datetime);
         }
         try {
             $subscription->update_dates($dates, 'gmt');
             wp_cache_delete($post_id, 'posts');
         } catch (Exception $e) {
             wcs_add_admin_notice($e->getMessage(), 'error');
         }
     }
 }
Пример #5
0
function rcl_confirm_user_registration()
{
    global $wpdb, $rcl_options;
    $reglogin = $_GET['rglogin'];
    $regpass = $_GET['rgpass'];
    $regcode = md5($reglogin);
    if ($regcode == $_GET['rgcode']) {
        if ($user = get_user_by('login', $reglogin)) {
            wp_update_user(array('ID' => $user->ID, 'role' => get_option('default_role')));
            $time_action = current_time('mysql');
            $action = $wpdb->get_var($wpdb->prepare("SELECT time_action FROM " . RCL_PREF . "user_action WHERE user = '******'", $user->ID));
            if (!$action) {
                $wpdb->insert(RCL_PREF . 'user_action', array('user' => $user->ID, 'time_action' => $time_action));
            }
            $creds = array();
            $creds['user_login'] = $reglogin;
            $creds['user_password'] = $regpass;
            $creds['remember'] = true;
            $sign = wp_signon($creds, false);
            if (!is_wp_error($sign)) {
                rcl_update_timeaction_user();
                do_action('rcl_confirm_registration', $user->ID);
                wp_redirect(rcl_get_authorize_url($user->ID));
                exit;
            }
        }
    }
    if ($rcl_options['login_form_recall'] == 2) {
        wp_safe_redirect('wp-login.php?checkemail=confirm');
    } else {
        wp_redirect(get_bloginfo('wpurl') . '?action-rcl=login&error=confirm');
    }
    exit;
}
Пример #6
0
 public function log($connector, $message, $args, $object_id, $contexts, $user_id = null)
 {
     global $wpdb;
     if (is_null($user_id)) {
         $user_id = get_current_user_id();
     }
     require_once MAINWP_WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
     $user = new WP_User($user_id);
     $roles = get_option($wpdb->get_blog_prefix() . 'user_roles');
     if (!isset($args['author_meta'])) {
         $args['author_meta'] = array('user_email' => $user->user_email, 'display_name' => defined('WP_CLI') && empty($user->display_name) ? 'WP-CLI' : $user->display_name, 'user_login' => $user->user_login, 'user_role_label' => !empty($user->roles) ? $roles[$user->roles[0]]['name'] : null, 'agent' => MainWP_WP_Stream_Author::get_current_agent());
         if (defined('WP_CLI') && function_exists('posix_getuid')) {
             $uid = posix_getuid();
             $user_info = posix_getpwuid($uid);
             $args['author_meta']['system_user_id'] = $uid;
             $args['author_meta']['system_user_name'] = $user_info['name'];
         }
     }
     // Remove meta with null values from being logged
     $meta = array_filter($args, function ($var) {
         return !is_null($var);
     });
     $recordarr = array('object_id' => $object_id, 'site_id' => is_multisite() ? get_current_site()->id : 1, 'blog_id' => apply_filters('blog_id_logged', is_network_admin() ? 0 : get_current_blog_id()), 'author' => $user_id, 'author_role' => !empty($user->roles) ? $user->roles[0] : null, 'created' => current_time('mysql', 1), 'summary' => vsprintf($message, $args), 'parent' => self::$instance->prev_record, 'connector' => $connector, 'contexts' => $contexts, 'meta' => $meta, 'ip' => mainwp_wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP));
     $record_id = MainWP_WP_Stream_DB::get_instance()->insert($recordarr);
     return $record_id;
 }
Пример #7
0
 public function export_roles()
 {
     global $pagenow;
     if ($pagenow !== 'users.php') {
         return;
     }
     if (!isset($_GET['page']) || $_GET['page'] !== 'users-' . URE_PLUGIN_FILE) {
         return;
     }
     if (!isset($_POST['action']) || $_POST['action'] !== 'export-roles') {
         return;
     }
     if (empty($_POST['ure_nonce']) || !wp_verify_nonce($_POST['ure_nonce'], 'user-role-editor')) {
         echo '<h3>Wrong nonce. Action prohibitied.</h3>';
         exit;
     }
     if (!current_user_can('ure_export_roles')) {
         echo esc_html__('You do not have sufficient permissions to use this add-on.', 'ure');
         exit;
     }
     $this->lib->get_user_roles();
     $serialized_roles = serialize($this->lib->roles);
     $timestamp = date('_Y-m-d_h_i_s', current_time('timestamp'));
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Cache-Control: private', false);
     // required for certain browsers
     header('Content-Type: application/pdf');
     header('Content-Disposition: attachment; filename="ure-roles-backup' . $timestamp . '.dat";');
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . strlen($serialized_roles));
     echo $serialized_roles;
     exit;
 }
Пример #8
0
 public function __construct()
 {
     global $start_date, $end_date;
     global $woocommerce;
     $current_month = date("j/n/Y", mktime(0, 0, 0, 1, date("m"), date("Y")));
     $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
     $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';
     if (!$start_date) {
         $start_date = $current_month;
     }
     if (!$end_date) {
         $end_date = date('Ymd', current_time('timestamp'));
     }
     $start_date = strtotime($start_date);
     $end_date = strtotime($end_date);
     add_action('admin_menu', array($this, 'hide_add_new_carts'));
     add_action('views_edit-carts', array($this, 'av8_remove_cart_views'));
     //Remove the All / Published / Trash view.
     add_action('manage_carts_posts_custom_column', array($this, 'av8_manage_cart_columns'), 1, 1);
     add_action('restrict_manage_posts', array($this, 'author_filter'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_index'));
     add_filter('restrict_manage_posts', array($this, 'restrict_manage_posts'), 1000);
     add_action('pre_get_posts', array($this, 'exclude_category'));
     add_filter('posts_where', array($this, 'filter_where'));
     add_filter('manage_edit-carts_columns', array($this, 'av8_carts_columns'));
     add_filter('manage_edit-carts_sortable_columns', array($this, 'av8_carts_sort'));
     add_filter('request', array($this, 'cart_column_orderby'));
     add_filter('bulk_actions-' . 'edit-carts', '__return_empty_array');
     //Remove bulk edit
     add_filter('parse_query', array($this, 'woocommerce_carts_search_custom_fields'));
     add_filter('get_search_query', array($this, 'woocommerce_carts_search_label'));
 }
 function mycred_get_stat_dates($instance = '', $value = 0)
 {
     $now = current_time('timestamp');
     $results = array();
     switch ($instance) {
         case 'x_dates':
             $from = $value - 1;
             $start = date('U', strtotime('-' . $from . ' days midnight', $now));
             for ($i = 0; $i < $value; $i++) {
                 if ($i == 0) {
                     $new_start = $start;
                 } else {
                     $new_start = $start + 86400 * $i;
                 }
                 $results[] = array('label' => date('Y-m-d', $new_start), 'from' => $new_start, 'until' => $new_start + 86399);
             }
             break;
         case 'today_this':
             $start = date('U', strtotime('today midnight', $now));
             $results[] = array('key' => 'today', 'from' => $start, 'until' => $now);
             $this_week = mktime(0, 0, 0, date("n", $now), date("j", $now) - date("N", $now) + 1);
             $results[] = array('key' => 'thisweek', 'from' => $this_week, 'until' => $now);
             $this_month = mktime(0, 0, 0, date("n", $now), 1, date('Y', $now));
             $results[] = array('key' => 'thismonth', 'from' => $this_month, 'until' => $now);
             $this_year = mktime(0, 0, 0, 1, 1, date('Y', $now));
             $results[] = array('key' => 'thisyear', 'from' => $this_year, 'until' => $now);
             break;
     }
     return $results;
 }
 function update_punch_card_ajax()
 {
     global $wpdb;
     $punch_cards_table = $wpdb->prefix . "punch_cards";
     $punch_cards_meta_table = $wpdb->prefix . "punch_cards_meta";
     $card_action = $_POST['card_action'];
     $card_id = $_POST['card_id'];
     $punches_array = array();
     $punch_card = Punch_Card::get_punch_card($card_id);
     $punches = (int) $punch_card->card_punches;
     switch ($card_action) {
         case 'add':
             $punches++;
             break;
         case 'remove':
             $punches--;
             break;
         case 'complete':
             $punches = 0;
             $punches_array['card_completed'] = (int) $punch_card->card_completed + 1;
             break;
         default:
             $punches = 0;
             break;
     }
     $punches_array['card_punches'] = $punches;
     $wpdb->update($punch_cards_table, $punches_array, array('card_id' => $card_id));
     $wpdb->insert($punch_cards_meta_table, array('card_id' => $card_id, 'punch_number' => $punches, 'punch_date' => current_time('mysql')));
     echo json_encode(array('action' => $card_action, 'card_id' => $card_id, 'punches' => $punches, 'punches_html' => Punch_Card::get_punches_html($card_id, $punches)));
     wp_die();
 }
 /**
  * Add an event to the database
  *
  * @since 1.0.0
  *
  * @param  array  $data The data to use for each field
  *
  * @return integer       The number of rows that were affected
  */
 public function insert($data = array())
 {
     $defaults = array('last_sync' => date('Y-m-d H:i:s', current_time('timestamp')));
     $group = wp_parse_args($data, $defaults);
     global $wpdb;
     return $wpdb->insert($this->table_name, $group);
 }
 public static function send_activity_report()
 {
     $current_time = current_time('timestamp');
     $mostly_recent_users = get_users(array('meta_key' => 'displet_last_login', 'meta_value' => $current_time - 60 * 60 * 24 * 7, 'meta_compare' => '>'));
     $recent_users = array();
     if (!empty($mostly_recent_users) && is_array($mostly_recent_users)) {
         $edit_url = admin_url('admin.php?page=displet-lead-manager&user_id=');
         foreach ($mostly_recent_users as $user) {
             if (!empty($user->displet_last_login) && is_numeric($user->displet_last_login)) {
                 $logins_for_day = 0;
                 if (!empty($user->displet_logins) && is_array($user->displet_logins)) {
                     foreach ($user->displet_logins as $login) {
                         if ($login > $current_time - 60 * 60 * 24) {
                             $logins_for_day++;
                         }
                     }
                 }
                 $property_stats = DispletRetsIdxViewedPropertiesController::get_property_view_stats($user->displet_user_properties);
                 $recent_users[] = array('url' => $edit_url . $user->ID, 'name' => $user->nickname, 'phone' => $user->displet_phone, 'logins_for_day' => $logins_for_day, 'logins_total' => count($user->displet_logins), 'price_average' => $property_stats['price_average'], 'zip_mode' => $property_stats['zip_mode']);
             }
         }
     }
     if (!empty($recent_users)) {
         $user_activity_report = '<table cellpadding="3" width="100%"><tr><th>Name</th><th>Phone</th><th>Logins In Last Day</th><th>Total Logins</th><th>Average Price</th><th>Most Frequented Zip Code</th></tr>';
         foreach ($recent_users as $user) {
             $price_average = !empty($user['price_average']) ? number_format($user['price_average']) : '';
             $user_activity_report .= '<tr><td align="left"><a href="' . $user['url'] . '">' . $user['name'] . '</a></td><td align="center">' . $user['phone'] . '</td><td align="center">' . $user['logins_for_day'] . '</td><td align="center">' . $user['logins_total'] . '</td><td align="center">$' . $price_average . '</td><td align="center">' . $user['zip_mode'] . '</td></tr>';
         }
         $user_activity_report .= '</table>';
         new DispletRetsIdxEmail('activity_report', array('activity_report' => $user_activity_report));
     }
 }
 function save_subscription($name, $email, $taxonomy, $frequency)
 {
     global $wpdb;
     $last_send = current_time('mysql');
     $taxonomy = serialize($taxonomy);
     $wpdb->insert($wpdb->prefix . 'miklaj_notification', compact('name', 'email', 'taxonomy', 'frequency', 'last_send'), array('%s', '%s', '%s', '%s', '%s'));
 }
Пример #14
0
 /**
  * Add a post to post connection
  * @param $parent_id
  * @param $child_id
  * @param int $author
  *
  * @return int|WP_Error
  */
 public function add_post_child($parent_id, $child_id, $author = 0)
 {
     if ($author == 0) {
         $author = get_current_user_id();
     }
     return $this->insert($this->table_name, array('parent_id' => $parent_id, 'child_id' => $child_id, 'author' => $author, 'modified' => current_time('mysql')));
 }
 protected function _setup_data()
 {
     //basically ALL we're going to get from this is the transaction object and use it to build the majority of our info.
     $session = $this->_data->get_session_data();
     $this->txn = $session['transaction'];
     if (empty($this->txn) || !$this->txn instanceof EE_Transaction) {
         throw new EE_Error(__('Incoming data for the EE_Session data handler must have a valid EE_Transaction object in order to setup the data'));
     }
     $this->reg_info = array();
     $this->incoming_data = $session;
     $this->taxes = $this->txn->tax_total();
     $this->grand_total_price_object = '';
     //other data from the session (if possible)
     $this->user_id = isset($session['user_id']) ? $session['user_id'] : '';
     $this->ip_address = isset($session['ip_address']) ? $session['ip_address'] : '';
     $this->user_agent = isset($session['user_agent']) ? $session['user_agent'] : '';
     $this->init_access = $this->last_access = '';
     $this->payment = $this->txn->get_first_related('Payment');
     $this->payment = empty($this->payment) ? EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => (int) current_time('timestamp'), 'PAY_gateway' => $this->txn->selected_gateway(), 'PAY_gateway_response' => $this->txn->gateway_response_on_transaction())) : $this->payment;
     //if there is no payments associated with the transaction then we just create a default payment object for potential parsing.
     $this->billing = $this->payment->details();
     EE_Registry::instance()->load_helper('Template');
     $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : '';
     //let's get all the registrations associated with this txn
     $this->reg_objs = $this->txn->registrations();
     $this->_assemble_data();
 }
Пример #16
0
function cp_process_paypal_transaction()
{
    global $wpdb;
    if (isset($_POST['txn_id'])) {
        // since paypal sends over the date as a string, we need to convert it
        // into a mysql date format. There will be a time difference due to PayPal's
        // US pacific time zone and your server time zone
        $payment_date = strtotime($_POST['payment_date']);
        $payment_date = strftime('%Y-%m-%d %H:%M:%S', $payment_date);
        //setup some values that are not always sent
        if (isset($_REQUEST['aid'])) {
            $aid = trim($_REQUEST['aid']);
            $the_ad = get_post($aid);
            $user_id = $the_ad->post_author;
        } else {
            $aid = '';
            $user_id = trim($_REQUEST['uid']);
        }
        $reason_code = isset($_POST['reason_code']) ? $_POST['reason_code'] : '';
        $pending_reason = isset($_POST['pending_reason']) ? $_POST['pending_reason'] : '';
        $parent_txn_id = isset($_POST['parent_txn_id']) ? $_POST['parent_txn_id'] : '';
        $test_ipn = isset($_POST['test_ipn']) ? $_POST['test_ipn'] : '';
        // check and make sure this transaction hasn't already been added
        $results = $wpdb->get_var($wpdb->prepare("SELECT txn_id FROM {$wpdb->cp_order_info} WHERE txn_id = %s LIMIT 1", appthemes_clean($_POST['txn_id'])));
        if (!$results) {
            $data = array('ad_id' => appthemes_clean($aid), 'user_id' => appthemes_clean($user_id), 'first_name' => appthemes_clean($_POST['first_name']), 'last_name' => appthemes_clean($_POST['last_name']), 'payer_email' => appthemes_clean($_POST['payer_email']), 'residence_country' => appthemes_clean($_POST['residence_country']), 'transaction_subject' => appthemes_clean($_POST['transaction_subject']), 'item_name' => appthemes_clean($_POST['item_name']), 'item_number' => appthemes_clean($_POST['item_number']), 'payment_type' => appthemes_clean($_POST['payment_type']), 'payer_status' => appthemes_clean($_POST['payer_status']), 'payer_id' => appthemes_clean($_POST['payer_id']), 'receiver_id' => appthemes_clean($_POST['receiver_id']), 'parent_txn_id' => appthemes_clean($parent_txn_id), 'txn_id' => appthemes_clean($_POST['txn_id']), 'mc_gross' => appthemes_clean($_POST['mc_gross']), 'mc_fee' => appthemes_clean($_POST['mc_fee']), 'payment_status' => appthemes_clean($_POST['payment_status']), 'pending_reason' => appthemes_clean($pending_reason), 'txn_type' => appthemes_clean($_POST['txn_type']), 'tax' => appthemes_clean($_POST['tax']), 'mc_currency' => appthemes_clean($_POST['mc_currency']), 'reason_code' => appthemes_clean($reason_code), 'custom' => appthemes_clean($_POST['custom']), 'test_ipn' => appthemes_clean($test_ipn), 'payment_date' => $payment_date, 'create_date' => current_time('mysql'));
            $wpdb->insert($wpdb->cp_order_info, $data);
            // ad transaction already exists so it must be an update via PayPal IPN (refund, etc)
        } else {
            //Updating transaction that was already found
            $data = array('payment_status' => appthemes_clean($_POST['payment_status']), 'mc_gross' => appthemes_clean($_POST['mc_gross']), 'txn_type' => appthemes_clean($_POST['txn_type']), 'reason_code' => appthemes_clean($reason_code), 'mc_currency' => appthemes_clean($_POST['mc_currency']), 'test_ipn' => appthemes_clean($_POST['test_ipn']), 'create_date' => $payment_date);
            $wpdb->update($wpdb->cp_order_info, $data, array('txn_id' => $_POST['txn_id']));
        }
    }
}
 protected function get_yearmonth_dir($timestamp = '')
 {
     if (!$timestamp) {
         $timestamp = current_time('timestamp');
     }
     return date('Y/m', $timestamp);
 }
Пример #18
0
function ninja_forms_export_form($form_id)
{
    if ($form_id == '') {
        return;
    }
    $plugin_settings = nf_get_settings();
    $form_row = ninja_forms_get_form_by_id($form_id);
    $data = $form_row['data'];
    $form_title = $data['form_title'];
    $form_row = ninja_forms_serialize_form($form_id);
    $form_title = preg_replace('/[^a-zA-Z0-9-]/', '', $form_title);
    $form_title = str_replace(" ", "-", $form_title);
    if (isset($plugin_settings['date_format'])) {
        $date_format = $plugin_settings['date_format'];
    } else {
        $date_format = 'm/d/Y';
    }
    //$today = date($date_format);
    $current_time = current_time('timestamp');
    $today = date($date_format, $current_time);
    header("Content-type: application/csv");
    header('Content-Disposition: attachment; filename="' . $form_title . '"-"' . $today . '".nff"');
    header("Pragma: no-cache");
    header("Expires: 0");
    echo $form_row;
    die;
}
Пример #19
0
 /**
  * Adds a user to a group
  * @param int $groupID - Group Identifier
  * @param int $userID - Identifier of the User to add
  **/
 public static function add_group_user($group_id, $user_ids, $args = array())
 {
     $defaults = array('agent_type' => 'pp_group', 'member_type' => 'member', 'status' => 'active', 'date_limited' => false, 'start_date_gmt' => constant('PP_MIN_DATE_STRING'), 'end_date_gmt' => constant('PP_MAX_DATE_STRING'));
     $args = array_merge($defaults, $args);
     extract($args, EXTR_SKIP);
     $date_limited = intval($date_limited);
     global $wpdb;
     $members_table = apply_filters('pp_use_group_members_table', $wpdb->pp_group_members, $agent_type);
     $user_ids = (array) $user_ids;
     if (!pp_get_group($group_id)) {
         return;
     }
     foreach ($user_ids as $user_id) {
         if (!$user_id) {
             continue;
         }
         $data = compact('group_id', 'user_id', 'member_type', 'status', 'date_limited', 'start_date_gmt', 'end_date_gmt');
         if ($already_member = $wpdb->get_col($wpdb->prepare("SELECT user_id FROM {$members_table} WHERE group_id = %d AND user_id = %d", $group_id, $user_id))) {
             $data = compact('status');
             $wpdb->update($members_table, $data, array('group_id' => $group_id, 'user_id' => $user_id));
         } else {
             $data['add_date_gmt'] = current_time('mysql', 1);
             $wpdb->insert($members_table, $data);
         }
         do_action('pp_add_group_user', $group_id, $user_id, $args);
     }
 }
Пример #20
0
/**
 * Create timestamps and unique identifiers for each cron.
 * @param  int $post_id
 * @return array
 */
function ppp_get_timestamps($post_id)
{
    // Make the timestamp in the users' timezone, b/c that makes more sense
    $offset = (int) -get_option('gmt_offset');
    $ppp_tweets = get_post_meta($post_id, '_ppp_tweets', true);
    if (empty($ppp_tweets)) {
        $ppp_tweets = array();
    }
    $times = array();
    foreach ($ppp_tweets as $key => $data) {
        if (!array_filter($data)) {
            continue;
        }
        $share_time = explode(':', $data['time']);
        $hours = (int) $share_time[0];
        $minutes = (int) substr($share_time[1], 0, 2);
        $ampm = strtolower(substr($share_time[1], -2));
        if ($ampm == 'pm' && $hours != 12) {
            $hours = $hours + 12;
        }
        if ($ampm == 'am' && $hours == 12) {
            $hours = 00;
        }
        $hours = $hours + $offset;
        $date = explode('/', $data['date']);
        $timestamp = mktime($hours, $minutes, 0, $date[0], $date[1], $date[2]);
        if ($timestamp > current_time('timestamp', 1)) {
            // Make sure the timestamp we're getting is in the future
            $times[strtotime(date_i18n('d-m-Y H:i:s', $timestamp, true))] = 'sharedate_' . $key . '_' . $post_id;
        }
    }
    return apply_filters('ppp_get_timestamps', $times);
}
Пример #21
0
 function log($message = '', $type = 'notice')
 {
     global $wp_filesystem;
     WP_Filesystem();
     // if we're not active, don't do anything
     if (!$this->active || !file_exists($this->logfile)) {
         return false;
     }
     // get the existing log
     $existing = $wp_filesystem->get_contents($this->logfile);
     // format our entry
     $entry = '[' . date('Y-d-m G:i:s', current_time('timestamp')) . '][' . sanitize_text_field($type) . ']';
     // flag it with the process ID
     $entry .= '[' . SearchWP::instance()->getPid() . ']';
     // sanitize the message
     $message = sanitize_text_field(esc_html($message));
     $message = str_replace('=&gt;', '=>', $message);
     // put back array identifiers
     $message = str_replace('-&gt;', '->', $message);
     // put back property identifiers
     $message = str_replace('&#039;', "'", $message);
     // put back apostrophe's
     // finally append the message
     $entry .= ' ' . $message;
     // append the entry
     $log = $existing . "\n" . $entry;
     // write log
     $wp_filesystem->put_contents($this->logfile, $log);
     error_log($log);
 }
Пример #22
0
 function end_el(&$output, $item, $depth = 0, $args = array())
 {
     if ($depth == 0 && $item->object == 'category') {
         $output .= "<div class='subcat'>";
         for ($i = 0; $i < count($item->children); $i++) {
             $child = $item->children[$i];
             $output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
             //$output .="<h5>".$child->title."</h5>";
             $output .= "<ul id='mn-latest-" . $child->ID . "'>";
             if ($child->object == 'category') {
                 $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
                 if ($r->have_posts()) {
                     while ($r->have_posts()) {
                         $r->the_post();
                         $output .= "<li ";
                         if (has_post_thumbnail()) {
                             $output .= "class='has-thumbnail' ";
                         }
                         $output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
                     }
                     // Reset the global $the_post as this query will have stomped on it
                     wp_reset_postdata();
                 }
             }
             $output .= "</ul>";
             $output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
             $output .= "</div>";
         }
         $output .= "</div> \n</div>\n";
     } else {
     }
     $output .= "</li>\n";
 }
 public function import($forceResync)
 {
     if (get_option('github_username')) {
         $lastseenid = get_option('reclaim_' . $this->shortname . '_last_seen_id');
         $page = 0;
         do {
             $req = sprintf(self::$apiurl, get_option('github_username'), $page);
             $feed = parent::import_via_curl($req, self::$timeout);
             $data = self::map_data(json_decode($feed, true));
             parent::insert_posts($data);
             $reqOk = count($data) > 0;
             if ($reqOk && (!isset($newlastseenid) || intval($newlastseenid) < intval($data[0]["ext_guid"]))) {
                 // store the last-seen-id, which is the first message of the first request
                 $newlastseenid = $data[0]["ext_guid"];
             }
             if (!$forceResync && $reqOk && intval($data[count($data) - 1]["ext_guid"]) < intval($lastseenid)) {
                 // abort requests if we've already seen these events
                 $reqOk = false;
             }
             parent::log(sprintf(__('Retrieved set of GitHub events: %d, last seen id: %s, new last seen id: %s, req-ok: %d', 'reclaim'), count($data), $lastseenid, $newlastseenid, $reqOk));
             $page++;
         } while ($reqOk);
         update_option('reclaim_' . $this->shortname . '_last_update', current_time('timestamp'));
         if (isset($newlastseenid)) {
             update_option('reclaim_' . $this->shortname . '_last_seen_id', $newlastseenid);
         }
     } else {
         parent::log(sprintf(__('%s user data missing. No import was done', 'reclaim'), $this->shortname));
     }
 }
 public function import($forceResync)
 {
     if (get_option('goodreads_user_id')) {
         if (!class_exists('SimplePie')) {
             require_once ABSPATH . WPINC . '/class-feed.php';
         }
         $rss_source = sprintf(self::$apiurl, get_option('goodreads_user_id'));
         /* Create the SimplePie object */
         $feed = new SimplePie();
         /* Set the URL of the feed you're retrieving */
         $feed->set_feed_url($rss_source);
         /* Tell SimplePie to cache the feed using WordPress' cache class */
         $feed->set_cache_class('WP_Feed_Cache');
         /* Tell SimplePie to use the WordPress class for retrieving feed files */
         $feed->set_file_class('WP_SimplePie_File');
         /* Tell SimplePie how long to cache the feed data in the WordPress database */
         $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', get_option('reclaim_update_interval'), $rss_source));
         /* Run any other functions or filters that WordPress normally runs on feeds */
         do_action_ref_array('wp_feed_options', array(&$feed, $rss_source));
         /* Initiate the SimplePie instance */
         $feed->init();
         /* Tell SimplePie to send the feed MIME headers */
         $feed->handle_content_type();
         if ($feed->error()) {
             parent::log(sprintf(__('no %s data', 'reclaim'), $this->shortname));
             parent::log($feed->error());
         } else {
             $data = self::map_data($feed);
             parent::insert_posts($data);
             update_option('reclaim_' . $this->shortname . '_last_update', current_time('timestamp'));
         }
     } else {
         parent::log(sprintf(__('%s user data missing. No import was done', 'reclaim'), $this->shortname));
     }
 }
Пример #25
0
function pmpro_ipnhandler_level_extend_memberships($level, $user_id)
{
    global $pmpro_msg, $pmpro_msgt;
    //does this level expire? are they an existing user of this level?
    if (!empty($level) && !empty($level->expiration_number) && pmpro_hasMembershipLevel($level->id, $user_id)) {
        //get the current enddate of their membership
        $user_level = pmpro_getMembershipLevelForUser($user_id);
        $expiration_date = $user_level->enddate;
        //calculate days left
        $todays_date = current_time('timestamp');
        $time_left = $expiration_date - $todays_date;
        //time left?
        if ($time_left > 0) {
            //convert to days and add to the expiration date (assumes expiration was 1 year)
            $days_left = floor($time_left / (60 * 60 * 24));
            //figure out days based on period
            if ($level->expiration_period == "Day") {
                $total_days = $days_left + $level->expiration_number;
            } elseif ($level->expiration_period == "Week") {
                $total_days = $days_left + $level->expiration_number * 7;
            } elseif ($level->expiration_period == "Month") {
                $total_days = $days_left + $level->expiration_number * 30;
            } elseif ($level->expiration_period == "Year") {
                $total_days = $days_left + $level->expiration_number * 365;
            }
            //update number and period
            $level->expiration_number = $total_days;
            $level->expiration_period = "Day";
        }
    }
    return $level;
}
Пример #26
0
 /**
  * Setup the schedule object
  * Loads the options from the database and populates properties
  *
  * @param string $id
  *
  * @throws Exception
  */
 public function __construct($id)
 {
     // Verify the schedule id
     if (!is_string($id) || !trim($id)) {
         throw new \Exception('Argument 1 for ' . __METHOD__ . ' must be a non empty string');
     }
     // Store id for later
     $this->id = $id;
     // Load the options
     $this->options = array_filter((array) get_option('hmbkp_schedule_' . $this->get_id()));
     // Setup The Backup class
     $this->backup = new Backup();
     // Set the archive filename to site name + schedule slug + date
     $this->backup->set_archive_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), current_time('Y-m-d-H-i-s'))) . '.zip');
     $this->backup->set_database_dump_filename(implode('-', array('database', sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id())) . '.sql');
     $this->backup->set_type($this->get_type());
     $this->backup->set_excludes($this->backup->default_excludes(), true);
     $this->backup->set_excludes($this->get_excludes());
     $this->backup->set_action_callback(array($this, 'do_action'));
     if (defined('HMBKP_SCHEDULE_START_TIME') && strtotime('HMBKP_SCHEDULE_START_TIME')) {
         $this->set_schedule_start_time(strtotime('HMBKP_SCHEDULE_START_TIME'));
     }
     // Setup the schedule if it isn't set
     if (!$this->is_cron_scheduled() && $this->get_reoccurrence() !== 'manually') {
         $this->schedule();
     }
 }
 public function run_schedule()
 {
     $frequency = apply_filters('woocommerce_square_inventory_poll_frequency', 'hourly');
     if (!wp_next_scheduled('woocommerce_square_inventory_poll')) {
         wp_schedule_event(current_time('timestamp'), $frequency, 'woocommerce_square_inventory_poll');
     }
 }
    /**
     * Output an export link
     */
    public function get_export_button()
    {
        $current_range = !empty($_GET['range']) ? $_GET['range'] : '7day';
        ?>
		<a
			href="#"
			download="report-<?php 
        echo $current_range;
        ?>
-<?php 
        echo date_i18n('Y-m-d', current_time('timestamp'));
        ?>
.csv"
			class="export_csv"
			data-export="chart"
			data-xaxes="<?php 
        _e('Date', 'woocommerce');
        ?>
"
			data-exclude_series="2"
			data-groupby="<?php 
        echo $this->chart_groupby;
        ?>
"
		>
			<?php 
        _e('Export CSV', 'woocommerce');
        ?>
		</a>
		<?php 
    }
Пример #29
0
 function gdlr_print_hotel_availability_item($settings = array())
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces, $hotel_option;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $current_date = current_time('Y-m-d');
     $next_date = date('Y-m-d', strtotime($current_date . "+1 days"));
     $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => 1, 'gdlr-children-number' => 0);
     $ret = gdlr_get_item_title($settings);
     $ret .= '<div class="gdlr-hotel-availability-wrapper';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= ' gdlr-hotel-branches-enable';
     }
     $ret .= '" ' . $margin_style . $item_id . ' >';
     $ret .= '<form class="gdlr-hotel-availability gdlr-item" id="gdlr-hotel-availability" method="post" action="' . esc_url(add_query_arg(array($hotel_option['booking-slug'] => ''), home_url('/'))) . '" >';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => ''));
     }
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']));
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'], 'multiple' => true));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'], 'multiple' => true));
     $ret .= '<div class="gdlr-hotel-availability-submit" >';
     $ret .= '<input type="hidden" name="hotel_data" value="1" >';
     $ret .= '<input type="hidden" name="gdlr-room-number" value="1" />';
     $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >';
     $ret .= '</div>';
     $ret .= '<div class="clear"></div>';
     $ret .= '</form>';
     $ret .= '</div>';
     return $ret;
 }
 public function ajax_hello_world()
 {
     $response = new stdClass();
     $response->hello = 'world';
     $response->time = current_time('mysql');
     wp_send_json($response);
 }