Пример #1
0
 /**
  * Install default content when theme is activated.
  *
  * Set the 'PC_INSTALL_DEFAULT_CONTENT' and 'PC_INSTALL_CONTENT_PROMPT' constants
  * to control how this appears to the user.
  *
  * @since 0.1.0
  */
 public static function install_default_content($theme_options_url)
 {
     /* Create default content, and configure menus, widgets etc. */
     /* Add some default pages. */
     $pages = array(array('title' => 'Blog', 'content' => '', 'template' => 'blog-page.php'), array('title' => 'About Us', 'content' => 'Some information all about us.', 'template' => ''), array('title' => 'Sitemap', 'content' => '', 'template' => 'sitemap-page.php'), array('title' => 'Contact Us', 'content' => 'Please use the contact form below for all enquiries. We will respond to your message as soon as possible.', 'template' => 'contact-page.php'));
     /* Create some new theme pages. */
     self::create_theme_pages($pages);
     /* Create nav menu if it doesn't already exist and add some pages. */
     self::create_new_theme_nav_menu($pages);
     /* Define the multi number for each widget type here, then increment for each additional widget added of the same type. */
     global $pc_info_box_multi_number;
     $pc_info_box_multi_number = next_widget_id_number('pc_info_widget_' . PC_THEME_NAME_SLUG);
     /* Add an Info Box widget to the header widget area. */
     $info_box_widget = array('widget_area' => 'header-widget-area', 'widget_name' => 'Info Box', 'default_settings' => array('title' => 'Header Info Box', 'info_description' => '', 'phone_number' => '(949) 867-5307', 'facebook_id' => 'PressCoders', 'twitter_id' => 'presscoders', 'youtube_id' => 'PressCoders', 'flickr_id' => '', 'googleplus_id' => 'http://plus.google.com', 'linkedin_id' => 'http://www.linkedin.com', 'rss_id' => 'http://www.presscoders.com', 'custom_id_1' => '', 'custom_img_1' => '', 'show_search' => ''));
     self::add_default_widget($info_box_widget, true);
     /* Install extra content if demo site active. */
     if (PC_INSTALL_DEMO_CONTENT && method_exists('PC_TS_Utility', 'theme_demo_default_content')) {
         /* Install theme specific demo content if class method has been declared. */
         PC_TS_Utility::theme_demo_default_content();
     }
     /* Render theme activation message. */
     self::theme_activation_message($theme_options_url);
 }
    function widget($args, $instance)
    {
        extract($args);
        $delay_speed = $instance['delay_speed'];
        $transition_speed = $instance['transition_speed'];
        $number_items = $instance['number_items'];
        $slider_groups = $instance['slider_groups'];
        $randomize = $instance['randomize'];
        $fi_post_link = $instance['fi_post_link'];
        $autoplay = $instance['autoplay'];
        $smooth_height = $instance['smooth_height'];
        $animation_loop = $instance['animation_loop'];
        $transition_effect = $instance['transition_effect'];
        /* */
        if (empty($slider_groups)) {
            $slider_groups = '';
        }
        $order = $randomize ? 'rand' : 'date';
        $autoplay_slides = $autoplay ? 'true' : 'false';
        $smooth_height = $smooth_height ? 'true' : 'false';
        $auto_animation_loop = $animation_loop ? 'true' : 'false';
        $r = new WP_Query(array('post_type' => 'portfolio', 'orderby' => $order, 'showposts' => $number_items, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'tax_query' => array(array('taxonomy' => 'portfolio_group', 'field' => 'id', 'terms' => $slider_groups))));
        if ($r->have_posts()) {
            // There is at least one post to show
            global $pc_is_front_page;
            global $pc_post_id;
            // need the post id to check for the sidebars per post/page feature
            global $wp_registered_sidebars;
            // global widget areas array
            global $pc_global_column_layout;
            // ***********************************************************
            // **     DETERMINE WIDGET AREA LOCATION AND WIDTH TYPE     **
            // ***********************************************************
            $widget_area = null;
            $sidebars_widgets = wp_get_sidebars_widgets();
            // Try to get the widget area the widget belongs to
            foreach ($sidebars_widgets as $sidebar => $widgets) {
                if ('wp_inactive_widgets' == $sidebar) {
                    continue;
                }
                // Ignore inactive widgets
                if (is_array($widgets)) {
                    if (in_array($this->id, $widgets)) {
                        $widget_area = $sidebar;
                    }
                }
            }
            // If widget instance exists in a widget area
            if ($widget_area) {
                // find the widget area width
                if (isset($wp_registered_sidebars[$widget_area]['width'])) {
                    $widget_area_width = $wp_registered_sidebars[$widget_area]['width'];
                    $width_default = 0;
                    // for debugging
                } else {
                    $widget_area_width = 'normal';
                    $width_default = 1;
                    // for debugging
                }
            }
            // *******************************************************
            // **     SET THE THUMBNAIL SIZE USED BY THE WIDGET     **
            // *******************************************************
            // add code to enter the correct classname, and slider thumbnail size, depending on the column layout and the widget area width
            if ($widget_area_width == 'full') {
                $slider_thumb_size = 'slider_content_full';
            } elseif ($widget_area_width == 'wide') {
                // check page layout to see if the page layout is twothirds, or full width
                $layout_num = (int) substr($pc_global_column_layout, 0, 1);
                if ($layout_num == 1) {
                    // full width layout
                    $slider_thumb_size = 'slider_content_full';
                } elseif ($layout_num == 2) {
                    // 2 column layout
                    $slider_thumb_size = 'slider_content_twothirds';
                } else {
                    // else assume 3 column layout
                    $slider_thumb_size = 'slider_content_third';
                }
            } else {
                // assume widget area width is 'normal'
                $slider_thumb_size = 'slider_content_third';
            }
            ?>

		<?php 
            echo $before_widget;
            ?>

			<script type="text/javascript">
				
				jQuery(window).load(function() {
					jQuery('.flexslider_<?php 
            echo $this->id;
            ?>
').flexslider({
						  animation: '<?php 
            echo $transition_effect;
            ?>
',
						  animationLoop: <?php 
            echo $auto_animation_loop;
            ?>
,
						  pauseOnAction: true,
						  slideshow: <?php 
            echo $autoplay_slides;
            ?>
,
						  pauseOnHover: true,
						  slideshowSpeed: <?php 
            echo $delay_speed;
            ?>
,
						  animationSpeed: <?php 
            echo $transition_speed;
            ?>
,
						  controlsContainer: ".flex-container_<?php 
            echo $this->id;
            ?>
",
						  smoothHeight: <?php 
            echo $smooth_height;
            ?>
,
						  multipleKeyboard: true,
						  start: function(slider) {
							<?php 
            // Add any 'start' callback code via a theme specific utility function cb
            if (method_exists('PC_TS_Utility', 'portfolio_slider_jquery_start_cb')) {
                echo PC_TS_Utility::portfolio_slider_jquery_start_cb();
            }
            ?>
						  },
						  before: function(slider) {
							// Add code here (via theme specific callback function)
						  },
						  after: function(slider) {
							// Add code here (via theme specific callback function)
						  }
					});
				});

			</script>

			<div class="flex-container flex-container_<?php 
            echo $this->id;
            ?>
">

				<div class="flexslider flexslider_<?php 
            echo $this->id;
            ?>
">
					<ul class="slides slides_<?php 
            echo $this->id;
            ?>
">

						<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>

							<?php 
                /* Image */
                $post_id = get_the_ID();
                $featured_image = PC_Utility::get_responsive_slider_image($post_id, $slider_thumb_size);
                //$show_title = get_post_meta($post_id, '_'.PC_THEME_NAME_SLUG.'_slide_cpt_show_title',true);
                $title = get_the_title();
                //($show_title == 0) ? get_the_title() : null;
                $portfolio_fi_url = trim(get_post_meta($post_id, '_' . PC_THEME_NAME_SLUG . '_portfolio_cpt_fi_link', true));
                $portfolio_title_url = trim(get_post_meta($post_id, '_' . PC_THEME_NAME_SLUG . '_portfolio_cpt_title_link', true));
                $post_thumbnail_id = get_post_thumbnail_id($post_id);
                $featured_image_src_arr = wp_get_attachment_image_src($post_thumbnail_id, 'full');
                /* Portfolio featured image link. */
                if ($fi_post_link) {
                    /* Override default PF CPT behavior and link FI to post url by default. */
                    $featured_image_src = get_permalink($post_id);
                    $featured_image = '<a href="' . $featured_image_src . '">' . $featured_image . '</a>';
                } else {
                    if (empty($portfolio_fi_url)) {
                        if ($featured_image && is_array($featured_image_src_arr)) {
                            $featured_image_src = $featured_image_src_arr[0];
                            $featured_image = '<a href="' . $featured_image_src . '">' . $featured_image . '</a>';
                        }
                    } else {
                        if ($portfolio_fi_url != 'http://none') {
                            $featured_image = '<a href="' . $portfolio_fi_url . '">' . $featured_image . '</a>';
                        }
                    }
                }
                /* Portfolio title link. */
                if (empty($portfolio_title_url)) {
                    $pl = get_permalink($post_id);
                    $title = '<a href="' . $pl . '">' . $title . '</a>';
                } else {
                    if ($portfolio_title_url != 'http://none') {
                        $title = '<a href="' . $portfolio_title_url . '">' . $title . '</a>';
                    }
                }
                if (!empty($title)) {
                    $title = '<h3 class="portfolio-title">' . $title . '</h3>';
                }
                $content = wpautop(do_shortcode(get_the_content()));
                ?>

							<?php 
                /* Allow optional theme specific slider structure to be defined. */
                if (method_exists('PC_TS_Utility', 'custom_portfolio_slider_li_structure')) {
                    $args = array('title' => $title, 'featured_image' => $featured_image, 'content' => $content, 'post_id' => $post_id);
                    PC_TS_Utility::custom_portfolio_slider_li_structure($args);
                    /* Otherwise use the default structure. */
                } else {
                    ?>

									<li>
										<?php 
                    echo '<div class="portfolio-slide-content">';
                    echo $title;
                    //if($show_title == 0) echo $title;
                    if (!empty($featured_image)) {
                        echo $featured_image;
                    }
                    if (!empty($content)) {
                        echo $content;
                    }
                    echo '</div>';
                    ?>
									</li>

							<?php 
                }
                ?>

						<?php 
            }
            ?>

					</ul>
				</div>

			</div>

		<?php 
            echo $after_widget;
            ?>

		<?php 
            /* Reset the global $the_post as this query will have stomped on it. */
            wp_reset_postdata();
        } else {
            echo "<div>No slider items to show. Please select a group that contains some items!</div>";
        }
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = $instance['title'];
        $number_posts = (int) $instance['number_posts'];
        $pc_blog_style_recent_posts_category = $instance['pc_blog_style_recent_posts_category'];
        $show_post_thumbs = isset($instance['show_post_thumbs']);
        // START - ** RECENT POSTS **
        // ** Show recent posts **
        $args = array('cat' => $pc_blog_style_recent_posts_category, 'showposts' => $number_posts, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
        $r = new WP_Query($args);
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            while ($r->have_posts()) {
                $r->the_post();
                $args1 = array('read_more' => __('Read More', 'presscoders'), 'spt' => $show_post_thumbs);
                if (method_exists('PC_TS_Utility', 'blog_style_recent_posts_widget_loop')) {
                    PC_TS_Utility::blog_style_recent_posts_widget_loop($args1);
                } else {
                    echo 'No function exists to handle the blog style recent posts. Please add a blog_style_recent_posts_widget_loop() method to the PC_TS_Utility class.';
                    break;
                }
                ?>
		
		<?php 
            }
            ?>

		<?php 
            echo $after_widget;
            ?>

		<?php 
            wp_reset_postdata();
            ?>

		<?php 
        }
        ?>

	<?php 
        // END - ** RECENT POSTS **
        ?>

<?php 
    }