/** START || JKIT Polylang Compatible for JKIT Template */ /** Add Language Condition in Dashboard Template */ function jkit_custom_template_condition_fields( $fields, $value, $page ) { $fields['language'] = array( 'type' => 'select', 'title' => esc_html__( 'Language', 'jeg-elementor-kit' ), 'description' => esc_html__( 'Select the language for the template.', 'jeg-elementor-kit' ), 'options' => call_user_func( function() { $languages = pll_the_languages( array( 'raw' => 1 ) ); $options = array( '' => esc_html__( 'All Language', 'jeg-elementor-kit' ) ); foreach ( $languages as $locale => $language ) { $options[ $locale ] = $language['name']; } return $options; } ), 'default' => '', ); return $fields; } add_filter( 'jkit_template_condition_fields', 'jkit_custom_template_condition_fields', 10, 3 ); /** Add Language Condition for Template */ function jkit_custom_check_template_contions( $flag, $post_id, $header_id, $conditions ) { if ( $conditions ) { foreach ( $conditions as $condition ) { if ( ! empty( $condition['language'] ) ) { $flag = $flag && $condition['language'] === pll_current_language(); } } } return $flag; } add_filter( 'jkit_check_template_conditions', 'jkit_custom_check_template_contions', 10, 4 ); /** END || JKIT Polylang Compatible for JKIT Template */