/** * Create export file with data */ public function create() { $sheet_id = !empty($_GET['sheet_id']) ? $_GET['sheet_id'] : null; $data = $this->data->get_all_data($sheet_id); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=sign-up-sheets-" . date('Ymd-His') . ".csv"); header("Pragma: no-cache"); header("Expires: 0"); $all_custom_fields = get_option('dls_sus_custom_fields'); if (!empty($all_custom_fields)) { $custom_field_names = array(); foreach ($all_custom_fields as $field) { $custom_field_names[] = $field['name']; } reset($all_custom_fields); } $custom_fields_heading = !empty($custom_field_names) ? '"' . implode('","', $custom_field_names) . '",' : null; $csv = '"Sheet ID","Sheet Title","Sheet Date","Task ID","Task Title","Task Date","Sign-up ID","Sign-up First Name","Sign-up Last Name","Sign-up Phone","Sign-up Email",' . $custom_fields_heading . '"Reminded"' . "\n"; foreach ($data as $d) { $csv .= '"' . $this->clean_csv($d->sheet_id) . '","' . $this->clean_csv($d->sheet_title) . '","' . $this->clean_csv(!empty($d->sheet_date) && $d->sheet_date !== '0000-00-00' ? date('Y-m-d', strtotime($d->sheet_date)) : null) . '","' . $this->clean_csv($d->task_id) . '","' . $this->clean_csv($d->task_title) . '","' . $this->clean_csv(!empty($d->task_date) && $d->task_date !== '0000-00-00' ? date('Y-m-d', strtotime($d->task_date)) : null) . '","' . $this->clean_csv($d->signup_id) . '","' . $this->clean_csv($d->firstname) . '","' . $this->clean_csv($d->lastname) . '","' . $this->clean_csv($d->phone) . '","' . $this->clean_csv($d->email) . '","'; if (!empty($all_custom_fields)) { foreach ($all_custom_fields as $field) { $slug = str_replace('-', '_', $field['slug']); if (!isset($d->signup_fields[$slug])) { $d->signup_fields[$slug] = ''; } $csv .= $this->clean_csv(is_array($d->signup_fields[$slug]) ? implode(', ', $d->signup_fields[$slug]) : $d->signup_fields[$slug]) . '","'; } } $csv .= $this->clean_csv(!empty($d->reminded) ? get_date_from_gmt($d->reminded, 'Y-m-d H:i:s') : null) . '"' . "\n"; } echo $csv; }
/** * Displays the last time the feed was updated and controls to update now * * @return string */ function rssmi_show_last_feed_update() { $wprssmi_admin_options = get_option('rss_admin_options'); // admin settings $last_db_update = $wprssmi_admin_options['last_db_update']; return "\n\t<h3>Last Update of the Feed Database: <em>" . get_date_from_gmt(date('Y-m-d H:i:s', $last_db_update), 'M j, Y @ g:i a') . "; " . human_time_diff($last_db_update, time()) . " ago</em></h3>\n\t<p><button type='button' name='getFeedsNow' id='getFeeds-Now' class='button button-primary' value=''>Update the feed Database</button></p>\n\n\t<div id='gfnote'>\n\t\t<em>(note: this could take several minutes)</em>\n\t</div>\n\t<div id='rssmi-ajax-loader-center'></div>\n\t<p>Think there is a scheduling problem? <a href='http://www.wprssimporter.com/faqs/the-cron-scheduler-isnt-working-whats-happening/' target='_blank'>Read this</a>.</p>"; }
public function format_date_time_gmt($timestamp_gmt) { $f = get_option('date_format') . ' ' . get_option('time_format'); $s = gmdate('Y-m-d H:i:s', $timestamp_gmt); $s = get_date_from_gmt($s, $f); return $s; }
public function prepare_items() { if (!is_null($this->total_items)) { return; } $this->total_items = count($this->_archives); $this->set_pagination_args(array('total_items' => $this->total_items, 'per_page' => $this->items_pre_page)); /** * @var FW_Extension_Backups $backups */ $backups = fw_ext('backups'); /** * Prepare items for output */ foreach ($this->_archives as $filename => $archive) { $time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $archive['time']), get_option('date_format') . ' ' . get_option('time_format')); $filename_hash = md5($filename); $details = array(); $details[] = $archive['full'] ? __('Full Backup', 'fw') : __('Content Backup', 'fw'); if (function_exists('fw_human_bytes')) { $details[] = fw_human_bytes(filesize($archive['path'])); } $details[] = fw_html_tag('a', array('href' => $backups->get_download_link($filename), 'target' => '_blank', 'id' => 'download-' . $filename_hash, 'data-download-file' => $filename), esc_html__('Download', 'fw')); $details[] = fw_html_tag('a', array('href' => '#', 'onclick' => 'return false;', 'id' => 'delete-' . $filename_hash, 'data-delete-file' => $filename, 'data-confirm' => __("Warning! \n" . "You are about to delete a backup, it will be lost forever. \n" . "Are you sure?", 'fw')), esc_html__('Delete', 'fw')); $this->items[] = array('cb' => fw_html_tag('input', array('type' => 'radio', 'name' => 'archive', 'value' => $filename, 'id' => 'archive-' . $filename_hash)), 'details' => '<div>' . $time . '</div>' . '<div>' . implode(' | ', $details) . '</div>'); } }
function get_formatted_time($date, $date_format = false, $time_format = false) { if (empty($date)) { return $date; } if (!$date_format) { $date_format = get_option('date_format'); } if (preg_match('/^\\d{1-2}\\/\\d{1-2}\\/\\d{4}$/', $date)) { global $frmpro_settings; $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); } $do_time = date('H:i:s', strtotime($date)) == '00:00:00' ? false : true; $date = get_date_from_gmt($date); $formatted = date_i18n($date_format, strtotime($date)); if ($do_time) { if (!$time_format) { $time_format = get_option('time_format'); } $trimmed_format = trim($time_format); if ($time_format and !empty($trimmed_format)) { $formatted .= ' ' . __('at', 'formidable') . ' ' . date_i18n($time_format, strtotime($date)); } } return $formatted; }
/** * Reset the post_date field on your posts. * A sadly necessary step after you change your timezone in WordPress * * @synopsis --post_type=<post-type> */ public function __invoke($args, $assoc_args) { global $wpdb; $query_args = array('post_type' => $assoc_args['post_type'], 'posts_per_page' => -1, 'post_status' => 'publish'); $query = new WP_Query($query_args); if (empty($query->posts)) { WP_CLI::error("No posts found"); } WP_CLI::line(sprintf("Updating post_date on %d posts.", count($query->posts))); foreach ($query->posts as $key => $post) { if (empty($post->post_date_gmt) || "0000-00-00 00:00:00" == $post->post_date_gmt) { WP_CLI::line(sprintf("Error: Post %d is missing a publish date.", $post->ID)); continue; } $original = $post->post_date; $new = get_date_from_gmt($post->post_date_gmt); if ($new == $original) { WP_CLI::line(sprintf("No Change: Post %d has the correct post_date of %s", $post->ID, $original)); continue; } $wpdb->update($wpdb->posts, array('post_date' => $new), array('ID' => $post->ID)); clean_post_cache($post->ID); WP_CLI::line(sprintf("Updated: Post %d changed from %s to %s", $post->ID, $original, $new)); if ($key && $key % 10 == 0) { sleep(1); } } WP_CLI::success("Posts were updated with the correct post_date."); }
/** * Unpatched, this test passes only when Europe/London is observing DST. * * @ticket 20328 */ function test_get_date_from_gmt_during_dst() { update_option('timezone_string', 'Europe/London'); $gmt = '2012-06-01 12:34:56'; $local = '2012-06-01 13:34:56'; $this->assertEquals($local, get_date_from_gmt($gmt)); }
function extract_posts($arg_url) { $httpclient = new HTTPClient(); $json_data = $httpclient->send($arg_url, 'get'); if (empty($json_data)) { $this->message = 'Empty content returned'; return false; } // convert json to php array $array_data = json_decode($json_data, true); // get data $facebook_posts = $array_data['data']; if (count($facebook_posts) > 0) { foreach ($facebook_posts as $facebook_post) { $post_content = $facebook_post['message']; $post_title = $facebook_post['name']; $post_author = $this->author_id; $post_status = $this->status_id; $post_date_gmt = gmdate('Y-m-d H:i:s', strtotime($facebook_post['created_time'])); $post_date = get_date_from_gmt($post_date_gmt); $facebook_id = $facebook_post['id']; // build the post array $this->posts[] = compact('post_content', 'post_title', 'post_author', 'post_status', 'post_date', 'post_date_gmt', 'facebook_id'); } // end of foreach } // end of if return true; }
function tc_format_date($timestamp, $date_only = false) { $format = get_option('date_format'); if (!$date_only) { $format .= ' - ' . get_option('time_format'); } $date = get_date_from_gmt(date('Y-m-d H:i:s', $timestamp), $format); return $date; }
/** * Test that a published post post_date_gmt is not altered */ function test_insert_post_publish_respect_post_date_gmt() { $post = array('post_author' => self::$admin_user_id, 'post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_date_gmt' => '2016-04-29 12:00:00'); $id = wp_insert_post($post); $out = get_post($id); $this->assertEquals($post['post_content'], $out->post_content); $this->assertEquals($post['post_title'], $out->post_title); $this->assertEquals(get_date_from_gmt($post['post_date_gmt']), $out->post_date); $this->assertEquals($post['post_date_gmt'], $out->post_date_gmt); }
/** * Check if the post is in sync before updating in Apple News. * * @access private * @return boolean */ private function is_post_in_sync() { $post = get_post($this->id); if (!$post) { throw new \Apple_Actions\Action_Exception(__('Could not find post with id ', 'apple-news') . $this->id); } $api_time = get_post_meta($this->id, 'apple_news_api_modified_at', true); $api_time = strtotime(get_date_from_gmt(date('Y-m-d H:i:s', strtotime($api_time)))); $local_time = strtotime($post->post_modified); $in_sync = $api_time >= $local_time; return apply_filters('apple_news_is_post_in_sync', $in_sync, $this->id, $api_time, $local_time); }
public function backup($backup_array) { global $updraftplus, $updraftplus_backup; $updraft_dir = trailingslashit($updraftplus->backups_dir_location()); $email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true); if (!is_array($email)) { $email = array($email); } foreach ($backup_array as $type => $file) { $descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type; $fullpath = $updraft_dir . $file; if (file_exists($fullpath) && filesize($fullpath) > UPDRAFTPLUS_WARN_EMAIL_SIZE) { $size_in_mb_of_big_file = round(filesize($fullpath) / 1048576, 1); $toobig_hash = md5($file); $updraftplus->log($file . ': ' . sprintf(__('This backup archive is %s Mb in size - the attempt to send this via email is likely to fail (few email servers allow attachments of this size). If so, you should switch to using a different remote storage method.', 'updraftplus'), $size_in_mb_of_big_file), 'warning', 'toobigforemail_' . $toobig_hash); } $any_attempted = false; $any_sent = false; foreach ($email as $ind => $addr) { if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) { continue; } foreach (explode(',', $addr) as $sendmail_addr) { $send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr; $updraftplus->log("{$file}: email to: {$send_short}"); $any_attempted = true; $subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i'); $sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath)); if ($sent) { $any_sent = true; } } } if ($any_sent) { if (isset($toobig_hash)) { $updraftplus->log_removewarning('toobigforemail_' . $toobig_hash); // Don't leave it still set for the next archive unset($toobig_hash); } $updraftplus->uploaded_file($file); } elseif ($any_attempted) { $updraftplus->log('Mails were not sent successfully'); $updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error'); } else { $updraftplus->log('No email addresses were configured to send to'); } } return null; }
public static function init() { // SCHEDULER if (isset($_POST['dh-do-schedule']) && current_user_can('manage_options')) { wp_clear_scheduled_hook('dh-do-backup'); if ($_POST['dh-do-schedule'] != 'disabled') { wp_schedule_event(current_time('timestamp', true) + 86400, $_POST['dh-do-schedule'], 'dh-do-backup'); $timestamp = get_date_from_gmt(date('Y-m-d H:i:s', wp_next_scheduled('dh-do-schedule')), get_option('time_format')); $nextbackup = sprintf(__('Next backup: %s', dreamobjects), $timestamp); DHDO::logger('Scheduled ' . $_POST['dh-do-schedule'] . ' backup. ' . $nextbackup); } } // RESET if (current_user_can('manage_options') && isset($_POST['dhdo-reset']) && $_POST['dhdo-reset'] == 'Y') { delete_option('dh-do-backupsection'); delete_option('dh-do-boto'); delete_option('dh-do-bucket'); delete_option('dh-do-key'); delete_option('dh-do-schedule'); delete_option('dh-do-secretkey'); delete_option('dh-do-section'); delete_option('dh-do-logging'); DHDO::logger('reset'); } // LOGGER: Wipe logger if blank if (current_user_can('manage_options') && isset($_POST['dhdo-logchange']) && $_POST['dhdo-logchange'] == 'Y') { if (!isset($_POST['dh-do-logging'])) { DHDO::logger('reset'); } } // UPDATE OPTIONS if (isset($_GET['settings-updated']) && isset($_GET['page']) && ($_GET['page'] == 'dreamobjects-menu' || $_GET['page'] == 'dreamobjects-menu-backup')) { add_action('admin_notices', array('DHDOMESS', 'updateMessage')); } // BACKUP ASAP if (current_user_can('manage_options') && isset($_GET['backup-now']) && $_GET['page'] == 'dreamobjects-menu-backup') { wp_schedule_single_event(current_time('timestamp', true) + 60, 'dh-do-backupnow'); add_action('admin_notices', array('DHDOMESS', 'backupMessage')); DHDO::logger('Scheduled ASAP backup in 60 seconds.'); } // BACKUP if (wp_next_scheduled('dh-do-backupnow') && ($_GET['page'] == 'dreamobjects-menu' || $_GET['page'] == 'dreamobjects-menu-backup')) { add_action('admin_notices', array('DHDOMESS', 'backupMessage')); } }
function extract_posts_from_data($raw) { global $wpdb; $importdata = $raw; if (null === $importdata) { $this->finished = true; return new Keyring_Error('keyring-instapaper-importer-failed-download', __('Failed to download or parse your links from Instapaper. Please wait a few minutes and try again.')); } // Make sure we have some bookmarks to parse if (!is_array($importdata) || count($importdata) < 2) { $this->finished = true; return; } usort($importdata, array($this, 'sort_by_time')); // Parse/convert everything to WP post structs foreach ($importdata as $post) { if ('bookmark' != $post->type) { continue; } $post_title = $post->title; // Parse/adjust dates $post_date_gmt = gmdate('Y-m-d H:i:s', $post->progress_timestamp); // last seen "progress" $post_date = get_date_from_gmt($post_date_gmt); // Apply selected category $post_category = array($this->get_option('category')); // Just default tags here $tags = $this->get_option('tags'); // Construct a post body $href = $post->url; $post_content = '<a href="' . $href . '" class="instapaper-title">' . $post_title . '</a>'; if (!empty($post->description)) { $post_content .= "\n\n<blockquote class='instapaper-note'>" . $post->description . '</blockquote>'; } // Other bits $post_author = $this->get_option('author'); $post_status = 'publish'; $instapaper_id = $post->bookmark_id; $instapaper_raw = $post; // Build the post array, and hang onto it along with the others $this->posts[] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_category', 'tags', 'href', 'instapaper_id', 'instapaper_raw'); } }
function yith_vendors_update_db_1_0_1() { $vendors_db_option = get_option('yith_product_vendors_db_version', '1.0.0'); if ($vendors_db_option && version_compare($vendors_db_option, '1.0.1', '<')) { global $wpdb; $sql = "SELECT woocommerce_term_id as vendor_id, meta_value as user_id\r\n FROM {$wpdb->woocommerce_termmeta} as wtm\r\n WHERE wtm.meta_key = %s\r\n AND woocommerce_term_id IN (\r\n SELECT DISTINCT term_id as vendor_id\r\n FROM {$wpdb->term_taxonomy} as tt\r\n WHERE tt.taxonomy = %s\r\n )"; $results = $wpdb->get_results($wpdb->prepare($sql, 'owner', YITH_Vendors()->get_taxonomy_name())); foreach ($results as $result) { $user = get_user_by('id', $result->user_id); if ($user) { update_woocommerce_term_meta($result->vendor_id, 'registration_date', get_date_from_gmt($user->user_registered)); update_woocommerce_term_meta($result->vendor_id, 'registration_date_gmt', $user->user_registered); if (defined('YITH_WPV_PREMIUM')) { $user->add_cap('view_woocommerce_reports'); } } } update_option('yith_product_vendors_db_version', '1.0.1'); } }
private function compute($whichtime) { // Returned value should be in UNIX time. $unixtime_now = time(); // Convert to date $now_timestring_gmt = gmdate('Y-m-d H:i:s', $unixtime_now); // Convert to blog's timezone $now_timestring_blogzone = get_date_from_gmt($now_timestring_gmt, 'Y-m-d H:i:s'); $int_key = 'db' == $whichtime ? '_database' : ''; $sched = isset($_POST['updraft_interval' . $int_key]) ? $_POST['updraft_interval' . $int_key] : 'manual'; // Was a particular week-day specified? if (isset($_POST['updraft_startday_' . $whichtime]) && ('weekly' == $sched || 'monthly' == $sched || 'fortnightly' == $sched)) { // Get specified day of week in range 0-6 $startday = min(absint($_POST['updraft_startday_' . $whichtime]), 6); // Get today's day of week in range 0-6 $day_today_blogzone = get_date_from_gmt($now_timestring_gmt, 'w'); if ($day_today_blogzone != $startday) { if ($startday < $day_today_blogzone) { $startday += 7; } $new_startdate_unix = $unixtime_now + ($startday - $day_today_blogzone) * 86400; $now_timestring_blogzone = get_date_from_gmt(gmdate('Y-m-d H:i:s', $new_startdate_unix), 'Y-m-d H:i:s'); } } // HH:MM, in blog time zone // This function is only called from the options validator, so we don't read the current option //$start_time = UpdraftPlus_Options::get_updraft_option('updraft_starttime_'.$whichtime); $start_time = isset($_POST['updraft_starttime_' . $whichtime]) ? $_POST['updraft_starttime_' . $whichtime] : '00:00'; list($start_hour, $start_minute) = $this->parse($start_time); // Now, convert the start time HH:MM from blog time to UNIX time $start_time_unix = get_gmt_from_date(substr($now_timestring_blogzone, 0, 11) . sprintf('%02d', $start_hour) . ':' . sprintf('%02d', $start_minute) . ':00', 'U'); // That may have already passed for today if ($start_time_unix < time()) { if ('weekly' == $sched || 'monthly' == $sched || 'fortnightly' == $sched) { $start_time_unix = $start_time_unix + 86400 * 7; } else { $start_time_unix = $start_time_unix + 86400; } } return $start_time_unix; }
function extract_posts_from_data($raw) { global $wpdb; $importdata = $raw; if (null === $importdata) { $this->finished = true; return new Keyring_Error('keyring-delicious-importer-failed-download', __('Failed to download or parse your bookmarks from Delicious. Please wait a few minutes and try again.')); } // Make sure we have some bookmarks to parse if (!is_object($importdata) || !count($importdata->post)) { $this->finished = true; return; } // Parse/convert everything to WP post structs foreach ($importdata->post as $post) { $post_title = (string) $post['description']; // Parse/adjust dates $post_date_gmt = strtotime((string) $post['time']); $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt); $post_date = get_date_from_gmt($post_date_gmt); // Apply selected category $post_category = array($this->get_option('category')); // Figure out tags $tags = (string) $post['tag']; $tags = array_merge($this->get_option('tags'), explode(' ', strtolower($tags))); // Construct a post body $href = (string) $post['href']; $extended = (string) $post['extended']; $post_content = '<a href="' . $href . '" class="delicious-title">' . $post_title . '</a>'; if (!empty($extended)) { $post_content .= "\n\n<blockquote class='delicious-note'>" . $extended . '</blockquote>'; } // Other bits $post_author = $this->get_option('author'); $post_status = 'publish'; $delicious_id = (string) $post['hash']; $delicious_raw = $post; // Build the post array, and hang onto it along with the others $this->posts[] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_category', 'delicious_id', 'tags', 'href', 'delicious_raw'); } }
public function backup($backup_array) { global $updraftplus, $updraftplus_backup; $updraft_dir = trailingslashit($updraftplus->backups_dir_location()); $email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true); if (!is_array($email)) { $email = array($email); } foreach ($backup_array as $type => $file) { $descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type; $fullpath = $updraft_dir . $file; #if (file_exists($fullpath) && filesize($fullpath) > ... $any_attempted = false; $any_sent = false; foreach ($email as $ind => $addr) { if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) { continue; } foreach (explode(',', $addr) as $sendmail_addr) { $send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr; $updraftplus->log("{$file}: email to: {$send_short}"); $any_attempted = true; $subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i'); $sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath)); if ($sent) { $any_sent = true; } } } if ($any_sent) { $updraftplus->uploaded_file($file); } elseif ($any_attempted) { $updraftplus->log('Mails were not sent successfully'); $updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error'); } else { $updraftplus->log('No email addresses were configured to send to'); } } return null; }
public function user_edit_form_tag() { global $gMemberNetwork, $profileuser; $store_lastlogin = $gMemberNetwork->settings->get('store_lastlogin', TRUE); echo '><h2>' . __('Account Information', GMEMBER_TEXTDOMAIN) . '</h2>'; echo '<table class="form-table">'; if (isset($profileuser->{$this->constants['meta_register_ip']}) && $profileuser->{$this->constants['meta_register_ip']}) { $register_ip = $gMemberNetwork->getIPLookup($profileuser->{$this->constants['meta_register_ip']}); } else { $register_ip = __('No Data Available', GMEMBER_TEXTDOMAIN); } echo '<tr class="register_ip"><th>' . __('Registration IP', GMEMBER_TEXTDOMAIN) . '</th><td><code>' . $register_ip . '</code></td></tr>'; $register_date = strtotime(get_date_from_gmt($profileuser->user_registered)); $register_on = $gMemberNetwork->getDate($register_date, 'datetime') . ' <small><small><span class="description">(' . sprintf(__('%s ago', GMEMBER_TEXTDOMAIN), apply_filters('string_format_i18n', human_time_diff($register_date))) . ')</span></small></small>'; echo '<tr class="register_date"><th>' . __('Registration on', GMEMBER_TEXTDOMAIN) . '</th><td>' . $register_on . '</td></tr>'; if ($store_lastlogin || current_user_can('edit_users')) { if (isset($profileuser->{$this->constants['meta_lastlogin']}) && '' != $profileuser->{$this->constants['meta_lastlogin']}) { $lastlogin_date = strtotime(get_date_from_gmt($profileuser->{$this->constants['meta_lastlogin']})); $lastlogin = $gMemberNetwork->getDate($lastlogin_date, 'datetime') . ' <small><small><span class="description">(' . sprintf(__('%s ago', GMEMBER_TEXTDOMAIN), apply_filters('string_format_i18n', human_time_diff($lastlogin_date))) . ')</span></small></small>'; } else { $lastlogin = '******' . __('No Data Available', GMEMBER_TEXTDOMAIN) . '</code>'; } echo '<tr class="last_login' . ($store_lastlogin ? '' : ' error') . '"><th>' . __('Last Login', GMEMBER_TEXTDOMAIN) . '</th><td>' . $lastlogin . ($store_lastlogin ? '' : ' — <strong>' . __('Last Logins are Disabled', GMEMBER_TEXTDOMAIN) . '</strong>') . '</td></tr>'; } if (!IS_PROFILE_PAGE && current_user_can('edit_users')) { echo '</table><h2>' . __('Administrative Options', GMEMBER_TEXTDOMAIN) . '</h2>'; echo '<table class="form-table">'; $nicename = $profileuser->user_login == $profileuser->user_nicename ? $this->sanitize_slug($profileuser->display_name) : $profileuser->user_nicename; echo '<tr><th><label for="gmember-slug">' . __('Slug', GMEMBER_TEXTDOMAIN) . '</label></th><td><input type="text" name="gmember_slug" id="gmember_slug" value="' . esc_attr($nicename) . '" class="regular-text" dir="ltr"' . (current_user_can('edit_users') ? '' : ' readonly="readonly" disabled="disabled"') . ' /><p class="description">' . __('This will be used in the URL of the user\'s page', GMEMBER_TEXTDOMAIN) . '</p></td></tr>'; echo '<tr><th>' . __('Account Login', GMEMBER_TEXTDOMAIN) . '</th><td><label for="gmember_disable_user">' . '<input type="checkbox" name="gmember_disable_user" id="gmember_disable_user" value="1"'; checked(1, get_the_author_meta($this->constants['meta_disable_user'], $profileuser->ID)); echo ' /> ' . __('Disable user login with this account', GMEMBER_TEXTDOMAIN) . '</label></td></tr>'; echo '<tr><th>' . __('Password Reset', GMEMBER_TEXTDOMAIN) . '</th><td><label for="gmember_password_reset">' . '<input type="checkbox" name="gmember_password_reset" id="gmember_password_reset" value="1"'; checked(1, get_the_author_meta($this->constants['meta_disable_password_reset'], $profileuser->ID)); echo ' /> ' . __('Disable this account password reset via wp-login.php', GMEMBER_TEXTDOMAIN) . '</label></td></tr>'; } echo '</table'; // it's correct, checkout the hook! }
/** * Insert or update a post. * * If the $postarr parameter has 'ID' set to a value, then post will be updated. * * You can set the post date manually, by setting the values for 'post_date' * and 'post_date_gmt' keys. You can close the comments or open the comments by * setting the value for 'comment_status' key. * * @since 1.0.0 * @since 4.2.0 Support was added for encoding emoji in the post title, content, and excerpt. * @since 4.4.0 A 'meta_input' array can now be passed to `$postarr` to add post meta data. * * @see sanitize_post() * @global wpdb $wpdb WordPress database abstraction object. * * @param array $postarr { * An array of elements that make up a post to update or insert. * * @type int $ID The post ID. If equal to something other than 0, * the post with that ID will be updated. Default 0. * @type int $post_author The ID of the user who added the post. Default is * the current user ID. * @type string $post_date The date of the post. Default is the current time. * @type string $post_date_gmt The date of the post in the GMT timezone. Default is * the value of `$post_date`. * @type mixed $post_content The post content. Default empty. * @type string $post_content_filtered The filtered post content. Default empty. * @type string $post_title The post title. Default empty. * @type string $post_excerpt The post excerpt. Default empty. * @type string $post_status The post status. Default 'draft'. * @type string $post_type The post type. Default 'post'. * @type string $comment_status Whether the post can accept comments. Accepts 'open' or 'closed'. * Default is the value of 'default_comment_status' option. * @type string $ping_status Whether the post can accept pings. Accepts 'open' or 'closed'. * Default is the value of 'default_ping_status' option. * @type string $post_password The password to access the post. Default empty. * @type string $post_name The post name. Default is the sanitized post title. * @type string $to_ping Space or carriage return-separated list of URLs to ping. * Default empty. * @type string $pinged Space or carriage return-separated list of URLs that have * been pinged. Default empty. * @type string $post_modified The date when the post was last modified. Default is * the current time. * @type string $post_modified_gmt The date when the post was last modified in the GMT * timezone. Default is the current time. * @type int $post_parent Set this for the post it belongs to, if any. Default 0. * @type int $menu_order The order the post should be displayed in. Default 0. * @type string $post_mime_type The mime type of the post. Default empty. * @type string $guid Global Unique ID for referencing the post. Default empty. * @type array $tax_input Array of taxonomy terms keyed by their taxonomy name. Default empty. * @type array $meta_input Array of post meta values keyed by their post meta key. Default empty. * } * @param bool $wp_error Optional. Whether to allow return of WP_Error on failure. Default false. * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure. */ function wp_insert_post($postarr, $wp_error = false) { global $wpdb; $user_id = get_current_user_id(); $defaults = array('post_author' => $user_id, 'post_content' => '', 'post_content_filtered' => '', 'post_title' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => '', 'ping_status' => '', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => '', 'import_id' => 0, 'context' => ''); $postarr = wp_parse_args($postarr, $defaults); unset($postarr['filter']); $postarr = sanitize_post($postarr, 'db'); // Are we updating or creating? $post_ID = 0; $update = false; $guid = $postarr['guid']; if (!empty($postarr['ID'])) { $update = true; // Get the post ID and GUID. $post_ID = $postarr['ID']; $post_before = get_post($post_ID); if (is_null($post_before)) { if ($wp_error) { return new WP_Error('invalid_post', __('Invalid post ID.')); } return 0; } $guid = get_post_field('guid', $post_ID); $previous_status = get_post_field('post_status', $post_ID); } else { $previous_status = 'new'; } $post_type = empty($postarr['post_type']) ? 'post' : $postarr['post_type']; $post_title = $postarr['post_title']; $post_content = $postarr['post_content']; $post_excerpt = $postarr['post_excerpt']; if (isset($postarr['post_name'])) { $post_name = $postarr['post_name']; } $maybe_empty = 'attachment' !== $post_type && !$post_content && !$post_title && !$post_excerpt && post_type_supports($post_type, 'editor') && post_type_supports($post_type, 'title') && post_type_supports($post_type, 'excerpt'); /** * Filter whether the post should be considered "empty". * * The post is considered "empty" if both: * 1. The post type supports the title, editor, and excerpt fields * 2. The title, editor, and excerpt fields are all empty * * Returning a truthy value to the filter will effectively short-circuit * the new post being inserted, returning 0. If $wp_error is true, a WP_Error * will be returned instead. * * @since 3.3.0 * * @param bool $maybe_empty Whether the post should be considered "empty". * @param array $postarr Array of post data. */ if (apply_filters('wp_insert_post_empty_content', $maybe_empty, $postarr)) { if ($wp_error) { return new WP_Error('empty_content', __('Content, title, and excerpt are empty.')); } else { return 0; } } $post_status = empty($postarr['post_status']) ? 'draft' : $postarr['post_status']; if ('attachment' === $post_type && !in_array($post_status, array('inherit', 'private', 'trash'))) { $post_status = 'inherit'; } if (!empty($postarr['post_category'])) { // Filter out empty terms. $post_category = array_filter($postarr['post_category']); } // Make sure we set a valid category. if (empty($post_category) || 0 == count($post_category) || !is_array($post_category)) { // 'post' requires at least one category. if ('post' == $post_type && 'auto-draft' != $post_status) { $post_category = array(get_option('default_category')); } else { $post_category = array(); } } // Don't allow contributors to set the post slug for pending review posts. if ('pending' == $post_status && !current_user_can('publish_posts')) { $post_name = ''; } /* * Create a valid post name. Drafts and pending posts are allowed to have * an empty post name. */ if (empty($post_name)) { if (!in_array($post_status, array('draft', 'pending', 'auto-draft'))) { $post_name = sanitize_title($post_title); } else { $post_name = ''; } } else { // On updates, we need to check to see if it's using the old, fixed sanitization context. $check_name = sanitize_title($post_name, '', 'old-save'); if ($update && strtolower(urlencode($post_name)) == $check_name && get_post_field('post_name', $post_ID) == $check_name) { $post_name = $check_name; } else { // new post, or slug has changed. $post_name = sanitize_title($post_name); } } /* * If the post date is empty (due to having been new or a draft) and status * is not 'draft' or 'pending', set date to now. */ if (empty($postarr['post_date']) || '0000-00-00 00:00:00' == $postarr['post_date']) { if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) { $post_date = current_time('mysql'); } else { $post_date = get_date_from_gmt($postarr['post_date_gmt']); } } else { $post_date = $postarr['post_date']; } // Validate the date. $mm = substr($post_date, 5, 2); $jj = substr($post_date, 8, 2); $aa = substr($post_date, 0, 4); $valid_date = wp_checkdate($mm, $jj, $aa, $post_date); if (!$valid_date) { if ($wp_error) { return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.')); } else { return 0; } } if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) { if (!in_array($post_status, array('draft', 'pending', 'auto-draft'))) { $post_date_gmt = get_gmt_from_date($post_date); } else { $post_date_gmt = '0000-00-00 00:00:00'; } } else { $post_date_gmt = $postarr['post_date_gmt']; } if ($update || '0000-00-00 00:00:00' == $post_date) { $post_modified = current_time('mysql'); $post_modified_gmt = current_time('mysql', 1); } else { $post_modified = $post_date; $post_modified_gmt = $post_date_gmt; } if ('attachment' !== $post_type) { if ('publish' == $post_status) { $now = gmdate('Y-m-d H:i:59'); if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) { $post_status = 'future'; } } elseif ('future' == $post_status) { $now = gmdate('Y-m-d H:i:59'); if (mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false)) { $post_status = 'publish'; } } } // Comment status. if (empty($postarr['comment_status'])) { if ($update) { $comment_status = 'closed'; } else { $comment_status = get_default_comment_status($post_type); } } else { $comment_status = $postarr['comment_status']; } // These variables are needed by compact() later. $post_content_filtered = $postarr['post_content_filtered']; $post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id; $ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status']; $to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : ''; $pinged = isset($postarr['pinged']) ? $postarr['pinged'] : ''; $import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0; /* * The 'wp_insert_post_parent' filter expects all variables to be present. * Previously, these variables would have already been extracted */ if (isset($postarr['menu_order'])) { $menu_order = (int) $postarr['menu_order']; } else { $menu_order = 0; } $post_password = isset($postarr['post_password']) ? $postarr['post_password'] : ''; if ('private' == $post_status) { $post_password = ''; } if (isset($postarr['post_parent'])) { $post_parent = (int) $postarr['post_parent']; } else { $post_parent = 0; } /** * Filter the post parent -- used to check for and prevent hierarchy loops. * * @since 3.1.0 * * @param int $post_parent Post parent ID. * @param int $post_ID Post ID. * @param array $new_postarr Array of parsed post data. * @param array $postarr Array of sanitized, but otherwise unmodified post data. */ $post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr); $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); // Don't unslash. $post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : ''; // Expected_slashed (everything!). $data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid'); $emoji_fields = array('post_title', 'post_content', 'post_excerpt'); foreach ($emoji_fields as $emoji_field) { if (isset($data[$emoji_field])) { $charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field); if ('utf8' === $charset) { $data[$emoji_field] = wp_encode_emoji($data[$emoji_field]); } } } if ('attachment' === $post_type) { /** * Filter attachment post data before it is updated in or added to the database. * * @since 3.9.0 * * @param array $data An array of sanitized attachment post data. * @param array $postarr An array of unsanitized attachment post data. */ $data = apply_filters('wp_insert_attachment_data', $data, $postarr); } else { /** * Filter slashed post data just before it is inserted into the database. * * @since 2.7.0 * * @param array $data An array of slashed post data. * @param array $postarr An array of sanitized, but otherwise unmodified post data. */ $data = apply_filters('wp_insert_post_data', $data, $postarr); } $data = wp_unslash($data); $where = array('ID' => $post_ID); if ($update) { /** * Fires immediately before an existing post is updated in the database. * * @since 2.5.0 * * @param int $post_ID Post ID. * @param array $data Array of unslashed post data. */ do_action('pre_post_update', $post_ID, $data); if (false === $wpdb->update($wpdb->posts, $data, $where)) { if ($wp_error) { return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error); } else { return 0; } } } else { // If there is a suggested ID, use it if not already present. if (!empty($import_id)) { $import_id = (int) $import_id; if (!$wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE ID = %d", $import_id))) { $data['ID'] = $import_id; } } if (false === $wpdb->insert($wpdb->posts, $data)) { if ($wp_error) { return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error); } else { return 0; } } $post_ID = (int) $wpdb->insert_id; // Use the newly generated $post_ID. $where = array('ID' => $post_ID); } if (empty($data['post_name']) && !in_array($data['post_status'], array('draft', 'pending', 'auto-draft'))) { $data['post_name'] = wp_unique_post_slug(sanitize_title($data['post_title'], $post_ID), $post_ID, $data['post_status'], $post_type, $post_parent); $wpdb->update($wpdb->posts, array('post_name' => $data['post_name']), $where); clean_post_cache($post_ID); } if (is_object_in_taxonomy($post_type, 'category')) { wp_set_post_categories($post_ID, $post_category); } if (isset($postarr['tags_input']) && is_object_in_taxonomy($post_type, 'post_tag')) { wp_set_post_tags($post_ID, $postarr['tags_input']); } // New-style support for all custom taxonomies. if (!empty($postarr['tax_input'])) { foreach ($postarr['tax_input'] as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (!$taxonomy_obj) { /* translators: %s: taxonomy name */ _doing_it_wrong(__FUNCTION__, sprintf(__('Invalid taxonomy: %s.'), $taxonomy), '4.4.0'); continue; } // array = hierarchical, string = non-hierarchical. if (is_array($tags)) { $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { wp_set_post_terms($post_ID, $tags, $taxonomy); } } } if (!empty($postarr['meta_input'])) { foreach ($postarr['meta_input'] as $field => $value) { update_post_meta($post_ID, $field, $value); } } $current_guid = get_post_field('guid', $post_ID); // Set GUID. if (!$update && '' == $current_guid) { $wpdb->update($wpdb->posts, array('guid' => get_permalink($post_ID)), $where); } if ('attachment' === $postarr['post_type']) { if (!empty($postarr['file'])) { update_attached_file($post_ID, $postarr['file']); } if (!empty($postarr['context'])) { add_post_meta($post_ID, '_wp_attachment_context', $postarr['context'], true); } } clean_post_cache($post_ID); $post = get_post($post_ID); if (!empty($postarr['page_template']) && 'page' == $data['post_type']) { $post->page_template = $postarr['page_template']; $page_templates = wp_get_theme()->get_page_templates($post); if ('default' != $postarr['page_template'] && !isset($page_templates[$postarr['page_template']])) { if ($wp_error) { return new WP_Error('invalid_page_template', __('The page template is invalid.')); } update_post_meta($post_ID, '_wp_page_template', 'default'); } else { update_post_meta($post_ID, '_wp_page_template', $postarr['page_template']); } } if ('attachment' !== $postarr['post_type']) { wp_transition_post_status($data['post_status'], $previous_status, $post); } else { if ($update) { /** * Fires once an existing attachment has been updated. * * @since 2.0.0 * * @param int $post_ID Attachment ID. */ do_action('edit_attachment', $post_ID); $post_after = get_post($post_ID); /** * Fires once an existing attachment has been updated. * * @since 4.4.0 * * @param int $post_ID Post ID. * @param WP_Post $post_after Post object following the update. * @param WP_Post $post_before Post object before the update. */ do_action('attachment_updated', $post_ID, $post_after, $post_before); } else { /** * Fires once an attachment has been added. * * @since 2.0.0 * * @param int $post_ID Attachment ID. */ do_action('add_attachment', $post_ID); } return $post_ID; } if ($update) { /** * Fires once an existing post has been updated. * * @since 1.2.0 * * @param int $post_ID Post ID. * @param WP_Post $post Post object. */ do_action('edit_post', $post_ID, $post); $post_after = get_post($post_ID); /** * Fires once an existing post has been updated. * * @since 3.0.0 * * @param int $post_ID Post ID. * @param WP_Post $post_after Post object following the update. * @param WP_Post $post_before Post object before the update. */ do_action('post_updated', $post_ID, $post_after, $post_before); } /** * Fires once a post has been saved. * * The dynamic portion of the hook name, `$post->post_type`, refers to * the post type slug. * * @since 3.7.0 * * @param int $post_ID Post ID. * @param WP_Post $post Post object. * @param bool $update Whether this is an existing post being updated or not. */ do_action("save_post_{$post->post_type}", $post_ID, $post, $update); /** * Fires once a post has been saved. * * @since 1.5.0 * * @param int $post_ID Post ID. * @param WP_Post $post Post object. * @param bool $update Whether this is an existing post being updated or not. */ do_action('save_post', $post_ID, $post, $update); /** * Fires once a post has been saved. * * @since 2.0.0 * * @param int $post_ID Post ID. * @param WP_Post $post Post object. * @param bool $update Whether this is an existing post being updated or not. */ do_action('wp_insert_post', $post_ID, $post, $update); return $post_ID; }
/** * @since 2.0.8 */ public static function get_localized_date($date_format, $date) { $date = get_date_from_gmt($date); return date_i18n($date_format, strtotime($date)); }
private function get_backup_file_basename_from_time($use_time) { global $updraftplus; return 'backup_' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $use_time), 'Y-m-d-Hi') . '_' . $this->blog_name . '_' . $updraftplus->nonce; }
/** * Create a new subscription * * Returns a new WC_Subscription object on success which can then be used to add additional data. * * @return WC_Subscription | WP_Error A WC_Subscription on success or WP_Error object on failure * @since 2.0 */ function wcs_create_subscription($args = array()) { $order = isset($args['order_id']) ? wc_get_order($args['order_id']) : null; if (!empty($order) && isset($order->post->post_date)) { $default_start_date = '0000-00-00 00:00:00' != $order->post->post_date_gmt ? $order->post->post_date_gmt : get_gmt_from_date($order->post->post_date); } else { $default_start_date = current_time('mysql', true); } $default_args = array('status' => '', 'order_id' => 0, 'customer_note' => null, 'customer_id' => !empty($order) ? $order->get_user_id() : null, 'start_date' => $default_start_date, 'created_via' => !empty($order) ? $order->created_via : '', 'order_version' => !empty($order) ? $order->order_version : WC_VERSION, 'currency' => !empty($order) ? $order->order_currency : get_woocommerce_currency(), 'prices_include_tax' => !empty($order) ? $order->prices_include_tax ? 'yes' : 'no' : get_option('woocommerce_prices_include_tax')); $args = wp_parse_args($args, $default_args); $subscription_data = array(); // validate the start_date field if (!is_string($args['start_date']) || false === wcs_is_datetime_mysql_format($args['start_date'])) { return new WP_Error('woocommerce_subscription_invalid_start_date_format', _x('Invalid date. The date must be a string and of the format: "Y-m-d H:i:s".', 'Error message while creating a subscription', 'woocommerce-subscriptions')); } else { if (strtotime($args['start_date']) > current_time('timestamp', true)) { return new WP_Error('woocommerce_subscription_invalid_start_date', _x('Subscription start date must be before current day.', 'Error message while creating a subscription', 'woocommerce-subscriptions')); } } // check customer id is set if (empty($args['customer_id']) || !is_numeric($args['customer_id']) || $args['customer_id'] <= 0) { return new WP_Error('woocommerce_subscription_invalid_customer_id', _x('Invalid subscription customer_id.', 'Error message while creating a subscription', 'woocommerce-subscriptions')); } // check the billing period if (empty($args['billing_period']) || !in_array(strtolower($args['billing_period']), array_keys(wcs_get_subscription_period_strings()))) { return new WP_Error('woocommerce_subscription_invalid_billing_period', __('Invalid subscription billing period given.', 'woocommerce-subscriptions')); } // check the billing interval if (empty($args['billing_interval']) || !is_numeric($args['billing_interval']) || absint($args['billing_interval']) <= 0) { return new WP_Error('woocommerce_subscription_invalid_billing_interval', __('Invalid subscription billing interval given. Must be an integer greater than 0.', 'woocommerce-subscriptions')); } $subscription_data['post_type'] = 'shop_subscription'; $subscription_data['post_status'] = 'wc-' . apply_filters('woocommerce_default_subscription_status', 'pending'); $subscription_data['ping_status'] = 'closed'; $subscription_data['post_author'] = 1; $subscription_data['post_password'] = uniqid('order_'); // translators: Order date parsed by strftime $post_title_date = strftime(_x('%b %d, %Y @ %I:%M %p', 'Used in subscription post title. "Subscription renewal order - <this>"', 'woocommerce-subscriptions')); // translators: placeholder is order date parsed by strftime $subscription_data['post_title'] = sprintf(_x('Subscription – %s', 'The post title for the new subscription', 'woocommerce-subscriptions'), $post_title_date); $subscription_data['post_date_gmt'] = $args['start_date']; $subscription_data['post_date'] = get_date_from_gmt($args['start_date']); if ($args['order_id'] > 0) { $subscription_data['post_parent'] = absint($args['order_id']); } if (!is_null($args['customer_note']) && !empty($args['customer_note'])) { $subscription_data['post_excerpt'] = $args['customer_note']; } // Only set the status if creating a new subscription, use wcs_update_subscription to update the status if ($args['status']) { if (!in_array('wc-' . $args['status'], array_keys(wcs_get_subscription_statuses()))) { return new WP_Error('woocommerce_invalid_subscription_status', __('Invalid subscription status given.', 'woocommerce-subscriptions')); } $subscription_data['post_status'] = 'wc-' . $args['status']; } $subscription_id = wp_insert_post(apply_filters('woocommerce_new_subscription_data', $subscription_data, $args), true); if (is_wp_error($subscription_id)) { return $subscription_id; } // Default order meta data. update_post_meta($subscription_id, '_order_key', 'wc_' . apply_filters('woocommerce_generate_order_key', uniqid('order_'))); update_post_meta($subscription_id, '_order_currency', $args['currency']); update_post_meta($subscription_id, '_prices_include_tax', $args['prices_include_tax']); update_post_meta($subscription_id, '_created_via', sanitize_text_field($args['created_via'])); // add/update the billing update_post_meta($subscription_id, '_billing_period', $args['billing_period']); update_post_meta($subscription_id, '_billing_interval', absint($args['billing_interval'])); update_post_meta($subscription_id, '_customer_user', $args['customer_id']); update_post_meta($subscription_id, '_order_version', $args['order_version']); return new WC_Subscription($subscription_id); }
/** * Content column, and "quick admin" rollover actions. * * Called "comment" in the CSS so we can re-use some WP core CSS. * * @since BuddyPress (1.6.0) * * @see WP_List_Table::single_row_columns() * * @param array $item A singular item (one full row). */ function column_comment($item) { // Determine what type of item (row) we're dealing with if ($item['is_spam']) { $item_status = 'spam'; } else { $item_status = 'all'; } // Preorder items: Reply | Edit | Spam | Delete Permanently $actions = array('reply' => '', 'edit' => '', 'spam' => '', 'unspam' => '', 'delete' => ''); // Build actions URLs $base_url = bp_get_admin_url('admin.php?page=bp-activity&aid=' . $item['id']); $spam_nonce = esc_html('_wpnonce=' . wp_create_nonce('spam-activity_' . $item['id'])); $delete_url = $base_url . "&action=delete&{$spam_nonce}"; $edit_url = $base_url . '&action=edit'; $ham_url = $base_url . "&action=ham&{$spam_nonce}"; $spam_url = $base_url . "&action=spam&{$spam_nonce}"; // Rollover actions // Reply - JavaScript only; implemented by AJAX. if ('spam' != $item_status) { if ($this->can_comment($item)) { $actions['reply'] = sprintf('<a href="#" class="reply hide-if-no-js">%s</a>', __('Reply', 'buddypress')); } else { $actions['reply'] = sprintf('<span class="form-input-tip" title="%s">%s</span>', __('Replies are disabled for this activity item', 'buddypress'), __('Replies disabled', 'buddypress')); } // Edit $actions['edit'] = sprintf('<a href="%s">%s</a>', $edit_url, __('Edit', 'buddypress')); } // Spam/unspam if ('spam' == $item_status) { $actions['unspam'] = sprintf('<a href="%s">%s</a>', $ham_url, __('Not Spam', 'buddypress')); } else { $actions['spam'] = sprintf('<a href="%s">%s</a>', $spam_url, __('Spam', 'buddypress')); } // Delete $actions['delete'] = sprintf('<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js(__('Are you sure?', 'buddypress')) . "'); ", __('Delete Permanently', 'buddypress')); // Start timestamp echo '<div class="submitted-on">'; /** * Filters available actions for plugins to alter. * * @since BuddyPress (1.6.0) * * @param array $actions Array of available actions user could use. * @param array $item Current item being added to page. */ $actions = apply_filters('bp_activity_admin_comment_row_actions', array_filter($actions), $item); /* translators: 2: activity admin ui date/time */ printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress'), bp_activity_get_permalink($item['id']), get_date_from_gmt($item['date_recorded'], get_option('date_format')), get_date_from_gmt($item['date_recorded'], get_option('time_format'))); // End timestamp echo '</div>'; // Get activity content - if not set, use the action if (!empty($item['content'])) { /** * Filters current activity item content. * * @since BuddyPress (1.2.0) * * @param array $item Array index holding current activity item content. */ $content = apply_filters_ref_array('bp_get_activity_content_body', array($item['content'])); } else { /** * Filters current activity item action. * * @since BuddyPress (1.2.0) * * @var array $item Array index holding current activity item action. */ $content = apply_filters_ref_array('bp_get_activity_action', array($item['action'])); } echo $content . ' ' . $this->row_actions($actions); }
function do_tweet_post($tweet) { global $wpdb; remove_action('publish_post', 'aktt_notify_twitter', 99); $data = array('post_content' => $wpdb->escape(aktt_make_clickable($tweet->tw_text)), 'post_title' => $wpdb->escape(trim_add_elipsis($tweet->tw_text, 30)), 'post_date' => get_date_from_gmt(date('Y-m-d H:i:s', $tweet->tw_created_at)), 'post_category' => array($this->blog_post_category), 'post_status' => 'publish', 'post_author' => $wpdb->escape($this->blog_post_author)); $data = apply_filters('aktt_do_tweet_post', $data, $tweet); // return false here to not make a blog post if (!$data) { return; } $post_id = wp_insert_post($data); add_post_meta($post_id, 'aktt_twitter_id', $tweet->tw_id, true); wp_set_post_tags($post_id, $this->blog_post_tags); add_action('publish_post', 'aktt_notify_twitter', 99); }
/** * Get a local date with its GMT equivalent, in MySQL datetime format. * * @param string $date RFC3339 timestamp * @param bool $force_utc Whether a UTC timestamp should be forced. * @return array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s), * null on failure. */ function json_get_date_with_gmt($date, $force_utc = false) { $date = json_parse_date($date, $force_utc); if (empty($date)) { return null; } $utc = date('Y-m-d H:i:s', $date); $local = get_date_from_gmt($utc); return array($local, $utc); }
private function map_data($rawData, $type = "posts") { $data = array(); $tags = array(); foreach ($rawData as $entry) { if (!$entry["public"]) { continue; } if ($entry["type"] != "PushEvent") { continue; } $post_format = 'status'; $content = self::construct_content($entry); $tags = self::get_hashtags($entry); $post_meta["_" . $this->shortname . "_link_id"] = $entry["id"]; $post_meta["_post_generator"] = $this->shortname; $post_meta["_reclaim_post_type"] = $type; // http://codex.wordpress.org/Function_Reference/wp_insert_post $data[] = array('post_author' => get_option($this->shortname . '_author'), 'post_category' => array(get_option($this->shortname . '_category')), 'post_date' => get_date_from_gmt(date('Y-m-d H:i:s', strtotime($entry["created_at"]))), 'post_format' => $post_format, 'post_content' => $content['content'], 'post_title' => strip_tags($content['title']), 'post_type' => 'post', 'post_status' => 'publish', 'tags_input' => $tags, 'ext_permalink' => $content['url'], 'ext_guid' => $entry["id"], 'post_meta' => $post_meta); parent::log(sprintf(__('%s posted new status: %s on %s', 'reclaim'), $this->shortname, $content["title"], $data[count($data) - 1]["post_date"])); } return $data; }
/** * Edit a post. * * @since 1.5.0 * * @param array $args Method parameters. * @return bool|IXR_Error True on success. */ public function mw_editPost($args) { $this->escape($args); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $content_struct = $args[3]; $publish = isset($args[4]) ? $args[4] : 0; if (!($user = $this->login($username, $password))) { return $this->error; } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action('xmlrpc_call', 'metaWeblog.editPost'); $postdata = get_post($post_ID, ARRAY_A); // If there is no post data for the give post id, stop // now and return an error. Other wise a new post will be // created (which was the old behavior). if (!$postdata || empty($postdata['ID'])) { return new IXR_Error(404, __('Invalid post ID.')); } if (!current_user_can('edit_post', $post_ID)) { return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.')); } // Use wp.editPost to edit post types other than post and page. if (!in_array($postdata['post_type'], array('post', 'page'))) { return new IXR_Error(401, __('Invalid post type')); } // Thwart attempt to change the post type. if (!empty($content_struct['post_type']) && $content_struct['post_type'] != $postdata['post_type']) { return new IXR_Error(401, __('The post type may not be changed.')); } // Check for a valid post format if one was given if (isset($content_struct['wp_post_format'])) { $content_struct['wp_post_format'] = sanitize_key($content_struct['wp_post_format']); if (!array_key_exists($content_struct['wp_post_format'], get_post_format_strings())) { return new IXR_Error(404, __('Invalid post format')); } } $this->escape($postdata); $ID = $postdata['ID']; $post_content = $postdata['post_content']; $post_title = $postdata['post_title']; $post_excerpt = $postdata['post_excerpt']; $post_password = $postdata['post_password']; $post_parent = $postdata['post_parent']; $post_type = $postdata['post_type']; $menu_order = $postdata['menu_order']; // Let WordPress manage slug if none was provided. $post_name = ""; $post_name = $postdata['post_name']; if (isset($content_struct['wp_slug'])) { $post_name = $content_struct['wp_slug']; } // Only use a password if one was given. if (isset($content_struct['wp_password'])) { $post_password = $content_struct['wp_password']; } // Only set a post parent if one was given. if (isset($content_struct['wp_page_parent_id'])) { $post_parent = $content_struct['wp_page_parent_id']; } // Only set the menu_order if it was given. if (isset($content_struct['wp_page_order'])) { $menu_order = $content_struct['wp_page_order']; } $page_template = null; if (!empty($content_struct['wp_page_template']) && 'page' == $post_type) { $page_template = $content_struct['wp_page_template']; } $post_author = $postdata['post_author']; // Only set the post_author if one is set. if (isset($content_struct['wp_author_id']) && $user->ID != $content_struct['wp_author_id']) { switch ($post_type) { case 'post': if (!current_user_can('edit_others_posts')) { return new IXR_Error(401, __('You are not allowed to change the post author as this user.')); } break; case 'page': if (!current_user_can('edit_others_pages')) { return new IXR_Error(401, __('You are not allowed to change the page author as this user.')); } break; default: return new IXR_Error(401, __('Invalid post type')); break; } $post_author = $content_struct['wp_author_id']; } if (isset($content_struct['mt_allow_comments'])) { if (!is_numeric($content_struct['mt_allow_comments'])) { switch ($content_struct['mt_allow_comments']) { case 'closed': $comment_status = 'closed'; break; case 'open': $comment_status = 'open'; break; default: $comment_status = get_option('default_comment_status'); break; } } else { switch ((int) $content_struct['mt_allow_comments']) { case 0: case 2: $comment_status = 'closed'; break; case 1: $comment_status = 'open'; break; default: $comment_status = get_option('default_comment_status'); break; } } } if (isset($content_struct['mt_allow_pings'])) { if (!is_numeric($content_struct['mt_allow_pings'])) { switch ($content_struct['mt_allow_pings']) { case 'closed': $ping_status = 'closed'; break; case 'open': $ping_status = 'open'; break; default: $ping_status = get_option('default_ping_status'); break; } } else { switch ((int) $content_struct["mt_allow_pings"]) { case 0: $ping_status = 'closed'; break; case 1: $ping_status = 'open'; break; default: $ping_status = get_option('default_ping_status'); break; } } } if (isset($content_struct['title'])) { $post_title = $content_struct['title']; } if (isset($content_struct['description'])) { $post_content = $content_struct['description']; } $post_category = array(); if (isset($content_struct['categories'])) { $catnames = $content_struct['categories']; if (is_array($catnames)) { foreach ($catnames as $cat) { $post_category[] = get_cat_ID($cat); } } } if (isset($content_struct['mt_excerpt'])) { $post_excerpt = $content_struct['mt_excerpt']; } $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null; $post_status = $publish ? 'publish' : 'draft'; if (isset($content_struct["{$post_type}_status"])) { switch ($content_struct["{$post_type}_status"]) { case 'draft': case 'pending': case 'private': case 'publish': $post_status = $content_struct["{$post_type}_status"]; break; default: $post_status = $publish ? 'publish' : 'draft'; break; } } $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; if ('publish' == $post_status) { if ('page' == $post_type && !current_user_can('publish_pages')) { return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); } else { if (!current_user_can('publish_posts')) { return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); } } } if ($post_more) { $post_content = $post_content . "<!--more-->" . $post_more; } $to_ping = null; if (isset($content_struct['mt_tb_ping_urls'])) { $to_ping = $content_struct['mt_tb_ping_urls']; if (is_array($to_ping)) { $to_ping = implode(' ', $to_ping); } } // Do some timestamp voodoo if (!empty($content_struct['date_created_gmt'])) { // We know this is supposed to be GMT, so we're going to slap that Z on there by force $dateCreated = rtrim($content_struct['date_created_gmt']->getIso(), 'Z') . 'Z'; } elseif (!empty($content_struct['dateCreated'])) { $dateCreated = $content_struct['dateCreated']->getIso(); } if (!empty($dateCreated)) { $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; } // We've got all the data -- post it: $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template'); $result = wp_update_post($newpost, true); if (is_wp_error($result)) { return new IXR_Error(500, $result->get_error_message()); } if (!$result) { return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); } // Only posts can be sticky if ($post_type == 'post' && isset($content_struct['sticky'])) { if ($content_struct['sticky'] == true) { stick_post($post_ID); } elseif ($content_struct['sticky'] == false) { unstick_post($post_ID); } } if (isset($content_struct['custom_fields'])) { $this->set_custom_fields($post_ID, $content_struct['custom_fields']); } if (isset($content_struct['wp_post_thumbnail'])) { // empty value deletes, non-empty value adds/updates if (empty($content_struct['wp_post_thumbnail'])) { delete_post_thumbnail($post_ID); } else { if (set_post_thumbnail($post_ID, $content_struct['wp_post_thumbnail']) === false) { return new IXR_Error(404, __('Invalid attachment ID.')); } } unset($content_struct['wp_post_thumbnail']); } // Handle enclosures $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; $this->add_enclosure_if_new($post_ID, $thisEnclosure); $this->attach_uploads($ID, $post_content); // Handle post formats if assigned, validation is handled // earlier in this function if (isset($content_struct['wp_post_format'])) { set_post_format($post_ID, $content_struct['wp_post_format']); } /** * Fires after a post has been successfully updated via the XML-RPC MovableType API. * * @since 3.4.0 * * @param int $post_ID ID of the updated post. * @param array $args An array of arguments to update the post. */ do_action('xmlrpc_call_success_mw_editPost', $post_ID, $args); return true; }
function mw_editPost($args) { global $wpdb, $post_default_category; $this->escape($args); $post_ID = (int) $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $content_struct = $args[3]; $publish = $args[4]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $user = set_current_user(0, $user_login); $cap = $publish ? 'publish_posts' : 'edit_posts'; $error_message = __('Sorry, you are not allowed to publish posts on this blog.'); $post_type = 'post'; if (!empty($content_struct['post_type'])) { if ($content_struct['post_type'] == 'page') { $cap = $publish ? 'publish_pages' : 'edit_pages'; $error_message = __('Sorry, you are not allowed to publish pages on this blog.'); $post_type = 'page'; } elseif ($content_type['post_type'] == 'post') { // This is the default, no changes needed } else { // No other post_type values are allowed here return new IXR_Error(401, __('Invalid post type.')); } } if (!current_user_can($cap)) { return new IXR_Error(401, $error_message); } $postdata = wp_get_single_post($post_ID, ARRAY_A); // If there is no post data for the give post id, stop // now and return an error. Other wise a new post will be // created (which was the old behavior). if (empty($postdata["ID"])) { return new IXR_Error(404, __("Invalid post id.")); } $this->escape($postdata); extract($postdata, EXTR_SKIP); // Let WordPress manage slug if none was provided. $post_name = ""; if (isset($content_struct["wp_slug"])) { $post_name = $content_struct["wp_slug"]; } // Only use a password if one was given. if (isset($content_struct["wp_password"])) { $post_password = $content_struct["wp_password"]; } // Only set a post parent if one was given. if (isset($content_struct["wp_page_parent_id"])) { $post_parent = $content_struct["wp_page_parent_id"]; } // Only set the menu_order if it was given. if (isset($content_struct["wp_page_order"])) { $menu_order = $content_struct["wp_page_order"]; } $post_author = $postdata["post_author"]; // Only set the post_author if one is set. if (isset($content_struct["wp_author_id"]) && $user->ID != $content_struct["wp_author_id"]) { switch ($post_type) { case "post": if (!current_user_can("edit_others_posts")) { return new IXR_Error(401, __("You are not allowed to change the post author as this user.")); } break; case "page": if (!current_user_can("edit_others_pages")) { return new IXR_Error(401, __("You are not allowed to change the page author as this user.")); } break; default: return new IXR_Error(401, __("Invalid post type.")); break; } $post_author = $content_struct["wp_author_id"]; } if (isset($content_struct["mt_allow_comments"])) { if (!is_numeric($content_struct["mt_allow_comments"])) { switch ($content_struct["mt_allow_comments"]) { case "closed": $comment_status = "closed"; break; case "open": $comment_status = "open"; break; default: $comment_status = get_option("default_comment_status"); break; } } else { switch ((int) $content_struct["mt_allow_comments"]) { case 0: $comment_status = "closed"; break; case 1: $comment_status = "open"; break; default: $comment_status = get_option("default_comment_status"); break; } } } if (isset($content_struct["mt_allow_pings"])) { if (!is_numeric($content_struct["mt_allow_pings"])) { switch ($content_struct["mt_allow_pings"]) { case "closed": $ping_status = "closed"; break; case "open": $ping_status = "open"; break; default: $ping_status = get_option("default_ping_status"); break; } } else { switch ((int) $content_struct["mt_allow_pings"]) { case 0: $ping_status = "closed"; break; case 1: $ping_status = "open"; break; default: $ping_status = get_option("default_ping_status"); break; } } } $post_title = $content_struct['title']; $post_content = apply_filters('content_save_pre', $content_struct['description']); $catnames = $content_struct['categories']; $post_category = array(); if (is_array($catnames)) { foreach ($catnames as $cat) { $post_category[] = get_cat_ID($cat); } } $post_excerpt = $content_struct['mt_excerpt']; $post_more = $content_struct['mt_text_more']; $post_status = $publish ? 'publish' : 'draft'; $tags_input = $content_struct['mt_keywords']; if ('publish' == $post_status) { if ('page' == $post_type && !current_user_can('publish_pages')) { return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); } else { if (!current_user_can('publish_posts')) { return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); } } } if ($post_more) { $post_content = $post_content . "\n<!--more-->\n" . $post_more; } $to_ping = $content_struct['mt_tb_ping_urls']; if (is_array($to_ping)) { $to_ping = implode(' ', $to_ping); } // Do some timestamp voodoo $dateCreatedd = $content_struct['dateCreated']; if (!empty($dateCreatedd)) { $dateCreated = $dateCreatedd->getIso(); $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT); } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; } // We've got all the data -- post it: $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input'); $result = wp_update_post($newpost); if (!$result) { return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); } $this->attach_uploads($ID, $post_content); logIO('O', "(MW) Edited ! ID: {$post_ID}"); return true; }
/** * Displays column data in the row of details. * * @package s2Member\Users_List * @since 3.5 * * @attaches-to ``add_filter ("manage_users_custom_column");`` * * @param string $val A value for this column, passed through by the Filter. * @param string $col The name of the column for which we might need to supply data for. * @param int|string $user_id Expects a WordPress User ID, passed through by the Filter. * @return string A column value introduced by this routine, or existing value, or, if empty, a dash. */ public static function users_list_display_cols($val = FALSE, $col = FALSE, $user_id = FALSE) { static $user, $last_user_id; // Used internally for optimization. static $fields, $last_fields_id; // Used for optimization. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_users_list_display_cols", get_defined_vars()); unset($__refs, $__v); $user = is_object($user) && $user_id === $last_user_id ? $user : new WP_User($user_id); if ($col === "s2member_registration_time") { $val = ($time = strtotime(get_date_from_gmt($user->user_registered))) ? esc_html(date("D M jS, Y", $time)) . '<br /><small>@ precisely ' . esc_html(date("g:i a", $time)) . '</small>' : "—"; } else { if ($col === "s2member_paid_registration_times") { $val = ""; // Initialize $val before we begin. if (is_array($v = get_user_option("s2member_paid_registration_times", $user_id))) { foreach ($v as $level => $time) { $time = strtotime(get_date_from_gmt(date("Y-m-d H:i:s", $time))); if ($level === "level") { // First Payment Time, regardless of Level. $val .= ($val ? "<br />" : "") . '<span title="' . esc_attr(date("D M jS, Y", $time)) . ' @ precisely ' . esc_attr(date("g:i a", $time)) . '">' . esc_html(date("D M jS, Y", $time)) . '</span>'; } else { if (preg_match("/^level([0-9]+)\$/i", $level) && ($level = preg_replace("/^level/", "", $level))) { $val .= ($val ? "<br />" : "") . '<small><em>@Level ' . esc_html($level) . ': <span title="' . esc_attr(date("D M jS, Y", $time)) . ' @ precisely ' . esc_attr(date("g:i a", $time)) . '">' . esc_html(date("D M jS, Y", $time)) . '</span></em></small>'; } } } } } else { if ($col === "s2member_subscr_id") { $val = ($v = get_user_option("s2member_subscr_id", $user_id)) ? esc_html($v) : "—"; } else { if ($col === "s2member_ccaps") { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_s2member_ccap_/", $cap)) { $ccaps[] = preg_replace("/^access_s2member_ccap_/", "", $cap); } } $val = !empty($ccaps) ? implode("<br />", $ccaps) : "—"; } else { if ($col === "s2member_auto_eot_time") { $val = ($v = get_user_option("s2member_auto_eot_time", $user_id)) ? date("D M jS, Y", (int) $v) . "<br /><small>@ precisely " . date("g:i a", (int) $v) . "</small>" : "—"; } else { if (preg_match("/^s2member_custom_field_/", $col)) { if (!$last_fields_id || $last_fields_id !== $user_id) { $fields = get_user_option("s2member_custom_fields", $user_id); } $field_var = preg_replace("/^s2member_custom_field_/", "", $col); if (isset($fields[$field_var]) && is_string($fields[$field_var]) && preg_match("/^http(s?)\\:/i", $fields[$field_var])) { $val = '<a href="' . esc_attr($fields[$field_var]) . '" target="_blank">' . esc_html(substr($fields[$field_var], strpos($fields[$field_var], ":") + 3, 25) . "...") . '</a>'; } else { if (isset($fields[$field_var]) && is_array($fields[$field_var]) && !empty($fields[$field_var])) { $val = preg_replace("/-\\|br\\|-/", "<br />", esc_html(implode("-|br|-", $fields[$field_var]))); } else { if (isset($fields[$field_var]) && is_string($fields[$field_var]) && strlen($fields[$field_var])) { $val = esc_html($fields[$field_var]); } } } $last_fields_id = $user_id; // Record this. } else { if ($col === "s2member_login_counter") { $val = ($v = get_user_option("s2member_login_counter", $user_id)) ? esc_html($v) : "—"; } else { if ($col === "s2member_last_login_time") { if ($time = get_user_option("s2member_last_login_time", $user_id)) { $time = strtotime(get_date_from_gmt(date("Y-m-d H:i:s", $time))); $val = esc_html(date("D M jS, Y", $time)) . '<br /><small>@ precisely ' . esc_html(date("g:i a", $time)) . '</small>'; } else { $val = "—"; } // Not applicable (we've never recorded them logging into the site). } } } } } } } } $last_user_id = $user_id; // Record this for internal optimizations. return apply_filters("ws_plugin__s2member_users_list_display_cols", strlen($val) ? $val : "—", get_defined_vars()); }