Changeset 938111
- Timestamp:
- 06/24/2014 11:18:44 PM (10 years ago)
- Location:
- genesis-featured-content-widget/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
genesis-featured-content-widget/trunk/gs-featured-content-widget.php
r897356 r938111 4 4 * Plugin URI: https://wpsmith.net/ 5 5 * Description: Based on the Genesis Featured Widget Amplified for additional functionality which allows support for custom post types, taxonomies, and extends the flexibility of the widget via action hooks to allow the elements to be re-positioned or other elements to be added. 6 * Version: 1.1. 46 * Version: 1.1. 7 7 * Author: Travis Smith 8 8 * Author URI: http://wpsmith.net/ … … 82 82 function gsfc_widgets_init() { 83 83 $gfwa = genesis_get_option( 'gsfc_gfwa' ); 84 if ( class_exists( 'Genesis_Featured_Widget_Amplified' ) && $gfwa ) 84 if ( class_exists( 'Genesis_Featured_Widget_Amplified' ) && $gfwa ) 85 85 unregister_widget( 'Genesis_Featured_Widget_Amplified' ); 86 86 87 register_widget( 'GS_Featured_Content' ); 87 88 } … … 104 105 return $links; 105 106 } 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 -
genesis-featured-content-widget/trunk/widget.php
r897356 r938111 389 389 public static function do_post_image( $instance ) { 390 390 //* Bail if empty show param 391 if ( empty( $instance['show_image'] ) ) return; 392 391 if ( empty( $instance['show_image'] ) ) { 392 return; 393 } 394 393 395 $align = $instance['image_alignment'] ? esc_attr( $instance['image_alignment'] ) : 'alignnone'; 394 $link = $instance['link_image_field'] && genesis_get_custom_field( $instance['link_image_field'] ) ? genesis_get_custom_field( $instance['link_image_field'] ) : get_permalink(); 396 $link = $instance['link_image_field'] ? $instance['link_image_field'] : get_permalink(); 397 $link = genesis_get_custom_field( 'gsfc_link_image_field' ) ? genesis_get_custom_field( 'gsfc_link_image_field' ) : $instance['link_image_field']; 395 398 396 399 $image = genesis_get_image( array( … … 427 430 */ 428 431 public static function action( $name, $instance ) { 432 433 434 429 435 do_action( $name, $instance ); 430 436 } … … 483 489 $hclass = ''; 484 490 } 485 486 printf( '<h2%s>%s%s%s</h2>', $hclass, $wrap_open, $title, $wrap_close ); 491 492 $pattern = apply_filters( 'gsfc_post_title_pattern', '<h2%s>%s%s%s</h2>' ); 493 printf( $pattern, $hclass, $wrap_open, $title, $wrap_close ); 487 494 } 488 495 … … 494 501 public static function do_post_content( $instance ) { 495 502 //* Bail if empty show param 496 if ( empty( $instance['show_content'] ) ) return; 497 498 if ( $instance['show_content'] == 'excerpt' ) { 499 add_filter( 'excerpt_more', array( 'GS_Featured_Content', 'excerpt_more' ) ); 500 the_excerpt(); 501 remove_filter( 'excerpt_more', array( 'GS_Featured_Content', 'excerpt_more' ) ); 502 } elseif ( $instance['show_content'] == 'content-limit' ) { 503 the_content_limit( ( int ) $instance['content_limit'], esc_html( $instance['more_text'] ) ); 504 } elseif ( $instance['show_content'] == 'content' ) { 505 the_content( esc_html( $instance['more_text'] ) ); 506 } else { 507 do_action( 'gsfc_show_content' ); 508 } 503 if ( empty( $instance['show_content'] ) ) { 504 return; 505 } 506 507 if ( '' !== $instance['show_content'] && ( $pre = apply_filters( 'gsfc_post_content_add_entry_content', false ) ) ) { 508 echo '<div class="entry-content">'; 509 } 510 switch ( $instance['show_content'] ) { 511 case 'excerpt': 512 add_filter( 'excerpt_more', array( 'GS_Featured_Content', 'excerpt_more' ) ); 513 the_excerpt(); 514 remove_filter( 'excerpt_more', array( 'GS_Featured_Content', 'excerpt_more' ) ); 515 break; 516 case 'content-limit': 517 the_content_limit( ( int ) $instance['content_limit'], esc_html( $instance['more_text'] ) ); 518 break; 519 case 'content': 520 the_content( esc_html( $instance['more_text'] ) ); 521 break; 522 default: 523 do_action( 'gsfc_show_content' ); 524 break; 525 } 526 if ( '' !== $instance['show_content'] && ( $pre = apply_filters( 'gsfc_post_content_add_entry_content', false ) ) ) { 527 echo '</div>'; 528 } 529 509 530 } 510 531 … … 607 628 */ 608 629 protected static function get_transient( $name ) { 609 if ( defined( 'WP_DEBUG' ) && WP_DEBUG &&apply_filters( 'gsfc_debug', false ) ) {630 if ( defined( 'WP_DEBUG' ) && WP_DEBUG apply_filters( 'gsfc_debug', false ) ) { 610 631 GS_Featured_Content::delete_transient( $name ); 611 632 return false; … … 1563 1584 */ 1564 1585 protected static function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) { 1565 $cache_key = 'gsfc_get_tax_' . md5( $value ); 1586 1587 $cache_key = 'gsfc_get_tax_' . md5( GS_Featured_Content::$widget_instance['widget']->id ); 1566 1588 $taxonomies = wp_cache_get( $cache_key, 'get_taxonomies' ); 1567 1589 1568 if ( false === $t erm_id) {1590 if ( false === $t ) { 1569 1591 $taxonomies = get_taxonomies( $args, $output, $operator ); 1570 1592 if ( $taxonomies && ! is_wp_error( $taxonomies ) ) { … … 1575 1597 } 1576 1598 } else { 1577 $t erm= get_taxonomies( $args, $output, $operator );1599 $t = get_taxonomies( $args, $output, $operator ); 1578 1600 } 1601 1602 1579 1603 } 1580 1604 … … 1660 1684 1661 1685 case 'select_taxonomy' : 1686 1687 1688 1689 1662 1690 printf( '<label for="%1$s">%2$s:</label><select id="%1$s" name="%3$s" onchange="gsfcSave(this)"><option value="" class="gs-pad-left-10" %4$s>%5$s</option>', 1663 1691 $obj->get_field_id( $field_id ), … … 1667 1695 __( 'All Taxonomies and Terms', 'gsfc' ) 1668 1696 ); 1669 1670 $taxonomies = GS_Featured_Content::get_taxonomies( apply_filters( 'gsfc_get_taxonomies_args', array( 'public' => true ), $instance, $obj ), 'objects' );1671 $taxonomies = array_filter( $taxonomies, array( __CLASS__, 'exclude_taxonomies' ) );1672 1697 1673 1698 foreach ( $taxonomies as $taxonomy ) { … … 1773 1798 */ 1774 1799 public static function do_form_fields( $instance, $object ) { 1775 GS_Featured_Content::$widget_instance = $instance;1776 1800 GS_Featured_Content::$widget_instance = ; 1801 1777 1802 //* Get Columns 1778 1803 $columns = GS_Featured_Content::get_form_fields(); … … 1792 1817 //* Merge with defaults 1793 1818 $instance = wp_parse_args( (array) $instance, $this->defaults ); 1794 GS_Featured_Content::$widget_instance = $instance; 1819 // GS_Featured_Content::$widget_instance = $instance; 1820 GS_Featured_Content::$widget_instance = array_merge( $instance, array( 'widget' => $this ) ); 1795 1821 1796 1822 //* Title Field … … 1803 1829 1804 1830 do_action( 'gsfc_output_form_fields', $instance, $this ); 1805 // GS_Featured_Content::$widget_instance = $instance;1806 1831 1807 1832 echo '</div>'; … … 1895 1920 } 1896 1921 1897 /**1898 * Linkify widget title1899 *1900 * @param string $widget_title1901 * @param array $instance The settings for the particular instance of the widget.1902 * @param string $id_base ID base of the widget.1903 * @return string Maybe modified widget title.1904 */1922 /** 1923 * Linkify widget title 1924 * 1925 * @param string $widget_title 1926 * @param array $instance The settings for the particular instance of the widget. 1927 * @param string $id_base ID base of the widget. 1928 * @return string Maybe modified widget title. 1929 */ 1905 1930 public function widget_title( $widget_title, $instance, $id_base ) { 1906 1931 … … 1921 1946 public function widget( $args, $instance ) { 1922 1947 1923 GS_Featured_Content::$widget_instance &= $instance;1948 GS_Featured_Content::$widget_instance ; 1924 1949 global $wp_query, $_genesis_displayed_ids, $gs_counter; 1925 1950 … … 2016 2041 2017 2042 //* Before Loop Action 2018 GS_Featured_Content::action( 'gs_before_loop', $instance ); 2043 if ( has_filter( 'gs_before_loop' ) ) { 2044 GS_Featured_Content::action( 'gs_before_loop', $instance ); 2045 } 2046 GS_Featured_Content::action( 'gsfc_before_loop', $instance ); 2019 2047 2020 2048 if ( 0 === $instance['posts_num'] ) return;
Note: See TracChangeset
for help on using the changeset viewer.