/** * Render HTML markup for the "upload_min" field type. * @access protected * @since 6.0.0 * @param string $key The unique ID of this field. * @param array $args Arguments used to construct this field. * @return string HTML markup for the field. */ protected function render_field_upload_min($key, $args) { $this->_has_upload = true; $url = $this->get_value($key, $args['std']); $id = $this->get_value($key . '-id', 0); $placeholder = WF()->get_placeholder_image_url(); $class = ' no-image'; if ('' != $url || 0 < intval($id)) { $class = ' has-image'; } $html = '<span class="upload-field">' . "\n"; $html .= '<input id="' . esc_attr($key) . '" name="' . esc_attr($key) . '" type="hidden" class="input-upload" value="' . esc_attr($url) . '" /> <a href="#" class="button" data-uploader-title="' . esc_attr(sprintf(__('Select %s', 'woothemes'), $args['name'])) . '" data-uploader-button-text="' . esc_attr(sprintf(__('Use image as %s', 'woothemes'), $args['name'])) . '">' . __('Upload', 'woothemes') . '</a>' . "\n"; $html .= '<input id="' . esc_attr($key) . '-id" name="' . esc_attr($key) . '-id" type="hidden" class="input-upload-id" value="' . esc_attr($id) . '" /> ' . "\n"; $html .= '</span>' . "\n"; $html .= '<div class="image-preview' . esc_attr($class) . '">' . "\n"; $html .= '<img src="' . esc_url($url) . '" data-placeholder="' . esc_url($placeholder) . '" />' . "\n"; $html .= '<a href="#" class="remove">' . sprintf(__('Remove %s', 'woothemes'), $args['name']) . '</a>' . "\n"; $html .= '</div><!--/.image-preview-->' . "\n"; return $html; }
// A class to handle all basic settings interactions. require_once $classes_path . 'class-wf-meta.php'; // Meta box generator class. /** * Returns the main instance of WF to prevent the need to use globals. * * @since 1.0.0 * @return object WF */ function WF() { return WF::instance(); } // End WF() // Run the WF() function to generate the initial instance. WF(); // Load the other WooFramework files. require_once $functions_path . 'admin-functions.php'; // Functions used in the WooFramework and in the theme files. require_once $functions_path . 'admin-setup.php'; // Set up the WooFramework. require_once $functions_path . 'admin-interface.php'; // Administration interfaces. require_once $functions_path . 'admin-seo.php'; // SEO functions. require_once $functions_path . 'admin-sbm.php'; // Widget Area functions. require_once $functions_path . 'admin-hooks.php'; // Contextual hooks. if (true == (bool) apply_filters('wf_enable_custom_nav', false)) { require_once $functions_path . 'admin-custom-nav.php';
/** * Update theme options in database with options as stored in theme. * @since 1.0.0 * @return void */ function woo_option_setup() { //Update EMPTY options $woo_array = array(); add_option('woo_options', $woo_array); $woo_array = WF()->settings->get_all(); // Allow child themes/plugins to filter here. $woo_array = apply_filters('woo_options_array', $woo_array); update_option('woo_options', $woo_array); }
function woo_get_dynamic_values($settings) { $all = WF()->settings->get_all(); if (is_array($all) && 0 < count($all)) { foreach ($settings as $k => $v) { $k = str_replace('woo_', '', $k); // Make sure we remove the prefix. if (isset($all['woo_' . $k])) { $settings[$k] = $all['woo_' . $k]; } } } return (array) apply_filters('woo_get_dynamic_values', $settings); }
<li><?php printf(__('Version %s', 'woothemes'), '<strong>' . $ct->__get('Version') . '</strong>'); ?> </li> <?php if ($ct->parent()) { ?> <li><?php printf(__('%s Version %s', 'woothemes'), $ct->parent()->__get('Name'), '<strong>' . $ct->parent()->__get('Version') . '</strong>'); ?> </li> <?php } if (current_user_can('install_themes')) { ?> <li><?php printf(__('WooFramework %s - %s', 'woothemes'), '<strong>' . $this->_theme_data['framework_version'] . '</strong>', sprintf(__('%sUpdate%s', 'woothemes') . ' <span class="dashicons dashicons-update"></span>', '<a href="' . esc_url(add_query_arg('page', 'woothemes_framework_update', admin_url('admin.php'))) . '">', '</a>')); ?> </li> <?php } ?> </ul> <hr /> <?php } } // End Class WF()->screens['welcome'] = new WF_Screen_Welcome();
</td> <td class="version"> <?php echo $this->_theme_data['theme_version']; ?> </td> </tr> </tbody> <tfoot> <tr class="odd"> <td> <strong><?php _e('WooFramework', 'woothemes'); ?> </strong> </td> <td class="version"> <?php echo $this->_theme_data['framework_version']; ?> </td> </tr> </tfoot> </table> <?php } } // End Class WF()->screens['framework'] = new WF_Screen_Framework();
function woo_image($args) { /* ------------------------------------------------------------------------- */ /* SET VARIABLES */ /* ------------------------------------------------------------------------- */ global $post; global $woo_options; //Defaults $key = 'image'; $width = null; $height = null; $class = ''; $quality = 90; $id = null; $link = 'src'; $repeat = 1; $offset = 0; $before = ''; $after = ''; $single = false; $force = false; $return = false; $is_auto_image = false; $src = ''; $meta = ''; $alignment = ''; $size = ''; $noheight = ''; $alt = ''; $img_link = ''; $attachment_id = array(); $attachment_src = array(); if (!is_array($args)) { parse_str($args, $args); } extract($args); $enable = get_option('pp_pb_post_loop_thumbnail_enable', '1') == true; if (!$enable) { if ($return) { return ''; } else { return; } } // Set post ID if (empty($id)) { $id = $post->ID; } $thumb_id = esc_html(get_post_meta($id, '_thumbnail_id', true)); // Set alignment if ($alignment == '') { $alignment = esc_html(get_post_meta($id, '_image_alignment', true)); } // Get standard sizes if (!$width && !$height) { $width = '100'; $height = '100'; } // Cast $width and $height to integer $width = intval($width); $height = intval($height); /* ------------------------------------------------------------------------- */ /* FIND IMAGE TO USE */ /* ------------------------------------------------------------------------- */ // When a custom image is sent through if ($src != '') { $custom_field = esc_url($src); $link = 'img'; // WP 2.9 Post Thumbnail support } elseif (get_option('woo_post_image_support') == 'true' && !empty($thumb_id)) { if (get_option('woo_pis_resize') == 'true') { if (0 == $height) { $img_data = wp_get_attachment_image_src($thumb_id, array(intval($width), 9999)); $height = $img_data[2]; } // Dynamically resize the post thumbnail $vt_crop = get_option('woo_pis_hard_crop'); if ($vt_crop == 'true') { $vt_crop = true; } else { $vt_crop = false; } $vt_image = vt_resize($thumb_id, '', $width, $height, $vt_crop); // Set fields for output $custom_field = esc_url($vt_image['url']); $width = $vt_image['width']; $height = $vt_image['height']; } else { // Use predefined size string if ($size) { $thumb_size = $size; } else { $thumb_size = array($width, $height); } $img_link = get_the_post_thumbnail($id, $thumb_size, array('class' => 'woo-image ' . esc_attr($class))); } // Grab the image from custom field } else { $custom_field = esc_url(get_post_meta($id, $key, true)); } // Automatic Image Thumbs - get first image from post attachment if (empty($custom_field) && get_option('woo_auto_img') == 'true' && empty($img_link) && !(is_singular() && in_the_loop() && $link == 'src')) { if ($offset >= 1) { $repeat = $repeat + $offset; } $attachments = get_children(array('post_parent' => $id, 'numberposts' => $repeat, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'DESC', 'orderby' => 'menu_order date')); // Search for and get the post attachment if (!empty($attachments)) { $counter = -1; foreach ($attachments as $att_id => $attachment) { $counter++; if ($counter < $offset) { continue; } if (get_option('woo_post_image_support') == 'true' && get_option('woo_pis_resize') == 'true') { // Dynamically resize the post thumbnail $vt_crop = get_option('woo_pis_hard_crop'); if ($vt_crop == 'true') { $vt_crop = true; } else { $vt_crop = false; } $vt_image = vt_resize($att_id, '', $width, $height, $vt_crop); // Set fields for output $custom_field = esc_url($vt_image['url']); $width = $vt_image['width']; $height = $vt_image['height']; } else { $src = wp_get_attachment_image_src($att_id, 'large', true); $custom_field = esc_url($src[0]); $attachment_id[] = $att_id; $src_arr[] = $custom_field; } $thumb_id = $att_id; $is_auto_image = true; } // Get the first img tag from content } else { $first_img = ''; $post = get_post($id); ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); if (!empty($matches[1][0])) { // Save Image URL $custom_field = esc_url($matches[1][0]); // Search for ALT tag $output = preg_match_all('/<img.+alt=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); if (!empty($matches[1][0])) { $alt = esc_attr($matches[1][0]); } } } } // Check if there is YouTube embed if (empty($custom_field) && empty($img_link)) { $embed = esc_html(get_post_meta($id, 'embed', true)); if ($embed) { $custom_field = esc_url(woo_get_video_image($embed)); } } // Return if there is no attachment or custom field set if (empty($custom_field) && empty($img_link)) { // Check if default placeholder image is uploaded // $placeholder = get_option( 'framework_woo_default_image' ); $placeholder = WF()->get_placeholder_image_url(); if ($placeholder && !(is_singular() && in_the_loop())) { $custom_field = esc_url($placeholder); // Resize the placeholder if if (get_option('woo_post_image_support') == 'true' && get_option('woo_pis_resize') == 'true') { // Dynamically resize the post thumbnail $vt_crop = get_option('woo_pis_hard_crop'); if ($vt_crop == 'true') { $vt_crop = true; } else { $vt_crop = false; } $vt_image = vt_resize('', $placeholder, $width, $height, $vt_crop); // Set fields for output $custom_field = esc_url($vt_image['url']); $width = $vt_image['width']; $height = $vt_image['height']; } } else { return; } } if (empty($src_arr) && empty($img_link)) { $src_arr[] = $custom_field; } /* ------------------------------------------------------------------------- */ /* BEGIN OUTPUT */ /* ------------------------------------------------------------------------- */ $output = ''; // Set output height and width $set_width = ' width="' . esc_attr($width) . '" '; $set_height = ''; if (!$noheight && 0 < $height) { $set_height = ' height="' . esc_attr($height) . '" '; } // Set standard class if ($class) { $class = 'woo-image ' . esc_attr($class); } else { $class = 'woo-image'; } // Do check to verify if images are smaller then specified. if ($force == true) { $set_width = ''; $set_height = ''; } // WP Post Thumbnail if (!empty($img_link)) { if ($link == 'img') { // Output the image without anchors $output .= wp_kses_post($before); $output .= $img_link; $output .= wp_kses_post($after); } elseif ($link == 'url') { // Output the large image $src = wp_get_attachment_image_src($thumb_id, 'large', true); $custom_field = esc_url($src[0]); $output .= $custom_field; } else { // Default - output with link if ((is_single() || is_page()) && $single == false) { $rel = 'rel="lightbox"'; $href = false; } else { $href = get_permalink($id); $rel = ''; } $title = 'title="' . esc_attr(get_the_title($id)) . '"'; $output .= wp_kses_post($before); if ($href == false) { $output .= $img_link; } else { $output .= '<a ' . $title . ' href="' . esc_url($href) . '" ' . $rel . '>' . $img_link . '</a>'; } $output .= wp_kses_post($after); } } elseif (get_option('woo_resize') == 'true' && empty($vt_image['url'])) { foreach ($src_arr as $key => $custom_field) { // Clean the image URL $href = esc_url($custom_field); $custom_field = cleanSource($custom_field); // Check if WPMU and set correct path AND that image isn't external if (function_exists('get_current_site')) { get_current_site(); //global $blog_id; Breaks with WP3 MS if (!$blog_id) { global $current_blog; $blog_id = $current_blog->blog_id; } if (isset($blog_id) && $blog_id > 0) { $imageParts = explode('files/', $custom_field); if (isset($imageParts[1])) { $custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; } } } //Set the ID to the Attachment's ID if it is an attachment if ($is_auto_image == true) { $quick_id = $attachment_id[$key]; } else { $quick_id = $id; } //Set custom meta if ($meta) { $alt = $meta; $title = 'title="' . esc_attr($meta) . '"'; } else { if ($alt != '' || !($alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true))) { $alt = esc_attr(get_post_meta($thumb_id, '_wp_attachment_image_alt', true)); } else { $alt = esc_attr(get_the_title($quick_id)); } $title = 'title="' . esc_attr(get_the_title($quick_id)) . '"'; } // Set alignment parameter if ($alignment != '') { $alignment = '&a=' . urlencode($alignment); } $img_url = esc_url(get_template_directory_uri() . '/functions/thumb.php?src=' . $custom_field . '&w=' . $width . '&h=' . $height . '&zc=1&q=' . $quality . $alignment); $img_link = '<img src="' . $img_url . '" alt="' . esc_attr($alt) . '" class="' . esc_attr(stripslashes($class)) . '" ' . $set_width . $set_height . ' />'; if ($link == 'img') { // Just output the image $output .= wp_kses_post($before); $output .= $img_link; $output .= wp_kses_post($after); } elseif ($link == 'url') { // Output the image without anchors if ($is_auto_image == true) { $src = wp_get_attachment_image_src($thumb_id, 'large', true); $custom_field = esc_url($src[0]); } $output .= $href; } else { // Default - output with link if ((is_single() || is_page()) && $single == false) { $rel = 'rel="lightbox"'; } else { $href = get_permalink($id); $rel = ''; } $output .= wp_kses_post($before); $output .= '<a ' . $title . ' href="' . esc_url($href) . '" ' . $rel . '>' . $img_link . '</a>'; $output .= wp_kses_post($after); } } // No dynamic resizing } else { foreach ($src_arr as $key => $custom_field) { //Set the ID to the Attachment's ID if it is an attachment if ($is_auto_image == true && isset($attachment_id[$key])) { $quick_id = $attachment_id[$key]; } else { $quick_id = $id; } //Set custom meta if ($meta) { $alt = esc_attr($meta); $title = 'title="' . esc_attr($meta) . '"'; } else { if (empty($alt)) { $alt = esc_attr(get_post_meta($thumb_id, '_wp_attachment_image_alt', true)); } $title = 'title="' . esc_attr(get_the_title($quick_id)) . '"'; } if (empty($alt)) { $alt = esc_attr(get_post($thumb_id)->post_excerpt); // If not, Use the Caption } if (empty($alt)) { $alt = esc_attr(get_post($thumb_id)->post_title); // Finally, use the title } $img_link = '<img src="' . esc_url($custom_field) . '" alt="' . esc_attr($alt) . '" ' . $set_width . $set_height . $title . ' class="' . esc_attr(stripslashes($class)) . '" />'; if ($link == 'img') { // Just output the image $output .= wp_kses_post($before); $output .= $img_link; $output .= wp_kses_post($after); } elseif ($link == 'url') { // Output the URL to original image if ($vt_image['url'] || $is_auto_image) { $src = wp_get_attachment_image_src($thumb_id, 'full', true); $custom_field = esc_url($src[0]); } $output .= $custom_field; } else { // Default - output with link if ((is_single() || is_page()) && $single == false) { // Link to the large image if single post if ($vt_image['url'] || $is_auto_image) { $src = wp_get_attachment_image_src($thumb_id, 'full', true); $custom_field = esc_url($src[0]); } $href = $custom_field; $rel = 'rel="lightbox"'; } else { $href = get_permalink($id); $rel = ''; } $output .= wp_kses_post($before); $output .= '<a href="' . esc_url($href) . '" ' . $rel . ' ' . $title . '>' . $img_link . '</a>'; $output .= wp_kses_post($after); } } } // Remove no height attribute - IE fix when no height is set $output = str_replace('height=""', '', $output); $output = str_replace('height="0"', '', $output); // Return or echo the output if ($return == TRUE) { return $output; } else { echo $output; } // Done }
/** * Load admin CSS on specific screens. * @since 6.0.0 * @return void */ function wf_load_admin_css() { $load_on = (array) apply_filters('wf_load_admin_css', array('woothemes', 'wf-framework', 'woothemes-backup')); wp_register_style('wf-admin', esc_url(WF()->get_assets_url() . 'css/admin.css'), array(), '1.0.0', 'all'); if (isset($_GET['page']) && in_array($_GET['page'], $load_on)) { wp_enqueue_style('wf-admin'); } }