/** * Render the Module Manager section. * * Active Module Manager plugin is assumed. * * @param WPV_Content_Template $ct Content Template */ function wpv_ct_editor_module_manager_section( $ct ) { ob_start(); // Copied from the old CT page (almost) without change $element = array( 'id'=> _VIEW_TEMPLATES_MODULE_MANAGER_KEY_ . $ct->id, 'title'=> $ct->title, 'section'=>_VIEW_TEMPLATES_MODULE_MANAGER_KEY_ ); do_action( 'wpmodules_inline_element_gui', $element ); $content = ob_get_contents(); ob_end_clean(); wpv_ct_editor_render_section( __( 'Module Manager', 'wpv-views' ), '', $content, false, 'wpv-setting-container-module-manager', 'wpv-setting-module-manager' ); }
function wpv_ct_editor_content_section( $ct ) { ob_start(); ?> <div class="js-code-editor code-editor content-editor" data-name="complete-output-editor"> <div class="code-editor-toolbar js-code-editor-toolbar"> <ul> <?php $menus_to_add = array( 'post', // wpv-post shortcodes plus non-Types fields under their own section 'post-extended', // generic shortcodes extended in the Basic section 'post-fields-placeholder', // non-Types fields on demand 'user', // basic user data 'body-view-templates', // Content Templates 'post-view', // Views listing posts 'taxonomy-view', // all available Views listing terms 'user-view' // all available Views listing users ); do_action( 'wpv_views_fields_button', 'wpv_content', $menus_to_add ); // Needed so CRED displays a button instead of a fake anchor tag if( wpv_ct_editor_is_cred_button_supported() ) { define("CT_INLINE", "1"); do_action('wpv_cred_forms_button', 'wpv_content'); } wpv_ct_editor_content_add_media_button( $ct->id, 'wpv_content' ); ?> </ul> </div> <!--suppress HtmlFormInputWithoutLabel --> <textarea cols="30" rows="10" id="wpv_content" name="wpv_content" data-bind="textInput: postContentAccepted"></textarea> <!-- CSS editor --> <div class="wpv-editor-metadata-toggle" data-bind="click: toggleCssEditor"> <span class="wpv-toggle-toggler-icon"> <i data-bind="attr: { class: isCssEditorExpanded() ? 'icon-caret-up icon-large' : 'icon-caret-down icon-large' }"></i> </span> <i class="icon-pushpin" data-bind="widthToggleVisible: isCssPinVisible"></i> <strong><?php _e( 'CSS editor', 'wpv-views' ); ?></strong> </div> <div class="wpv-ct-assets-inline-editor" data-bind="editorVisible: isCssEditorExpanded" data-target-editor="css"> <!--suppress HtmlFormInputWithoutLabel --> <textarea name="name" id="wpv_template_extra_css" data-bind="textInput: templateCssAccepted"></textarea> </div> <!-- JS editor --> <div class="wpv-editor-metadata-toggle" data-bind="click: toggleJsEditor"> <span class="wpv-toggle-toggler-icon"> <i data-bind="attr: { class: isJsEditorExpanded() ? 'icon-caret-up icon-large' : 'icon-caret-down icon-large' }"></i> </span> <i class="icon-pushpin" data-bind="widthToggleVisible: isJsPinVisible"></i> <strong><?php _e( 'JS editor', 'wpv-views' ); ?></strong> </div> <div class="wpv-ct-assets-inline-editor" data-bind="editorVisible: isJsEditorExpanded" data-target-editor="js"> <!--suppress HtmlFormInputWithoutLabel --> <textarea name="name" id="wpv_template_extra_js" data-bind="textInput: templateJsAccepted"></textarea> </div> <?php wpv_formatting_help_content_template(); ?> </div> <p class="update-button-wrap"> <span class="update-action-wrap"> <span class="js-wpv-message-container"></span> <span class="spinner ajax-loader" data-bind="spinnerActive: isContentSectionUpdating"></span> </span> <button data-bind=" enable: isContentSectionUpdateNeeded, attr: { class: isContentSectionUpdateNeeded() ? 'button-primary' : 'button-secondary' }, click: contentSectionUpdate"> <?php _e( 'Update', 'wpv-views' ); ?> </button> </p> <?php $content = ob_get_contents(); ob_end_clean(); wpv_ct_editor_render_section( __( 'Template', 'wpv-views' ), 'js-wpv-content-section', $content, true, '', '', array( 'section' => 'content_section', 'pointer_slug' => 'ptr_section' ) ); }
function wpv_ct_editor_settings_section( /** @noinspection PhpUnusedParameterInspection */ $ct ) { ob_start(); ?> <!-- output mode --> <h3> <?php _e( 'Output mode', 'wpv-views' ) ?> <i class="icon-question-sign js-wpv-show-pointer" data-section="settings_section" data-pointer-slug="ptr_output_mode"></i> </h3> <p> <label> <input type="radio" value="WP_mode" data-bind="checked: outputModeAccepted" /> <?php _e( 'Auto-insert paragraphs', 'wpv-views' ); ?> </label> </p> <p> <label> <input type="radio" value="raw_mode" data-bind="checked: outputModeAccepted" /> <?php _e( 'Manual paragraphs', 'wpv-views' ); ?> </label> </p> <p> <span class="update-action-wrap auto-update"> <span class="js-wpv-message-container"></span> <span class="spinner ajax-loader" data-bind="spinnerActive: isSettingsSectionUpdating"></span> </span> </p> <?php $content = ob_get_contents(); ob_end_clean(); wpv_ct_editor_render_section( __( 'Settings', 'wpv-views' ), 'js-wpv-settings-section', $content ); }
/** * @param WPV_Content_Template $ct * @since 1.9 */ function wpv_ct_editor_title_section( $ct ) { ob_start(); ?> <div id="titlediv"> <div id="titlewrap"> <label class="screen-reader-text js-title-reader" id="title-prompt-text" for="title"> <?php _e('Enter title here', 'wp-views'); ?> </label> <input id="title" name="title" type="text" size="30" autocomplete="off" data-bind="textInput: title"/> </div> </div> <div id="edit-slug-box"> <label for="slug"> <?php _e( 'Slug of this Content Template', 'wpv-views' ); ?> </label> <!--suppress HtmlFormInputWithoutLabel --> <input id="wpv-slug" name="slug" type="text" data-bind="textInput: slugAccepted"/> <?php if( $ct->can_be_trashed ) { ?> • <button class="button-secondary" data-bind="click: trashAction, disable: isTrashing"> <i class="icon-trash"></i> <?php _e( 'Move to trash', 'wpv-views' ); ?> </button> <span class="spinner ajax-loader" data-bind="spinnerActive: isTrashing"></span> <?php } ?> </div> <p> <span data-bind="visible: showAddDescriptionButton"> <button class="button-secondary" data-bind="click: showDescriptionField"> <?php _e('Add description', 'wpv-views'); ?> </button> </span> </p> <div class="wpv-description-container" data-bind="visible: isDescriptionVisible"> <p> <label for="wpv-description"> <?php _e('Describe this Content Template', 'wpv-views'); ?> </label> </p> <p> <textarea id="wpv-description" name="description" cols="72" rows="4" data-bind="textInput: descriptionAccepted"></textarea> </p> </div> <p class="update-button-wrap"> <span class="js-wpv-message-container"></span> <span class="spinner ajax-loader" data-bind="spinnerActive: isTitleSectionUpdating"></span> <button data-bind=" enable: isTitleSectionUpdateNeeded, attr: { class: isTitleSectionUpdateNeeded() ? 'button-primary' : 'button-secondary' }, click: titleSectionUpdate"> <?php _e('Update', 'wpv-views'); ?> </button> </p> <?php $content = ob_get_contents(); ob_end_clean(); // We're adding also the "wpv-title-section" class that's important for the Action bar styling. // Otherwise it has no relevance here. wpv_ct_editor_render_section( __( 'Title and Description', 'wpv-views' ), 'js-wpv-title-section wpv-title-section', $content, false, '', '', array( 'section' => 'title_section', 'pointer_slug' => 'ptr_section' ) ); }
function wpv_ct_editor_usage_section( $ct ) { ob_start(); $parent_view = null; if( $ct->is_owned_by_view ) { $parent_view = WPV_View_Base::get_instance($ct->loop_output_id); } if( null != $parent_view ) { if( $parent_view->is_published ) { $edit_page = 'views-editor'; if ( WPV_View_Base::is_archive_view( $parent_view->id ) ) { $edit_page = 'view-archives-editor'; } $loop_template_notice = sprintf( __( 'This Content Template is used as the loop block for the %s <a href="%s" target="_blank">%s</a>.', 'wpv-views' ), $parent_view->query_mode_display_name, esc_attr( add_query_arg( array( 'page' => $edit_page, 'view_id' => $parent_view->id ), admin_url( 'admin.php' ) ) ), $parent_view->title ); } else { $loop_template_notice = sprintf( __( 'This Content Template is used as the loop block for the trashed %s %s.', 'wpv-views' ), $parent_view->query_mode_display_name, "<strong>{$parent_view->title}</strong>" ); } printf( '<div class="wpv-advanced-setting"><p>%s</p></div>', $loop_template_notice ); } else { $asterisk_explanation = '<span data-bind="fadeVisibility: isAsteriskExplanationVisible(\'%s\', \'%s\')"><span style="color:red">*</span> ' . __('A different Content Template is already assigned to this item.', 'wpv-views') . '</span>'; // Render checkboxes for each type of assignment. $single_post_types_with_other_ct = wpv_ct_editor_usage_section_single_pages($ct, $asterisk_explanation); $cpt_archives_with_other_ct = wpv_ct_editor_usage_section_post_archives($ct, $asterisk_explanation); $taxonomy_archives_with_other_ct = wpv_ct_editor_usage_section_taxonomy_archives($ct, $asterisk_explanation); // Print information about other CT assignments for JS $other_assignments = array( 'single_posts' => $single_post_types_with_other_ct, 'cpt_archives' => $cpt_archives_with_other_ct, 'taxonomy_archives' => $taxonomy_archives_with_other_ct ); printf( '<span style="visibility: hidden" class="js-wpv-usage-other-assignments" data-value="%s"></span>', htmlentities(json_encode($other_assignments)) ); ?> <p class="update-button-wrap"> <span class="update-action-wrap"> <span class="js-wpv-message-container"></span> <span class="spinner ajax-loader" data-bind="spinnerActive: isUsageSectionUpdating"></span> </span> <button data-bind=" enable: isUsageSectionUpdateNeeded, attr: { class: isUsageSectionUpdateNeeded() ? 'button-primary' : 'button-secondary' }, click: usageSectionUpdate"> <?php _e('Update', 'wpv-views'); ?> </button> </p> <?php } $content = ob_get_contents(); ob_end_clean(); wpv_ct_editor_render_section( __( 'Usage', 'wpv-views' ), 'js-wpv-usage-section', $content, false, '', '', array( 'section' => 'usage_section', 'pointer_slug' => 'ptr_section' ) ); }