function wpv_ct_loader_inline_callback() { if (!current_user_can('manage_options')) { die("Undefined Nonce."); } if (!isset($_POST["wpnonce"]) || !wp_verify_nonce($_POST["wpnonce"], 'wpv_inline_content_template') && !wp_verify_nonce($_POST["wpnonce"], 'wpv-ct-inline-edit')) { die("Undefined Nonce."); } // @todo check why the hell this is here do_action('views_ct_inline_editor'); if (!isset($_POST["id"]) || !is_numeric($_POST["id"]) || intval($_POST['id']) < 1) { echo 'error'; die; } $template = get_post($_POST['id']); // @todo check what the hell is that constant // This is for the CRED button and icon!! define("CT_INLINE", "1"); if (is_object($template) && isset($template->ID) && isset($template->post_type) && $template->post_type == 'view-template') { $ct_id = $template->ID; ?> <div class="code-editor-toolbar js-code-editor-toolbar"> <ul class="js-wpv-v-icon js-wpv-v-icon-<?php echo esc_attr($ct_id); ?> "> <?php do_action('wpv_views_fields_button', 'wpv-ct-inline-editor-' . $ct_id); do_action('wpv_cred_forms_button', 'wpv-ct-inline-editor-' . $ct_id); ?> <li> <button class="button-secondary js-code-editor-toolbar-button js-wpv-media-manager" data-id="<?php echo esc_attr($ct_id); ?> " data-content="wpv-ct-inline-editor-<?php echo esc_attr($ct_id); ?> "> <i class="icon-picture"></i> <span class="button-label"><?php _e('Media', 'wpv-views'); ?> </span> </button> </li> </ul> </div> <textarea name="name" rows="10" class="js-wpv-ct-inline-editor-textarea" data-id="<?php echo esc_attr($ct_id); ?> " id="wpv-ct-inline-editor-<?php echo esc_attr($ct_id); ?> "><?php echo esc_textarea($template->post_content); ?> </textarea> <?php if (isset($_POST['include_instructions'])) { if ($_POST['include_instructions'] == 'inline_content_template') { wpv_formatting_help_inline_content_template($template); } if ($_POST['include_instructions'] == 'layouts_content_cell') { wpv_formatting_help_layouts_content_template_cell($template); } } ?> <?php } else { echo 'error'; } die; }
function wpv_ct_loader_inline_callback() { if ( ! current_user_can( 'manage_options' ) ) { die( "Undefined Nonce." ); } if ( ! isset( $_POST["wpnonce"] ) || ( ! wp_verify_nonce( $_POST["wpnonce"], 'wpv_inline_content_template' ) && ! wp_verify_nonce( $_POST["wpnonce"], 'wpv-ct-inline-edit' ) ) // Keep this for backwards compat and also for Layouts ) { die( "Undefined Nonce." ); } // @todo check why the hell this is here do_action('views_ct_inline_editor'); if ( ! isset( $_POST["id"] ) || ! is_numeric( $_POST["id"] ) || intval( $_POST['id'] ) < 1 ) { echo 'error'; die(); } $template = get_post( $_POST['id'] ); // @todo check what the hell is that constant // This is for the CRED button and icon!! define("CT_INLINE", "1"); if ( is_object( $template ) && isset( $template->ID ) && isset( $template->post_type ) && $template->post_type == 'view-template' ) { $ct_id = $template->ID; $loaded_from = ''; if ( isset( $_POST['include_instructions'] ) ) { if ( $_POST['include_instructions'] == 'inline_content_template' ) { $loaded_from = 'inline_content_template'; } if ( $_POST['include_instructions'] == 'layouts_content_cell' ) { $loaded_from = 'layouts_content_cell'; } } ?> <div class="code-editor-toolbar js-code-editor-toolbar"> <ul class="js-wpv-v-icon js-wpv-v-icon-<?php echo esc_attr( $ct_id ); ?>"> <?php do_action( 'wpv_views_fields_button', 'wpv-ct-inline-editor-' . $ct_id ); do_action( 'wpv_cred_forms_button', 'wpv-ct-inline-editor-' . $ct_id ); ?> <li> <button class="button-secondary js-code-editor-toolbar-button js-wpv-media-manager" data-id="<?php echo esc_attr( $ct_id ); ?>" data-content="wpv-ct-inline-editor-<?php echo esc_attr( $ct_id ); ?>"> <i class="icon-picture"></i> <span class="button-label"><?php _e('Media','wpv-views'); ?></span> </button> </li> </ul> </div> <textarea name="name" rows="10" class="js-wpv-ct-inline-editor-textarea" autocomplete="off" data-id="<?php echo esc_attr( $ct_id ); ?>" id="wpv-ct-inline-editor-<?php echo esc_attr( $ct_id ); ?>"><?php echo esc_textarea( $template->post_content ); ?></textarea> <?php if ( $loaded_from == 'inline_content_template' ) { ?> <?php $extra_css = get_post_meta( $ct_id, '_wpv_view_template_extra_css', true ); $extra_js = get_post_meta( $ct_id, '_wpv_view_template_extra_js', true ); ?> <div class="wpv-editor-metadata-toggle js-wpv-editor-metadata-toggle js-wpv-ct-assets-inline-editor-toggle" data-id="<?php echo esc_attr( $ct_id ); ?>" data-target="js-wpv-ct-assets-inline-css-editor-<?php echo esc_attr( $ct_id ); ?>" data-type="css"> <span class="wpv-toggle-toggler-icon js-wpv-toggle-toggler-icon"> <i class="icon-caret-down icon-large"></i> </span> <i class="icon-pushpin js-wpv-textarea-full" style="<?php echo ( empty( $extra_css ) ) ? 'display:none;' : ''; ?>"></i> <strong><?php _e( 'CSS editor', 'wpv-views' ); ?></strong> </div> <div id="wpv-ct-assets-inline-editor-<?php echo esc_attr( $ct_id ); ?>" class="wpv-ct-assets-inline-editor hidden js-wpv-ct-assets-inline-css-editor-<?php echo esc_attr( $ct_id ); ?>" data-id="<?php echo esc_attr( $ct_id ); ?>"> <textarea name="name" class="js-wpv-ct-assets-inline-editor-textarea" autocomplete="off" id="wpv-ct-assets-inline-css-editor-<?php echo esc_attr( $ct_id ); ?>" data-id="<?php echo esc_attr( $ct_id ); ?>"><?php echo esc_textarea( $extra_css ); ?></textarea> </div> <div class="wpv-editor-metadata-toggle js-wpv-editor-metadata-toggle js-wpv-ct-assets-inline-editor-toggle" data-id="<?php echo esc_attr( $ct_id ); ?>" data-target="js-wpv-ct-assets-inline-js-editor-<?php echo esc_attr( $ct_id ); ?>" data-type="js"> <span class="wpv-toggle-toggler-icon js-wpv-toggle-toggler-icon"> <i class="icon-caret-down icon-large"></i> </span> <i class="icon-pushpin js-wpv-textarea-full" style="<?php echo ( empty( $extra_js ) ) ? 'display:none;' : ''; ?>"></i> <strong><?php _e( 'JS editor', 'wpv-views' ); ?></strong> </div> <div id="wpv-ct-assets-inline-editor-<?php echo esc_attr( $ct_id ); ?>" class="wpv-ct-assets-inline-editor hidden js-wpv-ct-assets-inline-js-editor-<?php echo esc_attr( $ct_id ); ?>" data-id="<?php echo esc_attr( $ct_id ); ?>"> <textarea name="name" class="js-wpv-ct-assets-inline-editor-textarea" autocomplete="off" id="wpv-ct-assets-inline-js-editor-<?php echo esc_attr( $ct_id ); ?>" data-id="<?php echo esc_attr( $ct_id ); ?>"><?php echo esc_textarea( $extra_js ); ?></textarea> </div> <?php } ?> <?php switch ( $loaded_from ) { case 'inline_content_template': wpv_formatting_help_inline_content_template( $template ); break; case 'layouts_content_cell': wpv_formatting_help_layouts_content_template_cell( $template ); break; } ?> <?php } else { echo 'error'; } die(); }