コード例 #1
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     wp_enqueue_style('fw-option-' . $this->get_type(), FW_URI . '/includes/option-types/' . $this->get_type() . '/static/css/styles.css', array(), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-' . $this->get_type(), FW_URI . '/includes/option-types/' . $this->get_type() . '/static/js/scripts.js', array('jquery'), fw()->manifest->get_version());
     $output = fw_render_view(FW_DIR . '/includes/option-types/' . $this->get_type() . '/view.php', array('id' => $id, 'option' => $option, 'data' => $data));
     return $output;
 }
コード例 #2
0
 /**
  * Generate html
  *
  * @param string $id
  * @param array $option Option array merged with _get_defaults()
  * @param array $data {value => _get_value_from_input(), id_prefix => ..., name_prefix => ...}
  *
  * @return string HTML
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $defaults = $this->_get_defaults();
     $option['preview'] = array_merge($defaults['preview'], $option['preview']);
     $option['attr'] = array_merge($defaults['attr'], $option['attr']);
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/view.php'), compact('id', 'option', 'data'));
 }
コード例 #3
0
 protected function _render($id, $option, $data)
 {
     //replace option datetime formats with moment.js compatible datetime format
     foreach ($option['datetime-pickers'] as &$datetime_picker) {
         if (isset($datetime_picker['timepicker']) && isset($datetime_picker['datepicker'])) {
             if ($datetime_picker['timepicker'] === false && $datetime_picker['datepicker']) {
                 $datetime_picker['format'] = 'Y/m/d';
                 $datetime_picker['moment-format'] = 'YYYY/MM/DD';
             } elseif ($datetime_picker['datepicker'] === false && $datetime_picker['timepicker']) {
                 $datetime_picker['format'] = 'H:i';
                 $datetime_picker['moment-format'] = 'HH:mm';
             } else {
                 $datetime_picker['format'] = 'Y/m/d H:i';
                 $datetime_picker['moment-format'] = 'YYYY/MM/DD HH:mm';
             }
         } else {
             $datetime_picker['format'] = 'Y/m/d H:i';
             $datetime_picker['moment-format'] = 'YYYY/MM/DD HH:mm';
         }
         if (!isset($datetime_picker['scrollInput'])) {
             $datetime_picker['scrollInput'] = false;
         }
     }
     return fw_render_view(dirname(__FILE__) . '/view.php', array('id' => $id, 'option' => $option, 'data' => $data));
 }
コード例 #4
0
 /**
  * Generate option's html from option array
  * @param string $id
  * @param array $option
  * @param array $data
  * @return string HTML
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     unset($option['attr']['name'], $option['attr']['value']);
     $option['attr']['data-for-js'] = json_encode(array('title' => empty($option['popup-title']) ? $option['label'] : $option['popup-title'], 'options' => $this->transform_options($option['popup-options']), 'template' => $option['template'], 'size' => $option['size'], 'limit' => $option['limit']));
     $sortable_image = fw_get_framework_directory_uri('/static/img/sort-vertically.png');
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/views/view.php'), compact('id', 'option', 'data', 'sortable_image'));
 }
コード例 #5
0
 /**
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     extract($args);
     $user = esc_attr($instance['user']);
     $title = esc_attr($instance['title']);
     $number = (int) esc_attr($instance['number']) > 0 ? esc_attr($instance['number']) : 5;
     $before_widget = str_replace('class="', 'class="widget_twitter_tweets ', $before_widget);
     $title = str_replace('class="', 'class="widget_twitter_tweets ', $before_title) . $title . $after_title;
     $title = $before_title . $title . $after_title;
     //		wp_enqueue_script(
     //			'fw-theme-twitter-widget',
     //			get_template_directory_uri() . '/inc/widgets/twitter/static/js/scripts.js',
     //			array( 'jquery' ),
     //			'1.0'
     //		);
     $tweets = get_site_transient('scratch_tweets_' . $user . '_' . $number);
     if (empty($tweets)) {
         /* @var $connection TwitterOAuth */
         $connection = fw_ext_social_twitter_get_connection();
         $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $user . "&count=" . $number);
         set_site_transient('scratch_tweets_' . $user . '_' . $number, $tweets, 12 * HOUR_IN_SECONDS);
     }
     $view_path = dirname(__FILE__) . '/views/widget.php';
     echo fw_render_view($view_path, compact('before_widget', 'title', 'tweets', 'number', 'after_widget'));
 }
