15 if ( ! defined(
'ABSPATH' ) ) {
23 add_action(
'media_buttons', array( $this,
'add_shortcode_button'), 30);
25 add_action(
'admin_footer', array( $this,
'add_shortcode_popup') );
28 add_action(
'admin_enqueue_scripts', array( $this,
'add_scripts_and_styles') );
31 add_action(
'wp_ajax_gv_sortable_fields', array( $this,
'get_sortable_fields' ) );
41 global $current_screen, $pagenow;
42 return !empty( $current_screen->post_type ) &&
'gravityview' != $current_screen->post_type && in_array( $pagenow , array(
'post.php' ,
'post-new.php' ) );
64 <a href=
"#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class=
"thickbox hide-if-no-js button gform_media_link" id=
"add_gravityview" title=
"<?php esc_attr_e("Insert View
", 'gk-gravityview'); ?>"><span
class=
"icon gv-icon-astronaut-head"></span><?php esc_html_e(
'Add View',
'gk-gravityview' ); ?></a>
83 $post_type = get_post_type_object($post->post_type);
85 $views = get_posts( array(
'post_type' =>
'gravityview',
'posts_per_page' => -1 ) );
88 if( empty( $views ) ) {
94 <div
id=
"select_gravityview_view">
95 <form action=
"#" method=
"get" id=
"select_gravityview_view_form">
98 <h2
class=
""><?php esc_html_e(
'Embed a View',
'gk-gravityview' ); ?></h2>
99 <p
class=
"subtitle"><?php printf( esc_attr ( __(
'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s',
'gk-gravityview') ), $post_type->labels->singular_name,
'<a href="https://docs.gravityview.co/article/73-using-the-shortcode" target="_blank" rel="noopener noreferrer">',
'</a>' ); ?></p>
102 <h3><label
for=
"gravityview_id"><?php esc_html_e(
'Select a View',
'gk-gravityview' ); ?></label></h3>
104 <select name=
"gravityview_id" id=
"gravityview_id">
105 <option value=
""><?php esc_html_e(
'— Select a View to Insert —',
'gk-gravityview' ); ?></option>
107 foreach( $views as $view ) {
108 $title = empty( $view->post_title ) ? __(
'(no title)',
'gk-gravityview') : $view->post_title;
109 echo
'<option value="'. $view->ID .
'">'. esc_html( sprintf(
'%s #%d',
$title, $view->ID ) ) .
'</option>';
115 <table
class=
"form-table hide-if-js">
117 <caption><?php esc_html_e(
'View Settings',
'gk-gravityview' ); ?></caption>
123 foreach ( $settings as $key => $setting ) {
125 if( empty( $setting[
'show_in_shortcode'] ) ) {
continue; }
134 <input type=
"submit" class=
"button button-primary button-large alignleft hide-if-js" value=
"<?php esc_attr_e('Insert View', 'gk-gravityview' ); ?>" id=
"insert_gravityview_view" />
135 <input
class=
"button button-secondary alignright" type=
"submit" onclick=
"tb_remove(); return false;" value=
"<?php esc_attr_e("Cancel
", 'gk-gravityview'); ?>" />
159 wp_enqueue_style(
'dashicons' );
162 wp_enqueue_script(
'jquery-ui-datepicker' );
164 $protocol = is_ssl() ?
'https://' :
'http://';
166 wp_enqueue_style(
'jquery-ui-datepicker', $protocol.
'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(),
GV_PLUGIN_VERSION );
170 wp_enqueue_style(
'gravityview_postedit_styles' );
172 $script_debug = (defined(
'SCRIPT_DEBUG') && SCRIPT_DEBUG) ?
'' :
'.min';
175 wp_register_script(
'gravityview_postedit_scripts', plugins_url(
'assets/js/admin-post-edit'.$script_debug.
'.js',
GRAVITYVIEW_FILE), array(
'jquery',
'jquery-ui-datepicker' ),
GV_PLUGIN_VERSION );
176 wp_enqueue_script(
'gravityview_postedit_scripts' );
177 wp_localize_script(
'gravityview_postedit_scripts',
'gvGlobals', array(
178 'nonce' => wp_create_nonce(
'gravityview_ajaxaddshortcode'),
179 'loading_text' => esc_html__(
'Loading…',
'gk-gravityview' ),
180 'alert_1' => esc_html__(
'Please select a View',
'gk-gravityview'),
196 if ( empty( $_POST[
'viewid'] ) || !is_numeric( $_POST[
'viewid'] ) ) {
201 if( empty( $_POST[
'nonce'] ) || ! wp_verify_nonce( $_POST[
'nonce'],
'gravityview_ajaxaddshortcode' ) ) {
205 $viewid = (int)$_POST[
'viewid'];
const GV_PLUGIN_VERSION(! GravityKit\GravityView\Foundation\meets_min_php_version_requirement(__FILE__, '7.2.0'))
Constants.
is_post_editor_screen()
check if screen post editor and is not related with post type 'gravityview'
add_shortcode_popup()
Add shortcode popup div.
static render_setting_row( $key='', $current_settings=array(), $override_input=null, $name='template_settings[%s]', $id='gravityview_se_%s')
Output a table row for view settings.
get_sortable_fields()
Ajax Given a View id, calculates the assigned form, and returns the form fields (only the sortable on...
gravityview_get_template_setting( $post_id, $key)
Get the setting for a View.
add_scripts_and_styles()
Enqueue scripts and styles.
add_shortcode_button()
Add shortcode button to the Add Media right.
static no_views_text()
Get text for no views found.
new GravityView_Admin_Add_Shortcode
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
gravityview_get_sortable_fields( $formid, $current='')
Render dropdown (select) with the list of sortable fields from a form ID.
static defaults( $detailed=false, $group=null)
Retrieve the default View settings.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
If this file is called directly, abort.