public function register_modules_layouts_items($arg)
 {
     $ret = array();
     $layouts = WPDD_Layouts_Cache_Singleton::get_published_layouts();
     foreach ($layouts as $layout) {
         $ret[] = array('id' => self::LAYOUTS_MODULE_MANAGER_KEY . $layout->ID, 'title' => $layout->post_title, 'details' => sprintf(__("Fetch layout %s", 'ddl-layouts'), $layout->post_title));
     }
     usort($ret, array(new Toolset_ArrayUtils('title'), 'sort_string_ascendant'));
     $ret[] = array('id' => self::LAYOUTS_MODULE_MANAGER_KEY . self::LAYOUTS_MODULE_MANAGER_CSS_ID, 'title' => __("Layouts CSS", 'ddl-layouts'), 'details' => __("The Layouts CSS you can export as layouts.css file", 'ddl-layouts'));
     return $ret;
 }
    function meta_box($post)
    {
        global $wpddlayout;
        if ($wpddlayout->theme_has_page_templates() === false) {
            ?>
            <p class="toolset-alert toolset-alert-warning js-layout-support-warning line-height-16">
                <?php 
            echo sprintf(__("A template file that supports layouts is not available.", 'ddl-layouts'), '');
            ?>
<br>
                <?php 
            printf(__('Please check %shere%s to see how to set one up.', 'ddl-layouts'), '<a href="' . WPDLL_LEARN_ABOUT_SETTING_UP_TEMPLATE . '" target="_blank">', '</a>');
            ?>
            </p>
            <?php 
            return;
        }
        global $wpddl_features;
        $layout_tempates_available = WPDD_Layouts_Cache_Singleton::get_published_layouts();
        if (isset($_GET['post'])) {
            $template_selected = get_post_meta($_GET['post'], WPDDL_LAYOUTS_META_KEY, true);
        } else {
            $template_selected = '';
        }
        if ($post->post_type != 'page') {
            $none = new stdClass();
            $none->ID = 0;
            $none->post_name = 0;
            $none->post_title = __('None', 'ddl-layouts');
            array_unshift($layout_tempates_available, $none);
        }
        $post_type_obj = get_post_type_object($post->post_type);
        ?>

        <div class="js-dd-layout-selector">

            <script type="text/javascript">
                var ddl_old_template_text = "<?php 
        _e('Template', 'ddl-layouts');
        ?>
";
            </script>


            <?php 
        if ($post->post_type == 'page') {
            ?>
                <p>
                    <i class="icon-layouts-logo ont-icon-22 ont-color-orange"></i> <strong><?php 
            _e('Template and Layout', 'ddl-layouts');
            ?>
</strong>
                </p>
            <?php 
        }
        ?>
            <p>


                <?php 
        $template_selected = $this->wpml_layout_for_post_edit($template_selected);
        $template_option = $wpddlayout->get_option('templates');
        $post_type_theme = $wpddlayout->post_types_manager->get_layout_template_for_post_type($post->post_type);
        $theme_template = $post_type_theme == 'default' ? basename(get_page_template()) : $post_type_theme;
        $post_type_layout = $wpddlayout->post_types_manager->get_layout_to_type_object($post->post_type);
        ?>

                <input type="hidden" name="ddl-namespace-post-type-tpl" value="<?php 
        echo $post_type_theme == 'default' ? 'default' : $theme_template;
        ?>
" class="js-ddl-namespace-post-type-tpl" />
                <select name="layouts_template" id="js-layout-template-name" <?php 
        disabled($post->post_type == 'attachment');
        /* cannot assign layouts to attachment post type posts individually */
        ?>
 >
                    <?php 
        if (isset($template_option[$theme_template])) {
            $theme_default_layout = $template_option[$theme_template];
        } else {
            $theme_default_layout = '';
        }
        foreach ($layout_tempates_available as $template) {
            $layout = WPDD_Layouts::get_layout_settings($template->ID, true);
            $has_loop = is_object($layout) && property_exists($layout, 'has_loop') ? $layout->has_loop : false;
            $supported = true;
            $warning = '';
            if ($layout && property_exists($layout, 'type') && $layout->type == 'fixed' && !$wpddl_features->is_feature('fixed-layout')) {
                $warning = __("This layout is a fixed layout. The current theme doesn't support fixed layouts and might not display correctly", 'ddl-layouts');
            }
            if ($layout && property_exists($layout, 'type') && $layout->type == 'fluid' && !$wpddl_features->is_feature('fluid-layout')) {
                $warning = __("This layout is a fluid layout. The current theme doesn't support fluid layouts and might not display correctly", 'ddl-layouts');
            }
            if ($layout && $template_selected != $layout->slug && isset($layout->has_child) && ($layout->has_child === 'true' || $layout->has_child === true)) {
                $supported = false;
            }
            if ($supported) {
                $force_layout = ' data-force-layout="false"';
                if ($template_selected == $template->post_name) {
                    $selected = ' selected="selected"';
                } elseif (!isset($_GET['post']) && is_object($post_type_layout) && property_exists($post_type_layout, 'layout_id') && (int) $template->ID === (int) $post_type_layout->layout_id) {
                    $selected = ' selected="selected"';
                    $force_layout = ' data-force-layout="true"';
                } else {
                    $selected = '';
                }
                $title = $template->post_title;
                if ($title == '') {
                    $title = $template->post_name;
                }
                if ($template->post_name == $theme_default_layout && $post->post_type == 'page') {
                    $title .= __(' - Template default', 'ddl-layouts');
                }
                $data_object = array('layout_has_loop' => $has_loop, 'post_type' => $post->post_type, 'is_really_selected' => $selected !== '');
                $data_object = $data_object;
                ?>
                            <option data-object="<?php 
                echo htmlspecialchars(wp_json_encode($data_object));
                ?>
" value="<?php 
                echo $template->post_name;
                ?>
"<?php 
                echo $selected . $force_layout;
                ?>
 data-id="<?php 
                echo $template->ID;
                ?>
" data-ddl-warning="<?php 
                echo $warning;
                ?>
"><?php 
                echo $title;
                ?>
</option>
                        <?php 
            }
        }
        ?>

                </select>

                <input type="hidden" class="js-wpddl-default-template-message" value="<?php 
        echo $this->main_template;
        ?>
" data-message="<?php 
        _e('Show all templates', 'ddl-layouts');
        ?>
" />
                <?php 
        if ($post->post_type == 'page') {
            ?>
                    <select name="combined_layouts_template" id="js-combined-layout-template-name">

                    </select>


                <?php 
        }
        ?>
            <p>
                <a data-href="<?php 
        echo admin_url() . 'admin.php?page=dd_layouts_edit&amp;action=edit&layout_id=';
        ?>
" class="edit-layout-template js-edit-layout-template"><?php 
        _e('Edit this layout', 'ddl-layouts');
        ?>
</a>
            </p>
            </p>

            <?php 
        do_action('ddl_add_create_layout_button');
        ?>

            <div class="display_errors js-display-errors"></div>

            <p class="toolset-alert toolset-alert-warning js-layout-support-warning" style="display:none">
            </p>


            <?php 
        wp_nonce_field('wp_nonce_ddl_dismiss', 'wp_nonce_ddl_dismiss');
        ?>
        </div>



        <?php 
        $woocommerce_support_message = $wpddlayout->post_types_manager->check_layout_template_for_woocommerce($post_type_obj);
        ?>
        <?php 
        if ($woocommerce_support_message) {
            ?>

            <p class=" toolset-alert toolset-alert-warning js-layout-support-missing">
                <?php 
            echo $woocommerce_support_message;
            ?>
            </p>
        <?php 
        } elseif ($wpddlayout->post_types_manager->check_layout_template_page_exists($post_type_obj) === false) {
            ?>

            <p class=" toolset-alert toolset-alert-warning js-layout-support-missing">
                <?php 
            echo sprintf(__("A template file that supports layouts is not available.", 'ddl-layouts'), '<strong>"' . $post_type_obj->labels->singular_name . '"</strong>');
            ?>
<br>
                <?php 
            printf(__('Please check %shere%s to see how to set one up.', 'ddl-layouts'), '<a href="' . WPDLL_LEARN_ABOUT_SETTING_UP_TEMPLATE . '" target="_blank">', '</a>');
            ?>
            </p>
        <?php 
        }
        ?>


    <?php 
    }