示例#1
0
/**
 * Display a partial to integrate the link functionality in a framework field.
 *
 * @since 0.4.0
 * @param string $handle The field base handle.
 * @param array $link The link data.
 */
function ev_link_partial($handle, $link)
{
    $link = (array) $link;
    if (!isset($link['link'])) {
        $link = array();
    } else {
        $link = $link['link'];
    }
    $handle .= '[link]';
    $link_class = 'ev-link-ctrl';
    if (isset($link['url']) && !empty($link['url'])) {
        $link_class .= ' ev-link-on';
    }
    $url = isset($link['url']) ? $link['url'] : '';
    $target = isset($link['target']) ? $link['target'] : '';
    $rel = isset($link['rel']) ? $link['rel'] : '';
    $title = isset($link['title']) ? $link['title'] : '';
    $class = isset($link['class']) ? $link['class'] : '';
    $link_hidden_inputs = sprintf('<input data-link-url type="hidden" value="%s" name="%s[url]">', esc_attr($url), esc_attr($handle));
    $link_hidden_inputs .= sprintf('<input data-link-target type="hidden" value="%s" name="%s[target]">', esc_attr($target), esc_attr($handle));
    $link_hidden_inputs .= sprintf('<input data-link-rel type="hidden" value="%s" name="%s[rel]">', esc_attr($rel), esc_attr($handle));
    $link_hidden_inputs .= sprintf('<input data-link-title type="hidden" value="%s" name="%s[title]">', esc_attr($title), esc_attr($handle));
    $link_hidden_inputs .= sprintf('<input data-link-class type="hidden" value="%s" name="%s[class]">', esc_attr($class), esc_attr($handle));
    printf('<span class="%s" data-nonce="%s">', esc_attr($link_class), esc_attr(wp_create_nonce('ev_link')));
    ev_btn(__('Link', 'ev_framework'), 'action', array('attrs' => array('class' => 'ev-link-ctrl-btn'), 'size' => 'small', 'icon' => 'evfw-link', 'style' => 'round', 'hide_text' => true));
    echo $link_hidden_inputs;
    echo '</span>';
}
 /**
  * Render the modal content.
  *
  * @since 0.1.0
  * @param string $content The modal content.
  */
 public function render($content)
 {
     $title = $this->_config['title'];
     if ($title) {
         echo '<div class="ev-modal-header">';
         echo '<h1>' . esc_html($title) . '</h1>';
         echo '</div>';
     }
     echo '<form class="ev ev-modal">';
     wp_nonce_field('ev_modal', 'ev', false);
     echo $content;
     echo '<div class="ev-modal-footer">';
     ev_btn($this->_config['button'], 'save', array('attrs' => array('data-nonce' => $this->_config['button_nonce'], 'class' => 'ev-save', 'type' => 'submit'), 'size' => 'medium'));
     echo '</div>';
     echo '</form>';
 }
示例#3
0
 /**
  * Render the modal content.
  *
  * @since 0.1.0
  */
 public function render()
 {
     echo '<div class="ev-modal-header">';
     echo '<h1>' . esc_html($this->title()) . '</h1>';
     if (!empty($this->_config['title_controls'])) {
         printf('<div class="ev-modal-header-title-controls">%s</div>', wp_kses($this->_config['title_controls'], array('a' => array('href' => array(), 'title' => array(), 'target' => array()))));
     }
     echo '</div>';
     echo '<form class="ev ev-modal">';
     wp_nonce_field('ev_modal', 'ev', false);
     $this->render_elements();
     echo '<div class="ev-modal-footer">';
     echo $this->_config['footer_content'];
     $elements = $this->elements();
     if (!empty($elements)) {
         ev_btn($this->_config['button'], 'save', array('attrs' => array('data-nonce' => $this->_config['button_nonce'], 'class' => 'ev-save', 'type' => 'submit'), 'size' => 'medium'));
     }
     echo '</div>';
     echo '</form>';
 }
