SHOW:
|
|
- or go back to the newest paste.
1 | - | <?php |
1 | + | <?php |
2 | if ( ! function_exists( 'get_custom_header' ) ) { | |
3 | - | /********* ePanel v.3.2 ************/ |
3 | + | // compatibility with versions of WordPress prior to 3.4. |
4 | add_custom_background(); | |
5 | - | /* Adds jquery script */ |
5 | + | } else { |
6 | - | add_action( 'wp_print_scripts', 'et_jquery_script', 8 ); |
6 | + | add_theme_support( 'custom-background', apply_filters( 'et_custom_background_args', array() ) ); |
7 | - | function et_jquery_script(){ |
7 | + | } |
8 | - | wp_enqueue_script('jquery'); |
8 | + | |
9 | - | } |
9 | + | if (function_exists('add_post_type_support')) add_post_type_support( 'page', 'excerpt' ); |
10 | add_theme_support( 'automatic-feed-links' ); | |
11 | - | /* Admin scripts + ajax jquery code */ |
11 | + | |
12 | - | if ( ! function_exists( 'et_epanel_admin_js' ) ){ |
12 | + | add_action('init','et_activate_features'); |
13 | - | function et_epanel_admin_js(){ |
13 | + | function et_activate_features(){ |
14 | - | global $themename; |
14 | + | /* activate shortcodes */ |
15 | require_once(TEMPLATEPATH . '/epanel/shortcodes/shortcodes.php'); | |
16 | - | $epanel_jsfolder = get_template_directory_uri() . '/epanel/js'; |
16 | + | |
17 | - | wp_enqueue_script('jquery-ui-tabs'); |
17 | + | /* activate page templates */ |
18 | - | wp_enqueue_script('jquery-form'); |
18 | + | require_once(TEMPLATEPATH . '/epanel/page_templates/page_templates.php'); |
19 | - | wp_enqueue_script('epanel_checkbox',$epanel_jsfolder . '/checkbox.js'); |
19 | + | |
20 | - | wp_enqueue_script('epanel_functions_init',$epanel_jsfolder . '/functions-init.js'); |
20 | + | /* import epanel settings */ |
21 | - | wp_localize_script( 'epanel_functions_init', 'ePanelSettings', array( |
21 | + | require_once(TEMPLATEPATH . '/epanel/import_settings.php'); |
22 | - | 'clearpath' => get_template_directory_uri() . '/epanel/images/empty.png', |
22 | + | } |
23 | - | 'et_saving_text' => esc_html__( 'Saving...', $themename ), |
23 | + | |
24 | - | 'et_options_saved_text' => esc_html__( 'Options Saved.', $themename ), |
24 | + | add_filter('widget_text', 'do_shortcode'); |
25 | - | 'epanel_nonce' => wp_create_nonce('epanel_nonce') |
25 | + | add_filter('the_excerpt', 'do_shortcode'); |
26 | - | )); |
26 | + | |
27 | - | wp_enqueue_script('epanel_colorpicker',$epanel_jsfolder . '/colorpicker.js'); |
27 | + | if ( ! function_exists( 'et_options_stored_in_one_row' ) ){ |
28 | - | wp_enqueue_script('epanel_eye',$epanel_jsfolder . '/eye.js'); |
28 | + | function et_options_stored_in_one_row(){ |
29 | - | } |
29 | + | global $et_store_options_in_one_row; |
30 | - | } |
30 | + | |
31 | - | /* --------------------------------------------- */ |
31 | + | return isset( $et_store_options_in_one_row ) ? (bool) $et_store_options_in_one_row : false; |
32 | } | |
33 | - | /* Adds additional ePanel css */ |
33 | + | } |
34 | - | if ( ! function_exists( 'et_epanel_css_admin' ) ){ |
34 | + | |
35 | - | function et_epanel_css_admin() { ?> |
35 | + | /** |
36 | - | <link rel="stylesheet" href="<?php echo esc_url( get_template_directory_uri() . '/epanel/css/panel.css' ); ?>" type="text/css" /> |
36 | + | * Gets option value from the single theme option, stored as an array in the database |
37 | - | <style type="text/css"> |
37 | + | * if all options stored in one row. |
38 | - | .lightboxclose { background: url("<?php echo esc_url( get_template_directory_uri() . '/epanel/images/description-close.png' ); ?>") no-repeat; width: 19px; height: 20px; } |
38 | + | * Stores the serialized array with theme options into the global variable on the first function run on the page. |
39 | - | </style> |
39 | + | * |
40 | - | <!--[if IE 7]> |
40 | + | * If options are stored as separate rows in database, it simply uses get_option() function. |
41 | - | <style type="text/css"> |
41 | + | * |
42 | - | #epanel-save, #epanel-reset { font-size: 0px; display:block; line-height: 0px; bottom: 18px;} |
42 | + | * @param string $option_name Theme option name. |
43 | - | .box-desc { width: 414px; } |
43 | + | * @param string $default_value Default value that should be set if the theme option isn't set. |
44 | - | .box-desc-content { width: 340px; } |
44 | + | * @param string $used_for_object "Object" name that should be translated into corresponding "object" if WPML is activated. |
45 | - | .box-desc-bottom { height: 26px; } |
45 | + | * @return mixed Theme option value or false if not found. |
46 | - | #epanel-content .epanel-box input, #epanel-content .epanel-box select, .epanel-box textarea { width: 395px; } |
46 | + | */ |
47 | - | #epanel-content .epanel-box select { width:434px !important;} |
47 | + | if ( ! function_exists( 'et_get_option' ) ){ |
48 | - | #epanel-content .epanel-box .box-content { padding: 8px 17px 15px 16px; } |
48 | + | function et_get_option( $option_name, $default_value = '', $used_for_object = '' ){ |
49 | - | </style> |
49 | + | global $et_theme_options, $shortname; |
50 | - | <![endif]--> |
50 | + | |
51 | - | <!--[if IE 8]> |
51 | + | if ( et_options_stored_in_one_row() ){ |
52 | - | <style type="text/css"> |
52 | + | $et_theme_options_name = 'et_' . $shortname; |
53 | - | #epanel-save, #epanel-reset { font-size: 0px; display:block; line-height: 0px; bottom: 18px;} |
53 | + | |
54 | - | </style> |
54 | + | if ( ! isset( $et_theme_options ) ) $et_theme_options = get_option( $et_theme_options_name ); |
55 | - | <![endif]--> |
55 | + | $option_value = isset ( $et_theme_options[$option_name] ) ? $et_theme_options[$option_name] : false; |
56 | - | <?php } |
56 | + | } else { |
57 | - | } |
57 | + | $option_value = get_option( $option_name ); |
58 | - | /* --------------------------------------------- */ |
58 | + | } |
59 | ||
60 | - | /* Save/Reset actions | Adds theme options to WP-Admin menu */ |
60 | + | if ( ! $option_value && '' != $default_value ) $option_value = $default_value; |
61 | - | add_action('admin_menu', 'et_add_epanel'); |
61 | + | |
62 | - | function et_add_epanel() { |
62 | + | if ( '' != $used_for_object && in_array( $used_for_object, array( 'page', 'category' ) ) && is_array( $option_value ) ) |
63 | - | global $themename, $shortname, $options; |
63 | + | $option_value = et_generate_wpml_ids( $option_value, $used_for_object ); |
64 | - | $epanel = basename(__FILE__); |
64 | + | |
65 | return $option_value; | |
66 | - | if ( isset( $_GET['page'] ) && $_GET['page'] == $epanel && isset( $_POST['action'] ) ) { |
66 | + | } |
67 | - | epanel_save_data( 'js_disabled' ); //saves data when javascript is disabled |
67 | + | } |
68 | - | } |
68 | + | |
69 | if ( ! function_exists( 'et_update_option' ) ){ | |
70 | - | $core_page = add_theme_page( $themename . ' ' . esc_html__( 'Options', $themename ), $themename . ' ' . esc_html__( 'Theme Options', $themename ), 'switch_themes', basename(__FILE__), 'et_build_epanel' ); |
70 | + | function et_update_option( $option_name, $new_value ){ |
71 | global $et_theme_options, $shortname; | |
72 | - | add_action( "admin_print_scripts-{$core_page}", 'et_epanel_admin_js' ); |
72 | + | |
73 | - | add_action("admin_head-{$core_page}", 'et_epanel_css_admin'); |
73 | + | if ( et_options_stored_in_one_row() ){ |
74 | - | } |
74 | + | $et_theme_options_name = 'et_' . $shortname; |
75 | - | /* --------------------------------------------- */ |
75 | + | |
76 | if ( ! isset( $et_theme_options ) ) $et_theme_options = get_option( $et_theme_options_name ); | |
77 | - | /* Displays ePanel */ |
77 | + | $et_theme_options[$option_name] = $new_value; |
78 | - | if ( ! function_exists( 'et_build_epanel' ) ){ |
78 | + | |
79 | - | function et_build_epanel() { |
79 | + | $option_name = $et_theme_options_name; |
80 | $new_value = $et_theme_options; | |
81 | - | global $themename, $shortname, $options, $et_disabled_jquery; |
81 | + | } |
82 | ||
83 | - | // load theme settings array |
83 | + | update_option( $option_name, $new_value ); |
84 | - | et_load_core_options(); |
84 | + | } |
85 | } | |
86 | - | if ( isset($_GET['saved']) ) { |
86 | + | |
87 | - | if ( $_GET['saved'] ) echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $themename ) . ' ' . esc_html__( 'settings saved.', $themename ) . '</strong></p></div>'; |
87 | + | if ( ! function_exists( 'et_delete_option' ) ){ |
88 | - | } |
88 | + | function et_delete_option( $option_name ){ |
89 | - | if ( isset($_GET['reset']) ) { |
89 | + | global $et_theme_options, $shortname; |
90 | - | if ( $_GET['reset'] ) echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $themename ) . ' ' . esc_html__( 'settings reset.', $themename ) . '</strong></p></div>'; |
90 | + | |
91 | - | } |
91 | + | if ( et_options_stored_in_one_row() ){ |
92 | - | ?> |
92 | + | $et_theme_options_name = 'et_' . $shortname; |
93 | ||
94 | - | <div id="wrapper"> |
94 | + | if ( ! isset( $et_theme_options ) ) $et_theme_options = get_option( $et_theme_options_name ); |
95 | - | <div id="panel-wrap"> |
95 | + | |
96 | - | <form method="post" id="main_options_form" enctype="multipart/form-data"> |
96 | + | unset( $et_theme_options[$option_name] ); |
97 | - | <div id="epanel-wrapper"> |
97 | + | update_option( $et_theme_options_name, $et_theme_options ); |
98 | - | <div id="epanel"> |
98 | + | } else { |
99 | - | <div id="epanel-content-wrap"> |
99 | + | delete_option( $option_name ); |
100 | - | <div id="epanel-content"> |
100 | + | } |
101 | - | <img src="<?php echo get_template_directory_uri() ?>/epanel/images/logo.png" alt="ePanel" class="pngfix" id="epanel-logo" /> |
101 | + | } |
102 | - | <?php |
102 | + | } |
103 | - | global $epanelMainTabs; |
103 | + | |
104 | - | $epanelMainTabs = apply_filters( 'epanel_page_maintabs', $epanelMainTabs ); |
104 | + | add_filter('body_class','et_browser_body_class'); |
105 | - | ?> |
105 | + | function et_browser_body_class($classes) { |
106 | - | <ul id="epanel-mainmenu"> |
106 | + | global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; |
107 | - | <?php if(in_array('general',$epanelMainTabs)) { ?> |
107 | + | |
108 | - | <li><a href="#wrap-general"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/general-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'General Settings', $themename ); ?></a></li> |
108 | + | if($is_lynx) $classes[] = 'lynx'; |
109 | - | <?php }; ?> |
109 | + | elseif($is_gecko) $classes[] = 'gecko'; |
110 | - | <?php if(in_array('navigation',$epanelMainTabs)) { ?> |
110 | + | elseif($is_opera) $classes[] = 'opera'; |
111 | - | <li><a href="#wrap-navigation"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/navigation-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Navigation', $themename ); ?></a></li> |
111 | + | elseif($is_NS4) $classes[] = 'ns4'; |
112 | - | <?php }; ?> |
112 | + | elseif($is_safari) $classes[] = 'safari'; |
113 | - | <?php if(in_array('layout',$epanelMainTabs)) { ?> |
113 | + | elseif($is_chrome) $classes[] = 'chrome'; |
114 | - | <li><a href="#wrap-layout"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/layout-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Layout Settings', $themename ); ?></a></li> |
114 | + | elseif($is_IE) $classes[] = 'ie'; |
115 | - | <?php }; ?> |
115 | + | else $classes[] = 'unknown'; |
116 | - | <?php if(in_array('ad',$epanelMainTabs)) { ?> |
116 | + | |
117 | - | <li><a href="#wrap-advertisements"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/ad-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Ad Management', $themename ); ?></a></li> |
117 | + | if($is_iphone) $classes[] = 'iphone'; |
118 | - | <?php }; ?> |
118 | + | return $classes; |
119 | - | <?php if(in_array('colorization',$epanelMainTabs)) { ?> |
119 | + | } |
120 | - | <li><a href="#wrap-colorization"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/colorization-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Colorization', $themename ); ?></a></li> |
120 | + | |
121 | - | <?php }; ?> |
121 | + | // Tells wp_trim_words() function to use characters instead of words |
122 | - | <?php if(in_array('seo',$epanelMainTabs)) { ?> |
122 | + | function et_wp_trim_words_to_characters( $default_translated_text, $original_text, $context ) { |
123 | - | <li><a href="#wrap-seo"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/seo-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'SEO', $themename ); ?></a></li> |
123 | + | if ( ! is_admin() && 'words' == $original_text && 'word count: words or characters?' == $context ) { |
124 | - | <?php }; ?> |
124 | + | return 'characters'; |
125 | - | <?php if(in_array('integration',$epanelMainTabs)) { ?> |
125 | + | } |
126 | - | <li><a href="#wrap-integration"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/integration-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Integration', $themename ); ?></a></li> |
126 | + | |
127 | - | <?php }; ?> |
127 | + | return $default_translated_text; |
128 | - | <?php if(in_array('support',$epanelMainTabs)) { ?> |
128 | + | } |
129 | - | <li><a href="#wrap-support"><img src="<?php echo get_template_directory_uri() ?>/epanel/images/support-icon.png" class="pngfix" alt="" /><?php esc_html_e( 'Support Docs', $themename ); ?></a></li> |
129 | + | add_filter( 'gettext_with_context', 'et_wp_trim_words_to_characters', 20, 3 ); |
130 | - | <?php }; ?> |
130 | + | |
131 | - | <?php do_action( 'epanel_render_maintabs',$epanelMainTabs ); ?> |
131 | + | /*this function allows for the auto-creation of post excerpts*/ |
132 | - | </ul><!-- end epanel mainmenu --> |
132 | + | if ( ! function_exists( 'truncate_post' ) ){ |
133 | function truncate_post( $amount, $echo = true, $post = '' ) { | |
134 | - | <?php |
134 | + | global $shortname; |
135 | - | foreach ($options as $value) { |
135 | + | |
136 | - | if ( in_array( $value['type'], array( 'text', 'textlimit', 'textarea', 'select', 'checkboxes', 'different_checkboxes', 'colorpicker', 'textcolorpopup', 'upload' ) ) ) { ?> |
136 | + | if ( '' == $post ) global $post; |
137 | - | <div class="epanel-box"> |
137 | + | |
138 | - | <div class="box-title"> |
138 | + | $post_excerpt = ''; |
139 | - | <h3><?php echo esc_html( $value['name'] ); ?></h3> |
139 | + | $post_excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); |
140 | - | <img src="<?php echo get_template_directory_uri() ?>/epanel/images/help-image.png" alt="description" class="box-description" /> |
140 | + | |
141 | - | <div class="box-descr"> |
141 | + | if ( 'on' == et_get_option( $shortname . '_use_excerpt' ) && '' != $post_excerpt ) { |
142 | - | <p><?php echo wp_kses( $value['desc'], array( 'a' => array( |
142 | + | if ( $echo ) echo $post_excerpt; |
143 | - | 'href' => array(), |
143 | + | else return $post_excerpt; |
144 | - | 'title' => array(), |
144 | + | } else { |
145 | - | 'target' => array() |
145 | + | // get the post content |
146 | - | ) |
146 | + | $truncate = $post->post_content; |
147 | - | ) ); ?></p> |
147 | + | |
148 | - | </div> <!-- end box-desc-content div --> |
148 | + | // remove caption shortcode from the post content |
149 | - | </div> <!-- end div box-title --> |
149 | + | $truncate = preg_replace('@\[caption[^\]]*?\].*?\[\/caption]@si', '', $truncate); |
150 | ||
151 | - | <div class="box-content"> |
151 | + | // apply content filters |
152 | $truncate = apply_filters( 'the_content', $truncate ); | |
153 | - | <?php if ( 'text' == $value['type'] ) { ?> |
153 | + | |
154 | // decide if we need to append dots at the end of the string | |
155 | - | <?php |
155 | + | if ( strlen( $truncate ) <= $amount ) { |
156 | - | $et_input_value = ''; |
156 | + | $echo_out = ''; |
157 | - | $et_input_value = ( '' != et_get_option( $value['id'] ) ) ? et_get_option( $value['id'] ) : $value['std']; |
157 | + | } else { |
158 | - | $et_input_value = stripslashes( $et_input_value ); |
158 | + | $echo_out = '...'; |
159 | - | ?> |
159 | + | // $amount = $amount - 3; |
160 | } | |
161 | - | <input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="<?php echo esc_attr( $value['type'] ); ?>" value="<?php echo esc_attr( $et_input_value ); ?>" /> |
161 | + | |
162 | // trim text to a certain number of characters, also remove spaces from the end of a string ( space counts as a character ) | |
163 | - | <?php } elseif ( 'textlimit' == $value['type'] ) { ?> |
163 | + | $truncate = rtrim( wp_trim_words( $truncate, $amount, '' ) ); |
164 | ||
165 | - | <?php |
165 | + | // remove the last word to make sure we display all words correctly |
166 | - | $et_input_value = ''; |
166 | + | if ( '' != $echo_out ) { |
167 | - | $et_input_value = ( '' != et_get_option( $value['id'] ) ) ? et_get_option( $value['id'] ) : $value['std']; |
167 | + | $new_words_array = (array) explode( ' ', $truncate ); |
168 | - | $et_input_value = stripslashes( $et_input_value ); |
168 | + | array_pop( $new_words_array ); |
169 | - | ?> |
169 | + | |
170 | $truncate = implode( ' ', $new_words_array ); | |
171 | - | <input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="text" maxlength="<?php echo esc_attr( $value['max'] ); ?>" size="<?php echo esc_attr( $value['max'] ); ?>" value="<?php echo esc_attr( $et_input_value ); ?>" /> |
171 | + | |
172 | // append dots to the end of the string | |
173 | - | <?php } elseif ( 'colorpicker' == $value['type'] ) { ?> |
173 | + | $truncate .= $echo_out; |
174 | } | |
175 | - | <div id="colorpickerHolder"></div> |
175 | + | |
176 | if ( $echo ) echo $truncate; | |
177 | - | <?php } elseif ( 'textcolorpopup' == $value['type'] ) { ?> |
177 | + | else return $truncate; |
178 | }; | |
179 | - | <?php |
179 | + | } |
180 | - | $et_input_value = ''; |
180 | + | } |
181 | - | $et_input_value = ( '' != et_get_option( $value['id'] ) ) ? et_get_option( $value['id'] ) : $value['std']; |
181 | + | |
182 | - | ?> |
182 | + | /*this function truncates titles to create preview excerpts*/ |
183 | if ( ! function_exists( 'truncate_title' ) ){ | |
184 | - | <input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" class="colorpopup" type="text" value="<?php echo esc_attr( $et_input_value ); ?>" /> |
184 | + | function truncate_title( $amount, $echo = true, $post = '' ) { |
185 | if ( $post == '' ) $truncate = get_the_title(); | |
186 | - | <?php } elseif ( 'textarea' == $value['type'] ) { ?> |
186 | + | else $truncate = $post->post_title; |
187 | ||
188 | - | <?php |
188 | + | if ( strlen( $truncate ) <= $amount ) $echo_out = ''; |
189 | - | $et_textarea_value = ''; |
189 | + | else $echo_out = '...'; |
190 | - | $et_textarea_value = ( '' != et_get_option( $value['id'] ) ) ? et_get_option( $value['id'] ) : $value['std']; |
190 | + | |
191 | - | $et_textarea_value = stripslashes( $et_textarea_value ); |
191 | + | $truncate = wp_trim_words( $truncate, $amount, '' ); |
192 | - | ?> |
192 | + | |
193 | if ( '' != $echo_out ) $truncate .= $echo_out; | |
194 | - | <textarea name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_textarea( $et_textarea_value ); ?></textarea> |
194 | + | |
195 | if ( $echo ) | |
196 | - | <?php } elseif ( 'upload' == $value['type'] ) { ?> |
196 | + | echo $truncate; |
197 | else | |
198 | - | <input id="<?php echo esc_attr( $value['id'] ); ?>" class="uploadfield" type="text" size="90" name="<?php echo esc_attr( $value['id'] ); ?>" value="<?php echo esc_url( et_get_option($value['id']) ); ?>" /> |
198 | + | return $truncate; |
199 | - | <div class="upload_buttons"> |
199 | + | } |
200 | - | <span class="upload_image_reset"><?php esc_html_e( 'Reset', $themename ); ?></span> |
200 | + | } |
201 | - | <input class="upload_image_button" type="button" value="<?php esc_attr_e( 'Upload Image', $themename ); ?>" /> |
201 | + | |
202 | - | </div> |
202 | + | /*this function allows users to use the first image in their post as their thumbnail*/ |
203 | if ( ! function_exists( 'et_first_image' ) ){ | |
204 | - | <div class="clear"></div> |
204 | + | function et_first_image() { |
205 | global $post; | |
206 | - | <?php } elseif ( 'select' == $value['type'] ) { ?> |
206 | + | $img = ''; |
207 | $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
208 | - | <select name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>"> |
208 | + | if ( isset($matches[1][0]) ) $img = $matches[1][0]; |
209 | - | <?php foreach ( $value['options'] as $option_key=>$option ) { ?> |
209 | + | |
210 | - | <?php |
210 | + | return trim($img); |
211 | - | $et_select_active = ''; |
211 | + | } |
212 | - | $et_use_option_values = isset( $value['et_array_for'] ) && in_array( $value['et_array_for'], array( 'pages', 'categories' ) ) ? true : false; |
212 | + | } |
213 | ||
214 | - | $et_option_db_value = et_get_option($value['id']); |
214 | + | /* this function gets thumbnail from Post Thumbnail or Custom field or First post image */ |
215 | if ( ! function_exists( 'get_thumbnail' ) ) { | |
216 | - | if ( ( $et_use_option_values && is_numeric( $et_option_db_value ) && ( $et_option_db_value == $option_key ) ) || ( stripslashes( $et_option_db_value ) == trim( stripslashes( $option ) ) ) || ( ! $et_option_db_value && isset( $value['std'] ) && stripslashes( $option ) == stripslashes( $value['std'] ) ) ) |
216 | + | function get_thumbnail($width=100, $height=100, $class='', $alttext='', $titletext='', $fullpath=false, $custom_field='', $post='') { |
217 | - | $et_select_active = ' selected="selected"'; |
217 | + | if ( $post == '' ) global $post; |
218 | - | ?> |
218 | + | global $shortname; |
219 | - | <option<?php if ( $et_use_option_values ) echo ' value="' . esc_attr( $option_key ) . '"'; ?> <?php echo $et_select_active; ?>><?php echo esc_html( trim( $option ) ); ?></option> |
219 | + | |
220 | - | <?php } ?> |
220 | + | $thumb_array['thumb'] = ''; |
221 | - | </select> |
221 | + | $thumb_array['use_timthumb'] = true; |
222 | if ($fullpath) $thumb_array['fullpath'] = ''; //full image url for lightbox | |
223 | - | <?php } elseif ( 'checkboxes' == $value['type'] ) { |
223 | + | |
224 | $new_method = true; | |
225 | - | if ( empty( $value['options'] ) ) { |
225 | + | |
226 | - | esc_html_e( "You don't have pages", $themename ); |
226 | + | if ( has_post_thumbnail( $post->ID ) ) { |
227 | - | } else { |
227 | + | $thumb_array['use_timthumb'] = false; |
228 | - | $i = 1; |
228 | + | |
229 | - | $className = 'inputs'; |
229 | + | $et_fullpath = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); |
230 | - | if ( isset( $value['excludeDefault'] ) && $value['excludeDefault'] == 'true' ) $className .= ' different'; |
230 | + | $thumb_array['fullpath'] = $et_fullpath[0]; |
231 | $thumb_array['thumb'] = $thumb_array['fullpath']; | |
232 | - | foreach ( $value['options'] as $option ){ |
232 | + | } |
233 | - | $checked = ""; |
233 | + | |
234 | - | $class_name_last = 0 == $i % 3 ? ' last' : ''; |
234 | + | if ($thumb_array['thumb'] == '') { |
235 | if ($custom_field == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); | |
236 | - | if ( et_get_option( $value['id'] ) ) { |
236 | + | else { |
237 | - | if ( in_array( $option, et_get_option( $value['id'] ) ) ) $checked = "checked=\"checked\""; |
237 | + | $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, $custom_field, $single = true) ); |
238 | - | } |
238 | + | if ($thumb_array['thumb'] == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); |
239 | } | |
240 | - | $et_checkboxes_label = $value['id'] . '-' . $option; |
240 | + | |
241 | - | if ( 'custom' == $value['usefor'] ) { |
241 | + | if (($thumb_array['thumb'] == '') && ((et_get_option($shortname.'_grab_image')) == 'on')) { |
242 | - | $et_helper = (array) $value['helper']; |
242 | + | $thumb_array['thumb'] = esc_attr( et_first_image() ); |
243 | - | $et_checkboxes_value = $et_helper[$option]; |
243 | + | if ( $fullpath ) $thumb_array['fullpath'] = $thumb_array['thumb']; |
244 | - | } else { |
244 | + | } |
245 | - | if ( 'taxonomy_terms' == $value['usefor'] && isset( $value['taxonomy_name'] ) ) { |
245 | + | |
246 | - | $et_checkboxes_term = get_term_by( 'id', $option, $value['taxonomy_name'] ); |
246 | + | #if custom field used for small pre-cropped image, open Thumbnail custom field image in lightbox |
247 | - | $et_checkboxes_value = sanitize_text_field( $et_checkboxes_term->name ); |
247 | + | if ($fullpath) { |
248 | - | } else { |
248 | + | $thumb_array['fullpath'] = $thumb_array['thumb']; |
249 | - | $et_checkboxes_value = ( 'pages' == $value['usefor'] ) ? get_pagename( $option ) : get_categname( $option ); |
249 | + | if ($custom_field == '') $thumb_array['fullpath'] = apply_filters('et_fullpath', et_path_reltoabs(esc_attr($thumb_array['thumb']))); |
250 | - | } |
250 | + | elseif ( $custom_field <> '' && get_post_meta($post->ID, 'Thumbnail', $single = true) ) $thumb_array['fullpath'] = apply_filters( 'et_fullpath', et_path_reltoabs(esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true))) ); |
251 | - | } |
251 | + | } |
252 | - | ?> |
252 | + | } |
253 | ||
254 | - | <p class="<?php echo esc_attr( $className . $class_name_last ); ?>"> |
254 | + | return $thumb_array; |
255 | - | <input type="checkbox" class="usual-checkbox" name="<?php echo esc_attr( $value['id'] ); ?>[]" id="<?php echo esc_attr( $et_checkboxes_label ); ?>" value="<?php echo esc_attr( $option ); ?>" <?php echo esc_html( $checked ); ?> /> |
255 | + | } |
256 | } | |
257 | - | <label for="<?php echo esc_attr( $et_checkboxes_label ); ?>"><?php echo esc_html( $et_checkboxes_value ); ?></label> |
257 | + | |
258 | - | </p> |
258 | + | /* this function prints thumbnail from Post Thumbnail or Custom field or First post image */ |
259 | if ( ! function_exists( 'print_thumbnail' ) ) { | |
260 | - | <?php if ( $i%3 == 0 ) echo('<br class="clearfix"/>'); ?> |
260 | + | function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post='', $et_post_id = '' ) { |
261 | - | <?php $i++; |
261 | + | if ( is_array( $thumbnail ) ){ |
262 | - | } |
262 | + | extract( $thumbnail ); |
263 | - | } ?> |
263 | + | } |
264 | - | <br class="clearfix"/> |
264 | + | |
265 | if ( $post == '' ) global $post, $et_theme_image_sizes; | |
266 | - | <?php } elseif ( 'different_checkboxes' == $value['type'] ){ |
266 | + | |
267 | $output = ''; | |
268 | - | foreach ( $value['options'] as $option ){ |
268 | + | |
269 | - | $checked = ''; |
269 | + | $et_post_id = '' != $et_post_id ? (int) $et_post_id : $post->ID; |
270 | - | if ( et_get_option( $value['id']) !== false ) { |
270 | + | |
271 | - | if ( in_array( $option, et_get_option( $value['id'] ) ) ) $checked = "checked=\"checked\""; |
271 | + | if ( has_post_thumbnail( $et_post_id ) ) { |
272 | - | } elseif ( isset( $value['std'] ) ) { |
272 | + | $thumb_array['use_timthumb'] = false; |
273 | - | if ( in_array($option, $value['std']) ) $checked = "checked=\"checked\""; |
273 | + | |
274 | - | } ?> |
274 | + | $image_size_name = $width . 'x' . $height; |
275 | $et_size = isset( $et_theme_image_sizes ) && array_key_exists( $image_size_name, $et_theme_image_sizes ) ? $et_theme_image_sizes[$image_size_name] : array( $width, $height ); | |
276 | - | <p class="<?php echo esc_attr( 'postinfo-' . $option ); ?>"> |
276 | + | |
277 | - | <input type="checkbox" class="usual-checkbox" name="<?php echo esc_attr( $value['id'] ); ?>[]" id="<?php echo esc_attr( $value['id'] . '-' . $option ); ?>" value="<?php echo esc_attr( $option ); ?>" <?php echo esc_html( $checked ); ?> /> |
277 | + | $et_attachment_image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $et_post_id ), $et_size ); |
278 | - | </p> |
278 | + | $thumbnail = $et_attachment_image_attributes[0]; |
279 | - | <?php } ?> |
279 | + | } else { |
280 | - | <br class="clearfix"/> |
280 | + | $thumbnail_orig = $thumbnail; |
281 | ||
282 | - | <?php } ?> |
282 | + | $thumbnail = et_multisite_thumbnail( $thumbnail ); |
283 | ||
284 | - | </div> <!-- end box-content div --> |
284 | + | $cropPosition = ''; |
285 | - | </div> <!-- end epanel-box div --> |
285 | + | |
286 | $allow_new_thumb_method = false; | |
287 | - | <?php } elseif ( 'checkbox' == $value['type'] || 'checkbox2' == $value['type'] ) { ?> |
287 | + | |
288 | - | <?php |
288 | + | $new_method = true; |
289 | - | $et_box_class = 'checkbox' == $value['type'] ? 'epanel-box-small-1' : 'epanel-box-small-2'; |
289 | + | $new_method_thumb = ''; |
290 | - | ?> |
290 | + | $external_source = false; |
291 | - | <div class="<?php echo esc_attr( 'epanel-box ' . $et_box_class ); ?>"> |
291 | + | |
292 | - | <div class="box-title"><h3><?php echo esc_html( $value['name'] ); ?></h3> |
292 | + | $allow_new_thumb_method = !$external_source && $new_method && $cropPosition == ''; |
293 | - | <img src="<?php echo esc_url( get_template_directory_uri() . '/epanel/images/help-image.png' ); ?>" alt="description" class="box-description" /> |
293 | + | |
294 | - | <div class="box-descr"> |
294 | + | if ( $allow_new_thumb_method && $thumbnail <> '' ){ |
295 | - | <p><?php echo wp_kses( $value['desc'], array( 'a' => array( |
295 | + | $et_crop = get_post_meta( $post->ID, 'et_nocrop', true ) == '' ? true : false; |
296 | - | 'href' => array(), |
296 | + | $new_method_thumb = et_resize_image( et_path_reltoabs($thumbnail), $width, $height, $et_crop ); |
297 | - | 'title' => array(), |
297 | + | if ( is_wp_error( $new_method_thumb ) ) $new_method_thumb = ''; |
298 | - | 'target' => array() |
298 | + | } |
299 | - | ) |
299 | + | |
300 | - | ) ); ?></p> |
300 | + | $thumbnail = $new_method_thumb; |
301 | - | </div> <!-- end box-desc-content div --> |
301 | + | } |
302 | - | </div> <!-- end div box-title --> |
302 | + | |
303 | - | <div class="box-content"> |
303 | + | if ( false === $forstyle ) { |
304 | - | <?php |
304 | + | $output = '<img src="' . esc_url( $thumbnail ) . '"'; |
305 | - | $checked = ''; |
305 | + | |
306 | - | if ( '' != et_get_option( $value['id'] ) ) { |
306 | + | if ($class <> '') $output .= " class='" . esc_attr( $class ) . "' "; |
307 | - | if ( 'on' == et_get_option( $value['id'] ) ) { $checked = 'checked="checked"'; } |
307 | + | |
308 | - | else { $checked = ''; } |
308 | + | $dimensions = apply_filters( 'et_print_thumbnail_dimensions', " width='" . esc_attr( $width ) . "' height='" .esc_attr( $height ) . "'" ); |
309 | - | } |
309 | + | |
310 | - | elseif ( 'on' == $value['std'] ) { $checked = 'checked="checked"'; } |
310 | + | $output .= " alt='" . esc_attr( strip_tags( $alttext ) ) . "'{$dimensions} />"; |
311 | - | ?> |
311 | + | |
312 | - | <input type="checkbox" class="checkbox" name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] );?>" <?php echo $checked; ?> /> |
312 | + | if ( ! $resize ) $output = $thumbnail; |
313 | - | </div> <!-- end box-content div --> |
313 | + | } else { |
314 | - | </div> <!-- end epanel-box-small div --> |
314 | + | $output = $thumbnail; |
315 | } | |
316 | - | <?php } elseif ( 'support' == $value['type'] ) { ?> |
316 | + | |
317 | if ($echoout) echo $output; | |
318 | - | <div class="inner-content"> |
318 | + | else return $output; |
319 | - | <?php include( TEMPLATEPATH . "/includes/functions/" . $value['name'] . ".php" ); ?> |
319 | + | } |
320 | - | </div> |
320 | + | } |
321 | ||
322 | - | <?php } elseif ( 'contenttab-wrapstart' == $value['type'] || 'subcontent-start' == $value['type'] ) { ?> |
322 | + | if ( ! function_exists( 'et_new_thumb_resize' ) ){ |
323 | function et_new_thumb_resize( $thumbnail, $width, $height, $alt='', $forstyle = false ){ | |
324 | - | <?php $et_contenttab_class = 'contenttab-wrapstart' == $value['type'] ? 'content-div' : 'tab-content'; ?> |
324 | + | global $shortname; |
325 | ||
326 | - | <div id="<?php echo esc_attr( $value['name'] ); ?>" class="<?php echo esc_attr( $et_contenttab_class ); ?>"> |
326 | + | $new_method = true; |
327 | $new_method_thumb = ''; | |
328 | - | <?php } elseif ( 'contenttab-wrapend' == $value['type'] || 'subcontent-end' == $value['type'] ) { ?> |
328 | + | $external_source = false; |
329 | ||
330 | - | </div> <!-- end <?php echo esc_html( $value['name'] ); ?> div --> |
330 | + | $allow_new_thumb_method = !$external_source && $new_method; |
331 | ||
332 | - | <?php } elseif ( 'subnavtab-start' == $value['type'] ) { ?> |
332 | + | if ( $allow_new_thumb_method && $thumbnail <> '' ){ |
333 | $et_crop = true; | |
334 | - | <ul class="idTabs"> |
334 | + | $new_method_thumb = et_resize_image( $thumbnail, $width, $height, $et_crop ); |
335 | if ( is_wp_error( $new_method_thumb ) ) $new_method_thumb = ''; | |
336 | - | <?php } elseif ( 'subnavtab-end' == $value['type'] ) { ?> |
336 | + | } |
337 | ||
338 | - | </ul> |
338 | + | $thumb = esc_attr( $new_method_thumb ); |
339 | ||
340 | - | <?php } elseif ( 'subnav-tab' == $value['type'] ) { ?> |
340 | + | $output = '<img src="' . esc_url( $thumb ) . '" alt="' . esc_attr( $alt ) . '" width =' . esc_attr( $width ) . ' height=' . esc_attr( $height ) . ' />'; |
341 | ||
342 | - | <li><a href="#<?php echo esc_attr( $value['name'] ); ?>"><span class="pngfix"><?php echo esc_html( $value['desc'] ); ?></span></a></li> |
342 | + | return ( !$forstyle ) ? $output : $thumb; |
343 | } | |
344 | - | <?php } elseif ($value['type'] == "clearfix") { ?> |
344 | + | } |
345 | ||
346 | - | <div class="clearfix"></div> |
346 | + | if ( ! function_exists( 'et_multisite_thumbnail' ) ){ |
347 | function et_multisite_thumbnail( $thumbnail = '' ) { | |
348 | - | <?php } ?> |
348 | + | // do nothing if it's not a Multisite installation or current site is the main one |
349 | if ( is_main_site() ) return $thumbnail; | |
350 | - | <?php } //end foreach ($options as $value) ?> |
350 | + | |
351 | # get the real image url | |
352 | - | </div> <!-- end epanel-content div --> |
352 | + | preg_match( '#([_0-9a-zA-Z-]+/)?files/(.+)#', $thumbnail, $matches ); |
353 | - | </div> <!-- end epanel-content-wrap div --> |
353 | + | if ( isset( $matches[2] ) ){ |
354 | - | </div> <!-- end epanel div --> |
354 | + | $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $matches[2] ); |
355 | - | </div> <!-- end epanel-wrapper div --> |
355 | + | if ( is_file( $file ) ) $thumbnail = str_replace( ABSPATH, trailingslashit( get_site_url( 1 ) ), $file ); |
356 | else $thumbnail = ''; | |
357 | - | <div id="epanel-bottom"> |
357 | + | } |
358 | - | <?php wp_nonce_field( 'epanel_nonce' ); ?> |
358 | + | |
359 | - | <input name="save" type="submit" value="<?php esc_html_e( 'Save changes', $themename ); ?>" id="epanel-save" /> |
359 | + | return $thumbnail; |
360 | - | <input type="hidden" name="action" value="save_epanel" /> |
360 | + | } |
361 | } | |
362 | - | <img src="<?php echo esc_url( get_template_directory_uri() . '/epanel/images/defaults.png' ); ?>" class="defaults-button" alt="no" /> |
362 | + | |
363 | - | </div><!-- end epanel-bottom div --> |
363 | + | if ( ! function_exists( 'et_is_portrait' ) ){ |
364 | function et_is_portrait($imageurl, $post='', $ignore_cfields = false){ | |
365 | - | </form> |
365 | + | if ( $post == '' ) global $post; |
366 | ||
367 | - | <div style="clear: both;"></div> |
367 | + | if ( get_post_meta($post->ID,'et_disable_portrait',true) == 1 ) return false; |
368 | - | <div style="position: relative;"> |
368 | + | |
369 | - | <div class="defaults-hover"> |
369 | + | if ( !$ignore_cfields ) { |
370 | - | <?php _e( 'This will return all of the settings throughout the options page to their default values. <strong>Are you sure you want to do this?', $themename ); ?></strong> |
370 | + | if ( get_post_meta($post->ID,'et_imagetype',true) == 'l' ) return false; |
371 | - | <div class="clearfix"></div> |
371 | + | if ( get_post_meta($post->ID,'et_imagetype',true) == 'p' ) return true; |
372 | - | <form method="post"> |
372 | + | } |
373 | - | <?php wp_nonce_field( 'et-nojs-reset_epanel', '_wpnonce_reset' ); ?> |
373 | + | |
374 | - | <input name="reset" type="submit" value="<?php esc_html_e( 'Reset', $themename ); ?>" id="epanel-reset" /> |
374 | + | $imageurl = et_path_reltoabs(et_multisite_thumbnail($imageurl)); |
375 | - | <input type="hidden" name="action" value="reset" /> |
375 | + | |
376 | - | </form> |
376 | + | $et_thumb_size = @getimagesize($imageurl); |
377 | - | <img src="<?php echo esc_url( get_template_directory_uri() . '/epanel/images/no.gif' ); ?>" class="no" alt="no" /> |
377 | + | if ( empty($et_thumb_size) ) { |
378 | - | </div> |
378 | + | $et_thumb_size = @getimagesize( str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $imageurl ) ); |
379 | - | </div> |
379 | + | if ( empty($et_thumb_size) ) return false; |
380 | } | |
381 | - | </div> <!-- end panel-wrap div --> |
381 | + | $et_thumb_width = $et_thumb_size[0]; |
382 | - | </div> <!-- end wrapper div --> |
382 | + | $et_thumb_height = $et_thumb_size[1]; |
383 | ||
384 | - | <div id="epanel-ajax-saving"> |
384 | + | $result = ($et_thumb_width < $et_thumb_height) ? true : false; |
385 | - | <img src="<?php echo esc_url( get_template_directory_uri() . '/epanel/images/saver.gif' ); ?>" alt="loading" id="loading" /> |
385 | + | |
386 | - | <span><?php esc_html_e( 'Saving...', $themename ); ?></span> |
386 | + | return $result; |
387 | - | </div> |
387 | + | } |
388 | } | |
389 | - | <?php |
389 | + | |
390 | - | } |
390 | + | if ( ! function_exists( 'et_path_reltoabs' ) ){ |
391 | - | } |
391 | + | function et_path_reltoabs( $imageurl ){ |
392 | - | /* --------------------------------------------- */ |
392 | + | if ( strpos(strtolower($imageurl), 'http://') !== false || strpos(strtolower($imageurl), 'https://') !== false ) return $imageurl; |
393 | ||
394 | - | add_action('wp_ajax_save_epanel', 'et_epanel_save_callback'); |
394 | + | if ( strpos( strtolower($imageurl), $_SERVER['HTTP_HOST'] ) !== false ) |
395 | - | function et_epanel_save_callback() { |
395 | + | return $imageurl; |
396 | - | check_ajax_referer( 'epanel_nonce' ); |
396 | + | else { |
397 | - | epanel_save_data( 'ajax' ); |
397 | + | $imageurl = esc_url( apply_filters( 'et_path_relative_image', site_url() . '/' ) . $imageurl ); |
398 | } | |
399 | - | die(); |
399 | + | |
400 | - | } |
400 | + | return $imageurl; |
401 | } | |
402 | - | if ( ! function_exists( 'epanel_save_data' ) ){ |
402 | + | } |
403 | - | function epanel_save_data( $source ){ |
403 | + | |
404 | - | global $options; |
404 | + | if ( ! function_exists( 'in_subcat' ) ){ |
405 | function in_subcat($blogcat,$current_cat='') { | |
406 | - | if ( !current_user_can('switch_themes') ) |
406 | + | $in_subcategory = false; |
407 | - | die('-1'); |
407 | + | |
408 | if (cat_is_ancestor_of($blogcat,$current_cat) || $blogcat == $current_cat) $in_subcategory = true; | |
409 | - | // load theme settings array |
409 | + | |
410 | - | et_load_core_options(); |
410 | + | return $in_subcategory; |
411 | } | |
412 | - | $epanel = basename(__FILE__); |
412 | + | } |
413 | ||
414 | - | if ( isset($_POST['action']) ) { |
414 | + | if ( ! function_exists( 'show_page_menu' ) ){ |
415 | - | do_action( 'et_epanel_changing_options' ); |
415 | + | function show_page_menu($customClass = 'nav clearfix', $addUlContainer = true, $addHomeLink = true){ |
416 | global $shortname, $themename, $exclude_pages, $strdepth, $page_menu, $is_footer; | |
417 | - | if ( 'save_epanel' == $_POST['action'] ) { |
417 | + | |
418 | - | if ( 'ajax' != $source ) check_admin_referer( 'epanel_nonce' ); |
418 | + | //excluded pages |
419 | if (et_get_option($shortname.'_menupages') <> '') $exclude_pages = implode(",", et_get_option($shortname.'_menupages')); | |
420 | - | foreach ( $options as $value ) { |
420 | + | |
421 | - | if ( isset( $value['id'] ) ) { |
421 | + | //dropdown for pages |
422 | - | if ( isset( $_POST[ $value['id'] ] ) ) { |
422 | + | $strdepth = ''; |
423 | - | if ( in_array( $value['type'], array( 'text', 'textlimit' ) ) ) { |
423 | + | if (et_get_option($shortname.'_enable_dropdowns') == 'on') $strdepth = "depth=".et_get_option($shortname.'_tiers_shown_pages'); |
424 | if ($strdepth == '') $strdepth = "depth=1"; | |
425 | - | if ( isset( $value['validation_type'] ) ) { |
425 | + | |
426 | - | // saves the value as integer |
426 | + | if ($is_footer) { $strdepth="depth=1"; $strdepth2 = $strdepth; } |
427 | - | if ( 'number' == $value['validation_type'] ) |
427 | + | |
428 | - | et_update_option( $value['id'], intval( stripslashes( $_POST[$value['id']] ) ) ); |
428 | + | $page_menu = wp_list_pages("sort_column=".et_get_option($shortname.'_sort_pages')."&sort_order=".et_get_option($shortname.'_order_page')."&".$strdepth."&exclude=".$exclude_pages."&title_li=&echo=0"); |
429 | ||
430 | - | // makes sure the option is a url |
430 | + | if ($addUlContainer) echo('<ul class="'.$customClass.'">'); |
431 | - | if ( 'url' == $value['validation_type'] ) |
431 | + | if (et_get_option($shortname . '_home_link') == 'on' && $addHomeLink) { ?> |
432 | - | et_update_option( $value['id'], esc_url_raw( stripslashes( $_POST[$value['id']] ) ) ); |
432 | + | <li <?php if (is_front_page() || is_home()) echo('class="current_page_item"') ?>><a href="<?php echo esc_url( home_url() ); ?>"><?php _e('Home',$themename); ?></a></li> |
433 | <?php }; | |
434 | - | /* |
434 | + | |
435 | - | * html is not allowed |
435 | + | echo $page_menu; |
436 | - | * wp_strip_all_tags can't be used here, because it returns trimmed text, some options need spaces ( e.g 'character to separate BlogName and Post title' option ) |
436 | + | if ($addUlContainer) echo('</ul>'); |
437 | - | */ |
437 | + | } |
438 | - | if ( 'nohtml' == $value['validation_type'] ) |
438 | + | } |
439 | - | et_update_option( $value['id'], stripslashes( wp_filter_nohtml_kses( $_POST[$value['id']] ) ) ); |
439 | + | |
440 | - | } else { |
440 | + | if ( ! function_exists( 'show_categories_menu' ) ){ |
441 | - | // use html allowed for posts if the validation type isn't provided |
441 | + | function show_categories_menu($customClass = 'nav clearfix', $addUlContainer = true){ |
442 | - | et_update_option( $value['id'], wp_kses_post( stripslashes( $_POST[$value['id']] ) ) ); |
442 | + | global $shortname, $themename, $category_menu, $exclude_cats, $hide, $strdepth2, $projects_cat; |
443 | - | } |
443 | + | |
444 | //excluded categories | |
445 | - | } elseif ( 'select' == $value['type'] ) { |
445 | + | if (et_get_option($shortname.'_menucats') <> '') $exclude_cats = implode(",", et_get_option($shortname.'_menucats')); |
446 | ||
447 | - | // select boxes that list pages / categories should save page/category ID ( as integer ) |
447 | + | //hide empty categories |
448 | - | if ( isset( $value['et_array_for'] ) && in_array( $value['et_array_for'], array( 'pages', 'categories' ) ) ) |
448 | + | if (et_get_option($shortname.'_categories_empty') == 'on') $hide = '1'; |
449 | - | et_update_option( $value['id'], intval( stripslashes( $_POST[$value['id']] ) ) ); |
449 | + | else $hide = '0'; |
450 | - | else // html is not allowed in select boxes |
450 | + | |
451 | - | et_update_option( $value['id'], sanitize_text_field( stripslashes( $_POST[$value['id']] ) ) ); |
451 | + | //dropdown for categories |
452 | $strdepth2 = ''; | |
453 | - | } elseif ( in_array( $value['type'], array( 'checkbox', 'checkbox2' ) ) ) { |
453 | + | if (et_get_option($shortname.'_enable_dropdowns_categories') == 'on') $strdepth2 = "depth=".et_get_option($shortname.'_tiers_shown_categories'); |
454 | if ($strdepth2 == '') $strdepth2 = "depth=1"; | |
455 | - | // saves 'on' value to the database, if the option is enabled |
455 | + | |
456 | - | et_update_option( $value['id'], 'on' ); |
456 | + | $args = "orderby=".et_get_option($shortname.'_sort_cat')."&order=".et_get_option($shortname.'_order_cat')."&".$strdepth2."&exclude=".$exclude_cats."&hide_empty=".$hide."&title_li=&echo=0"; |
457 | ||
458 | - | } elseif ( 'upload' == $value['type'] ) { |
458 | + | $categories = get_categories( $args ); |
459 | ||
460 | - | // makes sure the option is a url |
460 | + | if ( !empty($categories) ) { |
461 | - | et_update_option( $value['id'], esc_url_raw( stripslashes( $_POST[$value['id']] ) ) ); |
461 | + | $category_menu = wp_list_categories($args); |
462 | if ($addUlContainer) echo('<ul class="'.$customClass.'">'); | |
463 | - | } elseif ( 'textcolorpopup' == $value['type'] ) { |
463 | + | echo $category_menu; |
464 | if ($addUlContainer) echo('</ul>'); | |
465 | - | // the color value |
465 | + | } |
466 | - | et_update_option( $value['id'], sanitize_text_field( stripslashes( $_POST[$value['id']] ) ) ); |
466 | + | } |
467 | } | |
468 | - | } elseif ( 'textarea' == $value['type'] ) { |
468 | + | |
469 | function head_addons(){ | |
470 | - | if ( isset( $value['validation_type'] ) ) { |
470 | + | global $shortname, $default_colorscheme; |
471 | - | // html is not allowed |
471 | + | |
472 | - | if ( 'nohtml' == $value['validation_type'] ) |
472 | + | if ( apply_filters('et_get_additional_color_scheme',et_get_option($shortname.'_color_scheme')) <> $default_colorscheme ) { ?> |
473 | - | et_update_option( $value['id'], wp_strip_all_tags( stripslashes( $_POST[$value['id']] ) ) ); |
473 | + | <link rel="stylesheet" href="<?php echo esc_url( get_template_directory_uri() . '/style-' . et_get_option($shortname.'_color_scheme') . '.css' ); ?>" type="text/css" media="screen" /> |
474 | - | } else { |
474 | + | <?php }; |
475 | - | if ( current_user_can( 'unfiltered_html' ) ) |
475 | + | |
476 | - | et_update_option( $value['id'], stripslashes( $_POST[$value['id']] ) ); |
476 | + | if ( et_get_option($shortname.'_child_css') == 'on' && et_get_option($shortname.'_child_cssurl') <> '' ) { //Enable child stylesheet ?> |
477 | - | else |
477 | + | <link rel="stylesheet" href="<?php echo esc_url( et_get_option($shortname.'_child_cssurl') ); ?>" type="text/css" media="screen" /> |
478 | - | et_update_option( $value['id'], stripslashes( wp_filter_post_kses( addslashes( $_POST[$value['id']] ) ) ) ); // wp_filter_post_kses() expects slashed |
478 | + | <?php }; |
479 | - | } |
479 | + | |
480 | //prints the theme name, version in meta tag | |
481 | - | } elseif ( 'checkboxes' == $value['type'] ) { |
481 | + | if ( ! function_exists( 'get_custom_header' ) ){ |
482 | // compatibility with versions of WordPress prior to 3.4. | |
483 | - | // saves categories / pages IDs, |
483 | + | $theme_info = get_theme_data(TEMPLATEPATH . '/style.css'); |
484 | - | et_update_option( $value['id'], array_map( 'intval', stripslashes_deep( $_POST[$value['id']] ) ) ); |
484 | + | echo '<meta content="' . esc_attr( $theme_info['Name'] . ' v.' . $theme_info['Version'] ) . '" name="generator"/>'; |
485 | } else { | |
486 | - | } elseif ( 'different_checkboxes' == $value['type'] ) { |
486 | + | $theme_info = wp_get_theme(); |
487 | echo '<meta content="' . esc_attr( $theme_info->display('Name') . ' v.' . $theme_info->display('Version') ) . '" name="generator"/>'; | |
488 | - | // saves 'author/date/categories/comments' options |
488 | + | } |
489 | - | et_update_option( $value['id'], array_map( 'wp_strip_all_tags', stripslashes_deep( $_POST[$value['id']] ) ) ); |
489 | + | |
490 | if ( et_get_option( $shortname . '_custom_colors' ) == 'on' ) et_epanel_custom_colors_css(); | |
491 | - | } |
491 | + | |
492 | - | } else { |
492 | + | };// end function head_addons() |
493 | - | if ( in_array( $value['type'], array( 'checkbox', 'checkbox2' ) ) ) |
493 | + | add_action('wp_head','head_addons',7); |
494 | - | et_update_option( $value['id'] , 'false' ); |
494 | + | |
495 | - | elseif ( 'different_checkboxes' == $value['type'] ) |
495 | + | function integration_head(){ |
496 | - | et_update_option( $value['id'] , array() ); |
496 | + | global $shortname; |
497 | - | else |
497 | + | if (et_get_option($shortname.'_integration_head') <> '' && et_get_option($shortname.'_integrate_header_enable') == 'on') echo( et_get_option($shortname.'_integration_head') ); |
498 | - | et_delete_option( $value['id'] ); |
498 | + | }; |
499 | - | } |
499 | + | add_action('wp_head','integration_head',12); |
500 | - | } |
500 | + | |
501 | - | } |
501 | + | function integration_body(){ |
502 | global $shortname; | |
503 | - | if ( 'js_disabled' == $source ) header("Location: themes.php?page=$epanel&saved=true"); |
503 | + | if (et_get_option($shortname.'_integration_body') <> '' && et_get_option($shortname.'_integrate_body_enable') == 'on') echo( et_get_option($shortname.'_integration_body') ); |
504 | - | die('1'); |
504 | + | }; |
505 | add_action('wp_footer','integration_body',12); | |
506 | - | } else if( 'reset' == $_POST['action'] ) { |
506 | + | |
507 | - | check_admin_referer( 'et-nojs-reset_epanel', '_wpnonce_reset' ); |
507 | + | /*this function gets page name by its id*/ |
508 | if ( ! function_exists( 'get_pagename' ) ){ | |
509 | - | foreach ($options as $value) { |
509 | + | function get_pagename( $page_id ) |
510 | - | if ( isset($value['id']) ) { |
510 | + | { |
511 | - | et_delete_option( $value['id'] ); |
511 | + | $page_object = get_page( $page_id ); |
512 | - | if ( isset($value['std']) ) et_update_option( $value['id'], $value['std'] ); |
512 | + | |
513 | - | } |
513 | + | return apply_filters( 'the_title', $page_object->post_title, $page_id ); |
514 | - | } |
514 | + | } |
515 | } | |
516 | - | header("Location: themes.php?page=$epanel&reset=true"); |
516 | + | |
517 | - | die('1'); |
517 | + | /*this function gets category name by its id*/ |
518 | - | } |
518 | + | if ( ! function_exists( 'get_categname' ) ){ |
519 | - | } |
519 | + | function get_categname( $cat_id ) |
520 | - | } |
520 | + | { |
521 | - | } |
521 | + | return get_cat_name( $cat_id ); |
522 | } | |
523 | - | function et_epanel_media_upload_scripts() { |
523 | + | } |
524 | - | wp_enqueue_script('media-upload'); |
524 | + | |
525 | - | wp_enqueue_script('thickbox'); |
525 | + | /*this function gets category id by its name*/ |
526 | - | wp_register_script('my-upload', get_template_directory_uri().'/epanel/js/custom_uploader.js', array('jquery','media-upload','thickbox')); |
526 | + | if ( ! function_exists( 'get_catId' ) ){ |
527 | - | wp_enqueue_script('my-upload'); |
527 | + | function get_catId( $cat_name ) |
528 | - | } |
528 | + | { |
529 | $cat_name_id = is_numeric( $cat_name ) ? (int) $cat_name : (int) get_cat_ID( html_entity_decode( $cat_name, ENT_QUOTES ) ); | |
530 | - | function et_epanel_media_upload_styles() { |
530 | + | |
531 | - | wp_enqueue_style('thickbox'); |
531 | + | // wpml compatibility |
532 | - | } |
532 | + | if ( function_exists( 'icl_object_id' ) ) |
533 | $cat_name_id = (int) icl_object_id( $cat_name_id, 'category', true ); | |
534 | - | global $pagenow; |
534 | + | |
535 | - | if ( 'themes.php' == $pagenow && isset( $_GET['page'] ) && ( $_GET['page'] == basename(__FILE__) ) ) { |
535 | + | return $cat_name_id; |
536 | - | add_action('admin_print_scripts', 'et_epanel_media_upload_scripts'); |
536 | + | } |
537 | - | add_action('admin_print_styles', 'et_epanel_media_upload_styles'); |
537 | + | } |
538 | - | } ?> |
538 | + | |
539 | /*this function gets page id by its name*/ | |
540 | if ( ! function_exists( 'get_pageId' ) ){ | |
541 | function get_pageId( $page_name ) | |
542 | { | |
543 | if ( is_numeric( $page_name ) ) { | |
544 | $page_id = intval( $page_name ); | |
545 | } else { | |
546 | $page_name = html_entity_decode( $page_name, ENT_QUOTES ); | |
547 | $page = get_page_by_title( $page_name ); | |
548 | $page_id = intval( $page->ID ); | |
549 | } | |
550 | ||
551 | // wpml compatibility | |
552 | if ( function_exists( 'icl_object_id' ) ) | |
553 | $page_id = (int) icl_object_id( $page_id, 'page', true ); | |
554 | ||
555 | return $page_id; | |
556 | } | |
557 | } | |
558 | ||
559 | /** | |
560 | * Transforms an array of posts, pages, post_tags or categories ids | |
561 | * into corresponding "objects" ids, if WPML plugin is installed | |
562 | * | |
563 | * @param array $ids_array Posts, pages, post_tags or categories ids. | |
564 | * @param string $type "Object" type. | |
565 | * @return array IDs. | |
566 | */ | |
567 | if ( ! function_exists( 'et_generate_wpml_ids' ) ){ | |
568 | function et_generate_wpml_ids( $ids_array, $type ) { | |
569 | if ( function_exists( 'icl_object_id' ) ){ | |
570 | $wpml_ids = array(); | |
571 | foreach ( $ids_array as $id ) { | |
572 | $translated_id = icl_object_id( $id, $type, false ); | |
573 | if ( ! is_null( $translated_id ) ) $wpml_ids[] = $translated_id; | |
574 | } | |
575 | $ids_array = $wpml_ids; | |
576 | } | |
577 | ||
578 | return array_map( 'intval', $ids_array ); | |
579 | } | |
580 | } | |
581 | ||
582 | /*this function controls the meta titles display*/ | |
583 | if ( ! function_exists( 'elegant_titles' ) ){ | |
584 | function elegant_titles() { | |
585 | global $shortname; | |
586 | ||
587 | $sitename = get_bloginfo('name'); | |
588 | $site_description = get_bloginfo('description'); | |
589 | ||
590 | #if the title is being displayed on the homepage | |
591 | if (is_home() || is_front_page()) { | |
592 | if (et_get_option($shortname.'_seo_home_title') == 'on') echo et_get_option($shortname.'_seo_home_titletext'); | |
593 | else { | |
594 | $seo_home_type = et_get_option( $shortname . '_seo_home_type' ); | |
595 | $seo_home_separate = et_get_option($shortname.'_seo_home_separate'); | |
596 | ||
597 | if ( $seo_home_type == 'BlogName | Blog description' ) echo $sitename . esc_html( $seo_home_separate ) . $site_description; | |
598 | if ( $seo_home_type == 'Blog description | BlogName') echo $site_description . esc_html( $seo_home_separate ) . $sitename; | |
599 | if ( $seo_home_type == 'BlogName only') echo $sitename; | |
600 | } | |
601 | } | |
602 | #if the title is being displayed on single posts/pages | |
603 | if ( ( is_single() || is_page() ) && ! is_front_page() ) { | |
604 | global $wp_query; | |
605 | $postid = $wp_query->post->ID; | |
606 | $key = et_get_option($shortname.'_seo_single_field_title'); | |
607 | $exists3 = get_post_meta($postid, ''.$key.'', true); | |
608 | if (et_get_option($shortname.'_seo_single_title') == 'on' && $exists3 !== '' ) echo $exists3; | |
609 | else { | |
610 | $seo_single_type = et_get_option($shortname.'_seo_single_type'); | |
611 | $seo_single_separate = et_get_option($shortname.'_seo_single_separate'); | |
612 | if ( $seo_single_type == 'BlogName | Post title' ) echo $sitename . esc_html( $seo_single_separate ) . wp_title('',false,''); | |
613 | if ( $seo_single_type == 'Post title | BlogName' ) echo wp_title('',false,'') . esc_html( $seo_single_separate ) . $sitename; | |
614 | if ( $seo_single_type == 'Post title only' ) echo wp_title('',false,''); | |
615 | } | |
616 | ||
617 | } | |
618 | #if the title is being displayed on index pages (categories/archives/search results) | |
619 | if (is_category() || is_archive() || is_search()) { | |
620 | $seo_index_type = et_get_option($shortname.'_seo_index_type'); | |
621 | $seo_index_separate = et_get_option($shortname.'_seo_index_separate'); | |
622 | if ( $seo_index_type == 'BlogName | Category name' ) echo $sitename . esc_html( $seo_index_separate ) . wp_title('',false,''); | |
623 | if ( $seo_index_type == 'Category name | BlogName') echo wp_title('',false,'') . esc_html( $seo_index_separate ) . $sitename; | |
624 | if ( $seo_index_type == 'Category name only') echo wp_title('',false,''); | |
625 | } | |
626 | } | |
627 | } | |
628 | ||
629 | /*this function controls the meta description display*/ | |
630 | if ( ! function_exists( 'elegant_description' ) ){ | |
631 | function elegant_description() { | |
632 | global $shortname; | |
633 | ||
634 | #homepage descriptions | |
635 | if ( is_home() && et_get_option($shortname.'_seo_home_description') == 'on' ) echo '<meta name="description" content="' . esc_attr( et_get_option($shortname.'_seo_home_descriptiontext') ) .'" />'; | |
636 | ||
637 | #single page descriptions | |
638 | global $wp_query; | |
639 | if ( isset($wp_query->post->ID) ) $postid = $wp_query->post->ID; | |
640 | $key2 = et_get_option($shortname.'_seo_single_field_description'); | |
641 | if ( isset($postid) ) $exists = get_post_meta($postid, ''.$key2.'', true); | |
642 | if (et_get_option($shortname.'_seo_single_description') == 'on' && $exists !== '') { | |
643 | if (is_single() || is_page()) echo '<meta name="description" content="' . esc_attr( $exists ) . '" />'; | |
644 | } | |
645 | ||
646 | #index descriptions | |
647 | remove_filter('term_description','wpautop'); | |
648 | $cat = get_query_var('cat'); | |
649 | $exists2 = category_description($cat); | |
650 | $description_added = false; | |
651 | ||
652 | $seo_index_description = et_get_option($shortname.'_seo_index_description'); | |
653 | ||
654 | if ($exists2 !== '' && $seo_index_description == 'on') { | |
655 | if (is_category()) { | |
656 | echo '<meta name="description" content="'. esc_attr( $exists2 ) .'" />'; | |
657 | $description_added = true; | |
658 | } | |
659 | } | |
660 | if (is_archive() && $seo_index_description == 'on' && ! $description_added) { | |
661 | echo '<meta name="description" content="Currently viewing archives from'. esc_attr( wp_title('',false,'') ) .'" />'; | |
662 | $description_added = true; | |
663 | } | |
664 | if (is_search() && $seo_index_description == 'on' && ! $description_added) { | |
665 | echo '<meta name="description" content="'. esc_attr( wp_title('',false,'') ) .'" />'; | |
666 | $description_added = true; | |
667 | } | |
668 | } | |
669 | } | |
670 | ||
671 | /*this function controls the meta keywords display*/ | |
672 | if ( ! function_exists( 'elegant_keywords' ) ){ | |
673 | function elegant_keywords() { | |
674 | global $shortname; | |
675 | ||
676 | #homepage keywords | |
677 | if (is_home() && et_get_option($shortname.'_seo_home_keywords') == 'on') echo '<meta name="keywords" content="'.esc_attr( et_get_option($shortname.'_seo_home_keywordstext') ).'" />'; | |
678 | ||
679 | #single page keywords | |
680 | global $wp_query; | |
681 | if (isset($wp_query->post->ID)) $postid = $wp_query->post->ID; | |
682 | $key3 = et_get_option($shortname.'_seo_single_field_keywords'); | |
683 | if (isset($postid)) $exists4 = get_post_meta($postid, ''.$key3.'', true); | |
684 | if (isset($exists4) && $exists4 !== '' && et_get_option($shortname.'_seo_single_keywords') == 'on') { | |
685 | if (is_single() || is_page()) echo '<meta name="keywords" content="' . esc_attr( $exists4 ) . '" />'; | |
686 | } | |
687 | } | |
688 | } | |
689 | ||
690 | /*this function controls canonical urls*/ | |
691 | if ( ! function_exists( 'elegant_canonical' ) ){ | |
692 | function elegant_canonical() { | |
693 | global $shortname; | |
694 | ||
695 | #homepage urls | |
696 | if (is_home() && et_get_option($shortname.'_seo_home_canonical') == 'on') echo '<link rel="canonical" href="'. esc_url( home_url() ).'" />'; | |
697 | ||
698 | #single page urls | |
699 | global $wp_query; | |
700 | if (isset($wp_query->post->ID)) $postid = $wp_query->post->ID; | |
701 | if (et_get_option($shortname.'_seo_single_canonical') == 'on') { | |
702 | if (is_single() || is_page()) echo '<link rel="canonical" href="'.esc_url( get_permalink() ).'" />'; | |
703 | } | |
704 | ||
705 | #index page urls | |
706 | if (et_get_option($shortname.'_seo_index_canonical') == 'on') { | |
707 | $current_page_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
708 | if (is_archive() || is_category() || is_search()) echo '<link rel="canonical" href="'. esc_url( $current_page_url ).'" />'; | |
709 | } | |
710 | } | |
711 | } | |
712 | ||
713 | add_action('wp_head','add_favicon'); | |
714 | function add_favicon(){ | |
715 | global $shortname; | |
716 | ||
717 | $faviconUrl = et_get_option($shortname.'_favicon'); | |
718 | if ($faviconUrl <> '') echo('<link rel="shortcut icon" href="'.esc_url( $faviconUrl ).'" />'); | |
719 | } | |
720 | ||
721 | add_action( 'init', 'et_create_images_temp_folder' ); | |
722 | function et_create_images_temp_folder(){ | |
723 | #clean et_temp folder once per week | |
724 | if ( false !== $last_time = get_option( 'et_schedule_clean_images_last_time' ) ){ | |
725 | $timeout = 86400 * 7; | |
726 | if ( ( $timeout < ( time() - $last_time ) ) && '' != get_option( 'et_images_temp_folder' ) ) et_clean_temp_images( get_option( 'et_images_temp_folder' ) ); | |
727 | } | |
728 | ||
729 | if ( false !== get_option( 'et_images_temp_folder' ) ) return; | |
730 | ||
731 | $uploads_dir = wp_upload_dir(); | |
732 | $destination_dir = ( false === $uploads_dir['error'] ) ? path_join( $uploads_dir['basedir'], 'et_temp' ) : null; | |
733 | ||
734 | if ( ! wp_mkdir_p( $destination_dir ) ) update_option( 'et_images_temp_folder', '' ); | |
735 | else { | |
736 | update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) ); | |
737 | update_option( 'et_schedule_clean_images_last_time', time() ); | |
738 | } | |
739 | } | |
740 | ||
741 | if ( ! function_exists( 'et_clean_temp_images' ) ){ | |
742 | function et_clean_temp_images( $directory ){ | |
743 | $dir_to_clean = @ opendir( $directory ); | |
744 | ||
745 | if ( $dir_to_clean ) { | |
746 | while (($file = readdir( $dir_to_clean ) ) !== false ) { | |
747 | if ( substr($file, 0, 1) == '.' ) | |
748 | continue; | |
749 | if ( is_dir( $directory.'/'.$file ) ) | |
750 | et_clean_temp_images( path_join( $directory, $file ) ); | |
751 | else | |
752 | @ unlink( path_join( $directory, $file ) ); | |
753 | } | |
754 | closedir( $dir_to_clean ); | |
755 | } | |
756 | ||
757 | #set last time cleaning was performed | |
758 | update_option( 'et_schedule_clean_images_last_time', time() ); | |
759 | } | |
760 | } | |
761 | ||
762 | add_filter( 'update_option_upload_path', 'et_update_uploads_dir' ); | |
763 | function et_update_uploads_dir( $upload_path ){ | |
764 | #check if we have 'et_temp' folder within $uploads_dir['basedir'] directory, if not - try creating it, if it's not possible $destination_dir = null | |
765 | ||
766 | $destination_dir = ''; | |
767 | $uploads_dir = wp_upload_dir(); | |
768 | $et_temp_dir = path_join( $uploads_dir['basedir'], 'et_temp' ); | |
769 | ||
770 | if ( is_dir( $et_temp_dir ) || ( false === $uploads_dir['error'] && wp_mkdir_p( $et_temp_dir ) ) ){ | |
771 | $destination_dir = $et_temp_dir; | |
772 | update_option( 'et_schedule_clean_images_last_time', time() ); | |
773 | } | |
774 | ||
775 | update_option( 'et_images_temp_folder', preg_replace( '#\/\/#', '/', $destination_dir ) ); | |
776 | ||
777 | return $upload_path; | |
778 | } | |
779 | ||
780 | if ( ! function_exists( 'et_resize_image' ) ){ | |
781 | function et_resize_image( $thumb, $new_width, $new_height, $crop ){ | |
782 | if ( is_ssl() ) $thumb = preg_replace( '#^http://#', 'https://', $thumb ); | |
783 | $info = pathinfo($thumb); | |
784 | $ext = $info['extension']; | |
785 | $name = wp_basename($thumb, ".$ext"); | |
786 | $is_jpeg = false; | |
787 | $site_uri = apply_filters( 'et_resize_image_site_uri', site_url() ); | |
788 | $site_dir = apply_filters( 'et_resize_image_site_dir', ABSPATH ); | |
789 | ||
790 | // If multisite, not the main site, WordPress version < 3.5 or ms-files rewriting is enabled ( not the fresh WordPress installation, updated from the 3.4 version ) | |
791 | if ( is_multisite() && ! is_main_site() && ( ! function_exists( 'wp_get_mime_types' ) || get_site_option( 'ms_files_rewriting' ) ) ) { | |
792 | //Get main site url on multisite installation | |
793 | ||
794 | switch_to_blog( 1 ); | |
795 | $site_uri = site_url(); | |
796 | restore_current_blog(); | |
797 | } | |
798 | ||
799 | if ( 'jpeg' == $ext ) { | |
800 | $ext = 'jpg'; | |
801 | $name = preg_replace( '#.jpeg$#', '', $name ); | |
802 | $is_jpeg = true; | |
803 | } | |
804 | ||
805 | $suffix = "{$new_width}x{$new_height}"; | |
806 | ||
807 | $destination_dir = '' != get_option( 'et_images_temp_folder' ) ? preg_replace( '#\/\/#', '/', get_option( 'et_images_temp_folder' ) ) : null; | |
808 | ||
809 | $matches = apply_filters( 'et_resize_image_site_dir', array(), $site_dir ); | |
810 | if ( !empty($matches) ){ | |
811 | preg_match( '#'.$matches[1].'$#', $site_uri, $site_uri_matches ); | |
812 | if ( !empty($site_uri_matches) ){ | |
813 | $site_uri = str_replace( $matches[1], '', $site_uri ); | |
814 | $site_uri = preg_replace( '#/$#', '', $site_uri ); | |
815 | $site_dir = str_replace( $matches[1], '', $site_dir ); | |
816 | $site_dir = preg_replace( '#\\\/$#', '', $site_dir ); | |
817 | } | |
818 | } | |
819 | ||
820 | #get local name for use in file_exists() and get_imagesize() functions | |
821 | $localfile = str_replace( apply_filters( 'et_resize_image_localfile', $site_uri, $site_dir, et_multisite_thumbnail($thumb) ), $site_dir, et_multisite_thumbnail($thumb) ); | |
822 | ||
823 | $add_to_suffix = ''; | |
824 | if ( file_exists( $localfile ) ) $add_to_suffix = filesize( $localfile ) . '_'; | |
825 | ||
826 | #prepend image filesize to be able to use images with the same filename | |
827 | $suffix = $add_to_suffix . $suffix; | |
828 | $destfilename_attributes = '-' . $suffix . '.' . $ext; | |
829 | ||
830 | $checkfilename = ( '' != $destination_dir && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name ); | |
831 | $checkfilename .= $destfilename_attributes; | |
832 | ||
833 | if ( $is_jpeg ) $checkfilename = preg_replace( '#.jpeg$#', '.jpg', $checkfilename ); | |
834 | ||
835 | $uploads_dir = wp_upload_dir(); | |
836 | $uploads_dir['basedir'] = preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] ); | |
837 | ||
838 | if ( null !== $destination_dir && '' != $destination_dir && apply_filters('et_enable_uploads_detection', true) ){ | |
839 | $site_dir = trailingslashit( preg_replace( '#\/\/#', '/', $uploads_dir['basedir'] ) ); | |
840 | $site_uri = trailingslashit( $uploads_dir['baseurl'] ); | |
841 | } | |
842 | ||
843 | #check if we have an image with specified width and height | |
844 | ||
845 | if ( file_exists( $checkfilename ) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename ); | |
846 | ||
847 | $size = @getimagesize( $localfile ); | |
848 | if ( !$size ) return new WP_Error('invalid_image_path', __('Image doesn\'t exist'), $thumb); | |
849 | list($orig_width, $orig_height, $orig_type) = $size; | |
850 | ||
851 | #check if we're resizing the image to smaller dimensions | |
852 | if ( $orig_width > $new_width || $orig_height > $new_height ){ | |
853 | if ( $orig_width < $new_width || $orig_height < $new_height ){ | |
854 | #don't resize image if new dimensions > than its original ones | |
855 | if ( $orig_width < $new_width ) $new_width = $orig_width; | |
856 | if ( $orig_height < $new_height ) $new_height = $orig_height; | |
857 | ||
858 | #regenerate suffix and appended attributes in case we changed new width or new height dimensions | |
859 | $suffix = "{$add_to_suffix}{$new_width}x{$new_height}"; | |
860 | $destfilename_attributes = '-' . $suffix . '.' . $ext; | |
861 | ||
862 | $checkfilename = ( '' != $destination_dir && null !== $destination_dir ) ? path_join( $destination_dir, $name ) : path_join( dirname( $localfile ), $name ); | |
863 | $checkfilename .= $destfilename_attributes; | |
864 | ||
865 | #check if we have an image with new calculated width and height parameters | |
866 | if ( file_exists($checkfilename) ) return str_replace( $site_dir, trailingslashit( $site_uri ), $checkfilename ); | |
867 | } | |
868 | ||
869 | #we didn't find the image in cache, resizing is done here | |
870 | if ( ! function_exists( 'wp_get_image_editor' ) ) { | |
871 | // compatibility with versions of WordPress prior to 3.5. | |
872 | $result = image_resize( $localfile, $new_width, $new_height, $crop, $suffix, $destination_dir ); | |
873 | } else { | |
874 | $et_image_editor = wp_get_image_editor( $localfile ); | |
875 | ||
876 | if ( ! is_wp_error( $et_image_editor ) ) { | |
877 | $et_image_editor->resize( $new_width, $new_height, $crop ); | |
878 | ||
879 | // generate correct file name/path | |
880 | $et_new_image_name = $et_image_editor->generate_filename( $suffix, $destination_dir ); | |
881 | ||
882 | do_action( 'et_resize_image_before_save', $et_image_editor, $et_new_image_name ); | |
883 | ||
884 | $et_image_editor->save( $et_new_image_name ); | |
885 | ||
886 | // assign new image path | |
887 | $result = $et_new_image_name; | |
888 | } else { | |
889 | // assign a WP_ERROR ( WP_Image_Editor instance wasn't created properly ) | |
890 | $result = $et_image_editor; | |
891 | } | |
892 | } | |
893 | ||
894 | if ( ! is_wp_error( $result ) ) { | |
895 | // transform local image path into URI | |
896 | ||
897 | if ( $is_jpeg ) $thumb = preg_replace( '#.jpeg$#', '.jpg', $thumb); | |
898 | ||
899 | $site_dir = str_replace( '\\', '/', $site_dir ); | |
900 | $result = str_replace( '\\', '/', $result ); | |
901 | $result = str_replace( '//', '/', $result ); | |
902 | $result = str_replace( $site_dir, trailingslashit( $site_uri ), $result ); | |
903 | } | |
904 | ||
905 | #returns resized image path or WP_Error ( if something went wrong during resizing ) | |
906 | return $result; | |
907 | } | |
908 | ||
909 | #returns unmodified image, for example in case if the user is trying to resize 800x600px to 1920x1080px image | |
910 | return $thumb; | |
911 | } | |
912 | } | |
913 | ||
914 | add_action( 'pre_get_posts', 'et_custom_posts_per_page' ); | |
915 | function et_custom_posts_per_page( $query = false ) { | |
916 | global $shortname; | |
917 | ||
918 | if ( is_admin() ) return; | |
919 | ||
920 | if ( ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() ) return; | |
921 | ||
922 | if ( $query->is_category ) { | |
923 | $query->set( 'posts_per_page', (int) et_get_option( $shortname . '_catnum_posts', '10' ) ); | |
924 | } elseif ( $query->is_tag ) { | |
925 | $query->set( 'posts_per_page', (int) et_get_option( $shortname . '_tagnum_posts', '10' ) ); | |
926 | } elseif ( $query->is_search ) { | |
927 | if ( isset($_GET['et_searchform_submit']) ) { | |
928 | $postTypes = array(); | |
929 | if ( !isset($_GET['et-inc-posts']) && !isset($_GET['et-inc-pages']) ) $postTypes = array('post'); | |
930 | if ( isset($_GET['et-inc-pages']) ) $postTypes = array('page'); | |
931 | if ( isset($_GET['et-inc-posts']) ) $postTypes[] = 'post'; | |
932 | $query->set( 'post_type', $postTypes ); | |
933 | ||
934 | if ( isset( $_GET['et-month-choice'] ) && $_GET['et-month-choice'] != 'no-choice' ) { | |
935 | $et_year = substr($_GET['et-month-choice'],0,4); | |
936 | $et_month = substr($_GET['et-month-choice'], 4, strlen($_GET['et-month-choice'])-4); | |
937 | ||
938 | $query->set( 'year', absint($et_year) ); | |
939 | $query->set( 'monthnum', absint($et_month) ); | |
940 | } | |
941 | ||
942 | if ( isset( $_GET['et-cat'] ) && $_GET['et-cat'] != 0 ) | |
943 | $query->set( 'cat', absint($_GET['et-cat']) ); | |
944 | } | |
945 | $query->set( 'posts_per_page', (int) et_get_option( $shortname . '_searchnum_posts', '10' ) ); | |
946 | } elseif ( $query->is_archive ) { | |
947 | $query->set( 'posts_per_page', (int) et_get_option( $shortname . '_archivenum_posts', '10' ) ); | |
948 | } | |
949 | } | |
950 | ||
951 | add_filter('pre_set_site_transient_update_themes', 'et_check_themes_updates'); | |
952 | function et_check_themes_updates( $update_transient ){ | |
953 | global $wp_version; | |
954 | ||
955 | if ( !isset($update_transient->checked) ) return $update_transient; | |
956 | else $themes = $update_transient->checked; | |
957 | ||
958 | $send_to_api = array( | |
959 | 'action' => 'check_theme_updates', | |
960 | 'installed_themes' => $themes | |
961 | ); | |
962 | ||
963 | $options = array( | |
964 | 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), | |
965 | 'body' => $send_to_api, | |
966 | 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() | |
967 | ); | |
968 | ||
969 | $last_update = new stdClass(); | |
970 | ||
971 | $theme_request = wp_remote_post( 'http://www.elegantthemes.com/api/api.php', $options ); | |
972 | if ( !is_wp_error($theme_request) && wp_remote_retrieve_response_code($theme_request) == 200 ){ | |
973 | $theme_response = unserialize( wp_remote_retrieve_body( $theme_request ) ); | |
974 | if ( !empty($theme_response) ) { | |
975 | $update_transient->response = array_merge(!empty($update_transient->response) ? $update_transient->response : array(),$theme_response); | |
976 | $last_update->checked = $themes; | |
977 | $last_update->response = $theme_response; | |
978 | } | |
979 | } | |
980 | ||
981 | $last_update->last_checked = time(); | |
982 | set_site_transient( 'et_update_themes', $last_update ); | |
983 | ||
984 | return $update_transient; | |
985 | } | |
986 | ||
987 | add_filter('site_transient_update_themes', 'et_add_themes_to_update_notification'); | |
988 | function et_add_themes_to_update_notification( $update_transient ){ | |
989 | $et_update_themes = get_site_transient( 'et_update_themes' ); | |
990 | if ( !is_object($et_update_themes) || !isset($et_update_themes->response) ) return $update_transient; | |
991 | $update_transient->response = array_merge(!empty($update_transient->response) ? $update_transient->response : array(), $et_update_themes->response); | |
992 | ||
993 | return $update_transient; | |
994 | } | |
995 | ||
996 | add_filter( 'default_hidden_meta_boxes', 'et_show_hidden_metaboxes', 10, 2 ); | |
997 | function et_show_hidden_metaboxes( $hidden, $screen ){ | |
998 | # make custom fields and excerpt meta boxes show by default | |
999 | if ( 'post' == $screen->base || 'page' == $screen->base ) | |
1000 | $hidden = array('slugdiv', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); | |
1001 | ||
1002 | return $hidden; | |
1003 | } | |
1004 | ||
1005 | add_filter('widget_title','et_widget_force_title'); | |
1006 | function et_widget_force_title( $title ){ | |
1007 | #add an empty title for widgets ( otherwise it might break the sidebar layout ) | |
1008 | if ( $title == '' ) $title = ' '; | |
1009 | ||
1010 | return $title; | |
1011 | } | |
1012 | ||
1013 | //modify the comment counts to only reflect the number of comments minus pings | |
1014 | if( version_compare( phpversion(), '4.4', '>=' ) ) add_filter('get_comments_number', 'et_comment_count', 0); | |
1015 | function et_comment_count( $count ) { | |
1016 | if ( ! is_admin() ) { | |
1017 | global $id; | |
1018 | $get_comments = get_comments( array('post_id' => $id, 'status' => 'approve') ); | |
1019 | $comments_by_type = separate_comments($get_comments); | |
1020 | return count($comments_by_type['comment']); | |
1021 | } else { | |
1022 | return $count; | |
1023 | } | |
1024 | } | |
1025 | ||
1026 | add_action( 'admin_init', 'et_theme_check_clean_installation' ); | |
1027 | function et_theme_check_clean_installation(){ | |
1028 | add_action( 'admin_notices', 'et_theme_epanel_reminder' ); | |
1029 | } | |
1030 | ||
1031 | if ( ! function_exists( 'et_theme_epanel_reminder' ) ){ | |
1032 | function et_theme_epanel_reminder(){ | |
1033 | global $shortname, $themename, $current_screen; | |
1034 | ||
1035 | if ( false === et_get_option( $shortname . '_logo' ) && 'appearance_page_core_functions' != $current_screen->id ){ | |
1036 | printf( __('<div class="updated"><p>This is a fresh installation of %1$s theme. Don\'t forget to go to <a href="%2$s">ePanel</a> to set it up. This message will disappear once you have clicked the Save button within the <a href="%2$s">theme\'s options page</a>.</p></div>',$themename), wp_get_theme(), admin_url( 'themes.php?page=core_functions.php' ) ); | |
1037 | } | |
1038 | } | |
1039 | } | |
1040 | ||
1041 | add_filter( 'gettext', 'et_admin_update_theme_message', 20, 3 ); | |
1042 | function et_admin_update_theme_message( $default_translated_text, $original_text, $domain ) { | |
1043 | global $themename; | |
1044 | $theme_page_message = 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>. <em>Automatic update is unavailable for this theme.</em>'; | |
1045 | $updates_page_message = 'Update package not available.'; | |
1046 | ||
1047 | if ( is_admin() && $original_text === $theme_page_message ) { | |
1048 | return __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>. <em>Auto-updates are not available for this theme. If this is an Elegant Themes theme, then you must re-download the theme from the member\'s area and <a href="http://www.elegantthemes.com/members-area/documentation.html#update" target="_blank">re-install it</a> in order to update it to the latest version.</em>', $themename ); | |
1049 | } | |
1050 | ||
1051 | if ( is_admin() && $original_text === $updates_page_message ){ | |
1052 | return __( 'Auto-updates are not available for this theme. If this is an Elegant Themes theme, then you must re-download the theme from the member\'s area and <a href="http://www.elegantthemes.com/members-area/documentation.html#update" target="_blank">re-install it</a> in order to update it to the latest version.', $themename ); | |
1053 | } | |
1054 | ||
1055 | return $default_translated_text; | |
1056 | } | |
1057 | ||
1058 | add_filter( 'body_class', 'et_add_fullwidth_body_class' ); | |
1059 | function et_add_fullwidth_body_class( $classes ){ | |
1060 | $fullwidth_view = false; | |
1061 | ||
1062 | if ( is_page_template('page-full.php') ) $fullwidth_view = true; | |
1063 | ||
1064 | if ( is_page() || is_single() ){ | |
1065 | $et_ptemplate_settings = get_post_meta( get_queried_object_id(),'et_ptemplate_settings',true ); | |
1066 | $fullwidth = isset( $et_ptemplate_settings['et_fullwidthpage'] ) ? (bool) $et_ptemplate_settings['et_fullwidthpage'] : false; | |
1067 | ||
1068 | if ( $fullwidth ) $fullwidth_view = true; | |
1069 | } | |
1070 | ||
1071 | if ( is_single() && 'on' == get_post_meta( get_queried_object_id(), '_et_full_post', true ) ) $fullwidth_view = true; | |
1072 | ||
1073 | $classes[] = apply_filters( 'et_fullwidth_view_body_class', $fullwidth_view ) ? 'et_fullwidth_view' : 'et_includes_sidebar'; | |
1074 | ||
1075 | return $classes; | |
1076 | } | |
1077 | ||
1078 | function et_add_responsive_shortcodes_css(){ | |
1079 | global $shortname; | |
1080 | ||
1081 | if ( 'on' == et_get_option( $shortname . '_responsive_shortcodes', 'on' ) ) | |
1082 | wp_enqueue_style( 'et-shortcodes-responsive-css', ET_SHORTCODES_DIR . '/css/shortcodes_responsive.css', false, ET_SHORTCODES_VERSION, 'all' ); | |
1083 | } | |
1084 | ||
1085 | /** | |
1086 | * Loads theme settings | |
1087 | * | |
1088 | */ | |
1089 | if ( ! function_exists( 'et_load_core_options' ) ) { | |
1090 | function et_load_core_options() { | |
1091 | global $shortname; | |
1092 | require_once( get_template_directory() . esc_attr( "/epanel/options_{$shortname}.php" ) ); | |
1093 | } | |
1094 | } | |
1095 | ||
1096 | /** | |
1097 | * Adds custom css option content to <head> | |
1098 | * | |
1099 | */ | |
1100 | function et_add_custom_css() { | |
1101 | global $shortname; | |
1102 | ||
1103 | $custom_css = et_get_option( "{$shortname}_custom_css" ); | |
1104 | ||
1105 | if ( false === $custom_css || '' == $custom_css ) return; | |
1106 | ||
1107 | echo '<style type="text/css" id="et-custom-css">' . "\n" . $custom_css . "\n" . '</style>'; | |
1108 | } | |
1109 | add_action( 'wp_head', 'et_add_custom_css', 100 ); | |
1110 | ||
1111 | if ( ! function_exists( 'et_get_google_fonts' ) ) : | |
1112 | /** | |
1113 | * Returns the list of popular google fonts | |
1114 | * | |
1115 | */ | |
1116 | function et_get_google_fonts() { | |
1117 | $google_fonts = array( | |
1118 | 'Open Sans' => array( | |
1119 | 'styles' => '300italic,400italic,600italic,700italic,800italic,400,300,600,700,800', | |
1120 | 'character_set' => 'latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic', | |
1121 | 'type' => 'sans-serif', | |
1122 | ), | |
1123 | 'Oswald' => array( | |
1124 | 'styles' => '400,300,700', | |
1125 | 'character_set' => 'latin,latin-ext', | |
1126 | 'type' => 'sans-serif', | |
1127 | ), | |
1128 | 'Droid Sans' => array( | |
1129 | 'styles' => '400,700', | |
1130 | 'character_set' => 'latin', | |
1131 | 'type' => 'sans-serif', | |
1132 | ), | |
1133 | 'Lato' => array( | |
1134 | 'styles' => '400,100,100italic,300,300italic,400italic,700,700italic,900,900italic', | |
1135 | 'character_set' => 'latin', | |
1136 | 'type' => 'sans-serif', | |
1137 | ), | |
1138 | 'Open Sans Condensed' => array( | |
1139 | 'styles' => '300,300italic,700', | |
1140 | 'character_set' => 'latin,cyrillic-ext,latin-ext,greek-ext,greek,vietnamese,cyrillic', | |
1141 | 'type' => 'sans-serif', | |
1142 | ), | |
1143 | 'PT Sans' => array( | |
1144 | 'styles' => '400,400italic,700,700italic', | |
1145 | 'character_set' => 'latin,latin-ext,cyrillic', | |
1146 | 'type' => 'sans-serif', | |
1147 | ), | |
1148 | 'Ubuntu' => array( | |
1149 | 'styles' => '400,300,300italic,400italic,500,500italic,700,700italic', | |
1150 | 'character_set' => 'latin,cyrillic-ext,cyrillic,greek-ext,greek,latin-ext', | |
1151 | 'type' => 'sans-serif', | |
1152 | ), | |
1153 | 'PT Sans Narrow' => array( | |
1154 | 'styles' => '400,700', | |
1155 | 'character_set' => 'latin,latin-ext,cyrillic', | |
1156 | 'type' => 'sans-serif', | |
1157 | ), | |
1158 | 'Yanone Kaffeesatz' => array( | |
1159 | 'styles' => '400,200,300,700', | |
1160 | 'character_set' => 'latin,latin-ext', | |
1161 | 'type' => 'sans-serif', | |
1162 | ), | |
1163 | 'Roboto Condensed' => array( | |
1164 | 'styles' => '400,300,300italic,400italic,700,700italic', | |
1165 | 'character_set' => 'latin,cyrillic-ext,latin-ext,greek-ext,cyrillic,greek,vietnamese', | |
1166 | 'type' => 'sans-serif', | |
1167 | ), | |
1168 | 'Source Sans Pro' => array( | |
1169 | 'styles' => '400,200,200italic,300,300italic,400italic,600,600italic,700,700italic,900,900italic', | |
1170 | 'character_set' => 'latin,latin-ext', | |
1171 | 'type' => 'sans-serif', | |
1172 | ), | |
1173 | 'Nunito' => array( | |
1174 | 'styles' => '400,300,700', | |
1175 | 'character_set' => 'latin', | |
1176 | 'type' => 'sans-serif', | |
1177 | ), | |
1178 | 'Francois One' => array( | |
1179 | 'styles' => '400', | |
1180 | 'character_set' => 'latin,latin-ext', | |
1181 | 'type' => 'sans-serif', | |
1182 | ), | |
1183 | 'Roboto' => array( | |
1184 | 'styles' => '400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic', | |
1185 | 'character_set' => 'latin,cyrillic-ext,latin-ext,cyrillic,greek-ext,greek,vietnamese', | |
1186 | 'type' => 'sans-serif', | |
1187 | ), | |
1188 | 'Raleway' => array( | |
1189 | 'styles' => '400,100,200,300,600,500,700,800,900', | |
1190 | 'character_set' => 'latin', | |
1191 | 'type' => 'sans-serif', | |
1192 | ), | |
1193 | 'Arimo' => array( | |
1194 | 'styles' => '400,400italic,700italic,700', | |
1195 | 'character_set' => 'latin,cyrillic-ext,latin-ext,greek-ext,cyrillic,greek,vietnamese', | |
1196 | 'type' => 'sans-serif', | |
1197 | ), | |
1198 | 'Cuprum' => array( | |
1199 | 'styles' => '400,400italic,700italic,700', | |
1200 | 'character_set' => 'latin,latin-ext,cyrillic', | |
1201 | 'type' => 'sans-serif', | |
1202 | ), | |
1203 | 'Play' => array( | |
1204 | 'styles' => '400,700', | |
1205 | 'character_set' => 'latin,cyrillic-ext,cyrillic,greek-ext,greek,latin-ext', | |
1206 | 'type' => 'sans-serif', | |
1207 | ), | |
1208 | 'Dosis' => array( | |
1209 | 'styles' => '400,200,300,500,600,700,800', | |
1210 | 'character_set' => 'latin,latin-ext', | |
1211 | 'type' => 'sans-serif', | |
1212 | ), | |
1213 | 'Abel' => array( | |
1214 | 'styles' => '400', | |
1215 | 'character_set' => 'latin', | |
1216 | 'type' => 'sans-serif', | |
1217 | ), | |
1218 | 'Droid Serif' => array( | |
1219 | 'styles' => '400,400italic,700,700italic', | |
1220 | 'character_set' => 'latin', | |
1221 | 'type' => 'serif', | |
1222 | ), | |
1223 | 'Arvo' => array( | |
1224 | 'styles' => '400,400italic,700,700italic', | |
1225 | 'character_set' => 'latin', | |
1226 | 'type' => 'serif', | |
1227 | ), | |
1228 | 'Lora' => array( | |
1229 | 'styles' => '400,400italic,700,700italic', | |
1230 | 'character_set' => 'latin', | |
1231 | 'type' => 'serif', | |
1232 | ), | |
1233 | 'Rokkitt' => array( | |
1234 | 'styles' => '400,700', | |
1235 | 'character_set' => 'latin', | |
1236 | 'type' => 'serif', | |
1237 | ), | |
1238 | 'PT Serif' => array( | |
1239 | 'styles' => '400,400italic,700,700italic', | |
1240 | 'character_set' => 'latin,cyrillic', | |
1241 | 'type' => 'serif', | |
1242 | ), | |
1243 | 'Bitter' => array( | |
1244 | 'styles' => '400,400italic,700', | |
1245 | 'character_set' => 'latin,latin-ext', | |
1246 | 'type' => 'serif', | |
1247 | ), | |
1248 | 'Merriweather' => array( | |
1249 | 'styles' => '400,300,900,700', | |
1250 | 'character_set' => 'latin', | |
1251 | 'type' => 'serif', | |
1252 | ), | |
1253 | 'Vollkorn' => array( | |
1254 | 'styles' => '400,400italic,700italic,700', | |
1255 | 'character_set' => 'latin', | |
1256 | 'type' => 'serif', | |
1257 | ), | |
1258 | 'Cantata One' => array( | |
1259 | 'styles' => '400', | |
1260 | 'character_set' => 'latin,latin-ext', | |
1261 | 'type' => 'serif', | |
1262 | ), | |
1263 | 'Kreon' => array( | |
1264 | 'styles' => '400,300,700', | |
1265 | 'character_set' => 'latin', | |
1266 | 'type' => 'serif', | |
1267 | ), | |
1268 | 'Josefin Slab' => array( | |
1269 | 'styles' => '400,100,100italic,300,300italic,400italic,600,700,700italic,600italic', | |
1270 | 'character_set' => 'latin', | |
1271 | 'type' => 'serif', | |
1272 | ), | |
1273 | 'Playfair Display' => array( | |
1274 | 'styles' => '400,400italic,700,700italic,900italic,900', | |
1275 | 'character_set' => 'latin,latin-ext,cyrillic', | |
1276 | 'type' => 'serif', | |
1277 | ), | |
1278 | 'Bree Serif' => array( | |
1279 | 'styles' => '400', | |
1280 | 'character_set' => 'latin,latin-ext', | |
1281 | 'type' => 'serif', | |
1282 | ), | |
1283 | 'Crimson Text' => array( | |
1284 | 'styles' => '400,400italic,600,600italic,700,700italic', | |
1285 | 'character_set' => 'latin', | |
1286 | 'type' => 'serif', | |
1287 | ), | |
1288 | 'Old Standard TT' => array( | |
1289 | 'styles' => '400,400italic,700', | |
1290 | 'character_set' => 'latin', | |
1291 | 'type' => 'serif', | |
1292 | ), | |
1293 | 'Sanchez' => array( | |
1294 | 'styles' => '400,400italic', | |
1295 | 'character_set' => 'latin,latin-ext', | |
1296 | 'type' => 'serif', | |
1297 | ), | |
1298 | 'Crete Round' => array( | |
1299 | 'styles' => '400,400italic', | |
1300 | 'character_set' => 'latin,latin-ext', | |
1301 | 'type' => 'serif', | |
1302 | ), | |
1303 | 'Cardo' => array( | |
1304 | 'styles' => '400,400italic,700', | |
1305 | 'character_set' => 'latin,greek-ext,greek,latin-ext', | |
1306 | 'type' => 'serif', | |
1307 | ), | |
1308 | 'Noticia Text' => array( | |
1309 | 'styles' => '400,400italic,700,700italic', | |
1310 | 'character_set' => 'latin,vietnamese,latin-ext', | |
1311 | 'type' => 'serif', | |
1312 | ), | |
1313 | 'Judson' => array( | |
1314 | 'styles' => '400,400italic,700', | |
1315 | 'character_set' => 'latin', | |
1316 | 'type' => 'serif', | |
1317 | ), | |
1318 | 'Lobster' => array( | |
1319 | 'styles' => '400', | |
1320 | 'character_set' => 'latin,cyrillic-ext,latin-ext,cyrillic', | |
1321 | 'type' => 'cursive', | |
1322 | ), | |
1323 | 'Unkempt' => array( | |
1324 | 'styles' => '400,700', | |
1325 | 'character_set' => 'latin', | |
1326 | 'type' => 'cursive', | |
1327 | ), | |
1328 | 'Changa One' => array( | |
1329 | 'styles' => '400,400italic', | |
1330 | 'character_set' => 'latin', | |
1331 | 'type' => 'cursive', | |
1332 | ), | |
1333 | 'Special Elite' => array( | |
1334 | 'styles' => '400', | |
1335 | 'character_set' => 'latin', | |
1336 | 'type' => 'cursive', | |
1337 | ), | |
1338 | 'Chewy' => array( | |
1339 | 'styles' => '400', | |
1340 | 'character_set' => 'latin', | |
1341 | 'type' => 'cursive', | |
1342 | ), | |
1343 | 'Comfortaa' => array( | |
1344 | 'styles' => '400,300,700', | |
1345 | 'character_set' => 'latin,cyrillic-ext,greek,latin-ext,cyrillic', | |
1346 | 'type' => 'cursive', | |
1347 | ), | |
1348 | 'Boogaloo' => array( | |
1349 | 'styles' => '400', | |
1350 | 'character_set' => 'latin', | |
1351 | 'type' => 'cursive', | |
1352 | ), | |
1353 | 'Fredoka One' => array( | |
1354 | 'styles' => '400', | |
1355 | 'character_set' => 'latin', | |
1356 | 'type' => 'cursive', | |
1357 | ), | |
1358 | 'Luckiest Guy' => array( | |
1359 | 'styles' => '400', | |
1360 | 'character_set' => 'latin', | |
1361 | 'type' => 'cursive', | |
1362 | ), | |
1363 | 'Cherry Cream Soda' => array( | |
1364 | 'styles' => '400', | |
1365 | 'character_set' => 'latin', | |
1366 | 'type' => 'cursive', | |
1367 | ), | |
1368 | 'Lobster Two' => array( | |
1369 | 'styles' => '400,400italic,700,700italic', | |
1370 | 'character_set' => 'latin', | |
1371 | 'type' => 'cursive', | |
1372 | ), | |
1373 | 'Righteous' => array( | |
1374 | 'styles' => '400', | |
1375 | 'character_set' => 'latin,latin-ext', | |
1376 | 'type' => 'cursive', | |
1377 | ), | |
1378 | 'Squada One' => array( | |
1379 | 'styles' => '400', | |
1380 | 'character_set' => 'latin', | |
1381 | 'type' => 'cursive', | |
1382 | ), | |
1383 | 'Black Ops One' => array( | |
1384 | 'styles' => '400', | |
1385 | 'character_set' => 'latin,latin-ext', | |
1386 | 'type' => 'cursive', | |
1387 | ), | |
1388 | 'Happy Monkey' => array( | |
1389 | 'styles' => '400', | |
1390 | 'character_set' => 'latin,latin-ext', | |
1391 | 'type' => 'cursive', | |
1392 | ), | |
1393 | 'Passion One' => array( | |
1394 | 'styles' => '400,700,900', | |
1395 | 'character_set' => 'latin,latin-ext', | |
1396 | 'type' => 'cursive', | |
1397 | ), | |
1398 | 'Nova Square' => array( | |
1399 | 'styles' => '400', | |
1400 | 'character_set' => 'latin', | |
1401 | 'type' => 'cursive', | |
1402 | ), | |
1403 | 'Metamorphous' => array( | |
1404 | 'styles' => '400', | |
1405 | 'character_set' => 'latin,latin-ext', | |
1406 | 'type' => 'cursive', | |
1407 | ), | |
1408 | 'Poiret One' => array( | |
1409 | 'styles' => '400', | |
1410 | 'character_set' => 'latin,latin-ext,cyrillic', | |
1411 | 'type' => 'cursive', | |
1412 | ), | |
1413 | 'Bevan' => array( | |
1414 | 'styles' => '400', | |
1415 | 'character_set' => 'latin', | |
1416 | 'type' => 'cursive', | |
1417 | ), | |
1418 | 'Shadows Into Light' => array( | |
1419 | 'styles' => '400', | |
1420 | 'character_set' => 'latin', | |
1421 | 'type' => 'cursive', | |
1422 | ), | |
1423 | 'The Girl Next Door' => array( | |
1424 | 'styles' => '400', | |
1425 | 'character_set' => 'latin', | |
1426 | 'type' => 'cursive', | |
1427 | ), | |
1428 | 'Coming Soon' => array( | |
1429 | 'styles' => '400', | |
1430 | 'character_set' => 'latin', | |
1431 | 'type' => 'cursive', | |
1432 | ), | |
1433 | 'Dancing Script' => array( | |
1434 | 'styles' => '400,700', | |
1435 | 'character_set' => 'latin', | |
1436 | 'type' => 'cursive', | |
1437 | ), | |
1438 | 'Pacifico' => array( | |
1439 | 'styles' => '400', | |
1440 | 'character_set' => 'latin', | |
1441 | 'type' => 'cursive', | |
1442 | ), | |
1443 | ||
1444 | 'Crafty Girls' => array( | |
1445 | 'styles' => '400', | |
1446 | 'character_set' => 'latin', | |
1447 | 'type' => 'cursive', | |
1448 | ), | |
1449 | 'Calligraffitti' => array( | |
1450 | 'styles' => '400', | |
1451 | 'character_set' => 'latin', | |
1452 | 'type' => 'cursive', | |
1453 | ), | |
1454 | 'Rock Salt' => array( | |
1455 | 'styles' => '400', | |
1456 | 'character_set' => 'latin', | |
1457 | 'type' => 'cursive', | |
1458 | ), | |
1459 | 'Amatic SC' => array( | |
1460 | 'styles' => '400,700', | |
1461 | 'character_set' => 'latin', | |
1462 | 'type' => 'cursive', | |
1463 | ), | |
1464 | 'Leckerli One' => array( | |
1465 | 'styles' => '400', | |
1466 | 'character_set' => 'latin', | |
1467 | 'type' => 'cursive', | |
1468 | ), | |
1469 | 'Tangerine' => array( | |
1470 | 'styles' => '400,700', | |
1471 | 'character_set' => 'latin', | |
1472 | 'type' => 'cursive', | |
1473 | ), | |
1474 | 'Reenie Beanie' => array( | |
1475 | 'styles' => '400', | |
1476 | 'character_set' => 'latin', | |
1477 | 'type' => 'cursive', | |
1478 | ), | |
1479 | 'Satisfy' => array( | |
1480 | 'styles' => '400', | |
1481 | 'character_set' => 'latin', | |
1482 | 'type' => 'cursive', | |
1483 | ), | |
1484 | 'Gloria Hallelujah' => array( | |
1485 | 'styles' => '400', | |
1486 | 'character_set' => 'latin', | |
1487 | 'type' => 'cursive', | |
1488 | ), | |
1489 | 'Permanent Marker' => array( | |
1490 | 'styles' => '400', | |
1491 | 'character_set' => 'latin', | |
1492 | 'type' => 'cursive', | |
1493 | ), | |
1494 | 'Covered By Your Grace' => array( | |
1495 | 'styles' => '400', | |
1496 | 'character_set' => 'latin', | |
1497 | 'type' => 'cursive', | |
1498 | ), | |
1499 | 'Walter Turncoat' => array( | |
1500 | 'styles' => '400', | |
1501 | 'character_set' => 'latin', | |
1502 | 'type' => 'cursive', | |
1503 | ), | |
1504 | 'Patrick Hand' => array( | |
1505 | 'styles' => '400', | |
1506 | 'character_set' => 'latin,vietnamese,latin-ext', | |
1507 | 'type' => 'cursive', | |
1508 | ), | |
1509 | 'Schoolbell' => array( | |
1510 | 'styles' => '400', | |
1511 | 'character_set' => 'latin', | |
1512 | 'type' => 'cursive', | |
1513 | ), | |
1514 | 'Indie Flower' => array( | |
1515 | 'styles' => '400', | |
1516 | 'character_set' => 'latin', | |
1517 | 'type' => 'cursive', | |
1518 | ), | |
1519 | ); | |
1520 | ||
1521 | return apply_filters( 'et_google_fonts', $google_fonts ); | |
1522 | } | |
1523 | endif; | |
1524 | ||
1525 | if ( ! function_exists( 'et_get_websafe_font_stack' ) ) : | |
1526 | /** | |
1527 | * Determines a websafe font stack, using font type | |
1528 | * | |
1529 | */ | |
1530 | function et_get_websafe_font_stack( $type = 'sans-serif' ) { | |
1531 | $font_stack = ''; | |
1532 | ||
1533 | switch ( $type ) { | |
1534 | case 'sans-serif': | |
1535 | $font_stack = 'Helvetica, Arial, Lucida, sans-serif'; | |
1536 | break; | |
1537 | case 'serif': | |
1538 | $font_stack = 'Georgia, "Times New Roman", serif'; | |
1539 | break; | |
1540 | case 'cursive': | |
1541 | $font_stack = 'cursive'; | |
1542 | break; | |
1543 | } | |
1544 | ||
1545 | return $font_stack; | |
1546 | } | |
1547 | endif; | |
1548 | ||
1549 | if ( ! function_exists( 'et_gf_attach_font' ) ) : | |
1550 | /** | |
1551 | * Attaches Google Font to given css elements | |
1552 | * | |
1553 | */ | |
1554 | function et_gf_attach_font( $et_gf_font_name, $elements ) { | |
1555 | $google_fonts = et_get_google_fonts(); | |
1556 | ||
1557 | printf( '%s { font-family: \'%s\', %s; }', | |
1558 | esc_html( $elements ), | |
1559 | esc_html( $et_gf_font_name ), | |
1560 | et_get_websafe_font_stack( $google_fonts[$et_gf_font_name]['type'] ) | |
1561 | ); | |
1562 | } | |
1563 | endif; | |
1564 | ||
1565 | if ( ! function_exists( 'et_gf_enqueue_fonts' ) ) : | |
1566 | /** | |
1567 | * Enqueues Google Fonts | |
1568 | * | |
1569 | */ | |
1570 | function et_gf_enqueue_fonts( $et_gf_font_names ) { | |
1571 | global $shortname; | |
1572 | ||
1573 | if ( ! is_array( $et_gf_font_names ) || empty( $et_gf_font_names ) ) return; | |
1574 | ||
1575 | $google_fonts = et_get_google_fonts(); | |
1576 | $protocol = is_ssl() ? 'https' : 'http'; | |
1577 | ||
1578 | foreach ( $et_gf_font_names as $et_gf_font_name ) { | |
1579 | $google_font_character_set = $google_fonts[$et_gf_font_name]['character_set']; | |
1580 | ||
1581 | // By default, only latin and latin-ext subsets are loaded, all available subsets can be enabled in ePanel | |
1582 | if ( 'false' == et_get_option( "{$shortname}_gf_enable_all_character_sets", 'false' ) ) { | |
1583 | $latin_ext = ''; | |
1584 | if ( false !== strpos( $google_fonts[$et_gf_font_name]['character_set'], 'latin-ext' ) ) | |
1585 | $latin_ext = ',latin-ext'; | |
1586 | ||
1587 | $google_font_character_set = "latin{$latin_ext}"; | |
1588 | } | |
1589 | ||
1590 | $query_args = array( | |
1591 | 'family' => sprintf( '%s:%s', | |
1592 | str_replace( ' ', '+', $et_gf_font_name ), | |
1593 | apply_filters( 'et_gf_set_styles', $google_fonts[$et_gf_font_name]['styles'], $et_gf_font_name ) | |
1594 | ), | |
1595 | 'subset' => apply_filters( 'et_gf_set_character_set', $google_font_character_set, $et_gf_font_name ), | |
1596 | ); | |
1597 | ||
1598 | $et_gf_font_name_slug = strtolower( str_replace( ' ', '-', $et_gf_font_name ) ); | |
1599 | wp_enqueue_style( 'et-gf-' . $et_gf_font_name_slug, add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); | |
1600 | } | |
1601 | } | |
1602 | endif; |