Ejemplo n.º 1
0
function wpreview_settings_page()
{
    $options = get_option('wp_review_options');
    $available_types = apply_filters('wp_review_metabox_types', array('star' => __('Star', 'wp-review'), 'point' => __('Point', 'wp-review'), 'percentage' => __('Percentage', 'wp-review')));
    $default_options = array('colors' => array('color' => '', 'fontcolor' => '', 'bgcolor1' => '', 'bgcolor2' => '', 'bordercolor' => ''), 'default_features' => array(), 'image_sizes' => array());
    // set defaults
    if (empty($options)) {
        update_option('wp_review_options', $options = $default_options);
    }
    if (empty($options['image_sizes'])) {
        $options['image_sizes'] = array();
    }
    $opt_name = 'wp_review_options_' . wp_get_theme();
    $options_updated = get_option($opt_name);
    $suggest_theme_defaults = true;
    if (!empty($_GET['wp-review-theme-defaults']) && empty($_GET['settings-updated'])) {
        wp_review_theme_defaults($options_updated, true);
        $options = get_option('wp_review_options');
        $suggest_theme_defaults = false;
    }
    // test to see if we need to sugges setting theme defaults
    if (empty($options_updated)) {
        $options_updated = array();
    }
    $opts_tmp = array_merge($options, $options_updated);
    if ($opts_tmp == $options) {
        $suggest_theme_defaults = false;
    }
    ?>
<div id="poststuff" class="wrap wp-review">
	<div id="post-body">
		<div id="col-right" style="float: left; padding-right: 3%; box-sizing: border-box;">
			<h2 style="margin-top: 0;"><?php 
    _e('WP Review Settings', 'wp-review');
    ?>
</h2>

			<form method="post" action="options.php">
			    <?php 
    settings_fields('wpreview-settings-group');
    ?>

				<?php 
    $defaultColors = apply_filters('wp_review_default_colors', array('color' => '#1e73be', 'fontcolor' => '#555555', 'bgcolor1' => '#e7e7e7', 'bgcolor2' => '#ffffff', 'bordercolor' => '#e7e7e7'));
    $defaultLocation = apply_filters('wp_review_default_location', 'bottom');
    $defaultCriteria = apply_filters('wp_review_default_criteria', array());
    $defaultItems = array();
    foreach ($defaultCriteria as $item) {
        $defaultItems[] = array('wp_review_item_title' => $item, 'wp_review_item_star' => '');
    }
    $options['colors'] = apply_filters('wp_review_colors', $options['colors'], 0);
    if (!isset($options['deafults'])) {
        $options['deafults'] = array();
    }
    /* Retrieve an existing value from the database. */
    $items = !empty($options['default_features']) ? $options['default_features'] : '';
    $color = !empty($options['colors']['color']) ? $options['colors']['color'] : '';
    $location = !empty($options['review_location']) ? $options['review_location'] : '';
    $fontcolor = !empty($options['colors']['fontcolor']) ? $options['colors']['fontcolor'] : '';
    $bgcolor1 = !empty($options['colors']['bgcolor1']) ? $options['colors']['bgcolor1'] : '';
    $bgcolor2 = !empty($options['colors']['bgcolor2']) ? $options['colors']['bgcolor2'] : '';
    $bordercolor = !empty($options['colors']['bordercolor']) ? $options['colors']['bordercolor'] : '';
    if ($items == '') {
        $items = $defaultItems;
    }
    if ($color == '') {
        $color = $defaultColors['color'];
    }
    if ($location == '') {
        $location = $defaultLocation;
    }
    if ($fontcolor == '') {
        $fontcolor = $defaultColors['fontcolor'];
    }
    if ($bgcolor1 == '') {
        $bgcolor1 = $defaultColors['bgcolor1'];
    }
    if ($bgcolor2 == '') {
        $bgcolor2 = $defaultColors['bgcolor2'];
    }
    if ($bordercolor == '') {
        $bordercolor = $defaultColors['bordercolor'];
    }
    $fields = array('location' => true, 'color' => true, 'fontcolor' => true, 'bgcolor1' => true, 'bgcolor2' => true, 'bordercolor' => true, 'custom_colors' => true, 'custom_location' => true, 'width' => true, 'align' => true);
    $displayed_fields = apply_filters('wp_review_metabox_item_fields', $fields);
    $location = apply_filters('wp_review_location', $location, 0);
    if (has_filter('wp_review_location')) {
        echo '<p class="wp-review-filter-msg"><div class="dashicons dashicons-info"></div>' . __('There is a filter set for the review location that may modify the options below.', 'wp-review') . '</p>';
    }
    if ($suggest_theme_defaults) {
        ?>
				<div class="wp-review-theme-defaults-msg updated settings-error">
					<p class="wp-review-field">
						<?php 
        _e('The current theme provides default settings for the plugin.', 'wp-review');
        ?>
<br />
					</p>
					<a href="<?php 
        echo admin_url('options-general.php?page=wp-review/admin/options.php&wp-review-theme-defaults=1');
        ?>
" class="button button-primary"><?php 
        _e('Set to theme defaults', 'wp-review');
        ?>
</a>
					<a href="#" class="dashicons dashicons-no-alt close-notice"></a>
				</div>
				<?php 
    }
    ?>

				<p class="wp-review-field">
					<label for="wp_review_location"><?php 
    _e('Review Location', 'wp-review');
    ?>
</label>
					<select name="wp_review_options[review_location]" id="wp_review_location">
						<option value="bottom" <?php 
    selected($location, 'bottom');
    ?>
><?php 
    _e('After Content', 'wp-review');
    ?>
</option>
						<option value="top" <?php 
    selected($location, 'top');
    ?>
><?php 
    _e('Before Content', 'wp-review');
    ?>
</option>
			            <option value="custom" <?php 
    selected($location, 'custom');
    ?>
><?php 
    _e('Custom (use shortcode)', 'wp-review');
    ?>
</option>
					</select>
				</p>
			    
			    <p class="wp-review-field" id="wp_review_shortcode_hint_field">
					
					<input id="wp_review_shortcode_hint" type="text" value="[wp-review]" readonly="readonly" />
			        <span><?php 
    _e('Copy &amp; paste this shortcode in the post content.', 'wp-review');
    ?>
</span>
				</p>

				<?php 
    if (has_filter('wp_review_colors')) {
        echo '<p class="wp-review-filter-msg"><div class="dashicons dashicons-info"></div>' . __('There is a filter set for the review colors that may modify the options below.', 'wp-review') . '</p>';
    }
    ?>
				
				<div class="wp-review-color-options">
					<p class="wp-review-field"<?php 
    if (empty($displayed_fields['color'])) {
        echo ' style="display: none;"';
    }
    ?>
>
						<label for="wp_review_color"><?php 
    _e('Review Color', 'wp-review');
    ?>
</label>
						<input type="text" class="wp-review-color" name="wp_review_options[colors][color]" value="<?php 
    echo $color;
    ?>
" />
					</p>

					<p class="wp-review-field"<?php 
    if (empty($displayed_fields['fontcolor'])) {
        echo ' style="display: none;"';
    }
    ?>
>
						<label for="wp_review_fontcolor"><?php 
    _e('Font Color', 'wp-review');
    ?>
</label>
						<input type="text" class="wp-review-color" name="wp_review_options[colors][fontcolor]" id ="wp_review_fontcolor" value="<?php 
    echo $fontcolor;
    ?>
" />
					</p>

					<p class="wp-review-field"<?php 
    if (empty($displayed_fields['bgcolor1'])) {
        echo ' style="display: none;"';
    }
    ?>
>
						<label for="wp_review_bgcolor1"><?php 
    _e('Heading Background Color', 'wp-review');
    ?>
</label>
						<input type="text" class="wp-review-color" name="wp_review_options[colors][bgcolor1]" id ="wp_review_bgcolor1" value="<?php 
    echo $bgcolor1;
    ?>
" />
					</p>

					<p class="wp-review-field"<?php 
    if (empty($displayed_fields['bgcolor2'])) {
        echo ' style="display: none;"';
    }
    ?>
>
						<label for="wp_review_bgcolor2"><?php 
    _e('Background Color', 'wp-review');
    ?>
</label>
						<input type="text" class="wp-review-color" name="wp_review_options[colors][bgcolor2]" id="wp_review_bgcolor2" value="<?php 
    echo $bgcolor2;
    ?>
" />
					</p>

					<p class="wp-review-field"<?php 
    if (empty($displayed_fields['bordercolor'])) {
        echo ' style="display: none;"';
    }
    ?>
>
						<label for="wp_review_bordercolor"><?php 
    _e('Border Color', 'wp-review');
    ?>
</label>
						<input type="text" class="wp-review-color" name="wp_review_options[colors][bordercolor]" id="wp_review_bordercolor" value="<?php 
    echo $bordercolor;
    ?>
" />
					</p>
				</div>

				<div class="wp-review-default-features" style="display: block;">
				<!-- Start repeater field -->
				<table id="wp-review-item" class="wp-review-item" width="100%">

					<thead>
						<tr>
							<th width="90%">
				<?php 
    if (has_filter('wp_review_default_criteria')) {
        echo '<p class="wp-review-filter-msg"><div class="dashicons dashicons-info"></div>' . __('Default features are set by a filter function. Remove it to change.', 'wp-review') . '</p>';
    } else {
        _e('Default features', 'wp-review');
    }
    ?>
							</th>
							<th width="10%"></th>
						</tr>
					</thead>

					<tbody>
					<?php 
    if (has_filter('wp_review_default_criteria')) {
        ?>
						<?php 
        foreach ($defaultCriteria as $item) {
            ?>
								<tr>
									<td>
										<input type="text" class="widefat" name="wp_review_options[default_features][]" value="<?php 
            if (!empty($item)) {
                echo esc_attr($item);
            }
            ?>
" disabled="disabled" readonly="readonly" />
									</td>
									<td></td>
								</tr>
							<?php 
        }
        ?>
					<?php 
    } else {
        ?>
 
						<?php 
        if (!empty($items)) {
            ?>
							<?php 
            foreach ($items as $item) {
                ?>

								<tr>
									<td>
										<input type="text" class="widefat" name="wp_review_options[default_features][]" value="<?php 
                if (!empty($item)) {
                    echo esc_attr($item);
                }
                ?>
" />
									</td>
									<td><a class="button remove-row" href="#"><?php 
                _e('Delete', 'wp-review');
                ?>
</a></td>
								</tr>
							<?php 
            }
            ?>
						<?php 
        }
        ?>
					<?php 
    }
    ?>
						<!-- empty hidden one for jQuery -->
						<tr class="empty-row screen-reader-text">
							<td><input type="text" class="widefat" data-name="wp_review_options[default_features][]" /></td>
							<td><a class="button remove-row" href="#"><?php 
    _e('Delete', 'wp-review');
    ?>
</a></td>
						</tr>

					</tbody>

				</table>
				<?php 
    if (!has_filter('wp_review_default_criteria')) {
        ?>
				<table width="100%">
					<tr>
						<td width="100%"><a id="add-row" class="button" href="#"><?php 
        _e('Add default feature', 'wp-review');
        ?>
</a></td>
					</tr>
				</table>
				<?php 
    }
    ?>
				</div>

			    <p class="submit">
			    <input type="submit" class="button-primary" value="<?php 
    _e('Save Changes');
    ?>
" />
			    </p>

			</form>
		</div>
		<?php 
    if (!apply_filters('wp_review_remove_branding', false)) {
        ?>
		<div id="col-left" style="float: right; margin-top: 47px;">
			<a href="https://mythemeshop.com/plugins/wp-review-pro/?utm_source=WP+Review&utm_medium=Link+CPC&utm_content=WP+Review+Pro+LP&utm_campaign=WordPressOrg" target="_blank">
				<img src="<?php 
        echo trailingslashit(WP_REVIEW_ASSETS);
        ?>
/images/wp-review-pro.jpg">
			</a>
		</div>
		<?php 
    }
    ?>
	</div>
</div>
<?php 
}
Ejemplo n.º 2
0
    $items = array(__('Audio'), __('Visual'), __('UX'), __('Price'));
    return $items;
}
add_filter('wp_review_default_criteria', 'mts_add_default_criteria');
// Customize wp_review_show_total() output
function mts_custom_review_total($content, $id, $type, $total)
{
    if (get_the_title($id) == 'Special Post With Blue Rating') {
        $color = '#0000FF';
        $content = preg_replace('/"review-type-[^"]+"/', '$0 style="background-color: ' . $color . ';"', $content);
    }
    return $content;
}
add_filter('wp_review_show_total', 'mts_custom_review_total', 10, 4);
// Exclude post types
function mts_wp_review_exclude_post_types($excluded)
{
    // default: $excluded = array('attachment');
    $excluded[] = 'page';
    // Don't allow reviews on pages
    return $excluded;
}
add_filter('wp_review_excluded_post_types', 'mts_wp_review_exclude_post_types');
// Set the review options in your theme
// These will be set as the global options for the plugin upon theme activation
$new_options = array('colors' => array('color' => '#dd3333', 'fontcolor' => '#555555', 'bgcolor1' => '#e7e7e7', 'bgcolor2' => '#ffffff', 'bordercolor' => '#e7e7e7'));
if (function_exists('wp_review_theme_defaults')) {
    wp_review_theme_defaults($new_options);
}
// Remove banner from options page
add_filter('wp_review_remove_branding', '__return_true');
Ejemplo n.º 3
0
function ts_theme_setup()
{
    global $smof_data, $content_width;
    /* Content Width */
    if (!isset($content_width) || !$content_width) {
        $content_width = 1000;
    }
    /* Add support for 'ThemeStockyard Essentials' */
    add_theme_support('ts-essentials');
    define('TS_ESSENTIALS_SUPPORTED_POSTTYPES', 'megamenu');
    // separate with commas
    /* Thumbnails */
    if (function_exists('add_image_size')) {
        add_theme_support('post-thumbnails');
        add_image_size('thumb_1200', 1200, 0, false);
        add_image_size('thumb_1200x600', 1200, 600, true);
        add_image_size('thumb_740', 740, 0, false);
        add_image_size('thumb_740x480', 740, 480, true);
        add_image_size('thumb_510x340', 510, 340, true);
        add_image_size('thumb_480', 480, 0, false);
        add_image_size('thumb_480x320', 480, 320, true);
    }
    /* When an image is deleted, remove any additional thumbnails that were created by aq_resize function */
    add_filter('delete_attachment', 'ts_aq_resized_images_removal', 900);
    /* Increase JPG quality for resized images */
    if (ts_option_vs_default('use_custom_jpeg_compression', 1) == 1) {
        add_filter('jpeg_quality', 'ts_image_full_quality');
        add_filter('wp_editor_set_quality', 'ts_image_full_quality');
    }
    /* Sharpen resized images */
    if (ts_option_vs_default('sharpen_resized_images', 1) == 1) {
        add_filter('image_make_intermediate_size', 'ts_sharpen_resized_files', 900);
    }
    /* Better SEO: page titles */
    add_filter('wp_title', 'ts_filter_wp_title', 10, 2);
    /* Sidebars */
    add_action('widgets_init', 'ts_register_sidebars');
    /* Post formats */
    add_theme_support('post-formats', array('gallery', 'video', 'audio'));
    // need to support more here
    /* Add support for nav menus */
    add_theme_support('nav-menus');
    register_nav_menus(array('top_bar' => __('Top Bar: Small Navigation', 'ThemeStockyard'), 'main_nav' => __('Main Navigation', 'ThemeStockyard'), 'footer_nav' => __('Footer Navigation', 'ThemeStockyard')));
    /* Add custom classes to wp_nav_menu */
    add_filter('nav_menu_css_class', 'ts_add_class_to_wp_nav_menu');
    /* Enable shortcodes in excerpts and widgets */
    add_filter('the_excerpt', 'do_shortcode');
    add_filter('widget_text', 'do_shortcode');
    /* Properly format shortcodes (particularly block elements) */
    add_filter('the_content', 'ts_shortcodes_formatter');
    add_filter('widget_text', 'ts_shortcodes_formatter', 9);
    /* End truncated excerpts with "..." */
    add_filter('excerpt_more', 'ts_new_excerpt_more');
    /* Localization */
    if (function_exists('load_theme_textdomain')) {
        load_theme_textdomain('ThemeStockyard', TS_SERVER_PATH . '/languages');
    }
    if (function_exists('load_child_theme_textdomain')) {
        add_action('after_setup_theme', 'ts_child_theme_setup');
        function ts_child_theme_setup()
        {
            load_child_theme_textdomain('ThemeStockyard', get_stylesheet_directory() . '/languages');
        }
    }
    /* Add support for woocommerce */
    add_theme_support('woocommerce');
    //define('WOOCOMMERCE_USE_CSS', false);
    add_filter('loop_shop_per_page', create_function('$cols', 'return 9;'), 20);
    /* Add custom CSS & JS (from Theme Options) to wp_head */
    add_action('wp_head', 'ts_wp_head_addons');
    /* Add custom JS & HTML (from Theme Options) to wp_footer */
    add_action('wp_footer', 'ts_wp_footer_addons', 999);
    /* Custom theme activation function */
    add_action('after_switch_theme', 'ts_activation_function');
    /* RSS feed link */
    add_theme_support('automatic-feed-links');
    add_action('feed_link', 'ts_custom_rss_feed', 99, 2);
    /* Wrap oEmbeds with responsive div */
    add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4);
    /* Modify the search form */
    add_filter('get_search_form', 'ts_html5_search_form');
    /* adding support for WP Reviews plugin */
    if (function_exists('wp_review_theme_defaults')) {
        $color_options = array('colors' => array('color' => ts_option_vs_default('primary_color', '#E2A8A8'), 'fontcolor' => ts_option_vs_default('body_font_color', '#555'), 'bgcolor1' => ts_option_vs_default('subtle_bg_color', '#f5f5f5'), 'bgcolor2' => ts_option_vs_default('content_background_color', '#fff'), 'bordercolor' => ts_option_vs_default('standard_border_color', '#eee')));
        wp_review_theme_defaults($color_options);
    }
    /* ajax load mini woocommerce cart */
    add_action("wp_ajax_ts_reload_mini_cart", "ts_reload_mini_cart");
    add_action("wp_ajax_nopriv_ts_reload_mini_cart", "ts_reload_mini_cart");
    /* ajax load infinite blog */
    add_action("wp_ajax_ts_load_infinite_blog", "ts_load_infinite_blog");
    add_action("wp_ajax_nopriv_ts_load_infinite_blog", "ts_load_infinite_blog");
    /* ajax postview counter */
    add_action("wp_ajax_ts_update_postviews", "ts_update_postviews");
    add_action("wp_ajax_nopriv_ts_update_postviews", "ts_update_postviews");
    /* add post id column to wp-admin/posts.php */
    add_filter('manage_posts_columns', 'ts_posts_columns_id', 5);
    add_action('manage_posts_custom_column', 'ts_posts_custom_id_columns', 5, 2);
    /* add custom query vars */
    add_filter('query_vars', 'ts_add_query_vars_filter');
    /* dynamic CSS from theme options */
    if (!function_exists('ts_style_options')) {
        function ts_style_options($wp)
        {
            if (!empty($_GET['theme-options']) && $_GET['theme-options'] == 'css') {
                # get theme options
                header("Content-type: text/css; charset: UTF-8");
                header("Cache-Control: must-revalidate");
                $offset = 72000;
                $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
                header($ExpStr);
                echo ts_dynamic_css();
                exit;
            }
        }
        add_action('parse_request', 'ts_style_options');
    }
    /* smart date/time conversion (for localizing dates/times for posts) */
    add_filter('get_the_date', 'ts_smart_date', 999, 3);
    add_filter('get_the_time', 'ts_smart_time', 999, 3);
    /* setup global $ts_previous_posts var */
    add_action('wp_head', 'ts_setup_previous_post_cache', 99999);
}