/** * Get the gallery of the global post * @required global $post this should be called inside a loop * @return array $ids */ function get_gallery_ids($key = '') { global $post; $prefix = ''; if (class_exists('wpgrade')) { $prefix = wpgrade::prefix(); } $ids = get_post_meta($post->ID, $prefix . $key, true); if (!empty($ids)) { $ids = explode(',', $ids); } return $ids; }
function rosa_post_classes($classes) { //only add this class for regular pages if (get_page_template_slug(get_the_ID()) == '') { $subtitle = trim(get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'page_cover_subtitle', true)); $title = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'page_cover_title', true); $description = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'page_cover_description', true); if (!(has_post_thumbnail() || !empty($subtitle) || $title !== ' ' || !empty($description))) { $classes[] = 'no-page-header'; } } return $classes; }
$post = get_post($shop_page_id); setup_postdata($post); $make_transparent_menu_bar = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'header_transparent_menu_bar', true); if ($make_transparent_menu_bar == 'on') { $class_name .= ' header--transparent'; } } } } //make the header menu bar transparent //only for static pages if (is_page()) { if (get_page_template_slug(get_the_ID()) == 'page-templates/contact.php') { $make_transparent_menu_bar = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'header_transparent_menu_bar_contact', true); } else { $make_transparent_menu_bar = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'header_transparent_menu_bar', true); } if ($make_transparent_menu_bar == 'on') { $class_name .= ' header--transparent'; } } $schema_org = ''; if (is_single()) { $schema_org .= 'itemscope itemtype="http://schema.org/Article"'; } else { $schema_org .= 'itemscope itemtype="http://schema.org/WebPage"'; } ?> <body <?php body_class($class_name);
static function gallery_slideshow($current_post, $template = null, $size = 'medium-size') { if ($template === null) { $image_scale_mode = get_post_meta($current_post->ID, wpgrade::prefix() . 'post_image_scale_mode', true); $slider_visiblenearby = get_post_meta($current_post->ID, wpgrade::prefix() . 'post_slider_visiblenearby', true); $slider_transition = get_post_meta($current_post->ID, wpgrade::prefix() . 'post_slider_transition', true); $slider_autoplay = get_post_meta($current_post->ID, wpgrade::prefix() . 'post_slider_autoplay', true); if ($slider_autoplay) { $slider_delay = get_post_meta($current_post->ID, wpgrade::prefix() . 'post_slider_delay', true); } $template = '<div class="wp-gallery" data-royalslider data-autoHeight data-customarrows data-sliderpauseonhover data-slidertransition="' . $slider_transition . '" '; $template .= ' data-imagescale="' . $image_scale_mode . '" '; if ($slider_visiblenearby) { $template .= ' data-visiblenearby '; } if ($slider_autoplay) { $template .= ' data-sliderautoplay="" '; $template .= ' data-sliderdelay="' . $slider_delay . '" '; } if ($image_scale_mode != 'fill') { $template .= ' data-imagealigncenter '; } if (wpgrade::option('show_title_caption_popup') == 1) { $template .= ' data-enable_caption=""'; } $template .= '>:gallery</div>'; } // first check if we have a meta with a gallery $gallery_ids = get_post_meta($current_post->ID, wpgrade::prefix() . 'main_gallery', true); if (!empty($gallery_ids)) { //recreate the gallery shortcode $gallery = '[gallery ids="' . $gallery_ids . '"]'; if (strpos($gallery, 'style') === false) { $gallery = str_replace("]", " style='big_thumb' size='" . $size . "' link='file']", $gallery); } $shrtcode = do_shortcode($gallery); //var_dump( $template, $shrtcode ); // $shrtcode = preg_replace('/(<dd class="wp-caption-text gallery-caption">.+?)+(<\/dd>)/i', '', $shrtcode); if (!empty($shrtcode)) { return strtr($template, array(':gallery' => $shrtcode)); } else { return null; } } else { // empty gallery_ids // search for the first gallery shortcode $gallery_matches = null; preg_match("!\\[gallery.+?\\]!", $current_post->post_content, $gallery_matches); if (!empty($gallery_matches)) { $gallery = $gallery_matches[0]; if (strpos($gallery, 'style') === false) { $gallery = str_replace("]", " style='big_thumb' size='" . $size . "' link='file']", $gallery); } $shrtcode = do_shortcode($gallery); if (!empty($shrtcode)) { return strtr($template, array(':gallery' => $shrtcode)); } else { return null; } } else { // gallery_matches is empty return null; } } }
$gallery_ids = get_post_meta(get_the_ID(), wpgrade::prefix() . 'main_gallery', true); if (get_page_template_slug(get_the_ID()) == 'page-templates/slideshow.php' && !empty($gallery_ids)) { $gallery_ids = explode(',', $gallery_ids); if (!empty($gallery_ids)) { $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'orderby' => "post__in", 'post__in' => $gallery_ids)); } else { $attachments = array(); } if (!empty($attachments)) { //let's grab the info regarding the slider $image_scale_mode = get_post_meta(get_the_ID(), wpgrade::prefix() . 'post_slider_image_scale_mode', true); $slider_visiblenearby = get_post_meta(get_the_ID(), wpgrade::prefix() . 'post_slider_visiblenearby', true); $slider_transition = get_post_meta(get_the_ID(), wpgrade::prefix() . 'post_slider_transition', true); $slider_autoplay = get_post_meta(get_the_ID(), wpgrade::prefix() . 'post_slider_autoplay', true); if ($slider_autoplay) { $slider_delay = get_post_meta(get_the_ID(), wpgrade::prefix() . 'post_slider_delay', true); } ?> <header id="post-<?php the_ID(); ?> -title" class="<?php echo $classes; ?> "> <?php if (!empty($subtitle) || !empty($title) && $title !== ' ' || !empty($description)) { ?> <div class="flexbox"> <div class="flexbox__item"> <hgroup class="article__headline">
<?php /* for PRO users! - * * ACTIVATION SETTINGS * These settings will be needed when the theme will get active * Careful with the first setup, most of them will go in the clients database and they will be stored there * This file will be included in inc/functions/callbacks/activation-hooks.php */ return array('pixlikes-settings' => array('show_on_post' => false, 'show_on_page' => false, 'show_on_hompage' => false, 'show_on_archive' => false, 'like_action' => 'click', 'hover_time' => 1000, 'free_votes' => false, 'load_likes_with_ajax' => false), 'pixtypes-settings' => array('metaboxes' => array(wpgrade::shortname() . '_page_header_area_cover' => array('id' => wpgrade::shortname() . '_page_header_area_cover', 'title' => __('Featured Header Area', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('default', 'page-templates/slideshow.php')), 'show_names' => true, 'fields' => array(array('name' => __('Header Height', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the height of the header area in relation to the browser window.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'page_header_height', 'type' => 'select', 'options' => array(array('name' => __(' ◉◯ Half', 'rosa_txtd'), 'value' => 'half-height'), array('name' => __('◉◉◯ Two Thirds', 'rosa_txtd'), 'value' => 'two-thirds-height'), array('name' => __('◉◉◉ Full Height', 'rosa_txtd'), 'value' => 'full-height')), 'std' => 'half-height'), array('name' => __('Subtitle', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_subtitle', 'type' => 'text'), array('name' => __('Title', 'rosa_txtd'), 'desc' => __("If left empty we will use the page title. Tip: put a space if you don't want any cover text.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_title', 'type' => 'text'), array('name' => __('Description', 'rosa_txtd'), 'desc' => __("You can use shortcodes (like the Separator) or even images to further embellish this.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_cover_description', 'type' => 'wysiwyg', 'options' => array('media_buttons' => true, 'textarea_rows' => 3, 'teeny' => false, 'tinymce' => true, 'quicktags' => true)), array('name' => __('Make Menu Bar Transparent', 'rosa_txtd'), 'desc' => __("This will remove the background from the menu and logo top bar.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'header_transparent_menu_bar', 'type' => 'checkbox'), array('name' => __('Content Border Style', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the style of the top and bottom borders of the content.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'page_border_style', 'type' => 'select', 'options' => array(array('name' => __('Simple', 'rosa_txtd'), 'value' => 'simple'), array('name' => __('Waves', 'rosa_txtd'), 'value' => 'waves')), 'std' => 'simple'))), wpgrade::shortname() . '_page_header_area_slideshow' => array('id' => wpgrade::shortname() . '_page_header_area_slideshow', 'title' => __('Slideshow Settings', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('page-templates/slideshow.php')), 'show_names' => true, 'fields' => array(array('name' => __('Images', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'main_gallery', 'type' => 'gallery'), array('name' => __('Image Scaling', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description"><strong>Fill</strong> scales image to completely fill slider container (recommended for landscape images)</p> <p class="cmb_metabox_description"><strong>Fit</strong> scales image to fit the container (recommended for portrait images)</p> <p class="cmb_metabox_description"><strong>Fit if Smaller</strong> scales image to fit only if size of slider container is less than size of image.</p> <p class="cmb_metabox_description"><a target="_blank" href="http://bit.ly/slider-image-scaling">Visual explanation</a></p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_image_scale_mode', 'type' => 'select', 'options' => array(array('name' => __('Fit', 'rosa_txtd'), 'value' => 'fit'), array('name' => __('Fill', 'rosa_txtd'), 'value' => 'fill'), array('name' => __('Fit if Smaller', 'rosa_txtd'), 'value' => 'fit-if-smaller')), 'std' => 'fill'), array('name' => __('Show Nearby Images', 'rosa_txtd'), 'desc' => __('Enable this if you want to avoid having empty space on the sides of the image when using mostly portrait images.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_visiblenearby', 'type' => 'select', 'options' => array(array('name' => __('Enabled', 'rosa_txtd'), 'value' => true), array('name' => __('Disabled', 'rosa_txtd'), 'value' => false)), 'std' => false), array('name' => __('Slider transition', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_transition', 'type' => 'select', 'options' => array(array('name' => __('Slide/Move', 'rosa_txtd'), 'value' => 'move'), array('name' => __('Fade', 'rosa_txtd'), 'value' => 'fade')), 'std' => 'move'), array('name' => __('Slider autoplay', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_autoplay', 'type' => 'select', 'options' => array(array('name' => __('Enabled', 'rosa_txtd'), 'value' => true), array('name' => __('Disabled', 'rosa_txtd'), 'value' => false)), 'std' => false), array('name' => __('Autoplay delay between slides (in milliseconds)', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'post_slider_delay', 'type' => 'text_small', 'std' => '1000'))), wpgrade::shortname() . '_gmap_settings' => array('id' => wpgrade::shortname() . '_gmap_settings', 'title' => __('Map Coordinates & Display Options', 'rosa_txtd'), 'pages' => array('page'), 'context' => 'normal', 'priority' => 'high', 'hidden' => true, 'show_on' => array('key' => 'page-template', 'value' => array('page-templates/contact.php')), 'show_names' => true, 'fields' => array(array('name' => __('Map Height', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description">Select the height of the Google Map area in relation to the browser window.</p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_gmap_height', 'type' => 'select', 'options' => array(array('name' => __(' ◉◯ Half', 'rosa_txtd'), 'value' => 'half-height'), array('name' => __('◉◉◯ Two Thirds', 'rosa_txtd'), 'value' => 'two-thirds-height'), array('name' => __('◉◉◉ Full Height', 'rosa_txtd'), 'value' => 'full-height')), 'std' => 'half-height'), array('name' => __('Location Type', 'rosa_txtd'), 'desc' => __('<p class="cmb_metabox_description">Select multiple if you want to display several pins on the map.</p>', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'page_gmap_pin_type', 'type' => 'select', 'options' => array(array('name' => __('Single', 'rosa_txtd'), 'value' => 'single'), array('name' => __('Multiple', 'rosa_txtd'), 'value' => 'multiple')), 'std' => 'single'), array('name' => __('Google Maps Pins', 'mies_txtd'), 'desc' => __('Paste here the Share URL you have taken from <a href="http://www.google.com/maps" target="_blank">Google Maps</a>.', 'rosa_txtd'), 'id' => 'gmap_urls', 'type' => 'gmap_pins', 'std' => array(1 => array('location_url' => "https://www.google.ro/maps/@51.5075586,-0.1284425,18z", 'name' => __('London', 'rosa_txtd'))), 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'multiple'))), array('name' => __('Google Maps URL', 'rosa_txtd'), 'desc' => __('Paste here the Share URL you have taken from <a href="http://www.google.com/maps" target="_blank">Google Maps</a>.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_url', 'type' => 'textarea_small', 'std' => '', 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'single'))), array('name' => __('Pin Content', 'rosa_txtd'), 'desc' => __('Insert here the content of the location marker - leave empty for no custom marker.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_marker_content', 'type' => 'wysiwyg', 'std' => '', 'options' => array('media_buttons' => true, 'textarea_rows' => 3, 'teeny' => false, 'tinymce' => true, 'quicktags' => true), 'display_on' => array('display' => true, 'on' => array('field' => wpgrade::prefix() . 'page_gmap_pin_type', 'value' => 'single'))), array('name' => __('Custom Colors', 'rosa_txtd'), 'desc' => __('Allow us to change the map colors to better match your website.', 'rosa_txtd'), 'id' => wpgrade::prefix() . 'gmap_custom_style', 'type' => 'checkbox', 'std' => 'on'), array('name' => __('Make Menu Bar Transparent', 'rosa_txtd'), 'desc' => __("This will remove the background from the menu and logo top bar.", 'rosa_txtd'), 'id' => wpgrade::prefix() . 'header_transparent_menu_bar_contact', 'type' => 'checkbox'), array('name' => __('Content Border Style', 'rosa_txtd'), 'desc' => '<p class="cmb_metabox_description">' . __('Select the style of the top and bottom borders of the content.', 'rosa_txtd') . '</p>', 'id' => wpgrade::prefix() . 'gmap_border_style', 'type' => 'select', 'options' => array(array('name' => __('Simple', 'rosa_txtd'), 'value' => 'simple'), array('name' => __('Waves', 'rosa_txtd'), 'value' => 'waves')), 'std' => 'simple'))))));
* Description: This is the template that is used for pages that have a header section with a slideshow instead of a featured image * It is a page with additional controls for the slideshow */ global $post; //some global variables that we use in our page sections $is_gmap = false; $footer_needs_big_waves = false; $page_section_idx = 0; get_header(); while (have_posts()) { the_post(); ?> <?php get_template_part('templates/page/header'); $classes = "article--page article--main"; $border_style = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'page_border_style', true); if (!empty($border_style)) { $classes .= ' border-' . $border_style; } if (!empty($post->post_content)) { ?> <article id="post-<?php the_ID(); ?> " <?php post_class($classes); ?> > <section class="article__content"> <div class="container">
/** * ... */ function wpgrade_callbacks_setup_shortcodes_plugin() { $current_options = get_option('wpgrade_shortcodes_list'); $config = wpgrade::config(); $shortcodes = $config['shortcodes']; // create an array with shortcodes which are needed by the // current theme if ($current_options) { $diff_added = array_diff($shortcodes, $current_options); $diff_removed = array_diff($current_options, $shortcodes); if ((!empty($diff_added) || !empty($diff_removed)) && is_admin()) { update_option('wpgrade_shortcodes_list', $shortcodes); } } else { // there is no current shortcodes list update_option('wpgrade_shortcodes_list', $shortcodes); } // we need to remember the prefix of the metaboxes so it can be used // by the shortcodes plugin $current_prefix = get_option('wpgrade_metaboxes_prefix'); if (empty($current_prefix)) { update_option('wpgrade_metaboxes_prefix', wpgrade::prefix()); } }
/** * Given a video link returns an array containing the matched services and * the corresponding video id. * @return array (youtube, vimeo) id hash if matched */ static function post_videos_id($post_id) { $result = array(); $vembed = get_post_meta($post_id, wpgrade::prefix() . 'vimeo_link', true); $vmatches = null; if (preg_match('#(src=\\"[^0-9]*)?vimeo\\.com/(video/)?(?P<id>[0-9]+)([^\\"]*\\"|$)#', $vembed, $vmatches)) { $result['vimeo'] = $vmatches["id"]; } $yembed = get_post_meta($post_id, wpgrade::prefix() . 'youtube_id', true); $ymatches = null; if (preg_match('/^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=)(?P<id>[^#\\&\\?\\"]*).*/', $yembed, $ymatches)) { $result['youtube'] = $ymatches["id"]; } return $result; }