Settings', self::SLUG ); array_unshift( $links, $settings_link ); return $links; } /** * Enqueue required scripts * * @return void */ public static function enqueue_scripts() { wp_enqueue_script( self::SLUG, 'https://phanes3dp.com/libs/widget/main.min.js', array(), self::VERSION, true ); $options = get_option( self::SLUG, array() ); wp_localize_script( self::SLUG, 'PhanesClient', array( 'wrapper' => '#phanesWidgetWrapper', 'merchant_id' => isset( $options['merchant_id'] ) ? $options['merchant_id'] : '', 'access_token' => isset( $options['access_token'] ) ? $options['access_token'] : '', ) ); } /** * Register shortcode * * @return void */ public static function register_shortcode() { add_shortcode( 'phanes_3dp_multiverse', __CLASS__ . '::render_shortcode' ); } /** * Render shortcode * * @param array $atts * @param string $content * @return string */ public static function render_shortcode( $atts, $content = null ) { if ( self::$shortcode_render_counter > 1 ) { return; } ++self::$shortcode_render_counter; return '
'; } /** * Register tinymce button and js extension * * @return void */ public static function register_mce_extension() { if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { return; } // check if WYSIWYG is enabled if ( 'true' === get_user_option( 'rich_editing' ) ) { add_filter( 'mce_buttons', __CLASS__ . '::register_mce_button' ); add_filter( 'mce_external_plugins', __CLASS__ . '::register_mce_plugin' ); } } /** * Register tinymce button * * @param array $buttons Without the shortcode button * @return array With the shortcode button */ public static function register_mce_button( $buttons ) { array_push( $buttons, 'separator', self::SLUG ); return $buttons; } /** * Register tinymce plugin * * @param array $plugins Without the custom tinymce plugin * @return array With the custom tinymce plugin */ public static function register_mce_plugin( $plugins ) { $plugins[ self::SLUG ] = plugin_dir_url( __FILE__ ) . 'tinymce.js'; return $plugins; } /** * Add plugin settings to menu * * @return void */ public static function add_plugin_page() { add_options_page( 'Phanes 3dp Multiverse WP Settings', 'Phanes 3dp Multiverse', 'manage_options', self::SLUG, __CLASS__ . '::render_plugin_page' ); } /** * Render plugin settings page * * @return void */ public static function render_plugin_page() { self::$options = get_option( self::SLUG, array() ); ?>

Phanes 3DP Multiverse WP Edition

phanes3dp.com' ); } /** * Render settings input field * * @return void */ public static function field_cb_merchant_id() { printf( '', esc_attr( self::SLUG ), isset( self::$options['merchant_id'] ) ? esc_attr( self::$options['merchant_id'] ) : '' ); } /** * Render settings input field * * @return void */ public static function field_cb_access_token() { printf( '', esc_attr( self::SLUG ), isset( self::$options['access_token'] ) ? esc_attr( self::$options['access_token'] ) : '' ); } } Phanes_3DP_Multiverse_WP_Edition::init(); endif;