コード例 #1
0
ファイル: skins-admin.php プロジェクト: iq007/MadScape
        /**
         * Settings page output
         */
        public function create_admin_page()
        {
            ?>

			<div class="wrap wpex-skins-admin">

				<h2>Theme Skins</h2>

				<?php 
            // Check if admin is enabled
            $notice = apply_filters('wpex_skins_deprecated_notice', true);
            // Display notice
            if ($notice) {
                ?>

					<div class="notice error" style="display:block!important;padding:20px;">
						<h4 style="margin:0 0 10px;font-size:16px;">Important Notice</h4>
						<p>Skins have been deprecated since Total 3.0.0. The theme has enough settings to allow you to create a design that fits your needs without loading extra bloat. If you select the "base" skin this admin panel will be removed and you will see an error message. To re-enable please visit the online snippets for this theme.</p>
						<p>We highly recommend you select the BASE skin and make all your edits via the Customizer to get the design you want or use a child theme (both are more optimized methods).</p>
					</div>

				<?php 
            }
            // Get skins array
            $skins = WPEX_Skin_Loader::skins_array();
            // Current skin from site_theme option
            $current_skin = wpex_active_skin();
            // Get fallback from redux
            if (!$current_skin) {
                $data = get_option('wpex_options');
                $current_skin = isset($data['site_theme']) ? $data['site_theme'] : 'base';
            }
            ?>

				<form method="post" action="options.php">

					<?php 
            settings_fields('wpex_skins_options');
            ?>

					<div class="wpex-skins-select theme-browser" id="theme_skin">

						<?php 
            // Loop through skins
            foreach ($skins as $key => $val) {
                $classes = 'wpex-skin theme';
                $checked = $active = '';
                if (!empty($current_skin) && $current_skin == $key) {
                    $checked = 'checked';
                    $classes .= ' active';
                }
                ?>

						<div class="<?php 
                echo $classes;
                ?>
">

							<input type="radio" id="wpex-skin-<?php 
                echo $key;
                ?>
" name="theme_skin" value="<?php 
                echo $key;
                ?>
" <?php 
                echo $checked;
                ?>
 class="wpex-skin-radio" />

							<?php 
                if (!empty($val['screenshot'])) {
                    ?>

								<div class="theme-screenshot">
									<img src="<?php 
                    echo esc_url($val['screenshot']);
                    ?>
" alt="Screenshot" />
								</div>

							<?php 
                } elseif (function_exists('wpex_placeholder_img_src')) {
                    ?>

								<div class="theme-screenshot">
									<img src="<?php 
                    echo wpex_placeholder_img_src();
                    ?>
" />
								</div>

							<?php 
                }
                ?>

							<h3 class="theme-name">
								<?php 
                if ('active' == $active) {
                    echo '<strong>Active:</strong> ';
                }
                ?>
								<?php 
                echo $val['name'];
                ?>
							</h3>

						</div>
						
						<?php 
            }
            ?>

					</div><!-- .wpex-skin -->

					<?php 
            submit_button();
            ?>

				</form>

			</div><!-- .wpex-skins-select -->

			<script type="text/javascript">
				( function($) {
					"use strict";
					$( '.wpex-skin' ).click( function() {
						$( '.wpex-skin' ).removeClass( 'active' );
						$( this ).addClass( 'active' );
						var radio = $(this).find( '.wpex-skin-radio' );
						radio.prop( 'checked', true );
						event.preventDefault();
					} );
				} ) ( jQuery );
			</script>

		<?php 
        }
コード例 #2
0
ファイル: core-functions.php プロジェクト: iq007/MadScape
/**
 * Returns correct HTMl for post thumbnails
 *
 * @since 2.0.0
 */
