| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main Themify class |
| 4 |
*/ |
| 5 |
if ( ! class_exists( 'Themify' ) ) { |
| 6 |
class Themify { |
| 7 |
/** Default sidebar layout |
| 8 |
* @var string */ |
| 9 |
public $layout; |
| 10 |
/** Default posts layout |
| 11 |
* @var string */ |
| 12 |
public $post_layout; |
| 13 |
public $post_layout_type=''; |
| 14 |
public $hide_title; |
| 15 |
public $hide_meta; |
| 16 |
public $hide_meta_author; |
| 17 |
public $hide_meta_category; |
| 18 |
public $hide_meta_comment; |
| 19 |
public $hide_meta_tag; |
| 20 |
public $hide_date; |
| 21 |
public $hide_image; |
| 22 |
public $media_position; |
| 23 |
|
| 24 |
public $unlink_title; |
| 25 |
public $unlink_image; |
| 26 |
|
| 27 |
public $display_content = ''; |
| 28 |
public $auto_featured_image; |
| 29 |
|
| 30 |
public $width = ''; |
| 31 |
public $height = ''; |
| 32 |
|
| 33 |
public $avatar_size = 96; |
| 34 |
public $page_navigation; |
| 35 |
public $posts_per_page; |
| 36 |
|
| 37 |
public $image_align = ''; |
| 38 |
public $image_setting = ''; |
| 39 |
|
| 40 |
public $query_category = ''; |
| 41 |
public $query_post_type = ''; |
| 42 |
public $query_taxonomy = ''; |
| 43 |
public $paged = ''; |
| 44 |
public $query_all_post_types; |
| 45 |
|
| 46 |
///////////////////////////////////////////// |
| 47 |
// Set Default Image Sizes |
| 48 |
///////////////////////////////////////////// |
| 49 |
|
| 50 |
// Default Index Layout |
| 51 |
static $content_width = 978; |
| 52 |
static $sidebar1_content_width = 670; |
| 53 |
|
| 54 |
// Default Single Post Layout |
| 55 |
static $single_content_width = 978; |
| 56 |
static $single_sidebar1_content_width = 670; |
| 57 |
|
| 58 |
// Default Single Image Size |
| 59 |
static $single_image_width = 978; |
| 60 |
static $single_image_height = 400; |
| 61 |
|
| 62 |
// Grid4 |
| 63 |
static $grid4_width = 222; |
| 64 |
static $grid4_height = 140; |
| 65 |
|
| 66 |
// Grid3 |
| 67 |
static $grid3_width = 306; |
| 68 |
static $grid3_height = 180; |
| 69 |
|
| 70 |
// Grid2 |
| 71 |
static $grid2_width = 474; |
| 72 |
static $grid2_height = 250; |
| 73 |
|
| 74 |
// List Large |
| 75 |
static $list_large_image_width = 680; |
| 76 |
static $list_large_image_height = 390; |
| 77 |
|
| 78 |
// List Thumb |
| 79 |
static $list_thumb_image_width = 230; |
| 80 |
static $list_thumb_image_height = 200; |
| 81 |
|
| 82 |
// List Grid2 Thumb |
| 83 |
static $grid2_thumb_width = 120; |
| 84 |
static $grid2_thumb_height = 100; |
| 85 |
|
| 86 |
// List Post |
| 87 |
static $list_post_width = 978; |
| 88 |
static $list_post_height = 400; |
| 89 |
|
| 90 |
// Sorting Parameters |
| 91 |
public $order = 'DESC'; |
| 92 |
public $orderby = 'date'; |
| 93 |
public $order_meta_key = false; |
| 94 |
public $more_text=''; |
| 95 |
public $more_link=''; |
| 96 |
public $themify_post_title_tag=''; |
| 97 |
public $image_size=''; |
| 98 |
public $post_filter=''; |
| 99 |
public $excerpt_length; |
| 100 |
public $post_module_hook = null; |
| 101 |
public $post_module_tax = null; |
| 102 |
public $lightboxed_permalink = false; |
| 103 |
|
| 104 |
function __construct() { |
| 105 |
} |
| 106 |
|
| 107 |
function template_redirect() { |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Returns post category IDs concatenated in a string |
| 112 |
* @param number Post ID |
| 113 |
* @return string Category IDs |
| 114 |
*/ |
| 115 |
public function get_categories_as_classes($post_id){ |
| 116 |
$categories = wp_get_post_categories($post_id); |
| 117 |
$class = ''; |
| 118 |
foreach($categories as $cat) |
| 119 |
$class .= ' cat-'.$cat; |
| 120 |
return $class; |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Returns category description |
| 125 |
* @return string |
| 126 |
*/ |
| 127 |
function get_category_description(){ |
| 128 |
$category_description = category_description(); |
| 129 |
if ( !empty( $category_description ) ){ |
| 130 |
return '<div class="category-description">' . $category_description . '</div>'; |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Initializes Themify class |
| 138 |
*/ |
| 139 |
function themify_builder_global_options(){ |
| 140 |
/** |
| 141 |
* Themify initialization class |
| 142 |
*/ |
| 143 |
global $themify; |
| 144 |
if ( class_exists( 'Themify' ) ) { |
| 145 |
$themify = new Themify(); |
| 146 |
} |
| 147 |
} |
| 148 |
add_action( 'init','themify_builder_global_options' ); |
| 149 |
|
| 150 |
|
| 151 |
if ( ! function_exists( 'themify_builder_plugin_data_filters' ) ) { |
| 152 |
add_filter( 'themify_get_data', 'themify_builder_plugin_data_filters' ); |
| 153 |
function themify_builder_plugin_data_filters( $data ) { |
| 154 |
if ('' != themify_builder_get( 'image_setting-img_settings_use' ) ) { |
| 155 |
$data['setting-img_settings_use'] = true; |
| 156 |
} |
| 157 |
if ( ($size= themify_builder_get('image_setting-global_feature_size'))!='' ) { |
| 158 |
$data['setting-global_feature_size'] = $size; |
| 159 |
} |
| 160 |
return $data; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
function themify_enable_full_google_fonts() { |
| 165 |
$settings = get_option( 'themify_builder_setting' ); |
| 166 |
return isset( $settings['builder_google_fonts'] ) && 'full' === $settings['builder_google_fonts']; |
| 167 |
} |
| 168 |
add_filter( 'themify_google_fonts_full_list', 'themify_enable_full_google_fonts' ); |
| 169 |
|
| 170 |
function themify_builder_init_google_fonts() { |
| 171 |
$settings = get_option( 'themify_builder_setting' ); |
| 172 |
if ( ! defined( 'THEMIFY_GOOGLE_FONTS' ) && isset( $settings['builder_google_fonts'] ) && 'disabled' === $settings['builder_google_fonts'] ) { |
| 173 |
define( 'THEMIFY_GOOGLE_FONTS', false ); |
| 174 |
} |
| 175 |
} |
| 176 |
add_action( 'init', 'themify_builder_init_google_fonts' ); |