コード例 #6
0
/**
 * Replace the content of the current template with the content of portfolio view
 *
 * @param string $the_content
 *
 * @return string
 */
function _filter_fw_ext_portfolio_the_content($the_content)
{
    /**
     * @var FW_Extension_Portfolio $portfolio
     */
    $portfolio = fw()->extensions->get('portfolio');
    return fw_render_view($portfolio->locate_view_path('content'), array('the_content' => $the_content));
}
コード例 #7
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $option = $this->prepare_options($option);
     if (!isset($option['preview']) || $option['preview'] !== false) {
         $option['attr']['data-preview'] = 'yes';
     }
     return fw_render_view(self::$extension['path'] . '/includes/option-types/' . $this->get_type() . '/views/main.php', array('id' => $id, 'option' => $option, 'data' => $data, 'settings' => self::$settings, 'extension' => self::$extension));
 }
コード例 #8
0
 protected function handle_shortcode($atts, $content, $tag)
 {
     $view_file = $this->get_path() . '/views/' . $atts['table_purpose'] . '.php';
     if (!file_exists($view_file)) {
         trigger_error(sprintf(__('No default view (views/view.php) found for shortcode: %s', 'fw'), $tag), E_USER_ERROR);
     }
     return fw_render_view($view_file, array('atts' => $atts, 'content' => $content, 'tag' => $tag));
 }
コード例 #9
0
ファイル: hooks.php プロジェクト: northpen/project_11
/**
 * Replace the content of the current template with the content of commercial view
 *
 * @param string $the_content
 *
 * @return string
 */
function _filter_fw_ext_commercial_the_content($the_content)
{
    /**
     * @var FW_Extension_Commercial $commercial
     */
    $commercial = fw()->extensions->get('commercial');
    return fw_render_view($commercial->locate_view_path('content'), array('the_content' => $the_content));
}
コード例 #10
0
/**
 * Replace the content of the current template with the content of event view
 *
 * @param string $the_content
 *
 * @return string
 */
function _filter_fw_ext_events_the_content($the_content)
{
    /**
     * @var FW_Extension_Events $events
     */
    $events = fw()->extensions->get('events');
    return fw_render_view($events->locate_view_path('content'), array('the_content' => $the_content));
}
コード例 #11
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     wp_enqueue_style('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/css/styles.css'), array(), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/scripts.js'), array('jquery', 'fw-events'), fw()->manifest->get_version(), true);
     $option = $this->check_parameters($option);
     $data = $this->check_data($option, $data);
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/view.php'), array('id' => $id, 'option' => $option, 'data' => $data));
 }
 /**
  * {@inheritdoc}
  */
 public function frontend_render(array $item, $input_value)
 {
     $options = $item['options'];
     $attr = array('type' => 'text', 'name' => $item['shortcode'], 'placeholder' => $options['placeholder'], 'value' => is_null($input_value) ? '' : $input_value, 'id' => 'id-' . fw_unique_increment());
     if ($options['required']) {
         $attr['required'] = 'required';
     }
     return fw_render_view($this->locate_path('/views/view.php', dirname(__FILE__) . '/view.php'), array('item' => $item, 'attr' => $attr));
 }
コード例 #13
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     wp_enqueue_style('fw-option-type-' . $this->get_type() . '-if', FW_URI . '/includes/option-types/' . $this->get_type() . '/static/css/styles.css', array('fw-font-awesome'), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-type-' . $this->get_type() . '-dialog', FW_URI . '/includes/option-types/' . $this->get_type() . '/static/js/scripts.js', array('jquery', 'fw-events'), fw()->manifest->get_version());
     $option['value'] = (string) $data['value'];
     unset($option['attr']['value']);
     // be sure to remove value from attributes
     return fw_render_view(dirname(__FILE__) . '/view.php', compact('id', 'option', 'data'));
 }
コード例 #14
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $option['properties']['type'] = 'single';
     $option['properties']['from'] = isset($data['value']) ? $data['value'] : $option['value'];
     if (isset($option['properties']['values']) && is_array($option['properties']['values'])) {
         $option['properties']['from'] = array_search($option['properties']['from'], $option['properties']['values']);
     }
     $option['attr']['data-fw-irs-options'] = json_encode($this->default_properties($option['properties']));
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/view.php'), array('id' => $id, 'option' => $option, 'data' => $data, 'value' => $data['value']));
 }
