$current_page_id, 'generator_id' => $found_generator_id, 'option_key' => $option_key, ); return $get_page_data; } /** * Load dynamic style of the existing shortcode id. * * @param mixed $found_generator_id to push id option for getting how many shortcode in the page. * @param mixed $shortcode_data to push all options. * @return array dynamic style use in the specific shortcode. */ public static function load_dynamic_style( $found_generator_id, $shortcode_data = '' ) { $settings = get_option( 'sp_eap_settings' ); $ea_dynamic_css = ''; // If multiple shortcode found in the page. if ( is_array( $found_generator_id ) ) { foreach ( $found_generator_id as $accordion_id ) { if ( $accordion_id && is_numeric( $accordion_id ) && get_post_status( $accordion_id ) !== 'trash' ) { $shortcode_data = get_post_meta( $accordion_id, 'sp_eap_shortcode_options', true ); include SP_EA_PATH . 'public/partials/dynamic-style.php'; } } } else { // If single shortcode found in the page. $accordion_id = $found_generator_id; include SP_EA_PATH . 'public/partials/dynamic-style.php'; } // Custom css merge with dynamic style. $custom_css = isset( $settings['ea_custom_css'] ) ? trim( html_entity_decode( $settings['ea_custom_css'] ) ) : ''; if ( ! empty( $custom_css ) ) { $ea_dynamic_css .= $custom_css; } // Focus style to improve accessibility. $focus_style = isset( $settings['eap_focus_style'] ) ? $settings['eap_focus_style'] : false; if ( $focus_style ) { $ea_dynamic_css .= '.sp-easy-accordion .ea-header a:focus, .sp-horizontal-accordion .ea-header a:focus{ box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important; }'; } // Google font enqueue dequeue check. $dynamic_style = array( 'dynamic_css' => $ea_dynamic_css, ); return $dynamic_style; } /** * If the option does not exist, it will be created. * * It will be serialized before it is inserted into the database. * * @param string $post_id existing shortcode id. * @param array $get_page_data get current page-id, shortcode-id and option-key from the page. * @return void */ public static function easy_accordion_update_options( $post_id, $get_page_data ) { $found_generator_id = $get_page_data['generator_id']; $option_key = $get_page_data['option_key']; $current_page_id = $get_page_data['page_id']; if ( $found_generator_id ) { $found_generator_id = is_array( $found_generator_id ) ? $found_generator_id : array( $found_generator_id ); if ( ! in_array( $post_id, $found_generator_id ) || empty( $found_generator_id ) ) { // If not found the shortcode id in the page options. array_push( $found_generator_id, $post_id ); if ( is_multisite() ) { update_site_option( $option_key, $found_generator_id ); } else { update_option( $option_key, $found_generator_id ); } } } else { // If option not set in current page add option. if ( $current_page_id ) { if ( is_multisite() ) { add_site_option( $option_key, array( $post_id ) ); } else { add_option( $option_key, array( $post_id ) ); } } } } } new SP_EA_Front_Scripts();