admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( ACS_Portfolio_Shortcode::NONCE ), ) ); } /** * Load the front end assets on this page. * * @return void */ public static function need_frontend_assets() { wp_enqueue_style( 'acs-portfolio-frontend' ); wp_enqueue_script( 'acs-portfolio-frontend' ); } /** * Admin styles and scripts. * * @param string $hook Current admin page hook. * @return void */ public function enqueue_admin_assets( $hook ) { $post_type = ACS_Portfolio_Post_Type::POST_TYPE; if ( 'post.php' === $hook || 'post-new.php' === $hook ) { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $screen && $post_type === $screen->post_type ) { wp_enqueue_style( 'dashicons' ); if ( ACS_Portfolio_Download::is_download_mode() ) { wp_enqueue_media(); $this->enqueue_admin_script(); } } } if ( ACS_Portfolio_Settings::is_settings_screen( $hook ) ) { $this->enqueue_admin_script(); } } /** * Register and localise the admin script. * * @return void */ private function enqueue_admin_script() { wp_enqueue_script( 'acs-portfolio-admin', ACS_PORTFOLIO_URL . 'assets/js/admin.js', array( 'jquery' ), ACS_PORTFOLIO_VERSION, true ); wp_localize_script( 'acs-portfolio-admin', 'acsPortfolioAdmin', array( 'selectTitle' => __( 'Choose the file to distribute', 'acs-portfolio' ), 'selectButton' => __( 'Use this file', 'acs-portfolio' ), 'noFile' => __( 'Not set. The full size featured image is offered instead.', 'acs-portfolio' ), 'blockedMime' => __( 'That file type cannot be used as a download.', 'acs-portfolio' ), 'blockedMimes' => ACS_Portfolio_Download::blocked_mimes(), ) ); } /** * Activation hook. * * @return void */ public static function activate() { ACS_Portfolio_Post_Type::register(); flush_rewrite_rules(); update_option( 'acs_portfolio_core_version', ACS_PORTFOLIO_VERSION ); } /** * Deactivation hook. * * @return void */ public static function deactivate() { flush_rewrite_rules(); } } register_activation_hook( __FILE__, array( 'ACS_Portfolio_Core', 'activate' ) ); register_deactivation_hook( __FILE__, array( 'ACS_Portfolio_Core', 'deactivate' ) ); /** * Load the bundled translations from the languages folder. */ add_action( 'init', static function () { // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- Loads the translations bundled in /languages; WordPress only loads language packs from translate.wordpress.org on its own. load_plugin_textdomain( 'acs-portfolio', false, dirname( plugin_basename( ACS_PORTFOLIO_FILE ) ) . '/languages' ); }, 0 ); ACS_Portfolio_Core::get_instance();