コード例 #15
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $option['value'] = (string) $data['value'];
     unset($option['attr']['value']);
     // be sure to remove value from attributes
     $option['attr'] = array_merge(array('rows' => '6'), $option['attr']);
     $table_shortcode = fw()->extensions->get('shortcodes')->get_shortcode('table');
     $view_path = $table_shortcode->get_declared_path() . '/includes/fw-option-type-textarea-cell/views/view.php';
     return fw_render_view($view_path, compact('id', 'option', 'data'));
 }
コード例 #16
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     wp_enqueue_style('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/css/styles.css'), array('fw-selectize'), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/scripts.js'), array('jquery', 'underscore', 'fw', 'fw-selectize'), fw()->manifest->get_version());
     if (!self::$googleFontsPrinted) {
         wp_localize_script('fw-option-' . $this->get_type(), 'googleFonts', self::$fonts['google']);
         self::$googleFontsPrinted = true;
     }
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/view.php'), array('id' => $id, 'option' => $option, 'data' => $data, 'fonts' => self::$fonts));
 }
コード例 #17
0
 public function widget($args, $instance)
 {
     extract($args);
     $number = (int) $instance['number'] > 0 ? esc_attr($instance['number']) : 5;
     $recent_posts = $this->fw_get_posts_with_info(array('sort' => 'post_date', 'items' => $number));
     $popular_posts = $this->fw_get_posts_with_info(array('sort' => 'comment_count', 'items' => $number));
     $this->_theme_action_add_static();
     $filepath = dirname(__FILE__) . '/views/widget.php';
     $data = array('before_widget' => str_replace('class="', 'class="wrap-tabs ', $before_widget), 'after_widget' => $after_widget, 'recent_posts' => $recent_posts, 'popular_posts' => $popular_posts);
     echo fw_render_view($filepath, $data);
 }
 /**
  * {@inheritdoc}
  */
 public function frontend_render(array $item, $input_value)
 {
     $keys = fw_ext('forms')->get_db_settings_option('recaptcha-keys');
     if (empty($keys)) {
         return '';
     }
     wp_register_script('g-recaptcha', 'https://www.google.com/recaptcha/api.js?onload=fw_forms_builder_item_recaptcha_init&render=explicit&hl=' . get_locale(), array('jquery'), null, true);
     wp_enqueue_script('frontend-recaptcha', $this->get_uri('/static/js/frontend-recaptcha.js'), array('g-recaptcha'), fw_ext('forms')->manifest->get_version(), true);
     wp_localize_script('frontend-recaptcha', 'form_builder_item_recaptcha', array('site_key' => $keys['site-key']));
     return fw_render_view($this->locate_path('/views/view.php', dirname(__FILE__) . '/view.php'), array('item' => $item, 'label' => isset($input_value['label']) ? $input_value['label'] : __('Security Code', 'fw'), 'attr' => array('class' => 'form-builder-item-recaptcha')));
 }
コード例 #19
0
 function widget($args, $instance)
 {
     extract($args);
     $flickr_id = esc_attr($instance['flickr_id']);
     $title = esc_attr($instance['title']);
     $number = (int) esc_attr($instance['number']) > 0 ? esc_attr($instance['number']) : 9;
     wp_enqueue_script('fw-theme-flickr-widget', FW_PT_THEME_URI . '/widgets/flickr/static/js/scripts.js', array('jquery'), fw()->theme->manifest->get_version());
     $filepath = dirname(__FILE__) . '/views/widget.php';
     $data = array('number' => $number, 'flickr_id' => $flickr_id, 'before_widget' => str_replace('class="', 'class="widget_flickr_image_gallery ', $before_widget), 'after_widget' => $after_widget, 'title' => str_replace('class="', 'class="widget_flickr_image_gallery ', $before_title) . $title . $after_title);
     echo fw_render_view($filepath, $data);
 }
コード例 #20
0
 protected function _render($atts, $content = null, $tag = '')
 {
     if (!isset($atts['table']) || !isset($atts['table']['header_options']) || !isset($atts['table']['header_options']['table_purpose'])) {
         return '';
     }
     $view_file = $this->locate_path('/views/' . $atts['table']['header_options']['table_purpose'] . '.php');
     if (!$view_file) {
         $view_file = $this->get_declared_path('/views/tabular.php');
     }
     $this->enqueue_static();
     return fw_render_view($view_file, array('atts' => $atts, 'content' => $content, 'tag' => $tag));
 }
