function cred_cell_dialog_template_callback()
        {
            ob_start();
            ?>

            <div class="ddl-form cred-edit-cells-form">
                <?php 
            if (defined('CRED_FORMS_CUSTOM_POST_NAME')) {
                ?>
                    <?php 
                require_once CRED_CLASSES_PATH . "/CRED.php";
                if (method_exists('CRED_CRED', 'is_embedded')) {
                    $cred_embedded = CRED_CRED::is_embedded();
                } else {
                    $cred_embedded = false;
                }
                ?>

                    <?php 
                if (!$cred_embedded) {
                    ?>
                        <fieldset>
                            <div class="fields-group">
                                <label class="radio">
                                    <input type="radio" name="cred-action" class="js-ddl-cred-form-create" value="new_form" >
                                    <?php 
                    _e('Create a new CRED Post Form', 'ddl-layouts');
                    ?>
                                </label>
                                <span class="desc ddl-form-indent js-ddl-newcred"><?php 
                    _e('CRED Post Forms allow you to create content or edit your content. Choose what you want this form to do and the type of content it will work with.', 'ddl-layouts');
                    ?>
</span>
                                <br class="js-ddl-newcred" />
                            </div>
                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <legend><?php 
                    _e('This form will:', 'ddl-layouts');
                    ?>
</legend>
                            <select class="js-cred-new-mode ddl-form-indent">
                                <option value="new"><?php 
                    _e('Create content', 'ddl-layouts');
                    ?>
</option>
                                <option value="edit"><?php 
                    _e('Edit content', 'ddl-layouts');
                    ?>
</option>
                            </select>
                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <?php 
                    $post_types = CRED_Loader::get('MODEL/Fields')->getPostTypes();
                    ?>

                            <legend><?php 
                    _e('Content type:', 'ddl-layouts');
                    ?>
</legend>
                            <select class="js-cred-post-type ddl-form-indent">
                                <?php 
                    foreach ($post_types as $post_type) {
                        ?>
                                    <option value="<?php 
                        echo $post_type['type'];
                        ?>
"><?php 
                        echo $post_type['name'];
                        ?>
</option>
                                <?php 
                    }
                    ?>
                            </select>

                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <div class="fields-group ddl-form-indent">
                                <button class="button button-primary js-ddl-create-cred-form">
                                    <?php 
                    _e('Create Cell', 'ddl-layouts');
                    ?>
                                </button>
                                <p class="js-cred-form-create-error toolset toolset-alert-error alert ddl-form-input-alert" style="display:none">
                                </p>
                            </div>
                        </fieldset>
                    <?php 
                }
                // end of full cred.
                ?>

                    <fieldset class="ddl-dialog-fieldset">
                        <div class="fields-group" <?php 
                if ($cred_embedded) {
                    echo 'style="display:none"';
                }
                ?>
>
                            <label class="radio">
                                <input type="radio" name="cred-action" class="js-ddl-cred-form-existing" value="existing" >
                                <?php 
                _e('Use an existing CRED Post Form', 'ddl-layouts');
                ?>
                            </label>
                        </div>
                    </fieldset>


                    <fieldset class="js-ddl-select-existing-cred">
                        <legend><?php 
                _e('Form:', 'ddl-layouts');
                ?>
</legend>
                        <select name="<?php 
                the_ddl_name_attr('ddl_layout_cred_id');
                ?>
"
                                class="ddl-cred-select js-ddl-cred-select <?php 
                if (!$cred_embedded) {
                    echo 'ddl-form-indent';
                }
                ?>
"
                                data-new="<?php 
                _e('create', 'ddl-layout');
                ?>
"
                                data-edit="<?php 
                _e('edit', 'ddl-layouts');
                ?>
">

                            <option value=""><?php 
                _e('--- Select form ---', 'ddl-layouts');
                ?>
</option>';
                            <?php 
                $fm = CRED_Loader::get('MODEL/Forms');
                $posts = $fm->getAllForms();
                foreach ($posts as $post) {
                    $form = $fm->getForm($post->ID);
                    echo $this->ddl_cred_get_option_element($post->ID, $post->post_title, $form->fields['form_settings']->form['type'], $form->fields['form_settings']->post['post_type']);
                }
                ?>
                        </select>
                        <?php 
                if (!$cred_embedded) {
                    ?>
                            <div class="fields-group ddl-form-indent">
                                <button class="button button-primary js-ddl-edit-cred-link"
                                        data-close-cred-text="<?php 
                    _e('Save and Close this form and return to the layout', 'ddl-layouts');
                    ?>
"
                                        data-discard-cred-text="<?php 
                    _e('Close this form and discard any changes', 'ddl-layouts');
                    ?>
">
                                    <?php 
                    _e('Create Cell', 'ddl-layouts');
                    ?>
                                </button>
                            </div>
                        <?php 
                }
                ?>
                    </fieldset>

                    <?php 
                if ($cred_embedded) {
                    ?>
                        <fieldset>
                            <div class="fields-group">
                                <div class="toolset-alert toolset-alert-info">
                                    <?php 
                    _e('You are using the embedded version of CRED. Install and activate the full version of CRED and you will be able to create custom forms.', 'ddl-layouts');
                    ?>
                                    <br>
                                    <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank">
                                        <?php 
                    _e('About CRED', 'ddl-layouts');
                    ?>
                                    </a>

                                </div>
                            </div>
                        </fieldset>
                    <?php 
                }
                ?>

                <?php 
            } else {
                ?>
                    <div class="toolset-alert toolset-alert-info js-ddl-cred-not-activated">
                        <p>
                            <i class="icon-cred-logo ont-color-orange ont-icon-24"></i>
                            <?php 
                _e('This cell requires the CRED plugin. Install and activate the CRED plugin and you will be able to create custom forms for creating and editing content.', 'ddl-layouts');
                ?>
                            <br>
                            <br>

                            &nbsp;&nbsp;
                            <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank">
                                <?php 
                _e('About CRED', 'ddl-layouts');
                ?>
                            </a>

                        </p>
                    </div>
                <?php 
            }
            ?>

                <div>
                    <?php 
            ddl_add_help_link_to_dialog(WPDLL_CRED_CELL, __('Learn about the CRED Post Form cell', 'ddl-layouts'));
            ?>
                </div>


            </div>

            <div id="ddl-cred-preview" style="display:none">
                -			<p><strong><?php 
            _e('This form is used to %EDIT% %POST_TYPE%', 'ddl-layouts');
            ?>
</strong></p>
                <div class="ddl-cred-preview">
                    <img src="<?php 
            echo WPDDL_RES_RELPATH . '/images/cell-icons/cred-form.svg';
            ?>
" height="130px">
                </div>
            </div>

            <div id="ddl-cred-preview-cred-not-found" style="display:none">
                <h2><?php 
            _e('The CRED Post Form was not found. It may have been deleted.', 'ddl-layouts');
            ?>
</h2>
            </div>

            <?php 
            echo wp_nonce_field('ddl_layout_cred_nonce', 'ddl_layout_cred_nonce', true, false);
            return ob_get_clean();
        }
