/** * Checks if template has BP cell and add filters. * * @param type $layout_id * @param type $args * @return type */ function has_cell($layout_id, $args) { $layout_settings = WPDD_Layouts::get_layout_settings($layout_id, true); $layout_instance = new WPDD_json2layout(); $layout = $layout_instance->json_decode(wp_json_encode($layout_settings)); if ($layout->has_cell_of_type('buddypress') && is_buddypress()) { // Do something } return $layout_id; }
function get_layout_from_id($id) { global $wpdb; $layout = WPDD_Layouts_Cache_Singleton::get_name_by_id($id); $result = null; if ($layout) { $result = new stdClass(); $result->ID = $id; $result->post_name = $layout; } if ($result) { $layout_json = self::get_layout_settings($result->ID); $json_parser = new WPDD_json2layout(); $layout = $json_parser->json_decode($layout_json); $layout->set_post_id($result->ID); $layout->set_post_slug($result->post_name); } return $layout; }
private function get_post_content_cell($opts) { $test = new WPDD_json2layout(); $layout = $test->json_decode(wp_json_encode($opts)); if (property_exists($opts, 'has_post_content_cell') && $opts->has_post_content_cell === true) { $cell_post_content = $layout->has_cell_of_type('cell-post-content'); $cell_content_template = $layout->get_all_cells_of_type('cell-content-template'); if ($cell_post_content) { $opts->cell_post_content_type = 'cell-post-content'; } elseif (count($cell_content_template) > 0) { if ($this->content_template_cell_has_body_tag($cell_content_template)) { $opts->cell_post_content_type = 'cell-content-template'; } else { $opts->cell_post_content_type = 'cell-content-template-no-body'; $opts->has_post_content_cell = false; } } } else { $cell_visual_editor = $layout->get_all_cells_of_type('cell-text'); if (count($cell_visual_editor) > 0) { $opts->cell_post_content_type = $this->visual_editor_cell_has_wpvbody_tag($cell_visual_editor); if ($opts->cell_post_content_type !== '') { $opts->has_post_content_cell = true; } } else { if (property_exists($opts, 'cell_post_content_type') === false) { $opts->cell_post_content_type = ''; } } } return $opts; }
_e('Preset layouts', 'ddl-layouts'); ?> </label> <?php // Previews for layout presets ?> <ul class="presets-list fields-group"> <?php $count = 0; ?> <?php foreach ($preset_layouts as $name => $details) { ?> <?php $file = $details['file']; $decoder = new WPDD_json2layout(true); $layout = $decoder->json_decode($details['layout'], true); $renderer = new WPDD_layout_preset_render($layout); ?> <li class="js-presets-list-item <?php if ($count === 0) { ?> selected<?php } ?> " <?php if ($count === 0) { ?> data-selected="true"<?php } ?>
function before_header_hook() { if (isset($_GET['layout_id'])) { $layout_selected = $_GET['layout_id']; } else { $post_id = get_the_ID(); $layout_selected = WPDD_Layouts::get_layout_settings($post_id, false); } if ($layout_selected > 0) { //$layout_content = get_post_meta($layout_selected, WPDDL_LAYOUTS_SETTINGS); $layout_content = WPDD_Layouts::get_layout_settings_raw_not_cached($layout_selected, false); if (sizeof($layout_content) > 0) { $test = new WPDD_json2layout(); $layout = $test->json_decode($layout_content[0]); $manager = new WPDD_layout_render_manager($layout); $renderer = $manager->get_renderer(); $html = $renderer->render_to_html(); echo $html; } } }