/** * Displays coupon custom columns data. * * @param string $column_index * @param int $post_id * * @return void */ function appthemes_coupon_add_column_data($column_index, $post_id) { $coupon = get_post($post_id); $coupon_meta = get_post_custom($post_id); switch ($column_index) { case 'discount': if ($coupon_meta['type'][0] == 'flat') { $discount = (double) $coupon_meta['amount'][0]; appthemes_display_price($discount); } else { $discount = (int) $coupon_meta['amount'][0]; echo $discount . '%'; } break; case 'usage': $uses = isset($coupon_meta['use_count'][0]) ? $coupon_meta['use_count'][0] : 0; if (empty($coupon_meta['use_limit'][0])) { printf(__('%d / Unlimited', 'appthemes-coupons'), $uses); } else { printf(_x('%1$d / %2$d', 'Coupon usage, 1 - uses, 2 - limit', 'appthemes-coupons'), $uses, $coupon_meta['use_limit'][0]); } break; case 'expires': if (empty($coupon_meta['end_date'][0])) { _e('Not expiring', 'appthemes-coupons'); } else { echo appthemes_display_date($coupon_meta['end_date'][0], 'date'); } break; case 'status': if ($coupon->post_status == 'publish') { _e('Active', 'appthemes-coupons'); } else { _e('Inactive', 'appthemes-coupons'); } break; } }
/** * Displays the coumn values for each user. * * @param string $r * @param string $column_name * @param int $user_id * * @return string */ function cp_manage_users_custom_column($r, $column_name, $user_id) { switch ($column_name) { case 'cp_ads_count': global $cp_counts; if (!isset($cp_counts)) { $cp_counts = cp_count_ads(); } if (!array_key_exists($user_id, $cp_counts)) { $cp_counts = cp_count_ads(); } if ($cp_counts[$user_id] > 0) { $r .= "<a href='edit.php?post_type=" . APP_POST_TYPE . "&author={$user_id}' title='" . esc_attr__('View ads by this author', APP_TD) . "' class='edit'>"; $r .= $cp_counts[$user_id]; $r .= '</a>'; } else { $r .= 0; } break; case 'last_login': $r = get_user_meta($user_id, 'last_login', true); if (!empty($r)) { $r = appthemes_display_date($r); } break; case 'registered': $user_info = get_userdata($user_id); $r = $user_info->user_registered; if (!empty($r)) { $r = appthemes_display_date($r, 'datetime', true); } break; case 'id': $r = $user_id; break; } return $r; }
?> </span> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> "><?php the_author_meta('display_name'); ?> </a> </li> <li><span><?php _e('Member Since:', APP_TD); ?> </span> <?php echo appthemes_display_date(get_the_author_meta('user_registered'), 'date', true); ?> </li> </ul> <?php cp_author_info('sidebar-ad'); ?> <div class="pad5"></div> <div class="clr"></div> </div>
/** * Displays the order status summary * @param object $post Wordpress Post object * @return void */ function display($post) { $order = appthemes_get_order($post->ID); ?> <style type="text/css"> #admin-order-status th{ padding-right: 10px; text-align: right; width: 40%; } </style> <table id="admin-order-status"> <tbody> <tr> <th><?php _e('ID', APP_TD); ?> : </th> <td><?php echo $order->get_ID(); ?> </td> </tr> <tr> <th><?php _e('Status', APP_TD); ?> : </th> <td><?php echo $order->get_display_status(); ?> </td> </tr> <tr> <th><?php _e('Gateway', APP_TD); ?> : </th> <td> <?php $gateway_id = $order->get_gateway(); if (!empty($gateway_id)) { $gateway = APP_Gateway_Registry::get_gateway($gateway_id); if ($gateway) { echo $gateway->display_name('admin'); } else { _e('Unknown', APP_TD); } } else { _e('Undecided', APP_TD); } ?> </td> </tr> <tr> <th><?php _e('Currency', APP_TD); ?> : </th> <td><?php echo APP_Currencies::get_currency_string($order->get_currency()); ?> </td> </tr> <?php if ($order->is_recurring()) { $period = $order->get_recurring_period(); ?> <tr> <th><?php _e('Recurs:', APP_TD); ?> </th> <td><?php printf(_n('Every day', 'Every %d days', $period, APP_TD), $period); ?> </td> </tr> <tr> <th><?php _e('Payment Date:', APP_TD); ?> </th> <td><?php echo appthemes_display_date(get_post($order->get_id())->post_date, 'date'); ?> </td> </tr> <?php } ?> <?php if ($order->get_parent() != 0) { ?> <tr> <th><?php _e('Previously', APP_TD); ?> </th> <td><a href="<?php echo get_edit_post_link($order->get_parent()); ?> ">#<?php echo $order->get_parent(); ?> </a></td> </tr> <?php } ?> </tbody> </table> <?php }
<div class="post"> <div id="user-photo"><?php appthemes_get_profile_pic($curauth->ID, $curauth->user_email, 250); ?> </div> <div class="author-main"> <ul class="author-info"> <li><strong><?php _e('Member Since:', APP_TD); ?> </strong> <?php echo appthemes_display_date($curauth->user_registered, 'date', true); ?> </li> <?php if (!empty($curauth->user_url)) { ?> <li><div class="dashicons-before globeico"></div><a href="<?php echo esc_url($curauth->user_url); ?> "><?php echo strip_tags($curauth->user_url); ?> </a></li><?php } ?> <?php
/** * Displays metabox content. * * @param object $post * * @return void */ public function display($post) { $this->display_styles(); $this->display_scripts($post); ?> <table id="attachments" class="form-table"> <thead> <tr id="attachments_header"> <th class="thumb"><?php _e('Thumbnail', APP_TD); ?> </th> <th class="title"><?php _e('Title', APP_TD); ?> </th> <th class="date"><?php _e('Upload Date', APP_TD); ?> </th> <th class="dimensions"><?php _e('Dimensions', APP_TD); ?> </th> <th class="delete"><?php _e('Detach/Sort', APP_TD); ?> </th> </tr> </thead> <tbody class="attachments"> <?php $menu_order = 0; foreach ($this->get_attachments($post) as $attachment) { ?> <tr id="media-attachment-<?php echo $attachment->ID; ?> " class="media-attachment"> <td class="thumb"><?php echo $this->display_attachment_thumbnail($attachment); ?> </td> <td class="title"><input type="text" name="attachment[<?php echo $attachment->ID; ?> ][post_title]" value="<?php echo $attachment->post_title; ?> " /></td> <td class="date"><?php echo appthemes_display_date($attachment->post_date, 'date'); ?> </td> <td class="dimensions"><?php echo $this->display_attachment_dimensions($attachment); ?> </td> <td class="icons delete"> <span class="delete ui-icon ui-icon-circle-minus"></span> <span class="grip ui-icon ui-icon-grip-solid-horizontal"></span> <input class="menu_order" type="hidden" name="attachment[<?php echo $attachment->ID; ?> ][menu_order]" value="<?php echo $menu_order; ?> " /> </td> </tr> <?php $menu_order++; } ?> </tbody> <tfoot> <tr> <td><input id="upload_media_button" class="upload_button button" type="button" value="<?php _e('Add Media Attachment', APP_TD); ?> " /></td> <td colspan="4"></td> </tr> </tfoot> </table> <?php }
function cp_custom_fields() { global $options_new_field, $wpdb, $current_user; $current_user = wp_get_current_user(); ?> <!-- show/hide the dropdown field values tr --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function() { jQuery("#mainform").validate({errorClass: "invalid"}); }); function show(o){ if(o){switch(o.value){ case 'drop-down': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break; case 'multiple-drop-down': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break; case 'radio': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break; case 'checkbox': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break; case 'text box': jQuery('#field_min_length_row').show(); jQuery('#field_values_row').hide(); break; default: jQuery('#field_values_row').hide(); jQuery('#field_min_length_row').hide(); }} } //show/hide immediately on document load jQuery(document).ready(function() { show(jQuery('#field_type').get(0)); }); //hide unwanted options for cp_currency field jQuery(document).ready(function() { var field_name = jQuery('#field_name').val(); if(field_name == 'cp_currency'){ jQuery("#field_type option[value='text box']").attr("disabled", "disabled"); jQuery("#field_type option[value='text area']").attr("disabled", "disabled"); jQuery("#field_type option[value='checkbox']").attr("disabled", "disabled"); } }); /* ]]> */ </script> <?php $theswitch = isset($_GET['action']) ? $_GET['action'] : ''; switch ($theswitch) { case 'addfield': ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('New Custom Field', APP_TD); ?> </h2> <?php // check and make sure the form was submitted if (isset($_POST['submitted'])) { $_POST['field_search'] = ''; // we aren't using this field so set it to blank for now to prevent notice $data = array('field_name' => cp_make_custom_name($_POST['field_label'], 'fields'), 'field_label' => appthemes_clean($_POST['field_label']), 'field_desc' => appthemes_clean($_POST['field_desc']), 'field_tooltip' => appthemes_clean($_POST['field_tooltip']), 'field_type' => appthemes_clean($_POST['field_type']), 'field_values' => appthemes_clean($_POST['field_values']), 'field_search' => appthemes_clean($_POST['field_search']), 'field_owner' => appthemes_clean($_POST['field_owner']), 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql')); $insert = $wpdb->insert($wpdb->cp_ad_fields, $data); if ($insert) { do_action('cp_custom_fields', 'addfield', $wpdb->insert_id); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Creating your field.....', APP_TD); ?> <br /><br /><img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=fields"> <?php } die; } else { ?> <form method="post" id="mainform" action=""> <?php cp_admin_fields($options_new_field); ?> <p class="submit"><input class="btn button-primary" name="save" type="submit" value="<?php _e('Create New Field', APP_TD); ?> " /> <input class="btn button-secondary" name="cancel" type="button" onClick="location.href='?page=fields'" value="<?php _e('Cancel', APP_TD); ?> " /></p> <input name="submitted" type="hidden" value="yes" /> <input name="field_owner" type="hidden" value="<?php echo $current_user->user_login; ?> " /> </form> <?php } ?> </div><!-- end wrap --> <?php break; case 'editfield': ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Edit Custom Field', APP_TD); ?> </h2> <?php if (isset($_POST['submitted']) && $_POST['submitted'] == 'yes') { $data = array('field_name' => appthemes_clean($_POST['field_name']), 'field_label' => appthemes_clean($_POST['field_label']), 'field_desc' => appthemes_clean($_POST['field_desc']), 'field_tooltip' => esc_attr(appthemes_clean($_POST['field_tooltip'])), 'field_type' => appthemes_clean($_POST['field_type']), 'field_values' => appthemes_clean($_POST['field_values']), 'field_min_length' => appthemes_clean($_POST['field_min_length']), 'field_owner' => appthemes_clean($_POST['field_owner']), 'field_modified' => current_time('mysql')); $wpdb->update($wpdb->cp_ad_fields, $data, array('field_id' => $_GET['id'])); do_action('cp_custom_fields', 'editfield', $_GET['id']); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"> <?php _e('Saving your changes.....', APP_TD); ?> <br /><br /> <img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /> </p> <meta http-equiv="refresh" content="0; URL=?page=fields"> <?php } else { ?> <form method="post" id="mainform" action=""> <?php cp_admin_db_fields($options_new_field, 'cp_ad_fields', 'field_id'); ?> <p class="submit"> <input class="btn button-primary" name="save" type="submit" value="<?php _e('Save changes', APP_TD); ?> " /> <input class="btn button-secondary" name="cancel" type="button" onClick="location.href='?page=fields'" value="<?php _e('Cancel', APP_TD); ?> " /> <input name="submitted" type="hidden" value="yes" /> <input name="field_owner" type="hidden" value="<?php echo $current_user->user_login; ?> " /> </p> </form> <?php } ?> </div><!-- end wrap --> <?php break; case 'delete': // check and make sure this fields perms allow deletion $sql = $wpdb->prepare("SELECT field_perm FROM {$wpdb->cp_ad_fields} WHERE field_id = %d LIMIT 1", $_GET['id']); $results = $wpdb->get_row($sql); // if it's not greater than zero, then delete it if (!($results->field_perm > 0)) { do_action('cp_custom_fields', 'delete', $_GET['id']); $delete = $wpdb->prepare("DELETE FROM {$wpdb->cp_ad_fields} WHERE field_id = %d", $_GET['id']); $wpdb->query($delete); } ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting custom field.....', APP_TD); ?> <br /><br /><img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=fields"> <?php break; // show the table of all custom fields // show the table of all custom fields default: $sql = "SELECT * FROM {$wpdb->cp_ad_fields} ORDER BY field_name desc"; $results = $wpdb->get_results($sql); ?> <div class="wrap"> <div class="icon32" id="icon-tools"><br /></div> <h2><?php _e('Custom Fields', APP_TD); ?> <a class="add-new-h2" href="?page=fields&action=addfield"><?php _e('Add New', APP_TD); ?> </a></h2> <p class="admin-msg"><?php _e('Custom fields allow you to customize your ad submission forms and collect more information. Each custom field needs to be added to a form layout in order to be visible on your website. You can create unlimited custom fields and each one can be used across multiple form layouts. It is highly recommended to NOT delete a custom field once it is being used on your ads because it could cause ad editing problems for your customers.', APP_TD); ?> </p> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Name', APP_TD); ?> </th> <th scope="col" style="width:100px;"><?php _e('Type', APP_TD); ?> </th> <th scope="col"><?php _e('Description', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Modified', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php if ($results) { ?> <tbody id="list"> <?php $rowclass = ''; $i = 1; foreach ($results as $result) { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i; ?> .</td> <td><a href="?page=fields&action=editfield&id=<?php echo $result->field_id; ?> "><strong><?php echo esc_html(translate($result->field_label, APP_TD)); ?> </strong></a></td> <td><?php echo $result->field_type; ?> </td> <td><?php echo esc_html(translate($result->field_desc, APP_TD)); ?> </td> <td><?php echo appthemes_display_date($result->field_modified); ?> <?php _e('by', APP_TD); ?> <?php echo $result->field_owner; ?> </td> <td style="text-align:center"> <?php // show the correct edit options based on perms switch ($result->field_perm) { case '1': // core fields no editing ?> <a href="?page=fields&action=editfield&id=<?php echo $result->field_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/edit.png" alt="" /></a> <img src="<?php echo get_template_directory_uri(); ?> /images/cross-grey.png" alt="" /> <?php break; case '2': // core fields some editing ?> <a href="?page=fields&action=editfield&id=<?php echo $result->field_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/edit.png" alt="" /></a> <img src="<?php echo get_template_directory_uri(); ?> /images/cross-grey.png" alt="" /> <?php break; default: // regular fields full editing echo '<a href="?page=fields&action=editfield&id=' . $result->field_id . '"><img src="' . get_template_directory_uri() . '/images/edit.png" alt="" /></a> '; echo '<a onclick="return confirmBeforeDelete();" href="?page=fields&action=delete&id=' . $result->field_id . '"><img src="' . get_template_directory_uri() . '/images/cross.png" alt="" /></a>'; break; } // endswitch ?> </td> </tr> <?php $i++; } // endforeach; ?> </tbody> <?php } else { ?> <tr> <td colspan="5"><?php _e('No custom fields found. This usually means your install script did not run correctly. Go back and try reactivating the theme again.', APP_TD); ?> </td> </tr> <?php } ?> </table> </div><!-- end wrap --> <?php } ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('WARNING: Deleting this field will prevent any existing ads currently using this field from displaying the field value. Deleting fields is NOT recommended unless you do not have any existing ads using this field. Are you sure you want to delete this field?? (This cannot be undone)', APP_TD); ?> "); } /* ]]> */ </script> <?php }
</strong></label></div> <div id="active_membership_pack" class="ad-static-field"><?php echo appthemes_display_date($current_user->membership_expires); ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('New Expiration:', APP_TD); ?> </strong></label></div> <div id="active_membership_pack" class="ad-static-field"> <?php echo appthemes_display_date(appthemes_mysql_date($current_user->membership_expires, $membership->duration)); ?> </div> <div class="clr"></div> </li> <?php } ?> <li> <div class="labelwrapper"><label><?php _e('Price:', APP_TD); ?> </label></div> <div id="review" class="ad-static-field"><?php appthemes_display_price($membership->price);
</a></li> <?php } elseif ($membership) { ?> <li><strong><?php _e('Membership Pack:', APP_TD); ?> </strong> <?php echo stripslashes($membership->pack_name); ?> </li> <li><strong><?php _e('Membership Expires:', APP_TD); ?> </strong> <?php echo appthemes_display_date($current_user->membership_expires); ?> </li> <li><a href="<?php echo CP_MEMBERSHIP_PURCHASE_URL; ?> "><?php _e('Renew or Extend Your Membership Pack', APP_TD); ?> </a></li> <?php } else { ?> <li><a href="<?php echo CP_MEMBERSHIP_PURCHASE_URL; ?>
function appthemes_get_reg_date($reg_date) { return appthemes_display_date($reg_date); }
function cp_profile_fields($user) { global $appthemes_extended_profile_fields; ?> <h3><?php _e('Extended Profile', 'appthemes'); ?> </h3> <table class="form-table"> <?php foreach ($appthemes_extended_profile_fields as $field_id => $field_values) { if (isset($field_values['protected']) && $field_values['protected'] == 'yes' && !is_admin()) { $protected = 'disabled="disabled"'; } else { $protected = ''; } //TODO - use this value for display purposes while protecting stored value //prepare, modify, or filter the field value based on the field ID switch ($field_id) { case 'active_membership_pack': $the_display_value = get_pack(get_the_author_meta($field_id, $user->ID), '', 'pack_name'); break; default: $the_display_value = false; break; } $the_value = get_the_author_meta($field_id, $user->ID); //begin writing the row and heading ?> <tr id="<?php echo $field_id; ?> _row"> <th><label for="<?php echo $field_id; ?> "><?php echo esc_html($field_values['title']); ?> </label></th> <td> <?php //print the appropriate profile field based on the type of field switch ($field_values['type']) { case 'date': ?> <input type="text" name="<?php echo $field_id; ?> " id="<?php echo $field_id; ?> " value="<?php esc_attr_e($the_value); ?> " class="regular-text" size="35" <?php if (!empty($protected)) { echo 'style="display: none;"'; } ?> /><br /> <span class="description" <?php if (!empty($protected)) { echo 'style="display: none;"'; } ?> ><?php echo $field_values['admin_description']; ?> <br /></span> <input type="text" name="<?php echo $field_id; ?> _display" id="<?php echo $field_id; ?> " value="<?php esc_attr_e(appthemes_display_date($the_value)); ?> " class="regular-text" size="35" disabled="disabled" /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; case 'active_membership_pack': ?> <input type="text" name="<?php echo $field_id; ?> " id="<?php echo $field_id; ?> " value="<?php esc_attr_e($the_value); ?> " class="regular-text" size="35" <?php if (!empty($protected)) { echo 'style="display: none;"'; } ?> /><br /> <span class="description" <?php if (!empty($protected)) { echo 'style="display: none;"'; } ?> ><?php echo $field_values['admin_description']; ?> <br /></span> <input type="text" name="<?php echo $field_id; ?> _display" id="<?php echo $field_id; ?> " value="<?php esc_attr_e($the_display_value); ?> " class="regular-text" size="35" disabled="disabled" /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; default: ?> <input type="text" name="<?php echo $field_id; ?> " id="<?php echo $field_id; ?> " value="<?php echo esc_attr_e($the_value); ?> " class="regular-text" size="35" <?php echo $protected; ?> /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; case 'statedropdown': global $wpdb; $regions = $wpdb->get_var($wpdb->prepare("SELECT field_values FROM " . $wpdb->prefix . "cp_ad_fields WHERE field_name = 'cp_state';")); if ($regions) { ?> <select name="<?php echo $field_id; ?> " id="<?php echo $field_id; ?> " > <option value="">-- <?php _e('Seleccionar', 'appthemes'); ?> --</option> <?php $options = explode(',', $regions); foreach ($options as $option) { ?> <option <?php if ($the_value == trim($option)) { echo "selected='selected'"; } ?> value="<?php esc_attr_e($option); ?> "><?php esc_attr_e($option); ?> </option> <?php } ?> </select> <br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php } break; case 'typedropdown': global $wpdb; $regions = $wpdb->get_var($wpdb->prepare("SELECT field_values FROM " . $wpdb->prefix . "cp_ad_fields WHERE field_name = 'cp_type';")); if ($regions) { ?> <select name="<?php echo $field_id; ?> " id="<?php echo $field_id; ?> " > <option value="">-- <?php _e('Seleccionar', 'appthemes'); ?> --</option> <?php $options = explode(',', $regions); foreach ($options as $option) { ?> <option <?php if ($the_value == trim($option)) { echo "selected='selected'"; } ?> value="<?php esc_attr_e($option); ?> "><?php esc_attr_e($option); ?> </option> <?php } ?> </select> <br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php } break; //close the row ?> </td> </tr> <?php } } ?> </table> <?php }
function cp_membership_reminder_cron() { global $wpdb, $cp_options; if (!$cp_options->membership_ending_reminder_email) { return; } $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $subject = sprintf(__('Membership Subscription Ending on %s', APP_TD), $blogname); $siteurl = home_url('/'); $days_before = $cp_options->membership_ending_reminder_days; $days_before = is_numeric($days_before) ? $days_before : 7; $timestamp = wp_next_scheduled('cp_send_membership_reminder'); $timestamp = $timestamp - 1 * 24 * 60 * 60 + get_option('gmt_offset') * 3600; // minus 1 day to get current schedule time, plus GMT offset $date_max = date('Y-m-d H:i:s', $timestamp + $days_before * 24 * 60 * 60); $date_min = date('Y-m-d H:i:s', $timestamp + ($days_before - 1) * 24 * 60 * 60); $query_users = $wpdb->prepare("SELECT {$wpdb->users}.ID FROM {$wpdb->users}\n\t\tLEFT JOIN {$wpdb->usermeta} ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id\n\t\tWHERE {$wpdb->usermeta}.meta_key = 'membership_expires'\n\t\tAND {$wpdb->usermeta}.meta_value < %s\n\t\tAND {$wpdb->usermeta}.meta_value > %s\n\t\t", $date_max, $date_min); $userids = $wpdb->get_col($query_users); if (!$userids) { return; } foreach ($userids as $user_id) { $user = get_userdata($user_id); $mailto = $user->user_email; $user_login = appthemes_clean($user->user_login); $membership = get_pack($user->active_membership_pack); $membership_pack_name = appthemes_clean($membership->pack_name); $membership_expires = appthemes_display_date($user->membership_expires); $message = html('p', sprintf(__('Hi %s,', APP_TD), $user_login)) . PHP_EOL; $message .= html('p', sprintf(__('Your membership pack will expire in %d days! Please renew your membership to continue posting classified ads.', APP_TD), $days_before)) . PHP_EOL; $message_details = __('Membership Details', APP_TD) . '<br />'; $message_details .= __('-----------------', APP_TD) . '<br />'; $message_details .= sprintf(__('Membership Pack: %s', APP_TD), $membership_pack_name) . '<br />'; $message_details .= sprintf(__('Membership Expires: %s', APP_TD), $membership_expires) . '<br />'; $message_details .= sprintf(__('Renew Your Membership Pack: %s', APP_TD), CP_MEMBERSHIP_PURCHASE_URL) . '<br />'; $message .= html('p', $message_details) . PHP_EOL; $message .= html('p', sprintf(__('For questions or problems, please contact us directly at %s', APP_TD), get_option('admin_email'))); $message .= html('p', __('Regards,', APP_TD) . '<br />' . sprintf(__('Your %s Team', APP_TD), $blogname)); $message .= html('p', $siteurl); $email = array('to' => $mailto, 'subject' => $subject, 'message' => $message); $email = apply_filters('cp_email_user_membership_reminder', $email, $order); appthemes_send_email($email['to'], $email['subject'], $email['message']); } }
/** * Displays ad listing custom columns data. * * @param string $column_index * @param int $post_id * * @return void */ function cp_ad_listing_add_column_data($column_index, $post_id) { $post = get_post($post_id); if (!$post) { return; } $post_meta = get_post_custom($post_id); switch ($column_index) { case 'cp_sys_expire_date': if (isset($post_meta['cp_sys_expire_date'][0]) && !empty($post_meta['cp_sys_expire_date'][0])) { echo appthemes_display_date($post_meta['cp_sys_expire_date'][0]); } break; case 'cp_price': cp_get_price($post->ID, 'cp_price'); break; case 'cp_daily_count': if (isset($post_meta['cp_daily_count'][0]) && !empty($post_meta['cp_daily_count'][0])) { echo $post_meta['cp_daily_count'][0]; } break; case 'cp_total_count': if (isset($post_meta['cp_total_count'][0]) && !empty($post_meta['cp_total_count'][0])) { echo $post_meta['cp_total_count'][0]; } break; } }
function cp_profile_fields($user) { global $appthemes_extended_profile_fields; ?> <h3><?php _e('Extended Profile', APP_TD); ?> </h3> <table class="form-table"> <?php foreach ($appthemes_extended_profile_fields as $field_id => $field_values) { if (isset($field_values['protected']) && $field_values['protected'] == 'yes' && !is_admin()) { $protected = 'disabled="disabled"'; } else { $protected = ''; } //TODO - use this value for display purposes while protecting stored value //prepare, modify, or filter the field value based on the field ID switch ($field_id) { case 'active_membership_pack': $user_active_pack = get_the_author_meta($field_id, $user->ID); $package = cp_get_membership_package($user_active_pack); $the_display_value = $package ? $package->pack_name : false; break; default: $the_display_value = false; break; } $the_value = get_the_author_meta($field_id, $user->ID); //begin writing the row and heading ?> <tr id="<?php echo esc_attr($field_id); ?> _row"> <th><label for="<?php echo esc_attr($field_id); ?> "><?php echo esc_html($field_values['title']); ?> </label></th> <td> <?php //print the appropriate profile field based on the type of field switch ($field_values['type']) { case 'date': $display_date = !empty($the_value) ? appthemes_display_date($the_value) : ''; if (!$protected) { ?> <input type="text" name="<?php echo esc_attr($field_id); ?> " id="<?php echo esc_attr($field_id); ?> " value="<?php echo esc_attr($the_value); ?> " class="regular-text" size="35" /><br /> <span class="description"><?php echo esc_attr($field_values['admin_description']); ?> <br /></span> <?php } ?> <input type="text" name="<?php echo esc_attr($field_id); ?> _display" id="<?php echo esc_attr($field_id); ?> " value="<?php echo esc_attr($display_date); ?> " class="regular-text" size="35" disabled="disabled" /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; case 'active_membership_pack': if (!$protected) { ?> <input type="text" name="<?php echo esc_attr($field_id); ?> " id="<?php echo esc_attr($field_id); ?> " value="<?php echo esc_attr($the_value); ?> " class="regular-text" size="35" /><br /> <span class="description"><?php echo esc_attr($field_values['admin_description']); ?> <br /></span> <?php } ?> <input type="text" name="<?php echo esc_attr($field_id); ?> _display" id="<?php echo esc_attr($field_id); ?> " value="<?php echo esc_attr($the_display_value); ?> " class="regular-text" size="35" disabled="disabled" /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; default: ?> <input type="text" name="<?php echo esc_attr($field_id); ?> " id="<?php echo esc_attr($field_id); ?> " value="<?php echo esc_attr($the_value); ?> " class="regular-text" size="35" <?php echo esc_attr($protected); ?> /><br /> <span class="description"><?php echo $field_values['description']; ?> </span> <?php break; //close the row ?> </td> </tr> <?php } } ?> </table> <?php }
<td> <h3> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h3> <div class="meta"><span class="folder"><?php echo get_the_term_list(get_the_id(), APP_TAX_CAT, '', ', ', ''); ?> </span> | <span class="clock"><span><?php echo appthemes_display_date($post->post_date, 'date'); ?> </span></span></div> </td> <td class="text-center"><?php echo $ad_views; ?> </td> <td class="text-center"><span style="color:<?php echo $fontcolor; ?> ;"><?php echo $post_status_name; ?>
function cp_get_ad_images($ad_id) { $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $ad_id, 'order' => 'ASC', 'orderby' => 'ID', 'no_found_rows' => true); // get all the images associated to this ad $images = get_posts($args); // print_r($images); // for debugging // get the total number of images already on this ad // we need it to figure out how many upload fields to show $imagecount = count($images); // make sure we have images associated to the ad if ($images) { $i = 1; $media_dims = ''; foreach ($images as $image) { // go get the width and height fields since they are stored in meta data $meta = wp_get_attachment_metadata($image->ID); if (is_array($meta) && array_key_exists('width', $meta) && array_key_exists('height', $meta)) { $media_dims = "<span id='media-dims-" . $image->ID . "'>{$meta['width']} × {$meta['height']}</span> "; } ?> <li class="images"> <div class="labelwrapper"> <label><?php _e('Image', APP_TD); ?> <?php echo $i; ?> :</label> </div> <div class="thumb-wrap-edit"> <?php echo cp_get_attachment_link($image->ID); ?> </div> <div class="image-meta"> <p class="image-delete"><input class="checkbox" type="checkbox" name="image[]" value="<?php echo $image->ID; ?> "> <?php _e('Delete Image', APP_TD); ?> </p> <p class="image-meta"><strong><?php _e('Upload Date:', APP_TD); ?> </strong> <?php echo appthemes_display_date($image->post_date, 'date'); ?> </p> <p class="image-meta"><strong><?php _e('File Info:', APP_TD); ?> </strong> <?php echo $media_dims; ?> <?php echo $image->post_mime_type; ?> </p> </div> <div class="clr"></div> <?php // get the alt text and print out the field $alt = get_post_meta($image->ID, '_wp_attachment_image_alt', true); ?> <p class="alt-text"> <div class="labelwrapper"> <label><?php _e('Alt Text:', APP_TD); ?> </label> </div> <input type="text" class="text" name="attachments[<?php echo $image->ID; ?> ][image_alt]" id="image_alt" value="<?php if (count($alt)) { echo esc_attr(stripslashes($alt)); } ?> " /> </p> <div class="clr"></div> </li> <?php $i++; } } // returns a count of array keys so we know how many images currently // are being used with this ad. this value is needed for cp_ad_edit_image_input_fields() return $imagecount; }
echo appthemes_display_date($current_user->membership_expires); ?> </div> <div class="clr"></div> </li> <li> <div class="labelwrapper"><label><strong><?php _e('New Expiration:', 'appthemes'); ?> </strong></label></div> <div id="active_membership_pack"> <?php if ($membership->pack_membership_price > 0) { echo appthemes_display_date(appthemes_mysql_date($current_user->membership_expires, $membership->pack_duration)); } else { echo appthemes_display_date(appthemes_mysql_date(current_time('mysql'), $membership->pack_duration)); } ?> </div> <div class="clr"></div> </li> <?php } ?> <li> <div class="labelwrapper"> <label><?php _e('Membership Purchase Fee', 'appthemes'); ?> :</label>
<li> <strong><?php _e('Membership Pack:', APP_TD); ?> </strong> <?php echo stripslashes($order_processed['pack_name']); ?> </li> <li> <strong><?php _e('Membership Expires:', APP_TD); ?> </strong> <?php echo appthemes_display_date($order_processed['updated_expires_date']); ?> </li> </ul> <div class="pad50"></div> <?php do_action('appthemes_after_membership_confirmation'); ?> <?php // remove the order option from the database because the free order was processed delete_option($cp_user_recent_order); } ?>
/** * Sends email reminder about ending membership plan, default is 7 days before expire. * Cron jobs execute the following function once per day. * * @return void */ function cp_membership_reminder_cron() { global $wpdb, $cp_options; if (!$cp_options->membership_ending_reminder_email) { return; } $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $subject = sprintf(__('Membership Subscription Ending on %s', APP_TD), $blogname); $siteurl = home_url('/'); $days_before = $cp_options->membership_ending_reminder_days; $days_before = is_numeric($days_before) ? $days_before : 7; $timestamp = wp_next_scheduled('cp_send_membership_reminder'); $timestamp = $timestamp - 1 * 24 * 60 * 60 + get_option('gmt_offset') * 3600; // minus 1 day to get current schedule time, plus GMT offset $date_max = date('Y-m-d H:i:s', $timestamp + $days_before * 24 * 60 * 60); $date_min = date('Y-m-d H:i:s', $timestamp + ($days_before - 1) * 24 * 60 * 60); $query_users = $wpdb->prepare("SELECT {$wpdb->users}.ID FROM {$wpdb->users}\n\t\tLEFT JOIN {$wpdb->usermeta} ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id\n\t\tWHERE {$wpdb->usermeta}.meta_key = 'membership_expires'\n\t\tAND {$wpdb->usermeta}.meta_value < %s\n\t\tAND {$wpdb->usermeta}.meta_value > %s\n\t\t", $date_max, $date_min); $userids = $wpdb->get_col($query_users); if (!$userids) { return; } $users = array(); foreach ($userids as $user_id) { $user = get_userdata($user_id); $mailto = $user->user_email; $user_login = appthemes_clean($user->user_login); $membership = cp_get_membership_package($user->active_membership_pack); $membership_pack_name = appthemes_clean($membership->pack_name); $membership_expires = appthemes_display_date($user->membership_expires); $message = html('p', sprintf(__('Hi %s,', APP_TD), $user_login)) . PHP_EOL; $message .= html('p', sprintf(__('Your membership pack will expire in %d days! Please renew your membership to continue posting classified ads.', APP_TD), $days_before)) . PHP_EOL; $message_details = __('Membership Details', APP_TD) . '<br />'; $message_details .= __('-----------------', APP_TD) . '<br />'; $message_details .= sprintf(__('Membership Pack: %s', APP_TD), $membership_pack_name) . '<br />'; $message_details .= sprintf(__('Membership Expires: %s', APP_TD), $membership_expires) . '<br />'; $message_details .= sprintf(__('Renew Your Membership Pack: %s', APP_TD), html_link(CP_MEMBERSHIP_PURCHASE_URL)) . '<br />'; $message .= html('p', $message_details) . PHP_EOL; $message .= html('p', sprintf(__('For questions or problems, please contact us directly at %s', APP_TD), get_option('admin_email'))); $message .= html('p', __('Regards,', APP_TD) . '<br />' . sprintf(__('Your %s Team', APP_TD), $blogname)); $message .= html('p', html_link($siteurl)); $email = array('to' => $mailto, 'subject' => $subject, 'message' => $message); $email = apply_filters('cp_email_user_membership_reminder', $email, $user_id); appthemes_send_email($email['to'], $email['subject'], $email['message']); $users[$user_id] = array('user' => html_link(sprintf('mailto:%s', $user->user_email), $user->user_login), 'membership' => $membership->pack_name, 'expires' => $user->membership_expires); } // allow overriding admin notifications if (!apply_filters('cp_admin_membership_reminder', true, $users)) { return; } ### notify admin // loop through the users again to notify the admin about expiring memberships foreach ($users as $user_id => $data) { $items[] = $data; } if (!empty($items)) { $table = new APP_Email_Table($items); $admin_email = get_option('admin_email'); $message = html('p', __('Dear Admin,', APP_TD)) . PHP_EOL; $message .= html('p', sprintf(__('Membership pack for these users expire in %d days! These users will need to renew their membership to continue posting classified ads on your site:', APP_TD), $days_before)) . PHP_EOL; $message .= html('p', $table->display()) . PHP_EOL; $email = array('to' => $admin_email, 'subject' => $subject, 'message' => $message); appthemes_send_email($email['to'], $email['subject'], $email['message']); } }