Beispiel #1
0
function enlightenment_build_google_fonts_list()
{
    $fonts = $_POST['data']['items'];
    $local = enlightenment_web_fonts();
    $output = '';
    foreach ($fonts as $font) {
        if (array_key_exists($font['family'], $local)) {
            continue;
        }
        if (current_theme_supports('enlightenment-web-fonts', 'filter_by_subsets')) {
            $continue = false;
            foreach (current_theme_supports('enlightenment-web-fonts', 'subsets') as $subset) {
                if (!in_array($subset, $font['subsets'])) {
                    $continue = true;
                }
            }
            if ($continue) {
                continue;
            }
        }
        $output .= enlightenment_checkbox(array('name' => current_theme_supports('enlightenment-theme-settings', 'option_name') . '[web_fonts][' . $font['family'] . '][family]', 'value' => $font['family'], 'checked' => false, 'label' => $font['family']), false);
        $output .= enlightenment_hidden_input(array('name' => current_theme_supports('enlightenment-theme-settings', 'option_name') . '[web_fonts][' . $font['family'] . '][category]', 'value' => $font['category']), false);
        $output .= enlightenment_hidden_input(array('name' => current_theme_supports('enlightenment-theme-settings', 'option_name') . '[web_fonts][' . $font['family'] . '][variants]', 'value' => join(',', $font['variants'])), false);
        $output .= enlightenment_hidden_input(array('name' => current_theme_supports('enlightenment-theme-settings', 'option_name') . '[web_fonts][' . $font['family'] . '][subsets]', 'value' => join(',', $font['subsets'])), false);
        $output .= '<br />';
    }
    echo apply_filters('enlightenment_build_google_fonts_list', $output);
    die;
}
Beispiel #2
0
function enlightenment_hidden_tab_field($tab)
{
    remove_filter('enlightenment_hidden_input_args', 'enlightenment_theme_settings_override_value');
    enlightenment_hidden_input(array('name' => 'tab', 'value' => $tab));
    add_filter('enlightenment_hidden_input_args', 'enlightenment_theme_settings_override_value');
}
Beispiel #3
0
function enlightenment_upload_media($args, $echo = true)
{
    $defaults = array('class' => '', 'id' => '', 'description' => '', 'upload_button_text' => __('Choose Media', 'enlightenment'), 'uploader_title' => __('Insert Media', 'enlightenment'), 'uploader_button_text' => __('Select', 'enlightenment'), 'remove_button_text' => __('Remove Media', 'enlightenment'), 'mime_type' => 'image', 'multiple' => false, 'thumbnail' => 'thumbnail', 'value' => '');
    $args = wp_parse_args($args, $defaults);
    $args = apply_filters('enlightenment_upload_media_args', $args);
    if (!isset($args['name']) || empty($args['name'])) {
        _doing_it_wrong(__FUNCTION__, __('Please specify a name attribute for your upload field.', 'enlightenment'), '');
        return;
    }
    wp_enqueue_media();
    $args['class'] .= ' button upload-media-button';
    $output = '<input ';
    $output .= enlightenment_class($args['class']);
    $output .= enlightenment_id($args['id']) . ' ';
    $output .= 'value="' . esc_attr($args['upload_button_text']) . '" ';
    $output .= 'type="button" ';
    $output .= 'data-uploader-title="' . esc_attr($args['uploader_title']) . '" ';
    $output .= 'data-uploader-button-text="' . esc_attr($args['uploader_button_text']) . '" ';
    $output .= 'data-mime-type="' . esc_attr($args['mime_type']) . '" ';
    $output .= 'data-multiple="' . esc_attr($args['multiple']) . '" ';
    $output .= 'data-thumbnail="' . esc_attr($args['thumbnail']) . '" ';
    $output .= '/>';
    $media = $args['value'];
    if ('' != $args['remove_button_text']) {
        $output .= '<input class="button remove-media-button" value="' . esc_attr($args['remove_button_text']) . '" type="button"' . (empty($media) ? ' style="display:none"' : '') . ' />';
    }
    if (null != $args['thumbnail']) {
        $output .= enlightenment_open_tag('div', 'preview-media');
        if (!empty($media)) {
            $attachment_id = intval($media);
            if (wp_attachment_is_image($attachment_id)) {
                $attachment = wp_get_attachment_image($attachment_id, $args['thumbnail']);
            } else {
                $attachment = '<a href="' . wp_get_attachment_url($attachment_id) . '">' . get_the_title($attachment_id) . '</a>';
            }
            $output .= $attachment;
        }
        $output .= enlightenment_close_tag();
    }
    $output .= enlightenment_hidden_input($args, false);
    $output .= empty($args['description']) ? '' : '<p class="description">' . strip_tags($args['description'], '<a><abbr><img>') . '</p>';
    $output = apply_filters('enlightenment_upload_media', $output, $args);
    if (!$echo) {
        return $output;
    }
    echo $output;
}
function enlightenment_template_hook_actions($args, $echo = true)
{
    global $wp_filter, $pagenow;
    $hook = enlightenment_get_template_hook($args['hook']);
    $available_functions = apply_filters($args['hook'] . '_available_functions', $hook['functions']);
    $template = enlightenment_get_template(enlightenment_current_template());
    if (current_theme_supports('enlightenment-page-builder') && 'post_type' == $template['type'] && ('post.php' == $pagenow || 'post-new.php' == $pagenow) && isset($_GET['action']) && 'edit' == $_GET['action']) {
        global $post;
        $template_hooks = array();
        $template_hooks[enlightenment_current_template()] = get_post_meta($post->ID, '_enlightenment_page_builder', true);
        if ('' == $template_hooks) {
            $template_hooks = enlightenment_theme_option('template_hooks');
        }
    } else {
        $template_hooks = enlightenment_theme_option('template_hooks');
    }
    if (isset($template_hooks[enlightenment_current_template()][$args['hook']])) {
        $hooked_functions = $template_hooks[enlightenment_current_template()][$args['hook']];
    } else {
        $hooked_functions = array();
        if (isset($wp_filter[$args['hook']]) && isset($wp_filter[$args['hook']][10])) {
            foreach ($wp_filter[$args['hook']][10] as $function) {
                $hooked_functions[] = $function['function'];
            }
        }
    }
    $available_functions = array_diff($available_functions, $hooked_functions);
    $output = '';
    $output .= '<div class="widget-liquid-left">';
    $output .= '<div id="widgets-left">';
    $output .= '<div id="available-widgets" class="widgets-holder-wrap available-functions-' . esc_attr($args['hook']) . '">';
    $output .= '<div class="sidebar-name">';
    $output .= '<h3>Available Functions <span id="removing-widget">Deactivate <span></span></span></h3>';
    $output .= '</div>';
    $output .= '<div class="widget-holder">';
    $output .= '<div id="widget-list" class="widget-list">';
    foreach ($available_functions as $function) {
        $output .= enlightenment_open_tag('div', 'widget', '', 'data-function="' . $function . '"');
        // ui-draggable' );
        $output .= '<div class="widget-top">';
        $output .= '<div class="widget-title">';
        $output .= '<h4>' . enlightenment_template_function_name($function) . '</h4>';
        $output .= enlightenment_close_tag('div');
        $output .= enlightenment_close_tag('div');
        $output .= enlightenment_close_tag('div');
    }
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '<div class="widget-liquid-right">';
    $output .= '<div id="widgets-right">';
    $output .= '<div class="widgets-holder-wrap">';
    $output .= '<div id="sidebar-' . esc_attr($args['hook']) . '" class="widgets-sortables hooked-functions-' . esc_attr($args['hook']) . '">';
    $output .= '<div class="sidebar-name">';
    $output .= '<h3>Hooked Functions <span class="spinner"></span></h3>';
    $output .= '</div>';
    foreach ($hooked_functions as $function) {
        $output .= enlightenment_open_tag('div', 'widget', '', 'data-function="' . $function . '"');
        $output .= '<div class="widget-top">';
        $output .= '<div class="widget-title">';
        $output .= '<h4>' . enlightenment_template_function_name($function) . '</h4>';
        $output .= enlightenment_close_tag('div');
        $output .= enlightenment_close_tag('div');
        $output .= enlightenment_close_tag('div');
    }
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= enlightenment_hidden_input(array('name' => $args['name'], 'value' => join(',', $hooked_functions)), false);
    ob_start();
    ?>
	<script>
		jQuery(document).ready(function($) {
			var submitted = false;
			$('form').submit(function() {
				submitted = true;
			});
			$('.available-functions-<?php 
    echo esc_attr($args['hook']);
    ?>
 .widget-list').sortable({
				connectWith: '.hooked-functions-<?php 
    echo esc_attr($args['hook']);
    ?>
',
				items: '.widget',
				placeholder: "widget-placeholder",
				revert: 'invalid',
			});
			$('.hooked-functions-<?php 
    echo esc_attr($args['hook']);
    ?>
').sortable({
				connectWith: '.available-functions-<?php 
    echo esc_attr($args['hook']);
    ?>
 .widget-list',
				items: '.widget',
				placeholder: "widget-placeholder",
				revert: 'invalid',
				activate: function(event, ui) {
					$(this).parent().addClass('widget-hover');
				},
				deactivate: function(event, ui) {
					$(this).parent().removeClass('widget-hover');
				},
				change: function(event, ui) {
					window.onbeforeunload = function(e) {
						if( ! submitted ) {
							var message = '<?php 
    _e('The changes you made will be lost if you navigate away from this page.', 'enlightenment');
    ?>
';
							e = e || window.event;
							// For IE and Firefox
							if(e) {
								e.returnValue = message;
							}
	
							// For Safari
							return message;
						}
					};
				},
				stop: function(event, ui) {
					if( $(ui.item).parent().hasClass('widgets-sortables') ) {
						var functions = [];
						$('.widget', $(ui.item).parent()).each(function() {
							functions.push($(this).data('function'));
						});
						$(ui.item).closest('.widget-liquid-right').next('input').val(functions.join());
					}
				},
				receive: function(event, ui) {
					var functions = [];
					$('.widget', $(ui.item).parent()).each(function() {
						functions.push($(this).data('function'));
					});
					$(ui.item).closest('.widget-liquid-right').next('input').val(functions.join());
				},
				remove: function(event, ui) {
					var functions = [];
					$('.widget', $(ui.item).closest('.widget-liquid-left').next('.widget-liquid-right')).each(function() {
						functions.push($(this).data('function'));
					});
					$(ui.item).closest('.widget-liquid-left').next('.widget-liquid-right').next('input').val(functions.join());
				},
			});
		});
	</script>
	<?php 
    $output .= ob_get_clean();
    $output .= '<br style="clear:both">';
    if (!$echo) {
        return $output;
    }
    echo $output;
}