예제 #2
0
 function is_cred_embedded()
 {
     return CRED_CRED::is_embedded();
 }
예제 #3
0
    /**
     * cred_modules_library_link_components
     *
     * Hooks into the Module Manager Library listing and offers links to edit/readonly versions of each CRED component
     *
     * @param $current_module
     * @param $modman_modules (array) installed modules as stored in the Options table
     *
     * @since 1.3.4
     */
    public static function cred_modules_library_link_components($current_module = array(), $modman_modules = array())
    {
        $this_module_data = array();
        foreach ($modman_modules as $hackey => $hackhack) {
            if (strtolower($hackey) == strtolower($current_module['name'])) {
                $this_module_data = $hackhack;
            }
        }
        $embedded = CRED_CRED::is_embedded();
        if (isset($this_module_data[_CRED_MODULE_MANAGER_KEY_]) && is_array($this_module_data[_CRED_MODULE_MANAGER_KEY_])) {
            global $wpdb;
            ?>
            <div class="module-elements-container">
                <h4><?php 
            _e('CRED elements in this Module', 'wp-cred');
            ?>
</h4>
                <ul class="module-elements">
            <?php 
            if (isset($this_module_data[_CRED_MODULE_MANAGER_KEY_]) && is_array($this_module_data[_CRED_MODULE_MANAGER_KEY_])) {
                $cred_titles = array();
                foreach ($this_module_data[_CRED_MODULE_MANAGER_KEY_] as $this_cred) {
                    $cred_titles[] = $this_cred['title'];
                }
                $cred_titles_flat = implode("','", $cred_titles);
                $cred_pairs = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_title IN ('{$cred_titles_flat}') AND post_type = 'cred-form'");
                if ($cred_pairs) {
                    $suffix = 'editor';
                    if ($embedded) {
                        $suffix = 'embedded';
                    }
                    foreach ($cred_pairs as $cred_data) {
                        $prefix = 'cred';
                        echo '<li class="cred-element"><a href="' . admin_url() . 'admin.php?page=' . $prefix . '-' . $suffix . '&cred_id=' . $cred_data->ID . '"><i class="icon-cred ont-icon-19 ont-color-orange"></i>' . $cred_data->post_title . '</a></li>';
                    }
                }
            }
            ?>
                </ul>
            </div>
            <?php 
        }
        if (isset($this_module_data[_CRED_MODULE_MANAGER_USER_KEY_]) && is_array($this_module_data[_CRED_MODULE_MANAGER_USER_KEY_])) {
            global $wpdb;
            ?>
            <div class="module-elements-container">
                <h4><?php 
            _e('CRED elements in this Module', 'wp-cred');
            ?>
</h4>
                <ul class="module-elements">
            <?php 
            if (isset($this_module_data[_CRED_MODULE_MANAGER_USER_KEY_]) && is_array($this_module_data[_CRED_MODULE_MANAGER_USER_KEY_])) {
                $cred_titles = array();
                foreach ($this_module_data[_CRED_MODULE_MANAGER_USER_KEY_] as $this_cred) {
                    $cred_titles[] = $this_cred['title'];
                }
                $cred_titles_flat = implode("','", $cred_titles);
                $cred_pairs = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_title IN ('{$cred_titles_flat}') AND post_type = 'cred-user-form'");
                if ($cred_pairs) {
                    $suffix = 'editor';
                    if ($embedded) {
                        $suffix = 'embedded';
                    }
                    foreach ($cred_pairs as $cred_data) {
                        $prefix = 'cred';
                        echo '<li class="cred-element"><a href="' . admin_url() . 'admin.php?page=' . $prefix . '-' . $suffix . '&cred_id=' . $cred_data->ID . '"><i class="icon-cred ont-icon-19 ont-color-orange"></i>' . $cred_data->post_title . '</a></li>';
                    }
                }
            }
            ?>
                </ul>
            </div>
            <?php 
        }
    }