function wpex_get_post_thumbnail($args = array())
{
    // Check if retina is enabled
    $retina_img = '';
    $attr = array();
    // Default args
    $defaults = array('attachment' => get_post_thumbnail_id(), 'size' => 'full', 'width' => '', 'height' => '', 'crop' => 'center-center', 'alt' => '', 'class' => '', 'return' => 'html', 'style' => '', 'retina' => wpex_global_obj('retina'), 'schema_markup' => false, 'placeholder' => false);
    // Parse args
    $args = wp_parse_args($args, $defaults);
    // Extract args
    extract($args);
    // Return dummy image
    if ('dummy' == $attachment || $placeholder) {
        return '<img src="' . wpex_placeholder_img_src() . '" />';
    }
    // Return if there isn't any attachment
    if (!$attachment) {
        return;
    }
    // Sanitize variables
    $size = 'wpex-custom' == $size ? 'wpex_custom' : $size;
    $size = 'wpex_custom' == $size ? false : $size;
    $crop = !$crop ? 'center-center' : $crop;
    $crop = 'true' == $crop ? 'center-center' : $crop;
    // Image must have an alt
    if (empty($alt)) {
        $alt = get_post_meta($attachment, '_wp_attachment_image_alt', true);
    }
    if (empty($alt)) {
        $alt = trim(strip_tags(get_post_field('post_excerpt', $attachment)));
    }
    if (empty($alt)) {
        $alt = trim(strip_tags(get_the_title($attachment)));
        $alt = str_replace('_', ' ', $alt);
        $alt = str_replace('-', ' ', $alt);
    }
    // Prettify alt attribute
    if ($alt) {
        $alt = ucwords($alt);
    }
    // If image width and height equal '9999' return full image
    if ('9999' == $width && '9999' == $height) {
        $size = $size ? $size : 'full';
        $width = $height = '';
    }
    // Define crop locations
    $crop_locations = array_flip(wpex_image_crop_locations());
    // Set crop location if defined in format 'left-top' and turn into array
    if ($crop && in_array($crop, $crop_locations)) {
        $crop = 'center-center' == $crop ? true : explode('-', $crop);
    }
    // Get attachment URl
    $attachment_url = wp_get_attachment_url($attachment);
    // Return if there isn't any attachment URL
    if (!$attachment_url) {
        return;
    }
    // Add classes
    if ($class) {
        $attr['class'] = $class;
    }
    // Add alt
    if ($alt) {
        $attr['alt'] = esc_attr($alt);
    }
    // Add style
    if ($style) {
        $attr['style'] = $style;
    }
    // Add schema markup
    if ($schema_markup) {
        $attr['itemprop'] = 'image';
    }
    // If on the fly image resizing is enabled or a custom width/height is defined
    if (wpex_get_mod('image_resizing', true) || ($width || $height)) {
        // Add Classes
        if ($class) {
            $class = ' class="' . $class . '"';
        }
        // If size is defined and not equal to wpex_custom
        if ($size && 'wpex_custom' != $size) {
            $dims = wpex_get_thumbnail_sizes($size);
            $width = $dims['width'];
            $height = $dims['height'];
            $crop = !empty($dims['crop']) ? $dims['crop'] : $crop;
        }
        // Crop standard image
        $image = wpex_image_resize(array('image' => $attachment_url, 'width' => $width, 'height' => $height, 'crop' => $crop));
        // Generate retina version
        if ($retina) {
            $retina_img = wpex_generate_retina_image($attachment_url, $width, $height, $crop);
            if ($retina_img) {
                $attr['data-at2x'] = $retina_img;
            } else {
                $attr['data-no-retina'] = '';
            }
        }
        // Return HTMl
        if ($image) {
            // Return image URL
            if ('url' == $return) {
                return $image['url'];
            } else {
                // Add attributes
                $attr = array_map('esc_attr', $attr);
                $html = '';
                foreach ($attr as $name => $value) {
                    $html .= ' ' . esc_attr($name) . '="' . esc_attr($value) . '"';
                }
                // Return img
                return '<img src="' . esc_url($image['url']) . '" width="' . esc_attr($image['width']) . '" height="' . esc_attr($image['height']) . '"' . $html . ' />';
            }
        }
    } else {
        // Sanitize size
        $size = $size ? $size : 'full';
        // Create retina version if retina is enabled (not needed for full images)
        if ($retina) {
            // Retina not needed for full images
            if ('full' != $size) {
                $dims = wpex_get_thumbnail_sizes($size);
                $retina_img = wpex_generate_retina_image($attachment_url, $dims['width'], $dims['height'], $dims['crop']);
            }
            // Add retina tag
            if ($retina_img) {
                $attr['data-at2x'] = $retina_img;
            } else {
                $attr['data-no-retina'] = '';
            }
        }
        // Return image URL
        if ('url' == $return) {
            $src = wp_get_attachment_image_src($attachment, $size, false);
            return $src[0];
        } else {
            return wp_get_attachment_image($attachment, $size, false, $attr);
        }
    }
}
コード例 #3
0
ファイル: term-thumbnails.php プロジェクト: iq007/MadScape
 /**
  * Thumbnail column value added to category admin.
  *
  * @since 2.1.0
  */
 public function admin_column($columns, $column, $id)
 {
     // Add thumbnail to columns
     if ('wpex-term-thumbnail-col' == $column) {
         if ($thumbnail_id = $this->get_term_thumbnail_id($id, 'thumbnail_id', true)) {
             $image = wp_get_attachment_image_src($thumbnail_id, 'thumbnail');
             $image = $image[0];
         } else {
             $image = wpex_placeholder_img_src();
         }
         $columns .= '<img src="' . esc_url($image) . '" alt="' . esc_attr__('Thumbnail', 'total') . '" class="wp-post-image" height="48" width="48" />';
     }
     // Return columns
     return $columns;
 }