public static function all_for_post($post_id, $args = array()) { $enclosures = array(); $file_types_for_this_episode = array(); $wordpress_enclosures = get_post_meta($post_id, 'enclosure', false); foreach ($wordpress_enclosures as $enclosure_data) { $enclosure = Enclosure::from_enclosure_meta($enclosure_data, $post_id); if ($enclosure->file_type && !in_array($enclosure->file_type->id, $file_types_for_this_episode)) { $file_types_for_this_episode[] = $enclosure->file_type->id; } $enclosures[] = $enclosure; } // process podPress files $podPress_enclosures = get_post_meta($post_id, '_podPressMedia', false); if (is_array($podPress_enclosures) && !empty($podPress_enclosures)) { foreach ($podPress_enclosures[0] as $file) { $enclosure = Enclosure::from_enclosure_podPress($file, $post_id); if (in_array($enclosure->file_type->id, $file_types_for_this_episode)) { continue; } $file_types_for_this_episode[] = $enclosure->file_type->id; $enclosures[] = $enclosure; } } // if ( isset( $args['only_valid'] ) && $args['only_valid'] ) { // foreach ( $enclosures as $enclosure ) { // if ( $enclosure->errors ) { // // unset( current( $enclosure ) ); // } // } // } return $enclosures; }
function generate_ryuzine_stylesheets() { // verify this came from the our screen and with proper authorization. if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) { return; } // Check permissions if (!current_user_can('administrator')) { echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>"; return; } $my_query = null; $my_query = new WP_Query(array('post_type' => 'ryuzine')); if ($my_query->have_posts()) { while ($my_query->have_posts()) { $my_query->the_post(); $stylesheet = ""; $issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false); if (!empty($issuestyles)) { foreach ($issuestyles as $appendstyle) { // If there are multiple ryustyles append them // $stylesheet = $stylesheet . $appendstyle; } } if ($stylesheet != "") { ryu_create_css($stylesheet, get_the_ID()); } } } // reset css check // // update_option('ryu_css_admin',0); wp_reset_query(); return; }
/** * Outputs any floor plan links for virtual tours on the property templates * * When the hook epl_buttons_single_property is used and the property * has floor plans links they will be output on the template */ function epl_button_floor_plan() { $floor_plan = get_post_meta(get_the_ID(), 'property_floorplan', true); $floor_plan_2 = get_post_meta(get_the_ID(), 'property_floorplan_2', true); $links = array(); if (!empty($floor_plan)) { $links[] = $floor_plan; } if (!empty($floor_plan_2)) { $links[] = $floor_plan_2; } if (!empty($links)) { foreach ($links as $k => $link) { if (!empty($link)) { $number_string = ''; if ($k > 0) { $number_string = ' ' . $k + 1; } ?> <span class="epl-floor-plan-button-wrapper<?php echo $number_string; ?> "> <button type="button" class="epl-button epl-floor-plan" onclick="location.href='<?php echo $link; ?> '"><?php echo apply_filters('epl_button_label_floorplan', __('Floor Plan', 'epl')) . $number_string; ?> </button></span><?php } } } }
function moxie_press_endpoint_data() { global $wp_query; // get query vars $json = $wp_query->get('json'); $name = $wp_query->get('name'); // use this template redirect only if json is requested if ($json != 'true') { return; } // build the query $movie_data = array(); // default args $args = array('post_type' => 'movie', 'posts_per_page' => 100); if ($name != '') { $args['name'] = $name; } // add name if provided in query // check if this particular request is cached, if not, perform the query if (false === ($moxie_cached_request = get_transient('moxie_cached_request_' . json_encode($args)))) { $moxie_cached_request = new WP_Query($args); set_transient('moxie_cached_request_' . json_encode($args), $moxie_cached_request); } // prepare the object we want to send as response if ($moxie_cached_request->have_posts()) { while ($moxie_cached_request->have_posts()) { $moxie_cached_request->the_post(); $id = get_the_ID(); $movie_data[] = array('id' => $id, 'title' => get_the_title(), 'poster_url' => get_post_meta($id, 'moxie_press_poster_url', true), 'rating' => get_post_meta($id, 'moxie_press_rating', true), 'year' => get_post_meta($id, 'moxie_press_year', true), 'short_description' => get_post_meta($id, 'moxie_press_description', true), 'mdbid' => get_post_meta($id, 'moxie_press_mdbid', true)); } wp_reset_postdata(); } // send json data using built-in WP function wp_send_json(array('data' => $movie_data)); }
/** * Add custom fields to $item nav object * in order to be used in custom Walker * * @access public * @since 1.0 * @return void */ function add_custom_nav_fields($menu_item) { foreach ($this->custom_fields as $key) { $menu_item->{$key} = get_post_meta($menu_item->ID, '_menu_item_megamenu_' . $key, true); } return $menu_item; }
static function setup_slider($slider_id, $settings) { self::set_active_skin(get_post_meta($slider_id, 'skin', true)); self::$slider_id = $slider_id; self::$slider_shortcode_atts = $settings; self::$slider_settings = muneeb_ssp_slider_options($slider_id); }
function ultimatum_meta() { global $wpdb; $table=$wpdb->prefix.ULTIMATUM_PREFIX.'_layout'; $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; wp_nonce_field( 'ultimatum_additional_meta', 'ultimatum_additional_meta_nonce' ); echo '<p><label for="ultimatum_author">'; _e("Show Author Info", 'ultimatum'); echo '</label>'; echo '<select name="ultimatum_author">'; $cura= get_post_meta($post_id,'ultimatum_author',true); echo '<option value="false"'; if($cura=='false') { echo ' selected="selected" '; } echo '>OFF</option>'; echo '<option value="true"'; if($cura=='true') { echo ' selected="selected" '; } echo '>ON</option>'; echo '</select></p>'; echo '<p><label for="ultimatum_video">'; _e("Video URL", 'ultimatum'); echo '</label>'; $curv= get_post_meta($post_id,'ultimatum_video',true); echo '<input type="text" name="ultimatum_video" value="'.$curv.'" size="50" />'; _e("Used in slideshows as post info ", 'ultimatum'); echo '</p>'; }
function swp_buffer_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['buffer'])) { $array['resource']['buffer'] = $_GLOBALS['sw']['buttons'][$array['postID']]['buffer']; // If not, let's check if Buffer is activated and create the button HTML } elseif (isset($array['options']['newOrderOfIcons']['buffer']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['buffer'])) { // Collect the Title $title = get_post_meta($array['postID'], 'nc_ogTitle', true); if (!$title) { $title = get_the_title(); } $array['totes'] += $array['shares']['buffer']; ++$array['count']; $array['resource']['buffer'] = '<div class="nc_tweetContainer swp_buffer" data-id="' . $array['count'] . '" data-network="buffer">'; $link = urlencode(urldecode(swp_process_url($array['url'], 'buffer', $array['postID']))); $array['resource']['buffer'] .= '<a target="_blank" href="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" data-link="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" class="nc_tweet buffer_link">'; if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['buffer'] > 0) { $array['resource']['buffer'] .= '<span class="iconFiller">'; $array['resource']['buffer'] .= '<span class="spaceManWilly">'; $array['resource']['buffer'] .= '<i class="sw sw-buffer"></i>'; $array['resource']['buffer'] .= '<span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span>'; $array['resource']['buffer'] .= '</span></span>'; $array['resource']['buffer'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['buffer']) . '</span>'; } else { $array['resource']['buffer'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-buffer"></i><span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span></span></span></span>'; } $array['resource']['buffer'] .= '</a>'; $array['resource']['buffer'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['buffer'] = $array['resource']['buffer']; } return $array; }
/** * Displaying Prodcuts * * Does prepare the data for displaying the products in the table. */ function display_seller_review() { $data = array(); $prefix = FARMTOYOU_META_PREFIX; //if search is call then pass searching value to function for displaying searching values $args = array('post_type' => FARMTOYOU_SELLER_REVIEW_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => '-1'); //get seller_review data from database $all_seller_review = get_posts($args); foreach ($all_seller_review as $key => $value) { $seller_id = get_post_meta($value->ID, $prefix . 'seller_id', true); $store_info = dokan_get_store_info($seller_id); $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan'); $curr_user_id = get_post_meta($value->ID, $prefix . 'current_user_id', true); $user_info = get_userdata($curr_user_id); $first_name = $user_info->first_name; $last_name = $user_info->last_name; $user_email = $user_info->user_email; $data[$key]['ID'] = isset($value->ID) ? $value->ID : ''; $data[$key]['seller_store'] = $store_name; $data[$key]['curr_user_name'] = $first_name . " " . $last_name; $data[$key]['curr_user_email'] = $user_email; $data[$key]['user_rating'] = get_post_meta($value->ID, $prefix . 'seller_rating', true); $data[$key]['user_comment'] = get_post_meta($value->ID, $prefix . 'user_comment', true); $data[$key]['post_status'] = isset($value->post_status) ? $value->post_status : ''; $data[$key]['post_date'] = isset($value->post_date) ? $value->post_date : ''; } return $data; }
function wpex_gallery_is_lightbox_enabled() { $link_images = get_post_meta(get_the_ID(), '_easy_image_gallery_link_images', true); if ('on' == $link_images) { return true; } }
function tz_save_data_page($post_id) { global $meta_box_category; // verify nonce if (!isset($_POST['tz_meta_box_nonce']) || !wp_verify_nonce($_POST['tz_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box_category['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } }
public function metabox_edit($post, $metabox) { wp_nonce_field(MI_PREFIX . 'meta_box', MI_PREFIX . 'meta_box_nonce'); $html .= ' <input type="hidden" name="metabox[]" id="metabox[]" value="' . $metabox['id'] . '"> <table class="form-table"> <tbody> '; $mi_forms = new MI_Forms(); foreach ($metabox['args']['fields'] as $id => $field) { $form = $mi_forms->field($id, $field, get_post_meta($post->ID, MI_PREFIX . $id, true)); $html .= ' <tr> <th scope="row"><label for="' . $form->name . '">' . $form->label . '</label></th> <td> '; $html .= $form->field; $html .= $form->desc ? '<p class="description">' . $form->desc . '</p>' : ''; $html .= ' </td> </tr> '; } $html .= ' </tbody> </table> '; echo $html; }
function create_page_option_elements() { global $post; $option_value = gdlr_decode_preventslashes(get_post_meta($post->ID, $this->setting['option_name'], true)); if (!empty($option_value)) { $option_value = json_decode($option_value, true); } $option_generator = new gdlr_admin_option_html(); echo '<div class="gdlr-page-option-wrapper position-' . $this->setting['position'] . '" >'; foreach ($this->option as $option_section) { echo '<div class="gdlr-page-option">'; echo '<div class="gdlr-page-option-title">' . $option_section['title'] . '</div>'; echo '<div class="gdlr-page-option-input-wrapper">'; foreach ($option_section['options'] as $option_slug => $option) { $option['slug'] = $option_slug; $option['name'] = ''; if (!empty($option_value) && isset($option_value[$option_slug])) { $option['value'] = $option_value[$option_slug]; } $option_generator->generate_admin_option($option); } echo '</div>'; // page-option-input-wrapper echo '</div>'; // page-option-title } echo '<textarea class="gdlr-input-hidden" name="' . $this->setting['option_name'] . '"></textarea>'; echo '</div>'; // gdlr-page-option-wrapper }
function save_newsletter($post_id) { // verify nonce if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('newsletter' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } $old = get_post_meta($post_id, "name", true); $new = $_POST["name"]; if ($new && $new != $old) { update_post_meta($post_id, "name", $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, "name", $old); } }
function like_post($post_id, $action = 'get') { if (!is_numeric($post_id)) { return; } switch ($action) { case 'get': $like_count = get_post_meta($post_id, '_qode-like', true); if (!$like_count) { $like_count = 0; add_post_meta($post_id, '_qode-like', $like_count, true); } return '<span class="qode-like-count">' . $like_count . '</span>'; break; case 'update': $like_count = get_post_meta($post_id, '_qode-like', true); if (isset($_COOKIE['qode-like_' . $post_id])) { return $like_count; } $like_count++; update_post_meta($post_id, '_qode-like', $like_count); setcookie('qode-like_' . $post_id, $post_id, time() * 20, '/'); return '<span class="qode-like-count">' . $like_count . '</span>'; break; } }
function mango_add_custom_nav_fields($menu_item) { $menu_item->icon = get_post_meta($menu_item->ID, '_menu_item_icon', true); $menu_item->icon_pos = get_post_meta($menu_item->ID, '_menu_item_icon_pos', true); $menu_item->nolink = get_post_meta($menu_item->ID, '_menu_item_nolink', true); $menu_item->hide = get_post_meta($menu_item->ID, '_menu_item_hide', true); $menu_item->mobile_hide = get_post_meta($menu_item->ID, '_menu_item_mobile_hide', true); $menu_item->hide_cat_image = get_post_meta($menu_item->ID, '_menu_item_hide_cat_image', true); $menu_item->hide_subcats_list = get_post_meta($menu_item->ID, '_menu_item_hide_subcats_list', true); $menu_item->hide_empty_subcats = get_post_meta($menu_item->ID, '_menu_item_hide_empty_subcats', true); $menu_item->cols = get_post_meta($menu_item->ID, '_menu_item_cols', true); $menu_item->tip_label = get_post_meta($menu_item->ID, '_menu_item_tip_label', true); $menu_item->tip_color = get_post_meta($menu_item->ID, '_menu_item_tip_color', true); $menu_item->tip_bg = get_post_meta($menu_item->ID, '_menu_item_tip_bg', true); $menu_item->popup_type = get_post_meta($menu_item->ID, '_menu_item_popup_type', true); $menu_item->popup_pos = get_post_meta($menu_item->ID, '_menu_item_popup_pos', true); $menu_item->popup_cols = get_post_meta($menu_item->ID, '_menu_item_popup_cols', true); $menu_item->popup_bg_image = get_post_meta($menu_item->ID, '_menu_item_popup_bg_image', true); $menu_item->popup_bg_pos = get_post_meta($menu_item->ID, '_menu_item_popup_bg_pos', true); $menu_item->popup_bg_repeat = get_post_meta($menu_item->ID, '_menu_item_popup_bg_repeat', true); $menu_item->popup_bg_size = get_post_meta($menu_item->ID, '_menu_item_popup_bg_size', true); $menu_item->popup_style = get_post_meta($menu_item->ID, '_menu_item_popup_style', true); $menu_item->subpopup_bg_image = get_post_meta($menu_item->ID, '_menu_item_subpopup_bg_image', true); $menu_item->subpopup_bg_pos = get_post_meta($menu_item->ID, '_menu_item_subpopup_bg_pos', true); $menu_item->subpopup_bg_repeat = get_post_meta($menu_item->ID, '_menu_item_subpopup_bg_repeat', true); $menu_item->subpopup_bg_size = get_post_meta($menu_item->ID, '_menu_item_subpopup_bg_size', true); $menu_item->subpopup_style = get_post_meta($menu_item->ID, '_menu_item_subpopup_style', true); $menu_item->block = get_post_meta($menu_item->ID, '_menu_item_block', true); $menu_item->show_category_img = get_post_meta($menu_item->ID, '_menu_item_show_category_img', true); return $menu_item; }
function comcon_meta_save() { global $post; $post_id = $post->ID; if (!isset($_POST['comcon-form-nonce']) || !wp_verify_nonce($_POST['comcon-form-nonce'], basename(__FILE__))) { return $post->ID; } $post_type = get_post_type_object($post->post_type); if (!current_user_can($post_type->cap->edit_post, $post_id)) { return $post->ID; } $input = array(); $input['position'] = isset($_POST['comcon-form-position']) ? $_POST['comcon-form-position'] : ''; $input['major'] = isset($_POST['comcon-form-major']) ? $_POST['comcon-form-major'] : ''; $input['order'] = str_pad($input['order'], 3, "0", STR_PAD_LEFT); foreach ($input as $field => $value) { $old = get_post_meta($post_id, 'comcon-form-' . $field, true); if ($value && '' == $old) { add_post_meta($post_id, 'comcon-form-' . $field, $value, true); } else { if ($value && $value != $old) { update_post_meta($post_id, 'comcon-form-' . $field, $value); } else { if ('' == $value && $old) { delete_post_meta($post_id, 'comcon-form-' . $field, $old); } } } } }
/** * Create a simple subscription product object. * * @access public * @param mixed $product */ public function __construct($product) { parent::__construct($product); $this->product_type = 'subscription'; // Load all meta fields $this->product_custom_fields = get_post_meta($this->id); // Convert selected subscription meta fields for easy access if (!empty($this->product_custom_fields['_subscription_price'][0])) { $this->subscription_price = $this->product_custom_fields['_subscription_price'][0]; } if (!empty($this->product_custom_fields['_subscription_period'][0])) { $this->subscription_period = $this->product_custom_fields['_subscription_period'][0]; } if (!empty($this->product_custom_fields['_subscription_period_interval'][0])) { $this->subscription_period_interval = $this->product_custom_fields['_subscription_period_interval'][0]; } if (!empty($this->product_custom_fields['_subscription_length'][0])) { $this->subscription_length = $this->product_custom_fields['_subscription_length'][0]; } if (!empty($this->product_custom_fields['_subscription_trial_length'][0])) { $this->subscription_trial_length = $this->product_custom_fields['_subscription_trial_length'][0]; } if (!empty($this->product_custom_fields['_subscription_trial_period'][0])) { $this->subscription_trial_period = $this->product_custom_fields['_subscription_trial_period'][0]; } if (!empty($this->product_custom_fields['_subscription_sign_up_fee'][0])) { $this->subscription_sign_up_fee = $this->product_custom_fields['_subscription_sign_up_fee'][0]; } $this->limit_subscriptions = !isset($this->product_custom_fields['_subscription_limit'][0]) ? 'no' : $this->product_custom_fields['_subscription_limit'][0]; }
function karma_post($post_id, $action = 'get') { if (!is_numeric($post_id)) { return; } $karma_count = get_post_meta($post_id, $this->option_key, true); switch ($action) { case 'get': if (!$karma_count) { $karma_count = 0; add_post_meta($post_id, $this->option_key, $karma_count, true); } return $karma_count; break; case 'update': if (isset($_COOKIE[$this->option_key . $post_id])) { return $karma_count; } $karma_count++; update_post_meta($post_id, $this->option_key, $karma_count); setcookie($this->option_key . $post_id, $post_id, time() * 20, '/'); return $karma_count; break; } }
function znpb_add_kallyas_template($current_layout, $post, $post_id) { if (!is_page($post_id)) { return $current_layout; } $sidebar_pos = get_post_meta($post_id, 'zn_page_layout', true); $sidebar_to_use = get_post_meta($post_id, 'zn_sidebar_select', true); $subheader_style = get_post_meta($post_id, 'zn_subheader_style', true) !== '0' ? get_post_meta($post_id, 'zn_subheader_style', true) : 'zn_def_header_style'; $sidebar_saved_data = zget_option('page_sidebar', 'unlimited_sidebars', false, array('layout' => 'right_sidebar', 'sidebar' => 'defaultsidebar')); if ($sidebar_pos == 'default' || empty($sidebar_pos)) { $sidebar_pos = $sidebar_saved_data['layout']; } if ($sidebar_to_use == 'default' || empty($sidebar_to_use)) { $sidebar_to_use = $sidebar_saved_data['sidebar']; } // We will add the new elements here $sidebar = ZNPB()->add_module_to_layout('TH_Sidebar', array('sidebar_select' => $sidebar_to_use)); $sidebar_column = ZNPB()->add_module_to_layout('ZnColumn', array(), array($sidebar), 'col-sm-3'); $sections[] = ZNPB()->add_module_to_layout('TH_CustomSubHeaderLayout', array('hm_header_style' => $subheader_style)); // If the sidebar was saved as left sidebar if ($sidebar_pos == 'left_sidebar') { $columns[] = $sidebar_column; } // Add the main shop content $archive_columns = $sidebar_pos == 'no_sidebar' ? 4 : 3; $textbox = ZNPB()->add_module_to_layout('TH_TextBox', array('stb_title' => $post->post_title, 'stb_content' => $post->post_content)); $columns[] = ZNPB()->add_module_to_layout('ZnColumn', array(), array($textbox), 'col-sm-9'); // If the sidebar was saved as right sidebar if ($sidebar_pos == 'right_sidebar') { $columns[] = $sidebar_column; } $sections[] = ZNPB()->add_module_to_layout('ZnSection', array(), $columns, 'col-sm-12'); return $sections; }
/** * Output the menu post type content. * * @since 1.0.0 */ function school_menu_output() { $menus = get_post_meta(get_the_id(), 'menus', true); if ($menus) { echo '<div class="school-menu-wrapper">'; for ($i = 0; $i < $menus; $i++) { $course = get_post_meta(get_the_id(), 'menus_' . $i . '_course', true); $menu_item = get_post_meta(get_the_id(), 'menus_' . $i . '_menu_item_name', true); $price = get_post_meta(get_the_id(), 'menus_' . $i . '_price', true); $source = get_post_meta(get_the_id(), 'menus_' . $i . '_source', true); $description = get_post_meta(get_the_id(), 'menus_' . $i . '_menu_item_description', true); if (!empty($course)) { echo '<h2 class="school-menu-course">' . esc_attr($course) . '</h2>'; } echo '<h3 class="school-menu-item-heading">'; echo '<span class"school-menu-item">' . esc_attr($menu_item) . '</span>'; echo '<span class="school-menu-price">' . esc_attr($price) . '</span>'; echo '</h3>'; if (!empty($source)) { echo '<p class="school-menu-source">' . esc_attr($source) . '</p>'; } echo '<p class="school-menu-description">' . esc_attr($description) . '</p>'; } echo '</div>'; } }
function echo_state_results() { $args = array('post_type' => 'property', 'posts_per_page' => '99999'); $query = new WP_Query($args); $stateCount = array(); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if (get_post_meta($query->post->ID, 'state', true)) { $cur = 0; if ($stateCount[get_post_meta($query->post->ID, 'state', true)]) { $cur = $stateCount[get_post_meta($query->post->ID, 'state', true)]; } $stateCount[get_post_meta($query->post->ID, 'state', true)] = $cur + 1; } //echo '(' . get_post_meta( $query->post->ID, 'state', true ). ') '; } } echo '<script type="text/javascript">'; //echo 'var stateCount = []; stateCount["Arizona"]=0; stateCount["Colorado"]=0; stateCount["Delaware"]=0; stateCount["Florida"]=0; stateCount["Georgia"]=0; stateCount["Hawaii"]=0; stateCount["Idaho"]=0; stateCount["Illinois"]=0; stateCount["Indiana"]=0; stateCount["Iowa"]=0; stateCount["Kansas"]=0; stateCount["Kentucky"]=0; stateCount["Louisiana"]=0; stateCount["Maryland"]=0; stateCount["Maine"]=0; stateCount["Massachusetts"]=0; stateCount["Minnesota"]=0; stateCount["Michigan"]=0; stateCount["Mississippi"]=0; stateCount["Missouri"]=0; stateCount["Montana"]=0; stateCount["NorthCarolina"]=0; stateCount["Nebraska"]=0; stateCount["Nevada"]=0; stateCount["NewHampshire"]=0; stateCount["NewJersey"]=0; stateCount["NewYork"]=0; stateCount["NorthDakota"]=0; stateCount["NewMexico"]=0; stateCount["Ohio"]=0; stateCount["Oklahoma"]=0; stateCount["Oregon"]=0; stateCount["Pennsylvania"]=0; stateCount["RhodeIsland"]=0; stateCount["SouthCarolina"]=0; stateCount["SouthDakota"]=0; stateCount["Tennessee"]=0; stateCount["Texas"]=0; stateCount["Utah"]=0; stateCount["Wisconsin"]=0; stateCount["Virginia"]=0; stateCount["Vermont"]=0; stateCount["Washington"]=0; stateCount["WestVirginia"]=0; stateCount["Wyoming"]=0; stateCount["California"]=0; stateCount["Connecticut"]=0; stateCount["Alaska"]=0; stateCount["Arkansas"]=0; stateCount["Alabama"]=0;'; echo 'var stateCount = [];'; foreach ($stateCount as $key => $value) { echo 'stateCount["' . str_replace(' ', '', $key) . '"] = "' . $value . '";'; } echo '</script>'; }
function es_participants_limit($id) { global $wpdb; $meta = get_post_meta($id); ?> <table id="event_limit" class="eventtable limit"> <thead> <tr> <td colspan="2" class="tribe_sectionheader"> <h4 id="spots">Nombre de places</h4> </td> </tr> </thead> <tbody> <tr> <td> <input min="3" autocomplete="off" type="number" name="EventSpotsLimit" id="EventSpotsLimit" value="<?php echo $meta["event_spots_limit"][0]; ?> " /> <br><br> <p> En plus de ces <span class="event-spot-limit-value">3</span> places, <strong>1</strong> place supplémentaire est réservée à la <strong>liste d'attente</strong>. </p> </td> </tr> </tbody> </table> <?php }
/** * Init the mailer and call for the cancelled email notification hook. * * @param $subscription WC Subscription * @since 2.0 */ public static function send_cancelled_email($subscription) { WC()->mailer(); if ($subscription->has_status(array('pending-cancel', 'cancelled')) && 'true' !== get_post_meta($subscription->id, '_cancelled_email_sent', true)) { do_action('cancelled_subscription_notification', $subscription); } }
/** * Check post/page content for auto terms * * @param integer $post_id * @param object $object * @return boolean */ function saveAutoTerms($post_id = null, $object = null) { // Get options $options = get_option(STAGS_OPTIONS_NAME_AUTO); // Auto terms for this CPT ? if (!isset($options[$object->post_type]) || empty($options[$object->post_type])) { return false; } // user preference for this post ? $meta_value = get_post_meta($object->ID, '_exclude_autotags', true); if (!empty($meta_value)) { return false; } // Loop option for find if autoterms is actived on any taxo $flag = false; foreach ($options[$object->post_type] as $taxo_name => $local_options) { if (!isset($local_options['use_auto_terms']) || $local_options['use_auto_terms'] != '1') { continue; } $this->autoTermsPost($object, $taxo_name, $local_options); $flag = true; } if ($flag == true) { // Clean cache ? if (isset($object->post_type) && $object->post_type == 'page') { clean_page_cache($post_id); } else { clean_post_cache($post_id); } } return true; }
function check_single_list_two() { global $post; if (get_post_meta($post->ID, "num_single_list_twos", $single = true) == "") { update_post_meta($post->ID, 'num_single_list_twos', 0, true); } }
function get_priority($image) { // we used to rank images based on a user-defined priority. images // with priority '1' were featured under the headline in a large // display. the others were shown inline with the article and // in order of priority. in a recent update wordpress (3.5?), wordpress // changed how they prioritize photos. photos are now prioritized // based on their order in the menu. therefore it is not possible to // assign priorities and have no images with a priority of 1. the // conditional below will ensure that old photos display as intended. if (strtotime($image->post_date) < strtotime('2013-03-30 00:00:00')) { return $image->menu_order; } // check to see if image position was set to 'feature'. if // so it will display large and under the headline. if (get_post_meta($image->ID, '_position', true) === 'feature') { return 1; } // if the image is not featured we don't want it to have a // priority of 1 so we will add 1 to it. the default // priority for all images is 0, so we only do this // for images that already have a custom priority. if ($image->menu_order !== 0) { return $image->menu_order + 1; } // images that were published after the March 30, 2013, // don't have a _position meta value set to 'feature', // and weren't assigned a custom menu order. return 0; }
/** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output **/ public function widget($args, $instance) { extract($args, EXTR_SKIP); $count = esc_attr($instance['count']); $count = 0 < $count && $count < 10 ? $count : 2; $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>')))); if ($loop->have_posts()) { echo $before_widget; if ($instance['title']) { echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title; } echo '<ul>'; while ($loop->have_posts()) { $loop->the_post(); global $post; $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>'; $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post); if ($read_more) { echo '<li>' . $read_more . '</li>'; } } if ($instance['more_text']) { echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>'; } echo '</ul>'; echo $after_widget; } wp_reset_postdata(); }
private function build_organizer_array($organizer_id, array $record) { $featured_image_content = $this->get_value_by_key($record, 'featured_image'); $featured_image = $organizer_id ? '' === get_post_meta($organizer_id, '_wp_attached_file', true) : $this->featured_image_uploader($featured_image_content)->upload_and_get_attachment(); $organizer = array('Organizer' => $this->get_value_by_key($record, 'organizer_name'), 'Email' => $this->get_value_by_key($record, 'organizer_email'), 'Phone' => $this->get_value_by_key($record, 'organizer_phone'), 'Website' => $this->get_value_by_key($record, 'organizer_website'), 'FeaturedImage' => $featured_image); return $organizer; }
/** * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order. * * If multiple exist we will return the latest order. * * @param $user_id * @param $course_id * @return array $user_course_orders */ public static function get_learner_course_active_order_id($user_id, $course_id) { $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true); $orders_query = new WP_Query(array('post_type' => 'shop_order', 'posts_per_page' => -1, 'post_status' => array('wc-processing', 'wc-completed'), 'meta_key' => '_customer_user', 'meta_value' => $user_id)); if ($orders_query->post_count == 0) { return false; } foreach ($orders_query->get_posts() as $order) { $order = new WC_Order($order->ID); $items = $order->get_items(); $user_orders = array(); foreach ($items as $item) { // if the product id on the order and the one given to this function // this order has been placed by the given user on the given course. $product = wc_get_product($item['product_id']); if ($product->is_type('variable')) { $item_product_id = $item['variation_id']; } else { $item_product_id = $item['product_id']; } if ($course_product_id == $item_product_id) { return $order->id; } } //end for each order item } // end for each order // if we reach this place we found no order return false; }