示例#4
0
/**
 * Output an HTML color control.
 *
 * @since 0.4.0
 * @param string $name The color control name attribute.
 * @param string $value The color selected value.
 * @param boolean $opacity The color control opacity value.
 * @param boolean $echo Set to true to print the control.
 * @return string
 */
function ev_color($name, $value, $opacity = false, $style = '', $echo = true)
{
    $html = '';
    $attrs = '';
    $field_color = $value;
    $field_opacity = '1';
    $style = (array) $style;
    $new_style = array();
    if (!empty($style)) {
        $style_class = 'ev-color-style-';
        foreach ($style as $s) {
            $new_style[] = $style_class . $s;
        }
    }
    if (is_array($value)) {
        $field_color = isset($value['color']) ? $value['color'] : '';
        $field_opacity = isset($value['opacity']) ? $value['opacity'] : '';
    }
    if (!empty($field_color)) {
        $new_style[] = 'ev-color-can-be-saved';
    }
    $new_style = implode(' ', $new_style);
    $html .= sprintf('<span class="ev-color-wrapper %s">', esc_attr($new_style));
    if ($opacity) {
        $attrs .= 'data-opacity=' . $field_opacity;
        $html .= sprintf('<input type="hidden" data-input-color-opacity name="%s" value="%s">', esc_attr($name . '[opacity]'), esc_attr($field_opacity));
    }
    if ($field_color) {
        $attrs .= ' style=border-color:' . $field_color;
    }
    $html .= sprintf('<input type="text" class="ev-color-input" name="%s" value="%s" %s>', esc_attr($name . '[color]'), esc_attr($field_color), esc_attr($attrs));
    $html .= '<div class="ev-color-controls-wrapper">';
    $html .= ev_btn(__('Presets', 'ev_framework'), 'action', array('attrs' => array('data-color-presets' => '', 'data-nonce' => wp_create_nonce('ev_color_presets')), 'style' => 'text', 'size' => 'medium', 'echo' => false));
    $html .= ev_btn(_x('Save', 'save color preset', 'ev_framework'), 'save', array('attrs' => array('data-color-save-preset' => '', 'data-nonce' => wp_create_nonce('ev_color_save_preset')), 'style' => 'text', 'size' => 'medium', 'echo' => false));
    // $html .= sprintf( '<a href="#" data-color-presets data-nonce="%s">%s</a>',
    // 	esc_attr( wp_create_nonce( 'ev_color_presets' ) ),
    // 	esc_html( __( 'Presets', 'ev_framework' ) )
    // );
    // $html .= sprintf( '<a href="#" data-color-save-preset data-nonce="%s">%s</a>',
    // 	esc_attr( wp_create_nonce( 'ev_color_save_preset' ) ),
    // 	esc_html( _x( 'Save', 'save color preset', 'ev_framework' ) )
    // );
    $html .= '</div>';
    $html .= '</span>';
    if ($echo) {
        echo $html;
    }
    return $html;
}
}
?>

	<div class="ev-attachment-upload-action">
		<?php 
ev_btn(__('Edit', 'ev_framework'), 'action', array('attrs' => array('class' => 'ev-edit-action'), 'style' => 'text', 'size' => 'medium'));
?>
		<?php 
ev_btn(__('Upload', 'ev_framework'), 'action', array('attrs' => array('class' => 'ev-upload-action'), 'style' => 'text', 'size' => 'medium'));
?>

		<?php 
if ($multiple) {
    ?>
			<?php 
    ev_btn(__('Remove all', 'ev_framework'), 'delete', array('attrs' => array('class' => 'ev-remove-all-action'), 'style' => 'text', 'size' => 'medium'));
    ?>
		<?php 
}
?>
	</div>

	<input type="hidden" data-id name="<?php 