コード例 #21
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $sets = $this->get_sets();
     if (isset($sets[$option['set']])) {
         $set = $sets[$option['set']];
     } else {
         $set = $this->generate_unknown_set($data['value']);
     }
     unset($sets);
     $option['attr']['value'] = (string) $data['value'];
     return fw_render_view(dirname(__FILE__) . '/view.php', compact('id', 'option', 'data', 'set'));
 }
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $table_shortcode = fw()->extensions->get('shortcodes')->get_shortcode('table');
     if (!$table_shortcode) {
         trigger_error(__('table-builder option type must be inside the table shortcode', 'fw'), E_USER_ERROR);
     }
     if (!isset($data['value']) || empty($data['value'])) {
         $data['value'] = $option['value'];
     }
     $this->replace_with_defaults($option);
     $view_path = $table_shortcode->get_declared_path() . '/includes/fw-option-type-table/views/view.php';
     return fw_render_view($view_path, array('id' => $option['attr']['id'], 'option' => $option, 'data' => $data));
 }
コード例 #23
0
 private function render_any_files($input_attr, $wrapper_attr, $l10n)
 {
     $l10n = array_merge(array('button_add' => __('Upload', 'fw'), 'button_edit' => __('Edit', 'fw')), $l10n);
     $wrapper_attr = array_merge($wrapper_attr, array('data-l10n-button-add' => $l10n['button_add'], 'data-l10n-button-edit' => $l10n['button_edit']));
     wp_enqueue_media();
     wp_enqueue_style('fw-option-type-' . $this->get_type() . '-modal', $this->css_uri . 'modal.css', array(), fw()->manifest->get_version());
     wp_enqueue_style('fw-option-type-' . $this->get_type() . '-any-files', $this->css_uri . 'any-files.css', array(), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-type-' . $this->get_type() . '-any-files', $this->js_uri . 'any-files.js', array('jquery', 'fw-events'), fw()->manifest->get_version(), true);
     $wrapper_attr['class'] .= ' any-files';
     $is_empty = empty($input_attr['value']);
     $wrapper_attr['class'] .= $is_empty ? ' empty' : '';
     return fw_render_view($this->views_path . 'any-files.php', array('wrapper_attr' => $wrapper_attr, 'input_attr' => $input_attr, 'is_empty' => $is_empty, 'l10n' => $l10n));
 }
コード例 #24
0
 function widget($args, $instance)
 {
     extract($args);
     $params = array();
     foreach ($instance as $key => $value) {
         $params[$key] = $value;
     }
     $title = $before_title . $params['widget-title'] . $after_title;
     unset($params['widget-title']);
     $filepath = dirname(__FILE__) . '/views/widget.php';
     $data = array('instance' => $params, 'title' => $title, 'before_widget' => str_replace('class="', 'class="widget_social_links ', $before_widget), 'after_widget' => $after_widget);
     echo fw_render_view($filepath, $data);
 }
コード例 #25
0
 /**
  * Generate option's html from option array
  * @param string $id
  * @param array $option
  * @param array $data
  * @return string HTML
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     $template_path = fw()->extensions->get($this->extension_name)->get_declared_path('/includes/slides/views/templates.php');
     $values = $data['value'];
     $thumb_size = $option['thumb_size'];
     $slides_options = $option['slides_options'];
     $multimedia_type = (array) $option['multimedia_type'];
     $type = $this->get_type();
     $template = fw_render_view($template_path, compact('id', 'option', 'thumb_size', 'data', 'values', 'type', 'slides_options'));
     wp_localize_script('fw-option-' . $this->get_type() . '-slides-js', 'slides_templates', $template);
     $path = fw()->extensions->get($this->extension_name)->get_declared_path('/includes/slides/views/slides.php');
     return fw_render_view($path, compact('id', 'option', 'thumb_size', 'data', 'values', 'type', 'slides_options', 'multimedia_type'));
 }
コード例 #26
0
 /**
  * Generate option's html from option array
  *
  * @param string $id
  * @param array $option
  * @param array $data
  *
  * @return string HTML
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     unset($option['attr']['name'], $option['attr']['value']);
     $option['attr']['data-for-js'] = json_encode(array('title' => isset($option['popup-title']) ? $option['popup-title'] : (string) $option['label'], 'options' => $this->transform_options($option['popup-options']), 'button' => $option['button'], 'size' => $option['size'], 'custom-events' => $option['custom-events']));
     if (!empty($data['value'])) {
         if (is_array($data['value'])) {
             $data['value'] = json_encode($data['value']);
         }
     } else {
         $data['value'] = '';
     }
     $sortable_image = fw_get_framework_directory_uri('/static/img/sort-vertically.png');
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/views/view.php'), compact('id', 'option', 'data', 'sortable_image'));
 }
コード例 #27
0
 /**
  * Generate option's html from option array
  * @param string $id
  * @param array $option
  * @param array $data
  * @return string HTML
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     unset($option['attr']['name'], $option['attr']['value']);
     wp_enqueue_style('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/css/styles.css'), array('fw'), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/' . $this->get_type() . '.js'), array('underscore', 'fw-events', 'jquery-ui-sortable', 'fw'), fw()->manifest->get_version(), true);
     $transformed_options = $this->transform_options($option['popup-options']);
     $localize_var_name = 'fw_option_type_' . str_replace('-', '_', $this->get_type()) . '_localize_' . md5(json_encode($transformed_options));
     wp_localize_script('fw-option-' . $this->get_type(), $localize_var_name, array('title' => empty($option['popup-title']) ? $option['label'] : $option['popup-title'], 'options' => $this->transform_options($option['popup-options']), 'template' => $option['template']));
     $option['attr']['data-localize-var-name'] = $localize_var_name;
     fw()->backend->render_options($option['popup-options']);
     // This makes sure that the option's static is enqueued
     $sortable_image = fw_get_framework_directory_uri('/static/img/sort-vertically.png');
     return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/views/view.php'), compact('id', 'option', 'data', 'sortable_image'));
 }
コード例 #28
0
 function widget($args, $instance)
 {
     extract($args);
     $params = array();
     $before_title = '';
     $after_title = '';
     foreach ($instance as $key => $value) {
         $params[$key] = $value;
     }
     $title = $before_title . esc_attr($params['title']) . $after_title;
     $filepath = dirname(__FILE__) . '/views/widget.php';
     $data = array('instance' => $params, 'title' => $title, 'before_widget' => '', 'after_widget' => '');
     if (defined('FW')) {
         echo fw_render_view($filepath, $data);
     }
 }
コード例 #29
0
 protected function _render($atts, $content = null, $tag = '')
 {
     if (!isset($atts['view'])) {
         return $this->get_error_msg();
     }
     if ($atts['view'] !== 'rand') {
         $view_path = $this->locate_path('/views/' . $atts['view'] . '.php');
         return fw_render_view($view_path);
     } else {
         $views = array('a', 'b', 'c');
         $random_index = mt_rand(0, count($views) - 1);
         $random_view = $views[$random_index];
         $random_view_path = $this->locate_path('/views/' . $random_view . '.php');
         return fw_render_view($random_view_path);
     }
 }
コード例 #30
0
 /**
  * @internal
  */
 protected function _render($id, $option, $data)
 {
     wp_enqueue_style('fw-option-' . $this->get_type(), FW_URI . '/includes/option-types/' . $this->get_type() . '/static/css/styles.css', array(), fw()->manifest->get_version());
     wp_enqueue_script('fw-option-' . $this->get_type(), FW_URI . '/includes/option-types/' . $this->get_type() . '/static/js/scripts.js', array('fw-events', 'jquery-ui-sortable'), fw()->manifest->get_version(), true);
     if (empty($data['value']) || !is_array($data['value'])) {
         $data['value'] = array();
     }
     $controls = array_merge(array('delete' => '<small class="dashicons dashicons-no-alt" title="' . esc_attr(__('Remove', 'fw')) . '"></small>'), $option['box-controls']);
     if (isset($controls['delete'])) {
         $_delete = $controls['delete'];
         unset($controls['delete']);
         $controls['delete'] = $_delete;
         unset($_delete);
     }
     return fw_render_view(FW_DIR . '/includes/option-types/' . $this->get_type() . '/view.php', array('id' => $id, 'option' => $option, 'data' => $data, 'controls' => $controls));
 }