Example #1
0
function layotter_include_example_element()
{
    if (Layotter_Settings::example_element_enabled()) {
        require_once __DIR__ . '/example/field-group.php';
        require_once __DIR__ . '/example/element.php';
    }
}
Example #2
0
/**
 * Output backend HTML for Layotter
 *
 * @param $post object Post object as provided by Wordpress
 */
function layotter_output_interface($post)
{
    $hidden_style = 'width: 1px; height: 1px; position: fixed; top: -999px; left: -999px;';
    $visible_style = 'width: 100%; height: 200px;margin-bottom: 30px;';
    echo '<textarea id="content" name="content" style="' . $hidden_style . '"></textarea>';
    if (Layotter_Settings::is_debug_mode_enabled()) {
        echo '<p>';
        printf(__('Debug mode enabled: Inspect and manually edit the JSON structure generated by Layotter. Use with caution. A faulty structure will break your page layout and content. Go to <a href="%s">Layotter\'s settings page</a> to disable debug mode.', 'layotter'), admin_url('admin.php?page=layotter-settings'));
        echo '</p>';
        echo '<textarea id="layotter-json" name="layotter_json" style="' . $visible_style . '"></textarea>';
    } else {
        echo '<textarea id="layotter-json" name="layotter_json" style="' . $hidden_style . '"></textarea>';
    }
    require_once __DIR__ . '/../views/editor.php';
}
Example #3
0
 /**
  * Return frontend HTML for this column
  *
  * @param array $row_options Formatted options for the parent row
  * @param array $post_options Formatted options for the parent post
  * @return string Frontend HTML
  */
 public function get_frontend_view($row_options, $post_options)
 {
     $elements_html = '';
     foreach ($this->elements as $element) {
         $elements_html .= $element->get_frontend_view($this->options->get_formatted_values(), $row_options, $post_options, $this->width);
     }
     $class = Layotter_Settings::get_col_layout_class($this->width);
     if (has_filter('layotter/view/column')) {
         return apply_filters('layotter/view/column', $elements_html, $class, $this->options->get_formatted_values(), $row_options, $post_options);
     } else {
         $html_wrapper = Layotter_Settings::get_html_wrapper('cols');
         $html_before = str_replace('%%CLASS%%', $class, $html_wrapper['before']);
         return $html_before . $elements_html . $html_wrapper['after'];
     }
 }
Example #4
0
function layotter_frontend_assets()
{
    if (!is_admin() and Layotter_Settings::default_css_enabled()) {
        wp_enqueue_style('layotter-frontend', plugins_url('assets/css/frontend.css', __DIR__));
    }
}
Example #5
0
 /**
  * Check if Layotter is enabled for a specific post
  *
  * @param int $post_id Post ID
  * @return bool Whether Layotter is enabled
  */
 public static function is_enabled_for_post($post_id)
 {
     $override_enabled = apply_filters('layotter/enable_for_posts', array());
     $override_disabled = apply_filters('layotter/disable_for_posts', array());
     if (in_array($post_id, $override_enabled)) {
         return true;
     }
     if (in_array($post_id, $override_disabled)) {
         return false;
     }
     $post_type = get_post_type($post_id);
     $enabled_post_types = Layotter_Settings::get_enabled_post_types();
     return in_array($post_type, $enabled_post_types);
 }
Example #6
0
 /**
  * Return frontend HTML for this row
  *
  * @param array $post_options Formatted options for the parent post
  * @return string Frontend HTML
  */
 public function get_frontend_view($post_options)
 {
     $cols_html = '';
     foreach ($this->cols as $col) {
         $cols_html .= $col->get_frontend_view($this->options->get_formatted_values(), $post_options);
     }
     if (has_filter('layotter/view/row')) {
         return apply_filters('layotter/view/row', $cols_html, $this->options->get_formatted_values(), $post_options);
     } else {
         $html_wrapper = Layotter_Settings::get_html_wrapper('rows');
         return $html_wrapper['before'] . $cols_html . $html_wrapper['after'];
     }
 }
Example #7
0
 /**
  * Get the frontend view
  *
  * @param array $col_options Formatted options for the parent column
  * @param array $row_options Formatted options for the parent row
  * @param array $post_options Formatted options for the parent post
  * @param string $col_width Width of the parent column, e.g. '1/3'
  * @return string Frontend view HTML
  */
 public final function get_frontend_view($col_options, $row_options, $post_options, $col_width)
 {
     ob_start();
     $this->frontend_view($this->formatted_values, $col_width, $col_options, $row_options, $post_options);
     $element_html = ob_get_clean();
     if (has_filter('layotter/view/element')) {
         return apply_filters('layotter/view/element', $element_html, $this->options->get_formatted_values(), $col_options, $row_options, $post_options);
     } else {
         $html_wrapper = Layotter_Settings::get_html_wrapper('elements');
         return $html_wrapper['before'] . $element_html . $html_wrapper['after'];
     }
 }
Example #8
0
 /**
  * Return frontend HTML for this post
  *
  * @return string Frontend HTML
  */
 public function get_frontend_view()
 {
     $rows_html = '';
     foreach ($this->rows as $row) {
         $rows_html .= $row->get_frontend_view($this->options->get_formatted_values());
     }
     // if a custom filter for frontend was hooked, run through that filter and return HTML
     if (has_filter('layotter/view/post')) {
         return apply_filters('layotter/view/post', $rows_html, $this->options->get_formatted_values());
     } else {
         // otherwise, get HTML wrapper from settings, apply and return HTML
         $html_wrapper = Layotter_Settings::get_html_wrapper('wrapper');
         return $html_wrapper['before'] . $rows_html . $html_wrapper['after'];
     }
 }