echo esc_attr($handle);
?>
" value="<?php 
echo esc_attr($value);
?>
">
<?php 
echo '</div>';
示例#6
0
 /**
  * Render the field help text.
  *
  * @since 0.1.0
  */
 private function _render_help()
 {
     $help = $this->help();
     /**
      * Print content between the field label and field help. Useful for
      * outputting custom controls for the field.
      *
      * @since 0.4.0
      * @param Ev_Field
      */
     do_action('ev_fw_before_field_help', $this);
     do_action("ev_fw_before_field_help[type:{$this->_type}]", $this);
     if ($help !== false && $help['text'] != '') {
         $help_allowed_html = array('code' => array(), 'strong' => array(), 'b' => array(), 'a' => array('href' => array()), 'br' => array());
         printf('<div class="ev-help ev-help-%s">', esc_attr($help['type']));
         switch ($help['type']) {
             case 'tooltip':
                 printf('<div class="ev-help-handle ev-tooltip" data-title="%s"><span>%s</span></div>', esc_attr($help['text']), __('Need help?', 'ev_framework'));
                 break;
             case 'popup':
                 printf('<div class="ev-help-handle"><span>%s</span><span class="ev-help-popup-text">%s</span></div>', __('Need help?', 'ev_framework'), wp_kses($help['text'], $help_allowed_html));
                 break;
             case 'inline':
             default:
                 $help_text = wp_kses($help['text'], $help_allowed_html);
                 echo $help_text;
                 break;
         }
         echo '</div>';
     }
     if ($this->_repeatable !== false) {
         ev_btn(__('Remove all', 'ev_framework'), 'delete', array('attrs' => array('class' => 'ev-repeat-remove-all'), 'style' => 'text', 'size' => 'large'));
         // printf( '<a href="#" class="ev-repeat-remove-all">%s</a>', esc_html( __( 'Remove all', 'ev_framework' ) ) );
         /* Print the repeatable field template for later use. */
         $this->repeatable_template();
     }
     /**
      * Print content after the field help. Useful for
      * outputting custom controls for the field.
      *
      * @since 0.4.0
      * @param Ev_Field
      */
     do_action('ev_fw_after_field_help', $this);
     do_action("ev_fw_after_field_help[type:{$this->_type}]", $this);
 }
 /**
  * Render a group of fields in the fields container.
  *
  * @since 0.1.0
  * @param array $element The group data.
  * @param integer $index The group index.
  * @param integer $current_index The index of the current group.
  */
 private function render_group($group, $index, $current_index = 0)
 {
     $class = '';
     if (isset($_GET['tab'])) {
         if ($_GET['tab'] === $group['handle']) {
             $class = 'ev-active';
         }
     } elseif ($index == $current_index) {
         $class = 'ev-active';
     }
     printf('<div aria-labelledby="%s" id="ev-tab-%s" class="ev-tab %s" role="tabpanel">', esc_attr($group['handle']), esc_attr($group['handle']), esc_attr($class));
     $can_be_saved = false;
     if ($this->_groups_with_form === true) {
         foreach ($group['fields'] as $index => $field) {
             if (!ev_is_skipped_on_saving($field['type'])) {
                 $can_be_saved = true;
                 break;
             }
         }
     }
     if ($can_be_saved && $this->_groups_with_form === true) {
         printf('<form method="%s" action="%s">', 'post', admin_url('/admin-ajax.php'));
         printf('<input type="hidden" name="group" value="%s">', esc_attr($group['handle']));
         printf('<input type="hidden" name="context" value="%s">', esc_attr($this->handle()));
     }
     foreach ($group['fields'] as $index => $field) {
         $this->render_field($field);
     }
     if ($can_be_saved && $this->_groups_with_form === true) {
         $group_callback = 'ev_save_options_tab';
         echo '<div class="ev-form-submit-container">';
         ev_btn(__('Save', 'ev_framework'), 'save', array('attrs' => array('data-callback' => $group_callback, 'type' => 'submit'), 'size' => 'medium'));
         echo '</div>';
         echo '</form>';
     }
     echo '</div>';
 }