[ 'code' => self::DEFAULT_LANGUAGE, 'id' => null, 'native_name' => self::DEFAULT_LANGUAGE_TITLE, 'major' => null, 'active' => null, 'default_locale' => self::DEFAULT_LANGUAGE_LOCALE, 'encode_url' => null, 'tag' => self::DEFAULT_LANGUAGE, 'translated_name' => self::DEFAULT_LANGUAGE_TITLE, 'url' => null, 'country_flag_url' => null, 'language_code' => self::DEFAULT_LANGUAGE, ] ]; } return $list; } public function bootstrap() { register_activation_hook( FQP_PLUGIN_BASE_NAME, [ $this, 'activate' ] ); add_action( 'init', [ $this, 'start_session' ] ); add_action( 'init', [ $this, 'load_textdomain' ] ); add_action( 'init', [ $this, 'register_post_type' ] ); add_action( 'init', [ $this, 'add_shortcodes' ] ); $settings = new Settings(); add_action( 'admin_init', [ $settings, 'register_settings' ] ); add_action( 'admin_menu', [ $settings, 'admin_menu' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); add_action( 'admin_post_fqp_export_csv', function () { ( new SubmissionsExport() )->export(); } ); add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); add_action( 'save_post', [ $this, 'set_quote_post_id' ], 10, 2 ); } public function activate() { //DB::init_database(); } public function start_session() { if ( !session_id() ) { session_start(); } } public function register_post_type() { register_post_type( self::PARTNER_POST_TYPE, [ 'labels' => array( 'name' => 'Partners', 'singular_name' => 'Partner', 'add_new' => 'Add New Partner', 'add_new_item' => 'New Partner', 'edit_item' => 'Edit Partner', 'new_item' => 'New Partner', 'view_item' => 'View Partner', 'search_items' => 'Search Partner', 'not_found' => 'Partner was not found', 'not_found_in_trash' => 'No Partner was found in Trash', 'parent_item_colon' => '', 'menu_name' => 'Partners', ), 'description' => '', 'public' => false, 'show_ui' => true, 'show_in_menu' => false, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'page-attributes'], // 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats' 'taxonomies' => [], 'has_archive' => false, 'rewrite' => [ 'slug' => 'partner', ], 'query_var' => true, 'menu_icon' => plugins_url( 'img/icon.png', FQP_PLUGIN_BASE_NAME ), ] ); add_image_size( self::PARTNER_POST_TYPE . '-thumbnail', 100, 100, false ); } public function load_textdomain() { $path = FQP_PLUGIN_DIR_PATH . 'languages/'; $langs = self::get_lang_list(); $lang = self::get_curr_lang(); if ( array_key_exists( $lang, $langs ) ) { $locale = $langs[$lang]['default_locale']; } else { $locale = get_locale(); } $mo_file = self::TEXT_DOMAIN . '-' . $locale . '.mo'; if ( $loaded = load_textdomain( self::TEXT_DOMAIN, $path . $mo_file ) ) { return $loaded; } return load_textdomain( self::TEXT_DOMAIN, WP_LANG_DIR . '/plugins/' . $mo_file ); } public function admin_enqueue_scripts( $hook ) { $is_prices_page = ( dirname( FQP_PLUGIN_BASE_NAME ) . '/admin/prices.php' == $hook ); wp_enqueue_style( 'fasoon_quote', plugins_url( '/css/admin.css', FQP_PLUGIN_BASE_NAME ) ); if ( $is_prices_page ) { wp_enqueue_script( 'auto_numeric', plugins_url( '/js/autoNumeric/autoNumeric-min.js', FQP_PLUGIN_BASE_NAME ), [ 'jquery' ] ); wp_enqueue_script( 'fasoon', plugins_url( '/js/fasoon-quote.js', FQP_PLUGIN_BASE_NAME ), [ 'auto_numeric' ] ); wp_localize_script( 'fasoon', 'fasoon_php_vars', [ 'currency' => FQP::currency() ] ); } } public function enqueue_scripts() { global $post; if ( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'fasoon_short_pricing' ) || has_shortcode( $post->post_content, 'fasoon_full_pricing' ) || has_shortcode( $post->post_content, 'fasoon_quote_price' ) ) ) { wp_enqueue_style( 'fasoon_quote_price', plugins_url( '/css/user.css', FQP_PLUGIN_BASE_NAME ) ); } } public function add_shortcodes() { new Shortcode\ShortPricing(); new Shortcode\FullPricing(); new Shortcode\QuotePrice(); new Shortcode\SimplePricing(); new Shortcode\QuotePriceTabs(); } public function set_quote_post_id( $post_id, $post ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return $post_id; } if ( !is_a( $post, 'WP_Post' ) || !has_shortcode( $post->post_content, 'fasoon_quote_price' ) ) { return $post_id; } if ( !current_user_can( 'edit_page', $post_id ) ) { return $post_id; } $value = get_option( self::QUOTE_FORM_PAGE_ID_OPTION ); if ( !is_array( $value ) ) { $value = []; } $value[self::get_curr_lang()] = $post_id; update_option( self::QUOTE_FORM_PAGE_ID_OPTION, $value ); return $post_id; } }