; return $config; } public static function get_custom_icons_config() { $config = get_option( self::OPTION_NAME, false ); if ( false === $config ) { $icons = new \WP_Query( [ 'post_type' => Icons_Manager::CPT, 'posts_per_page' => -1, 'post_status' => 'publish', ] ); $config = []; foreach ( $icons->posts as $icon_set ) { $set_config = json_decode( self::get_icon_set_config( $icon_set->ID ), true ); $set_config['custom_icon_post_id'] = $icon_set->ID; $set_config['label'] = $icon_set->post_title; if ( isset( $set_config['fetchJson'] ) ) { unset( $set_config['icons'] ); } $config[ $set_config['name'] ] = $set_config; } update_option( self::OPTION_NAME, $config ); } return $config; } public static function icon_set_prefix_exists( $prefix ) { $config = self::get_custom_icons_config(); if ( empty( $config ) ) { return false; } foreach ( $config as $icon_set_name => $icon_config ) { if ( $prefix === $icon_config['prefix'] ) { return true; } } return false; } public function transition_post_status( $new_status, $old_status, $post ) { if ( Icons_Manager::CPT !== $post->post_type ) { return; } if ( 'publish' === $old_status && 'publish' !== $new_status ) { $this->clear_icon_list_option(); } } protected function actions() { parent::actions(); if ( is_admin() ) { add_action( 'add_meta_boxes_' . Icons_Manager::CPT, [ $this, 'add_meta_box' ] ); add_action( 'save_post_' . Icons_Manager::CPT, [ $this, 'save_post_meta' ], 10, 3 ); add_filter( 'display_post_states', [ $this, 'display_post_states' ], 10, 2 ); add_action( 'manage_' . Icons_Manager::CPT . '_posts_custom_column', [ $this, 'render_columns' ], 10, 2 ); add_filter( 'enter_title_here', [ $this, 'update_enter_title_here' ], 10, 2 ); add_filter( 'manage_' . Icons_Manager::CPT . '_posts_columns', [ $this, 'manage_columns' ], 100 ); add_action( 'current_screen', [ $this, 'add_custom_icon_templates' ] ); } add_action( 'transition_post_status', [ $this, 'transition_post_status' ], 10, 3 ); add_action( 'before_delete_post', [ $this, 'handle_delete_icon_set' ] ); add_filter( 'elementor/icons_manager/additional_tabs', [ $this, 'register_icon_libraries_control' ] ); add_filter( 'elementor/editor/localize_settings', [ $this, 'add_custom_icons_url' ] ); // Ajax. add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); } }