is_hustle_wizard(); $is_restricted_post_type = $this->is_restricted_post_type(); // If page different than Post or Page, abort. if ( ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow && ! $is_hustle_wizard ) || $is_restricted_post_type ) { return; } add_action( 'media_buttons', array( $this, 'attach_button' ) ); add_action( 'admin_footer', array( $this, 'enqueue_js_scripts' ) ); if ( $is_hustle_wizard ) { add_action( 'admin_footer', array( $this, 'enqueue_preview_scripts_for_hustle' ) ); } } /** * Check if current page is Hustle wizard page * * @since 1.0.5 * * @return bool */ public function is_hustle_wizard() { $page = Forminator_Core::sanitize_text_field( 'page' ); // Hustle wizard pages. $pages = array( 'hustle_popup', 'hustle_slidein', 'hustle_embedded', 'hustle_sshare', ); // Check if current page is hustle wizard page. if ( $page && in_array( $page, $pages, true ) ) { return true; } return false; } /** * Check if current page is in restricted post type * * @since 1.32.0 * * @return bool */ public function is_restricted_post_type() { $post_type = Forminator_Core::sanitize_text_field( 'post_type' ); if ( ! $post_type ) { $post_type = get_post_type( Forminator_Core::sanitize_text_field( 'post' ) ); } // Restricted post types. $post_types = array( 'cfs' ); // Filter to include more post types. $post_types = apply_filters( 'forminator_exclude_shortcode_generator_post_types', $post_types ); // Check if current page is a restricted post type page. if ( $post_type && in_array( $post_type, $post_types, true ) ) { return true; } return false; } /** * Attach button * * @since 1.0 */ public function attach_button() { // Button markup. printf( '', 'forminator-generate-shortcode', '', esc_html__( 'Add Form', 'forminator' ) ); } /** * Enqueue JS * * @since 1.0 * @param string $content Content. * * @return mixed */ public function enqueue_js_scripts( $content ) { $sui_version = FORMINATOR_SUI_VERSION; $sanitize_version = str_replace( '.', '-', $sui_version ); $sui_body_class = "sui-$sanitize_version"; wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-widget' ); wp_enqueue_script( 'jquery-ui-mouse' ); wp_enqueue_script( 'jquery-ui-tabs' ); // Get shortcode generator styles. wp_enqueue_style( 'forminator-shortcode-generator-styles', forminator_plugin_url() . 'build/css/forminator-scgen.min.css', array(), FORMINATOR_VERSION ); // Get SUI JS. $sui_handle = 'shared-ui'; wp_enqueue_script( $sui_handle, forminator_plugin_url() . 'build/js/shared-ui.min.js', array( 'jquery', 'clipboard' ), $sui_body_class, true ); // Get shortcode generator scripts. wp_enqueue_script( 'forminator-shortcode-generator', forminator_plugin_url() . 'build/admin/scgen.min.js', array( 'jquery' ), FORMINATOR_VERSION, false ); wp_localize_script( 'forminator-shortcode-generator', 'forminatorScgenData', array( 'suiVersion' => $sui_body_class, ) ); $this->print_markup(); ?>
4 ) ? 'true' : 'false'; $placeholder = esc_html__( 'Select Custom Form', 'forminator' ); $html .= ''; return $html; } /** * Print polls select * * @since 1.0 * @return string */ public function get_polls() { $html = ''; $modules = Forminator_API::get_polls( null, 1, 999 ); $search = ( count( $modules ) > 4 ) ? 'true' : 'false'; $placeholder = esc_html__( 'Select Poll', 'forminator' ); $html .= ''; return $html; } /** * Print quizzes select * * @since 1.0 * @return string */ public function get_quizzes() { $html = ''; $modules = Forminator_API::get_quizzes( null, 1, 999 ); $search = ( count( $modules ) > 4 ) ? 'true' : 'false'; $placeholder = esc_html__( 'Select Quiz', 'forminator' ); $html .= ''; return $html; } }