PK!\O%&*$*$settings-url.phpnuW+A 'url', 'title' => __( 'URL modifications', 'polylang' ), 'description' => __( 'Decide how your URLs will look like.', 'polylang' ), 'configure' => true, ) ); $this->links_model = &$polylang->links_model; $this->page_on_front = &$polylang->static_pages->page_on_front; } /** * Displays the fieldset to choose how the language is set * * @since 1.8 */ protected function force_lang() {?>

' . esc_html( home_url( $this->links_model->using_permalinks ? 'en/my-post/' : '?lang=en&p=1' ) ) . ''; ?>

' . esc_html( str_replace( array( '://', 'www.' ), array( '://en.', '' ), home_url( 'my-post/' ) ) ) . ''; ?>

options['force_lang'] ? '' : 'style="display: none;"'; ?>> model->get_languages_list() as $lg ) { printf( '' . '', esc_attr( $lg->slug ), esc_attr( $lg->name ), esc_url( isset( $this->options['domains'][ $lg->slug ] ) ? $this->options['domains'][ $lg->slug ] : ( $lg->slug == $this->options['default_lang'] ? $this->links_model->home : '' ) ) ); } ?>

' . esc_html( home_url( 'en/' ) ) . ''; ?>

' . esc_html( home_url( 'language/en/' ) ) . ''; ?>

model->post->get_language( $this->page_on_front ); $lang = $lang ? $lang : $this->model->get_language( $this->options['default_lang'] ); printf( /* translators: %s are urls */ esc_html__( 'Example: %s instead of %s', 'polylang' ), '' . esc_html( $this->links_model->home_url( $lang ) ) . '', '' . esc_html( _get_page_link( $this->page_on_front ) ) . '' ); ?>

force_lang(); ?>
$this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> hide_default(); ?>
links_model->using_permalinks ) { ?>
$this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> rewrite(); ?>
page_on_front ) { ?>
$this->options['force_lang'] ? '' : 'style="display: none;"'; ?>> redirect_lang(); ?>
$domain ) { if ( empty( $domain ) ) { $lang = $this->model->get_language( $key ); add_settings_error( 'general', 'pll_invalid_domain', esc_html( sprintf( /* translators: %s is a native language name */ __( 'Please enter a valid URL for %s.', 'polylang' ), $lang->name ) ) ); } else { $newoptions['domains'][ $key ] = esc_url_raw( trim( $domain ) ); } } } foreach ( array( 'hide_default', 'redirect_lang' ) as $key ) { $newoptions[ $key ] = isset( $options[ $key ] ) ? 1 : 0; } if ( 3 == $options['force_lang'] ) { if ( ! class_exists( 'PLL_Xdata_Domain', true ) ) { $newoptions['browser'] = 0; } $newoptions['hide_default'] = 0; } // Check if domains exist if ( $newoptions['force_lang'] > 1 ) { $this->check_domains( $newoptions ); } return $newoptions; // Take care to return only validated options } /** * Check if subdomains or domains are accessible * * @since 1.8 * * @param array $options new set of options to test */ protected function check_domains( $options ) { $options = array_merge( $this->options, $options ); $model = new PLL_Model( $options ); $links_model = $model->get_links_model(); foreach ( $this->model->get_languages_list() as $lang ) { $url = add_query_arg( 'deactivate-polylang', 1, $links_model->home_url( $lang ) ); // Don't redefine vip_safe_wp_remote_get() as it has not the same signature as wp_remote_get() $response = function_exists( 'vip_safe_wp_remote_get' ) ? vip_safe_wp_remote_get( esc_url_raw( $url ) ) : wp_remote_get( esc_url_raw( $url ) ); $response_code = wp_remote_retrieve_response_code( $response ); if ( 200 != $response_code ) { add_settings_error( 'general', 'pll_invalid_domain', esc_html( sprintf( /* translators: %s is an url */ __( 'Polylang was unable to access the URL %s. Please check that the URL is valid.', 'polylang' ), $url ) ) ); } } } } PK!\Cppsettings-module.phpnuW+Aoptions = &$polylang->options; $this->model = &$polylang->model; $this->links_model = &$polylang->links_model; $args = wp_parse_args( $args, array( 'title' => '', 'description' => '', 'active_option' => false, ) ); foreach ( $args as $prop => $value ) { $this->$prop = $value; } // All possible action links, even if not always a link ;-) $this->action_links = array( 'configure' => sprintf( '%s', esc_attr__( 'Configure this module', 'polylang' ), '#', esc_html__( 'Settings', 'polylang' ) ), 'deactivate' => sprintf( '%s', esc_attr__( 'Deactivate this module', 'polylang' ), wp_nonce_url( '?page=mlang&tab=modules&pll_action=deactivate&noheader=true&module=' . $this->module, 'pll_deactivate' ), esc_html__( 'Deactivate', 'polylang' ) ), 'activate' => sprintf( '%s', esc_attr__( 'Activate this module', 'polylang' ), wp_nonce_url( '?page=mlang&tab=modules&pll_action=activate&noheader=true&module=' . $this->module, 'pll_activate' ), esc_html__( 'Activate', 'polylang' ) ), 'activated' => esc_html__( 'Activated', 'polylang' ), 'deactivated' => esc_html__( 'Deactivated', 'polylang' ), ); $this->buttons = array( 'cancel' => sprintf( '', esc_html__( 'Cancel' ) ), 'save' => sprintf( '', esc_html__( 'Save Changes' ) ), ); // Ajax action to save options add_action( 'wp_ajax_pll_save_options', array( $this, 'save_options' ) ); } /** * Tells if the module is active * * @since 1.8 * * @return bool */ public function is_active() { return empty( $this->active_option ) || ! empty( $this->options[ $this->active_option ] ); } /** * Activates the module * * @since 1.8 */ public function activate() { if ( ! empty( $this->active_option ) ) { $this->options[ $this->active_option ] = true; update_option( 'polylang', $this->options ); } } /** * Deactivates the module * * @since 1.8 */ public function deactivate() { if ( ! empty( $this->active_option ) ) { $this->options[ $this->active_option ] = false; update_option( 'polylang', $this->options ); } } /** * Protected method to display a configuration form * * @since 1.8 */ protected function form() { // Child classes can provide a form } /** * Public method returning the form if any * * @since 1.8 * * @return string */ public function get_form() { static $form = false; // Read the form only once if ( false === $form ) { ob_start(); $this->form(); $form = ob_get_clean(); } return $form; } /** * Allows child classes to validate their options before saving * * @since 1.8 * * @param array $options Raw options * @return array Options */ protected function update( $options ) { return array(); // It's responsibility of the child class to decide what is saved } /** * Ajax method to save the options * * @since 1.8 */ public function save_options() { check_ajax_referer( 'pll_options', '_pll_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_die( -1 ); } if ( $this->module == $_POST['module'] ) { // It's up to the child class to decide which options are saved, whether there are errors or not $post = array_diff_key( $_POST, array_flip( array( 'action', 'module', 'pll_ajax_backend', '_pll_nonce' ) ) ); $options = $this->update( $post ); $this->options = array_merge( $this->options, $options ); update_option( 'polylang', $this->options ); // Refresh language cache in case home urls have been modified $this->model->clean_languages_cache(); // Refresh rewrite rules in case rewrite, hide_default, post types or taxonomies options have been modified // Don't use flush_rewrite_rules as we don't have the right links model and permastruct delete_option( 'rewrite_rules' ); ob_start(); if ( ! get_settings_errors() ) { // Send update message add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' ); settings_errors(); $x = new WP_Ajax_Response( array( 'what' => 'success', 'data' => ob_get_clean() ) ); $x->send(); } else { // Send error messages settings_errors(); $x = new WP_Ajax_Response( array( 'what' => 'error', 'data' => ob_get_clean() ) ); $x->send(); } } } /** * Get the row actions * * @since 1.8 * * @return array */ protected function get_actions() { if ( $this->is_active() && $this->get_form() ) { $actions[] = 'configure'; } if ( $this->active_option ) { $actions[] = $this->is_active() ? 'deactivate' : 'activate'; } if ( empty( $actions ) ) { $actions[] = $this->is_active() ? 'activated' : 'deactivated'; } return $actions; } /** * Get the actions links * * @since 1.8 * * @return array */ public function get_action_links() { return array_intersect_key( $this->action_links, array_flip( $this->get_actions() ) ); } /** * Default upgrade message ( to Pro version ) * * @since 1.9 * * @return string */ protected function default_upgrade_message() { return sprintf( '%s %s', __( 'You need Polylang Pro to enable this feature.', 'polylang' ), 'https://polylang.pro', __( 'Upgrade now.', 'polylang' ) ); } /** * Allows child classes to display an upgrade message * * @since 1.9 * * @return string */ public function get_upgrade_message() { return ''; } /** * Get the buttons * * @since 1.9 * * @return array */ public function get_buttons() { return $this->buttons; } } PK!\1-- languages.phpnuW+A ISO 639-1 language code * [1] => WordPress locale * [2] => name * [3] => text direction * [4] => flag code */ $languages = array( 'af' => array( 'af', 'af', 'Afrikaans', 'ltr', 'za' ), 'ar' => array( 'ar', 'ar', 'العربية', 'rtl', 'arab' ), 'ary' => array( 'ar', 'ary', 'العربية المغربية', 'rtl', 'ma' ), 'as' => array( 'as', 'as', 'অসমীয়া', 'ltr', 'in' ), 'az' => array( 'az', 'az', 'Azərbaycan', 'ltr', 'az' ), 'azb' => array( 'az', 'azb', 'گؤنئی آذربایجان', 'rtl', 'az' ), 'bel' => array( 'be', 'bel', 'Беларуская мова', 'ltr', 'by' ), 'bg_BG' => array( 'bg', 'bg_BG', 'български', 'ltr', 'bg' ), 'bn_BD' => array( 'bn', 'bn_BD', 'বাংলা', 'ltr', 'bd' ), 'bo' => array( 'bo', 'bo', 'བོད་ཡིག', 'ltr', 'tibet' ), 'bs_BA' => array( 'bs', 'bs_BA', 'Bosanski', 'ltr', 'ba' ), 'ca' => array( 'ca', 'ca', 'Català', 'ltr', 'catalonia' ), 'ceb' => array( 'ceb', 'ceb', 'Cebuano', 'ltr', 'ph' ), 'cs_CZ' => array( 'cs', 'cs_CZ', 'Čeština', 'ltr', 'cz' ), 'cy' => array( 'cy', 'cy', 'Cymraeg', 'ltr', 'wales' ), 'da_DK' => array( 'da', 'da_DK', 'Dansk', 'ltr', 'dk' ), 'de_CH' => array( 'de', 'de_CH', 'Deutsch', 'ltr', 'ch' ), 'de_CH_informal' => array( 'de', 'de_CH_informal', 'Deutsch', 'ltr', 'ch' ), 'de_DE' => array( 'de', 'de_DE', 'Deutsch', 'ltr', 'de' ), 'de_DE_formal' => array( 'de', 'de_DE_formal', 'Deutsch', 'ltr', 'de' ), 'dzo' => array( 'dz', 'dzo', 'རྫོང་ཁ', 'ltr', 'bt' ), 'el' => array( 'el', 'el', 'Ελληνικά', 'ltr', 'gr' ), 'en_AU' => array( 'en', 'en_AU', 'English', 'ltr', 'au' ), 'en_CA' => array( 'en', 'en_CA', 'English', 'ltr', 'ca' ), 'en_GB' => array( 'en', 'en_GB', 'English', 'ltr', 'gb' ), 'en_NZ' => array( 'en', 'en_NZ', 'English', 'ltr', 'nz' ), 'en_US' => array( 'en', 'en_US', 'English', 'ltr', 'us' ), 'en_ZA' => array( 'en', 'en_ZA', 'English', 'ltr', 'za' ), 'eo' => array( 'eo', 'eo', 'Esperanto', 'ltr', 'esperanto' ), 'es_AR' => array( 'es', 'es_AR', 'Español', 'ltr', 'ar' ), 'es_CL' => array( 'es', 'es_CL', 'Español', 'ltr', 'cl' ), 'es_CO' => array( 'es', 'es_CO', 'Español', 'ltr', 'co' ), 'es_ES' => array( 'es', 'es_ES', 'Español', 'ltr', 'es' ), 'es_GT' => array( 'es', 'es_GT', 'Español', 'ltr', 'gt' ), 'es_MX' => array( 'es', 'es_MX', 'Español', 'ltr', 'mx' ), 'es_PE' => array( 'es', 'es_PE', 'Español', 'ltr', 'pe' ), 'es_VE' => array( 'es', 'es_VE', 'Español', 'ltr', 've' ), 'et' => array( 'et', 'et', 'Eesti', 'ltr', 'ee' ), 'eu' => array( 'eu', 'eu', 'Euskara', 'ltr', 'basque' ), 'fa_AF' => array( 'fa', 'fa_AF', 'فارسی', 'rtl', 'af' ), 'fa_IR' => array( 'fa', 'fa_IR', 'فارسی', 'rtl', 'ir' ), 'fi' => array( 'fi', 'fi', 'Suomi', 'ltr', 'fi' ), 'fo' => array( 'fo', 'fo', 'Føroyskt', 'ltr', 'fo' ), 'fr_BE' => array( 'fr', 'fr_BE', 'Français', 'ltr', 'be' ), 'fr_CA' => array( 'fr', 'fr_CA', 'Français', 'ltr', 'quebec' ), 'fr_FR' => array( 'fr', 'fr_FR', 'Français', 'ltr', 'fr' ), 'fy' => array( 'fy', 'fy', 'Frysk', 'ltr', 'nl' ), 'gd' => array( 'gd', 'gd', 'Gàidhlig', 'ltr', 'scotland' ), 'gl_ES' => array( 'gl', 'gl_ES', 'Galego', 'ltr', 'galicia' ), 'gu' => array( 'gu', 'gu', 'ગુજરાતી', 'ltr', 'in' ), 'haz' => array( 'haz', 'haz', 'هزاره گی', 'rtl', 'af' ), 'he_IL' => array( 'he', 'he_IL', 'עברית', 'rtl', 'il' ), 'hi_IN' => array( 'hi', 'hi_IN', 'हिन्दी', 'ltr', 'in' ), 'hr' => array( 'hr', 'hr', 'Hrvatski', 'ltr', 'hr' ), 'hu_HU' => array( 'hu', 'hu_HU', 'Magyar', 'ltr', 'hu' ), 'hy' => array( 'hy', 'hy', 'Հայերեն', 'ltr', 'am' ), 'id_ID' => array( 'id', 'id_ID', 'Bahasa Indonesia', 'ltr', 'id' ), 'is_IS' => array( 'is', 'is_IS', 'Íslenska', 'ltr', 'is' ), 'it_IT' => array( 'it', 'it_IT', 'Italiano', 'ltr', 'it' ), 'ja' => array( 'ja', 'ja', '日本語', 'ltr', 'jp' ), 'jv_ID' => array( 'jv', 'jv_ID', 'Basa Jawa', 'ltr', 'id' ), 'ka_GE' => array( 'ka', 'ka_GE', 'ქართული', 'ltr', 'ge' ), 'kab' => array( 'kab', 'kab', 'Taqbaylit', 'ltr', 'dz' ), 'kk' => array( 'kk', 'kk', 'Қазақ тілі', 'ltr', 'kz' ), 'km' => array( 'km', 'km', 'ភាសាខ្មែរ', 'ltr', 'kh' ), 'ko_KR' => array( 'ko', 'ko_KR', '한국어', 'ltr', 'kr' ), 'ckb' => array( 'ku', 'ckb', 'کوردی', 'rtl', 'kurdistan' ), 'lo' => array( 'lo', 'lo', 'ພາສາລາວ', 'ltr', 'la' ), 'lt_LT' => array( 'lt', 'lt_LT', 'Lietuviškai', 'ltr', 'lt' ), 'lv' => array( 'lv', 'lv', 'Latviešu valoda', 'ltr', 'lv' ), 'mk_MK' => array( 'mk', 'mk_MK', 'македонски јазик', 'ltr', 'mk' ), 'ml_IN' => array( 'ml', 'ml_IN', 'മലയാളം', 'ltr', 'in' ), 'mn' => array( 'mn', 'mn', 'Монгол хэл', 'ltr', 'mn' ), 'mr' => array( 'mr', 'mr', 'मराठी', 'ltr', 'in' ), 'ms_MY' => array( 'ms', 'ms_MY', 'Bahasa Melayu', 'ltr', 'my' ), 'my_MM' => array( 'my', 'my_MM', 'ဗမာစာ', 'ltr', 'mm' ), 'nb_NO' => array( 'nb', 'nb_NO', 'Norsk Bokmål', 'ltr', 'no' ), 'ne_NP' => array( 'ne', 'ne_NP', 'नेपाली', 'ltr', 'np' ), 'nl_BE' => array( 'nl', 'nl_BE', 'Nederlands', 'ltr', 'be' ), 'nl_NL' => array( 'nl', 'nl_NL', 'Nederlands', 'ltr', 'nl' ), 'nl_NL_formal' => array( 'nl', 'nl_NL_formal', 'Nederlands', 'ltr', 'nl' ), 'nn_NO' => array( 'nn', 'nn_NO', 'Norsk Nynorsk', 'ltr', 'no' ), 'oci' => array( 'oc', 'oci', 'Occitan', 'ltr', 'occitania' ), 'pa_IN' => array( 'pa', 'pa_IN', 'ਪੰਜਾਬੀ', 'ltr', 'in' ), 'pl_PL' => array( 'pl', 'pl_PL', 'Polski', 'ltr', 'pl' ), 'ps' => array( 'ps', 'ps', 'پښتو', 'rtl', 'af' ), 'pt_BR' => array( 'pt', 'pt_BR', 'Português', 'ltr', 'br' ), 'pt_PT' => array( 'pt', 'pt_PT', 'Português', 'ltr', 'pt' ), 'rhg' => array( 'rhg', 'rhg', 'Ruáinga', 'ltr', 'mm' ), 'ro_RO' => array( 'ro', 'ro_RO', 'Română', 'ltr', 'ro' ), 'ru_RU' => array( 'ru', 'ru_RU', 'Русский', 'ltr', 'ru' ), 'sah' => array( 'sah', 'sah', 'Сахалыы', 'ltr', 'ru' ), 'si_LK' => array( 'si', 'si_LK', 'සිංහල', 'ltr', 'lk' ), 'sk_SK' => array( 'sk', 'sk_SK', 'Slovenčina', 'ltr', 'sk' ), 'sl_SI' => array( 'sl', 'sl_SI', 'Slovenščina', 'ltr', 'si' ), 'so_SO' => array( 'so', 'so_SO', 'Af-Soomaali', 'ltr', 'so' ), 'sq' => array( 'sq', 'sq', 'Shqip', 'ltr', 'al' ), 'sr_RS' => array( 'sr', 'sr_RS', 'Српски језик', 'ltr', 'rs' ), 'su_ID' => array( 'su', 'su_ID', 'Basa Sunda', 'ltr', 'id' ), 'sv_SE' => array( 'sv', 'sv_SE', 'Svenska', 'ltr', 'se' ), 'szl' => array( 'szl', 'szl', 'Ślōnskŏ gŏdka', 'ltr', 'pl' ), 'ta_IN' => array( 'ta', 'ta_IN', 'தமிழ்', 'ltr', 'in' ), 'ta_LK' => array( 'ta', 'ta_LK', 'தமிழ்', 'ltr', 'lk' ), 'tah' => array( 'ty', 'tah', 'Reo Tahiti', 'ltr', 'pf' ), 'te' => array( 'te', 'te', 'తెలుగు', 'ltr', 'in' ), 'th' => array( 'th', 'th', 'ไทย', 'ltr', 'th' ), 'tl' => array( 'tl', 'tl', 'Tagalog', 'ltr', 'ph' ), 'tr_TR' => array( 'tr', 'tr_TR', 'Türkçe', 'ltr', 'tr' ), 'tt_RU' => array( 'tt', 'tt_RU', 'Татар теле', 'ltr', 'ru' ), 'ug_CN' => array( 'ug', 'ug_CN', 'Uyƣurqə', 'ltr', 'cn' ), 'uk' => array( 'uk', 'uk', 'Українська', 'ltr', 'ua' ), 'ur' => array( 'ur', 'ur', 'اردو', 'rtl', 'pk' ), 'uz_UZ' => array( 'uz', 'uz_UZ', 'Oʻzbek', 'ltr', 'uz' ), 'vec' => array( 'vec', 'vec', 'Vèneto', 'ltr', 'veneto' ), 'vi' => array( 'vi', 'vi', 'Tiếng Việt', 'ltr', 'vn' ), 'zh_CN' => array( 'zh', 'zh_CN', '中文 (中国)', 'ltr', 'cn' ), 'zh_HK' => array( 'zh', 'zh_HK', '中文 (香港)', 'ltr', 'hk' ), 'zh_TW' => array( 'zh', 'zh_TW', '中文 (台灣)', 'ltr', 'tw' ), ); /** * Filter the list of predefined languages * * @since 1.7.10 * * @param array $languages */ $languages = apply_filters( 'pll_predefined_languages', $languages ); PK!\/table-languages.phpnuW+A 'Languages', // Do not translate ( used for css class ) 'ajax' => false, ) ); } /** * Generates content for a single row of the table * * @since 1.8 * * @param object $item The current item */ public function single_row( $item ) { /** * Filter the list of classes assigned a row in the languages list table * * @since 1.8 * * @param array $classes list of class names * @param object $item the current item */ $classes = apply_filters( 'pll_languages_row_classes', array(), $item ); echo '' : ' class="' . esc_attr( implode( ' ', $classes ) ) . '">' ); $this->single_row_columns( $item ); echo ''; } /** * Displays the item information in a column ( default case ) * * @since 0.1 * * @param object $item * @param string $column_name * @return string */ function column_default( $item, $column_name ) { switch ( $column_name ) { case 'locale': case 'slug': return esc_html( $item->$column_name ); case 'term_group': case 'count': return (int) $item->$column_name; default: return $item->$column_name; // flag } } /** * Displays the item information in the column 'name' * Displays the edit and delete action links * * @since 0.1 * * @param object $item * @return string */ function column_name( $item ) { return sprintf( '%s', esc_attr__( 'Edit this language', 'polylang' ), esc_url( admin_url( 'admin.php?page=mlang&pll_action=edit&lang=' . $item->term_id ) ), esc_html( $item->name ) ); } /** * Displays the item information in the default language * Displays the 'make default' action link * * @since 1.8 * * @param object $item * @return string */ function column_default_lang( $item ) { $options = get_option( 'polylang' ); if ( $options['default_lang'] != $item->slug ) { $s = sprintf('
%3$s
', esc_attr__( 'Select as default language', 'polylang' ), wp_nonce_url( '?page=mlang&pll_action=default-lang&noheader=true&lang=' . $item->term_id, 'default-lang' ), /* translators: accessibility text, %s is a native language name */ esc_html( sprintf( __( 'Choose %s as default language', 'polylang' ), $item->name ) ) ); /** * Filter the default language row action in the languages list table * * @since 1.8 * * @param string $s html markup of the action * @param object $item */ $s = apply_filters( 'pll_default_lang_row_action', $s, $item ); } else { $s = sprintf( '%1$s', /* translators: accessibility text */ esc_html__( 'Default language', 'polylang' ) ); $actions = array(); } return $s; } /** * Gets the list of columns * * @since 0.1 * * @return array the list of column titles */ function get_columns() { return array( 'name' => esc_html__( 'Full name', 'polylang' ), 'locale' => esc_html__( 'Locale', 'polylang' ), 'slug' => esc_html__( 'Code', 'polylang' ), 'default_lang' => sprintf( '%2$s', esc_attr__( 'Default language', 'polylang' ), esc_html__( 'Default language', 'polylang' ) ), 'term_group' => esc_html__( 'Order', 'polylang' ), 'flag' => esc_html__( 'Flag', 'polylang' ), 'count' => esc_html__( 'Posts', 'polylang' ), ); } /** * Gets the list of sortable columns * * @since 0.1 * * @return array */ function get_sortable_columns() { return array( 'name' => array( 'name', true ), // sorted by name by default 'locale' => array( 'locale', false ), 'slug' => array( 'slug', false ), 'term_group' => array( 'term_group', false ), 'count' => array( 'count', false ), ); } /** * Gets the name of the default primary column. * * @since 2.1 * * @return string Name of the default primary column, in this case, 'name'. */ protected function get_default_primary_column_name() { return 'name'; } /** * Generates and display row actions links for the list table. * * @since 1.8 * * @param object $item The item being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. * @return string The row actions output. */ protected function handle_row_actions( $item, $column_name, $primary ) { if ( $primary !== $column_name ) { return ''; } $actions = array( 'edit' => sprintf( '%s', esc_attr__( 'Edit this language', 'polylang' ), esc_url( admin_url( 'admin.php?page=mlang&pll_action=edit&lang=' . $item->term_id ) ), esc_html__( 'Edit','polylang' ) ), 'delete' => sprintf( '%s', esc_attr__( 'Delete this language and all its associated data', 'polylang' ), wp_nonce_url( '?page=mlang&pll_action=delete&noheader=true&lang=' . $item->term_id, 'delete-lang' ), esc_js( __( 'You are about to permanently delete this language. Are you sure?', 'polylang' ) ), esc_html__( 'Delete','polylang' ) ), ); /** * Filter the list of row actions in the languages list table * * @since 1.8 * * @param array $actions list of html markup actions * @param object $item */ $actions = apply_filters( 'pll_languages_row_actions', $actions, $item ); return $this->row_actions( $actions ); } /** * Sort items * * @since 0.1 * * @param object $a The first object to compare * @param object $b The second object to compare * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b. */ protected function usort_reorder( $a, $b ) { $orderby = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'name'; // Determine sort order if ( is_numeric( $a->$orderby ) ) { $result = $a->$orderby > $b->$orderby ? 1 : -1; } else { $result = strcmp( $a->$orderby, $b->$orderby ); } // Send final sort direction to usort return ( empty( $_GET['order'] ) || 'asc' == $_GET['order'] ) ? $result : -$result; } /** * Prepares the list of items for displaying * * @since 0.1 * * @param array $data */ function prepare_items( $data = array() ) { $per_page = $this->get_items_per_page( 'pll_lang_per_page' ); $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() ); usort( $data, array( $this, 'usort_reorder' ) ); $total_items = count( $data ); $this->items = array_slice( $data, ( $this->get_pagenum() - 1 ) * $per_page, $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); } } PK!\Veview-about.phpnuW+A

', '' ); if ( ! defined( 'POLYLANG_PRO' ) ) { echo ' '; printf( /* translators: %s are html tags */ esc_html__( 'Support and extra features are available to %sPolylang Pro%s users.' ), '', '' ); } ?>

', '' ); ?>

PK!\{settings-media.phpnuW+A 'media', 'title' => __( 'Media' ), 'description' => __( 'Activate languages and translations for media', 'polylang' ), 'active_option' => 'media_support', ) ); } } PK!\#00view-languages.phpnuW+A

active_tab ) { case 'lang': // Languages tab case 'strings': // String translations tab case 'settings': // Settings tab include PLL_SETTINGS_INC . '/view-tab-' . $this->active_tab . '.php'; break; default: /** * Fires when loading the active Polylang settings tab * Allows plugins to add their own tab * * @since 1.5.1 */ do_action( 'pll_settings_active_tab_' . $this->active_tab ); break; } ?>
PK!\view-tab-lang.phpnuW+A
display(); ?>

', ! empty( $edit_lang ) ? esc_attr( $edit_lang->name ) : '' ); ?>

', ! empty( $edit_lang ) ? esc_attr( $edit_lang->locale ) : '' ); ?>

', ! empty( $edit_lang ) ? esc_attr( $edit_lang->slug ) : '' ); ?>

%s', ! empty( $edit_lang ) && $edit_lang->is_rtl ? '' : 'checked="checked"', esc_html__( 'left to right', 'polylang' ) ); printf( '', ! empty( $edit_lang ) && $edit_lang->is_rtl ? 'checked="checked"' : '', esc_html__( 'right to left', 'polylang' ) ); ?>

', ! empty( $edit_lang ) ? esc_attr( $edit_lang->term_group ) : '' ); ?>

PK!\kύsettings-tools.phpnuW+A 'tools', 'title' => __( 'Tools', 'polylang' ), 'description' => __( 'Decide whether to remove all data when deleting Polylang.', 'polylang' ), ) ); } /** * displays the settings form * * @since 1.8 */ protected function form() { printf( '', empty( $this->options['uninstall'] ) ? '' : 'checked="checked"', esc_html__( 'Remove all Polylang data when using the "Delete" link on the plugins screen.', 'polylang' ) ); } /** * sanitizes the settings before saving * * @since 1.8 * * @param array $options */ protected function update( $options ) { $newoptions['uninstall'] = isset( $options['uninstall'] ) ? 1 : 0; return $newoptions; // take care to return only validated options } } PK!\ɫview-tab-strings.phpnuW+A
search_box( __( 'Search translations', 'polylang' ), 'translations' ); wp_nonce_field( 'string-translation', '_wpnonce_string-translation' ); $string_table->display(); printf( '
', esc_html__( 'Clean strings translation database', 'polylang' ) ); ?>

PK!\Vo o settings-cpt.phpnuW+A 'cpt', 'title' => __( 'Custom post types and Taxonomies', 'polylang' ), 'description' => __( 'Activate the languages and translations management for the custom post types and taxonomies.', 'polylang' ), ) ); // FIXME should be OK when the modules will be loaded from the settings page $post_types = get_post_types( array( 'public' => true, '_builtin' => false ) ); $post_types = array_diff( $post_types, get_post_types( array( '_pll' => true ) ) ); /** This filter is documented in include/model.php */ $this->post_types = array_unique( apply_filters( 'pll_get_post_types', $post_types, true ) ); $taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ); $taxonomies = array_diff( $taxonomies, get_taxonomies( array( '_pll' => true ) ) ); /** This filter is documented in include/model.php */ $this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $taxonomies , true ) ); } /** * Tells if the module is active * * @since 1.8 * * @return bool */ public function is_active() { return ! empty( $this->post_types ) || ! empty( $this->taxonomies ); } /** * Displays the settings form * * @since 1.8 */ protected function form() { if ( ! empty( $this->post_types ) ) {?>

taxonomies ) ) { ?>

'Strings translations', // Do not translate ( used for css class ) 'ajax' => false, ) ); $this->languages = $languages; $this->strings = PLL_Admin_Strings::get_strings(); $this->groups = array_unique( wp_list_pluck( $this->strings, 'context' ) ); $this->selected_group = empty( $_GET['group'] ) || ! in_array( $_GET['group'], $this->groups ) ? -1 : $_GET['group']; add_action( 'mlang_action_string-translation', array( $this, 'save_translations' ) ); } /** * Displays the item information in a column ( default case ) * * @since 0.6 * * @param array $item * @param string $column_name * @return string */ function column_default( $item, $column_name ) { return $item[ $column_name ]; } /** * Displays the checkbox in first column * * @since 1.1 * * @param array $item * @return string */ function column_cb( $item ) { return sprintf( '', esc_attr( $item['row'] ), /* translators: accessibility text, %s is a string potentially in any language */ sprintf( __( 'Select %s' ), format_to_edit( $item['string'] ) ), empty( $item['icl'] ) ? 'disabled' : '' // Only strings registered with WPML API can be removed ); } /** * Displays the string to translate * * @since 1.0 * * @param array $item * @return string */ function column_string( $item ) { return format_to_edit( $item['string'] ); // Don't interpret special chars for the string column } /** * Displays the translations to edit * * @since 0.6 * * @param array $item * @return string */ function column_translations( $item ) { $languages = array_combine( wp_list_pluck( $this->languages, 'slug' ), wp_list_pluck( $this->languages, 'name' ) ); $out = ''; foreach ( $item['translations'] as $key => $translation ) { $input_type = $item['multiline'] ? '' : ''; $out .= sprintf( '
' . $input_type . '
' . "\n", esc_attr( $key ), esc_attr( $item['row'] ), esc_html( $languages[ $key ] ), format_to_edit( $translation ) ); // Don't interpret special chars } return $out; } /** * Gets the list of columns * * @since 0.6 * * @return array the list of column titles */ function get_columns() { return array( 'cb' => '', // Checkbox 'string' => esc_html__( 'String', 'polylang' ), 'name' => esc_html__( 'Name', 'polylang' ), 'context' => esc_html__( 'Group', 'polylang' ), 'translations' => esc_html__( 'Translations', 'polylang' ), ); } /** * Gets the list of sortable columns * * @since 0.6 * * @return array */ function get_sortable_columns() { return array( 'string' => array( 'string', false ), 'name' => array( 'name', false ), 'context' => array( 'context', false ), ); } /** * Gets the name of the default primary column. * * @since 2.1 * * @return string Name of the default primary column, in this case, 'string'. */ protected function get_default_primary_column_name() { return 'string'; } /** * Sort items * * @since 0.6 * * @param object $a The first object to compare * @param object $b The second object to compare * @return int -1 or 1 if $a is considered to be respectively less than or greater than $b. */ protected function usort_reorder( $a, $b ) { $result = strcmp( $a[ $_GET['orderby'] ], $b[ $_GET['orderby'] ] ); // determine sort order return ( empty( $_GET['order'] ) || 'asc' === $_GET['order'] ) ? $result : -$result; // send final sort direction to usort } /** * Prepares the list of items for displaying * * @since 0.6 */ function prepare_items() { $data = $this->strings; // Filter for search string $s = empty( $_GET['s'] ) ? '' : wp_unslash( $_GET['s'] ); foreach ( $data as $key => $row ) { if ( ( -1 !== $this->selected_group && $row['context'] !== $this->selected_group ) || ( ! empty( $s ) && stripos( $row['name'], $s ) === false && stripos( $row['string'], $s ) === false ) ) { unset( $data[ $key ] ); } } // Load translations foreach ( $this->languages as $language ) { // Filters by language if requested if ( ( $lg = get_user_meta( get_current_user_id(), 'pll_filter_content', true ) ) && $language->slug !== $lg ) { continue; } $mo = new PLL_MO(); $mo->import_from_db( $language ); foreach ( $data as $key => $row ) { $data[ $key ]['translations'][ $language->slug ] = $mo->translate( $row['string'] ); $data[ $key ]['row'] = $key; // Store the row number for convenience } } $per_page = $this->get_items_per_page( 'pll_strings_per_page' ); $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() ); if ( ! empty( $_GET['orderby'] ) ) { // No sort by default usort( $data, array( $this, 'usort_reorder' ) ); } $total_items = count( $data ); $this->items = array_slice( $data, ( $this->get_pagenum() - 1 ) * $per_page, $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); } /** * Get the list of possible bulk actions * * @since 1.1 * * @return array */ function get_bulk_actions() { return array( 'delete' => __( 'Delete','polylang' ) ); } /** * Get the current action selected from the bulk actions dropdown. * overrides parent function to avoid submit button to trigger bulk actions * * @since 1.8 * * @return string|false The action name or False if no action was selected */ public function current_action() { return empty( $_POST['submit'] ) ? parent::current_action() : false; } /** * Displays the dropdown list to filter strings per group * * @since 1.1 * * @param string $which only 'top' is supported */ function extra_tablenav( $which ) { if ( 'top' !== $which ) { return; } echo '
'; printf( '', /* translators: accessibility text */ esc_html__( 'Filter by group', 'polylang' ) ); echo '' . "\n"; submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); echo '
'; } /** * Saves the strings translations in DB * Optionaly clean the DB * * @since 1.9 */ public function save_translations() { check_admin_referer( 'string-translation', '_wpnonce_string-translation' ); if ( ! empty( $_POST['submit'] ) ) { foreach ( $this->languages as $language ) { if ( empty( $_POST['translation'][ $language->slug ] ) ) { // In case the language filter is active ( thanks to John P. Bloch ) continue; } $mo = new PLL_MO(); $mo->import_from_db( $language ); foreach ( $_POST['translation'][ $language->slug ] as $key => $translation ) { /** * Filter the string translation before it is saved in DB * Allows to sanitize strings registered with pll_register_string * * @since 1.6 * * @param string $translation the string translation * @param string $name the name as defined in pll_register_string * @param string $context the context as defined in pll_register_string */ $translation = apply_filters( 'pll_sanitize_string_translation', $translation, $this->strings[ $key ]['name'], $this->strings[ $key ]['context'] ); $mo->add_entry( $mo->make_entry( $this->strings[ $key ]['string'], $translation ) ); } // Clean database ( removes all strings which were registered some day but are no more ) if ( ! empty( $_POST['clean'] ) ) { $new_mo = new PLL_MO(); foreach ( $this->strings as $string ) { $new_mo->add_entry( $mo->make_entry( $string['string'], $mo->translate( $string['string'] ) ) ); } } isset( $new_mo ) ? $new_mo->export_to_db( $language ) : $mo->export_to_db( $language ); } add_settings_error( 'general', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'updated' ); /** * Fires after the strings translations are saved in DB * * @since 1.2 */ do_action( 'pll_save_strings_translations' ); } // Unregisters strings registered through WPML API if ( $this->current_action() === 'delete' && ! empty( $_POST['strings'] ) && function_exists( 'icl_unregister_string' ) ) { foreach ( $_POST['strings'] as $key ) { icl_unregister_string( $this->strings[ $key ]['context'], $this->strings[ $key ]['name'] ); } } // To refresh the page ( possible thanks to the $_GET['noheader']=true ) $args = array_intersect_key( $_REQUEST, array_flip( array( 's', 'paged', 'group' ) ) ); if ( ! empty( $_GET['paged'] ) && ! empty( $_POST['submit'] ) ) { $args['paged'] = (int) $_GET['paged']; // Don't rely on $_REQUEST['paged'] or $_POST['paged']. See #14 } if ( ! empty( $args['s'] ) ) { $args['s'] = urlencode( $args['s'] ); // Searched string needs to be encoded as it comes from $_POST } PLL_Settings::redirect( $args ); } } PK!\fx`` settings.phpnuW+A $item ) { if ( 'elementor' === $item ) { $elementor_menu_order[] = 'separator-elementor'; $elementor_menu_order[] = $item; $elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG; unset( $menu_order[ $elementor_separator ] ); unset( $menu_order[ $elementor_library ] ); } elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) { $elementor_menu_order[] = $item; } } // Return order. return $elementor_menu_order; } /** * Register Elementor Pro sub-menu. * * Add new Elementor Pro sub-menu under the main Elementor menu. * * Fired by `admin_menu` action. * * @since 1.0.0 * @access public */ public function register_pro_menu() { add_submenu_page( self::PAGE_ID, __( 'Custom Fonts', 'elementor' ), __( 'Custom Fonts', 'elementor' ), 'manage_options', 'elementor_custom_fonts', [ $this, 'elementor_custom_fonts' ] ); add_submenu_page( self::PAGE_ID, __( 'Custom Icons', 'elementor' ), __( 'Custom Icons', 'elementor' ), 'manage_options', 'elementor_custom_icons', [ $this, 'elementor_custom_icons' ] ); add_submenu_page( self::PAGE_ID, '', ' ' . __( 'Go Pro', 'elementor' ), 'manage_options', 'go_elementor_pro', [ $this, 'handle_external_redirects' ] ); add_submenu_page( Source_Local::ADMIN_MENU_SLUG, __( 'Theme Templates', 'elementor' ), __( 'Theme Builder', 'elementor' ), 'manage_options', 'theme_templates', [ $this, 'elementor_theme_templates' ] ); add_submenu_page( Source_Local::ADMIN_MENU_SLUG, __( 'Popups', 'elementor' ), __( 'Popups', 'elementor' ), 'manage_options', 'popup_templates', [ $this, 'elementor_popups' ] ); } /** * Register Elementor knowledge base sub-menu. * * Add new Elementor knowledge base sub-menu under the main Elementor menu. * * Fired by `admin_menu` action. * * @since 2.0.3 * @access public */ public function register_knowledge_base_menu() { add_submenu_page( self::PAGE_ID, '', __( 'Getting Started', 'elementor' ), 'manage_options', 'elementor-getting-started', [ $this, 'elementor_getting_started' ] ); add_submenu_page( self::PAGE_ID, '', __( 'Get Help', 'elementor' ), 'manage_options', 'go_knowledge_base_site', [ $this, 'handle_external_redirects' ] ); } /** * Go Elementor Pro. * * Redirect the Elementor Pro page the clicking the Elementor Pro menu link. * * Fired by `admin_init` action. * * @since 2.0.3 * @access public */ public function handle_external_redirects() { if ( empty( $_GET['page'] ) ) { return; } if ( 'go_elementor_pro' === $_GET['page'] ) { wp_redirect( Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-menu&utm_campaign=gopro&utm_medium=wp-dash' ) ); die; } if ( 'go_knowledge_base_site' === $_GET['page'] ) { wp_redirect( 'https://go.elementor.com/docs-admin-menu/' ); die; } } /** * Display settings page. * * Output the content for the getting started page. * * @since 2.2.0 * @access public */ public function elementor_getting_started() { if ( User::is_current_user_can_edit_post_type( 'page' ) ) { $create_new_label = __( 'Create Your First Page', 'elementor' ); $create_new_cpt = 'page'; } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) { $create_new_label = __( 'Create Your First Post', 'elementor' ); $create_new_cpt = 'post'; } ?>

handle_external_redirects(); // Save general settings in one list for a future usage $this->handle_general_settings_update(); $this->maybe_remove_all_admin_notices(); } /** * Change "Settings" menu name. * * Update the name of the Settings admin menu from "Elementor" to "Settings". * * Fired by `admin_menu` action. * * @since 1.0.0 * @access public */ public function admin_menu_change_name() { global $submenu; if ( isset( $submenu['elementor'] ) ) { // @codingStandardsIgnoreStart $submenu['elementor'][0][0] = __( 'Settings', 'elementor' ); // @codingStandardsIgnoreEnd } } /** * Update CSS print method. * * Clear post CSS cache. * * Fired by `add_option_elementor_css_print_method` and * `update_option_elementor_css_print_method` actions. * * @since 1.7.5 * @access public */ public function update_css_print_method() { Plugin::$instance->files_manager->clear_cache(); } /** * Create tabs. * * Return the settings page tabs, sections and fields. * * @since 1.5.0 * @access protected * * @return array An array with the settings page tabs, sections and fields. */ protected function create_tabs() { $validations_class_name = __NAMESPACE__ . '\Settings_Validations'; $default_breakpoints = Responsive::get_default_breakpoints(); return [ self::TAB_GENERAL => [ 'label' => __( 'General', 'elementor' ), 'sections' => [ 'general' => [ 'fields' => [ self::UPDATE_TIME_FIELD => [ 'full_field_id' => self::UPDATE_TIME_FIELD, 'field_args' => [ 'type' => 'hidden', ], 'setting_args' => [ $validations_class_name, 'current_time' ], ], 'cpt_support' => [ 'label' => __( 'Post Types', 'elementor' ), 'field_args' => [ 'type' => 'checkbox_list_cpt', 'std' => [ 'page', 'post' ], 'exclude' => [ 'attachment', 'elementor_library' ], ], 'setting_args' => [ $validations_class_name, 'checkbox_list' ], ], 'disable_color_schemes' => [ 'label' => __( 'Disable Default Colors', 'elementor' ), 'field_args' => [ 'type' => 'checkbox', 'value' => 'yes', 'sub_desc' => __( 'Checking this box will disable Elementor\'s Default Colors, and make Elementor inherit the colors from your theme.', 'elementor' ), ], ], 'disable_typography_schemes' => [ 'label' => __( 'Disable Default Fonts', 'elementor' ), 'field_args' => [ 'type' => 'checkbox', 'value' => 'yes', 'sub_desc' => __( 'Checking this box will disable Elementor\'s Default Fonts, and make Elementor inherit the fonts from your theme.', 'elementor' ), ], ], ], ], 'usage' => [ 'label' => __( 'Improve Elementor', 'elementor' ), 'fields' => [ 'allow_tracking' => [ 'label' => __( 'Usage Data Sharing', 'elementor' ), 'field_args' => [ 'type' => 'checkbox', 'value' => 'yes', 'default' => '', 'sub_desc' => __( 'Become a super contributor by opting in to share non-sensitive plugin data and to get our updates.', 'elementor' ) . sprintf( ' %2$s', 'https://go.elementor.com/usage-data-tracking/', __( 'Learn more.', 'elementor' ) ), ], 'setting_args' => [ __NAMESPACE__ . '\Tracker', 'check_for_settings_optin' ], ], ], ], ], ], self::TAB_STYLE => [ 'label' => __( 'Style', 'elementor' ), 'sections' => [ 'style' => [ 'fields' => [ 'default_generic_fonts' => [ 'label' => __( 'Default Generic Fonts', 'elementor' ), 'field_args' => [ 'type' => 'text', 'std' => 'Sans-serif', 'class' => 'medium-text', 'desc' => __( 'The list of fonts used if the chosen font is not available.', 'elementor' ), ], ], 'container_width' => [ 'label' => __( 'Content Width', 'elementor' ), 'field_args' => [ 'type' => 'number', 'attributes' => [ 'min' => 300, 'placeholder' => '1140', 'class' => 'medium-text', ], 'sub_desc' => 'px', 'desc' => __( 'Sets the default width of the content area (Default: 1140)', 'elementor' ), ], ], 'space_between_widgets' => [ 'label' => __( 'Space Between Widgets', 'elementor' ), 'field_args' => [ 'type' => 'number', 'attributes' => [ 'placeholder' => '20', 'class' => 'medium-text', ], 'sub_desc' => 'px', 'desc' => __( 'Sets the default space between widgets (Default: 20)', 'elementor' ), ], ], 'stretched_section_container' => [ 'label' => __( 'Stretched Section Fit To', 'elementor' ), 'field_args' => [ 'type' => 'text', 'attributes' => [ 'placeholder' => 'body', 'class' => 'medium-text', ], 'desc' => __( 'Enter parent element selector to which stretched sections will fit to (e.g. #primary / .wrapper / main etc). Leave blank to fit to page width.', 'elementor' ), ], ], 'page_title_selector' => [ 'label' => __( 'Page Title Selector', 'elementor' ), 'field_args' => [ 'type' => 'text', 'attributes' => [ 'placeholder' => 'h1.entry-title', 'class' => 'medium-text', ], 'desc' => __( 'Elementor lets you hide the page title. This works for themes that have "h1.entry-title" selector. If your theme\'s selector is different, please enter it above.', 'elementor' ), ], ], 'viewport_lg' => [ 'label' => __( 'Tablet Breakpoint', 'elementor' ), 'field_args' => [ 'type' => 'number', 'attributes' => [ 'placeholder' => $default_breakpoints['lg'], 'min' => $default_breakpoints['md'] + 1, 'max' => $default_breakpoints['xl'] - 1, 'class' => 'medium-text', ], 'sub_desc' => 'px', /* translators: %d: Breakpoint value */ 'desc' => sprintf( __( 'Sets the breakpoint between desktop and tablet devices. Below this breakpoint tablet layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['lg'] ), ], ], 'viewport_md' => [ 'label' => __( 'Mobile Breakpoint', 'elementor' ), 'field_args' => [ 'type' => 'number', 'attributes' => [ 'placeholder' => $default_breakpoints['md'], 'min' => $default_breakpoints['sm'] + 1, 'max' => $default_breakpoints['lg'] - 1, 'class' => 'medium-text', ], 'sub_desc' => 'px', /* translators: %d: Breakpoint value */ 'desc' => sprintf( __( 'Sets the breakpoint between tablet and mobile devices. Below this breakpoint mobile layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['md'] ), ], ], 'global_image_lightbox' => [ 'label' => __( 'Image Lightbox', 'elementor' ), 'field_args' => [ 'type' => 'checkbox', 'value' => 'yes', 'std' => 'yes', 'sub_desc' => __( 'Open all image links in a lightbox popup window. The lightbox will automatically work on any link that leads to an image file.', 'elementor' ), 'desc' => __( 'You can customize the lightbox design by going to: Top-left hamburger icon > Global Settings > Lightbox.', 'elementor' ), ], ], ], ], ], ], self::TAB_INTEGRATIONS => [ 'label' => __( 'Integrations', 'elementor' ), 'sections' => [], ], self::TAB_ADVANCED => [ 'label' => __( 'Advanced', 'elementor' ), 'sections' => [ 'advanced' => [ 'fields' => [ 'css_print_method' => [ 'label' => __( 'CSS Print Method', 'elementor' ), 'field_args' => [ 'class' => 'elementor_css_print_method', 'type' => 'select', 'options' => [ 'external' => __( 'External File', 'elementor' ), 'internal' => __( 'Internal Embedding', 'elementor' ), ], 'desc' => '', ], ], 'editor_break_lines' => [ 'label' => __( 'Switch Editor Loader Method', 'elementor' ), 'field_args' => [ 'type' => 'select', 'options' => [ '' => __( 'Disable', 'elementor' ), 1 => __( 'Enable', 'elementor' ), ], 'desc' => __( 'For troubleshooting server configuration conflicts.', 'elementor' ), ], ], 'allow_svg' => [ 'label' => __( 'Enable SVG Uploads', 'elementor' ), 'field_args' => [ 'type' => 'select', 'std' => '', 'options' => [ '' => __( 'Disable', 'elementor' ), 1 => __( 'Enable', 'elementor' ), ], 'desc' => __( 'Please note! Allowing uploads of any files (SVG included) is a potential security risk.', 'elementor' ) . '
' . __( 'Elementor will try to sanitize the SVG files, removing potential malicious code and scripts.', 'elementor' ) . '
' . __( 'We recommend you only enable this feature if you understand the security risks involved.', 'elementor' ), ], ], ], ], ], ], ]; } /** * Get settings page title. * * Retrieve the title for the settings page. * * @since 1.5.0 * @access protected * * @return string Settings page title. */ protected function get_page_title() { return __( 'Elementor', 'elementor' ); } /** * Handle general settings update. * * Save general settings in one list for a future usage. * * @since 2.0.0 * @access private */ private function handle_general_settings_update() { if ( ! empty( $_POST['option_page'] ) && self::PAGE_ID === $_POST['option_page'] && ! empty( $_POST['action'] ) && 'update' === $_POST['action'] ) { check_admin_referer( 'elementor-options' ); $saved_general_settings = get_option( General_Settings_Manager::META_KEY ); if ( ! $saved_general_settings ) { $saved_general_settings = []; } $general_settings = Manager::get_settings_managers( 'general' )->get_model()->get_settings(); foreach ( $general_settings as $setting_key => $setting ) { if ( ! empty( $_POST[ $setting_key ] ) ) { $pure_setting_key = str_replace( 'elementor_', '', $setting_key ); $saved_general_settings[ $pure_setting_key ] = $_POST[ $setting_key ]; } } update_option( General_Settings_Manager::META_KEY, $saved_general_settings ); } } /** * @since 2.2.0 * @access private */ private function maybe_remove_all_admin_notices() { $elementor_pages = [ 'elementor-getting-started', 'elementor_custom_fonts', 'elementor_custom_icons', 'elementor-license', 'popup_templates', 'theme_templates', ]; if ( empty( $_GET['page'] ) || ! in_array( $_GET['page'], $elementor_pages, true ) ) { return; } remove_all_actions( 'admin_notices' ); } /** * Settings page constructor. * * Initializing Elementor "Settings" page. * * @since 1.0.0 * @access public */ public function __construct() { parent::__construct(); add_action( 'admin_init', [ $this, 'on_admin_init' ] ); add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 ); add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 ); add_action( 'admin_menu', [ $this, 'register_pro_menu' ], self::MENU_PRIORITY_GO_PRO ); add_action( 'admin_menu', [ $this, 'register_knowledge_base_menu' ], 501 ); // Clear CSS Meta after change print method. add_action( 'add_option_elementor_css_print_method', [ $this, 'update_css_print_method' ] ); add_action( 'update_option_elementor_css_print_method', [ $this, 'update_css_print_method' ] ); add_filter( 'custom_menu_order', '__return_true' ); add_filter( 'menu_order', [ $this, 'menu_order' ] ); foreach ( Responsive::get_editable_breakpoints() as $breakpoint_key => $breakpoint ) { foreach ( [ 'add', 'update' ] as $action ) { add_action( "{$action}_option_elementor_viewport_{$breakpoint_key}", [ 'Elementor\Core\Responsive\Responsive', 'compile_stylesheet_templates' ] ); } } } } PK!\Ҝ::table-settings.phpnuW+A 'Settings', // Do not translate ( used for css class ) 'ajax' => false, ) ); } /** * Get the table classes for styling * * @since 1.8 */ protected function get_table_classes() { return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class } /** * Displays a single row * * @since 1.8 * * @param object $item PLL_Settings_Module object */ public function single_row( $item ) { // Classes to reuse css from the plugins list table $classes = $item->is_active() ? 'active' : 'inactive'; if ( $message = $item->get_upgrade_message() ) { $classes .= ' update'; } // Display the columns printf( '', esc_attr( $item->module ), esc_attr( $classes ) ); $this->single_row_columns( $item ); echo ''; // Display an upgrade message if there is any, reusing css from the plugins updates if ( $message = $item->get_upgrade_message() ) { printf( ' %s ', sprintf( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ? '
%s
' : // backward compatibility with WP < 4.6 '

%s

', $message ) ); } // The settings if there are // "inactive" class to reuse css from the plugins list table if ( $form = $item->get_form() ) { printf( ' %s %s

%s

', esc_attr( $item->module ), esc_html( $item->title ), $form, implode( $item->get_buttons() ) ); } } /** * Generates the columns for a single row of the table * * @since 1.8 * * @param object $item The current item */ protected function single_row_columns( $item ) { list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); foreach ( $columns as $column_name => $column_display_name ) { $classes = "$column_name column-$column_name"; if ( $primary === $column_name ) { $classes .= ' column-primary'; } if ( in_array( $column_name, $hidden ) ) { $classes .= ' hidden'; } if ( 'cb' == $column_name ) { echo ''; echo $this->column_cb( $item ); echo ''; } else { printf( '', esc_attr( $classes ) ); echo $this->column_default( $item, $column_name ); echo ''; } } } /** * Displays the item information in a column ( default case ) * * @since 1.8 * * @param object $item * @param string $column_name * @return string */ protected function column_default( $item, $column_name ) { if ( 'plugin-title' == $column_name ) { return sprintf( '%s', esc_html( $item->title ) ) . $this->row_actions( $item->get_action_links(), true /*always visible*/ ); } return $item->$column_name; } /** * Gets the list of columns * * @since 1.8 * * @return array the list of column titles */ public function get_columns() { return array( 'cb' => '', // For the 4px border inherited from plugins when the module is activated 'plugin-title' => esc_html__( 'Module', 'polylang' ), // plugin-title for styling 'description' => esc_html__( 'Description', 'polylang' ), ); } /** * Gets the name of the primary column. * * @since 1.8 * * @return string The name of the primary column. */ protected function get_primary_column_name() { return 'plugin-title'; } /** * Prepares the list of items for displaying * * @since 1.8 * * @param array $items */ public function prepare_items( $items = array() ) { $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() ); $this->items = $items; } /** * Avoids displaying an empty tablenav * * @since 2.1 * * @param string $which 'top' or 'bottom' */ protected function display_tablenav( $which ) {} } PK!\ settings-browser.phpnuW+A 'browser', 'title' => __( 'Detect browser language', 'polylang' ), 'description' => __( 'When the front page is visited, set the language according to the browser preference', 'polylang' ), 'active_option' => $this->is_available() ? 'browser' : false, ) ); if ( ! class_exists( 'PLL_Xdata_Domain', true ) ) { add_action( 'admin_print_footer_scripts', array( $this, 'print_js' ) ); } } /** * Tells if the option is available * * @since 2.0 * * @return bool */ protected function is_available() { return ( 3 > $this->options['force_lang'] ) || class_exists( 'PLL_Xdata_Domain', true ); } /** * Tells if the module is active * * @since 1.8 * * @return bool */ public function is_active() { return $this->is_available() ? parent::is_active() : false; } /** * Displays the javascript to handle dynamically the change in url modifications * as the preferred browser language is not used when the language is set from different domains * * @since 1.8 */ public function print_js() { wp_enqueue_script( 'jquery' ); if ( parent::is_active() && 3 > $this->options['force_lang'] ) { $func = 'removeClass( "inactive" ).addClass( "active" )'; $link = sprintf( '%s', $this->action_links['deactivate'] ); } else { $func = 'removeClass( "active" ).addClass( "inactive" )'; $link = sprintf( '%s', $this->action_links['activate'] ); } $deactivated = sprintf( '%s', $this->action_links['deactivated'] ); ?> __( 'Andorra', 'polylang' ), 'ae' => __( 'United Arab Emirates', 'polylang' ), 'af' => __( 'Afghanistan', 'polylang' ), 'ag' => __( 'Antigua and Barbuda', 'polylang' ), 'ai' => __( 'Anguilla', 'polylang' ), 'al' => __( 'Albania', 'polylang' ), 'am' => __( 'Armenia', 'polylang' ), 'an' => __( 'Netherlands Antilles', 'polylang' ), 'ao' => __( 'Angola', 'polylang' ), 'ar' => __( 'Argentina', 'polylang' ), 'arab' => __( 'Arab league', 'polylang' ), 'as' => __( 'American Samoa', 'polylang' ), 'at' => __( 'Austria', 'polylang' ), 'au' => __( 'Australia', 'polylang' ), 'aw' => __( 'Aruba', 'polylang' ), 'ax' => __( 'Åland Islands', 'polylang' ), 'az' => __( 'Azerbaijan', 'polylang' ), 'ba' => __( 'Bosnia and Herzegovina', 'polylang' ), 'basque' => __( 'Basque Country', 'polylang' ), 'bb' => __( 'Barbados', 'polylang' ), 'bd' => __( 'Bangladesh', 'polylang' ), 'be' => __( 'Belgium', 'polylang' ), 'bf' => __( 'Burkina Faso', 'polylang' ), 'bg' => __( 'Bulgaria', 'polylang' ), 'bh' => __( 'Bahrain', 'polylang' ), 'bi' => __( 'Burundi', 'polylang' ), 'bj' => __( 'Benin', 'polylang' ), 'bm' => __( 'Bermuda', 'polylang' ), 'bn' => __( 'Brunei', 'polylang' ), 'bo' => __( 'Bolivia', 'polylang' ), 'br' => __( 'Brazil', 'polylang' ), 'bs' => __( 'Bahamas', 'polylang' ), 'bt' => __( 'Bhutan', 'polylang' ), 'bw' => __( 'Botswana', 'polylang' ), 'by' => __( 'Belarus', 'polylang' ), 'bz' => __( 'Belize', 'polylang' ), 'ca' => __( 'Canada', 'polylang' ), 'catalonia' => __( 'Catalonia', 'polylang' ), 'cc' => __( 'Cocos', 'polylang' ), 'cd' => __( 'Democratic Republic of the Congo', 'polylang' ), 'cf' => __( 'Central African Republic', 'polylang' ), 'cg' => __( 'Congo', 'polylang' ), 'ch' => __( 'Switzerland', 'polylang' ), 'ci' => __( 'Ivory Coast', 'polylang' ), 'ck' => __( 'Cook Islands', 'polylang' ), 'cl' => __( 'Chile', 'polylang' ), 'cm' => __( 'Cameroon', 'polylang' ), 'cn' => __( 'China', 'polylang' ), 'co' => __( 'Colombia', 'polylang' ), 'cr' => __( 'Costa Rica', 'polylang' ), 'cu' => __( 'Cuba', 'polylang' ), 'cv' => __( 'Cape Verde', 'polylang' ), 'cx' => __( 'Christmas Island', 'polylang' ), 'cy' => __( 'Cyprus', 'polylang' ), 'cz' => __( 'Czech Republic', 'polylang' ), 'de' => __( 'Germany', 'polylang' ), 'dj' => __( 'Djibouti', 'polylang' ), 'dk' => __( 'Denmark', 'polylang' ), 'dm' => __( 'Dominica', 'polylang' ), 'do' => __( 'Dominican Republic', 'polylang' ), 'dz' => __( 'Algeria', 'polylang' ), 'ec' => __( 'Ecuador', 'polylang' ), 'ee' => __( 'Estonia', 'polylang' ), 'eg' => __( 'Egypt', 'polylang' ), 'eh' => __( 'Western Sahara', 'polylang' ), 'england' => __( 'England', 'polylang' ), 'er' => __( 'Eritrea', 'polylang' ), 'es' => __( 'Spain', 'polylang' ), 'esperanto' => __( 'Esperanto', 'polylang' ), 'et' => __( 'Ethiopia', 'polylang' ), 'fi' => __( 'Finland', 'polylang' ), 'fj' => __( 'Fiji', 'polylang' ), 'fk' => __( 'Falkland Islands', 'polylang' ), 'fm' => __( 'Micronesia', 'polylang' ), 'fo' => __( 'Faroe Islands', 'polylang' ), 'fr' => __( 'France', 'polylang' ), 'ga' => __( 'Gabon', 'polylang' ), 'galicia' => __( 'Galicia', 'polylang' ), 'gb' => __( 'United Kingdom', 'polylang' ), 'gd' => __( 'Grenada', 'polylang' ), 'ge' => __( 'Georgia', 'polylang' ), 'gh' => __( 'Ghana', 'polylang' ), 'gi' => __( 'Gibraltar', 'polylang' ), 'gl' => __( 'Greenland', 'polylang' ), 'gm' => __( 'Gambia', 'polylang' ), 'gn' => __( 'Guinea', 'polylang' ), 'gp' => __( 'Guadeloupe', 'polylang' ), 'gq' => __( 'Equatorial Guinea', 'polylang' ), 'gr' => __( 'Greece', 'polylang' ), 'gs' => __( 'South Georgia and the South Sandwich Islands', 'polylang' ), 'gt' => __( 'Guatemala', 'polylang' ), 'gu' => __( 'Guam', 'polylang' ), 'gw' => __( 'Guinea-Bissau', 'polylang' ), 'gy' => __( 'Guyana', 'polylang' ), 'hk' => __( 'Hong Kong', 'polylang' ), 'hm' => __( 'Heard Island and McDonald Islands', 'polylang' ), 'hn' => __( 'Honduras', 'polylang' ), 'hr' => __( 'Croatia', 'polylang' ), 'ht' => __( 'Haiti', 'polylang' ), 'hu' => __( 'Hungary', 'polylang' ), 'id' => __( 'Indonesia', 'polylang' ), 'ie' => __( 'Republic of Ireland', 'polylang' ), 'il' => __( 'Israel', 'polylang' ), 'in' => __( 'India', 'polylang' ), 'io' => __( 'British Indian Ocean Territory', 'polylang' ), 'iq' => __( 'Iraq', 'polylang' ), 'ir' => __( 'Iran', 'polylang' ), 'is' => __( 'Iceland', 'polylang' ), 'it' => __( 'Italy', 'polylang' ), 'jm' => __( 'Jamaica', 'polylang' ), 'jo' => __( 'Jordan', 'polylang' ), 'jp' => __( 'Japan', 'polylang' ), 'ke' => __( 'Kenya', 'polylang' ), 'kg' => __( 'Kyrgyzstan', 'polylang' ), 'kh' => __( 'Cambodia', 'polylang' ), 'ki' => __( 'Kiribati', 'polylang' ), 'km' => __( 'Comoros', 'polylang' ), 'kn' => __( 'Saint Kitts and Nevis', 'polylang' ), 'kp' => __( 'North Korea', 'polylang' ), 'kr' => __( 'South Korea', 'polylang' ), 'kurdistan' => __( 'Kurdistan', 'polylang' ), 'kw' => __( 'Kuwait', 'polylang' ), 'ky' => __( 'Cayman Islands', 'polylang' ), 'kz' => __( 'Kazakhstan', 'polylang' ), 'la' => __( 'Laos', 'polylang' ), 'lb' => __( 'Lebanon', 'polylang' ), 'lc' => __( 'Saint Lucia', 'polylang' ), 'li' => __( 'Liechtenstein', 'polylang' ), 'lk' => __( 'Sri Lanka', 'polylang' ), 'lr' => __( 'Liberia', 'polylang' ), 'ls' => __( 'Lesotho', 'polylang' ), 'lt' => __( 'Lithuania', 'polylang' ), 'lu' => __( 'Luxembourg', 'polylang' ), 'lv' => __( 'Latvia', 'polylang' ), 'ly' => __( 'Libya', 'polylang' ), 'ma' => __( 'Morocco', 'polylang' ), 'mc' => __( 'Monaco', 'polylang' ), 'md' => __( 'Moldova', 'polylang' ), 'me' => __( 'Montenegro', 'polylang' ), 'mg' => __( 'Madagascar', 'polylang' ), 'mh' => __( 'Marshall Islands', 'polylang' ), 'mk' => __( 'Macedonia', 'polylang' ), 'ml' => __( 'Mali', 'polylang' ), 'mm' => __( 'Myanmar', 'polylang' ), 'mn' => __( 'Mongolia', 'polylang' ), 'mo' => __( 'Macao', 'polylang' ), 'mp' => __( 'Northern Mariana Islands', 'polylang' ), 'mq' => __( 'Martinique', 'polylang' ), 'mr' => __( 'Mauritania', 'polylang' ), 'ms' => __( 'Montserrat', 'polylang' ), 'mt' => __( 'Malta', 'polylang' ), 'mu' => __( 'Mauritius', 'polylang' ), 'mv' => __( 'Maldives', 'polylang' ), 'mw' => __( 'Malawi', 'polylang' ), 'mx' => __( 'Mexico', 'polylang' ), 'my' => __( 'Malaysia', 'polylang' ), 'mz' => __( 'Mozambique', 'polylang' ), 'na' => __( 'Namibia', 'polylang' ), 'nc' => __( 'New Caledonia', 'polylang' ), 'ne' => __( 'Niger', 'polylang' ), 'nf' => __( 'Norfolk Island', 'polylang' ), 'ng' => __( 'Nigeria', 'polylang' ), 'ni' => __( 'Nicaragua', 'polylang' ), 'nl' => __( 'Netherlands', 'polylang' ), 'no' => __( 'Norway', 'polylang' ), 'np' => __( 'Nepal', 'polylang' ), 'nr' => __( 'Nauru', 'polylang' ), 'nu' => __( 'Niue', 'polylang' ), 'nz' => __( 'New Zealand', 'polylang' ), 'occitania' => __( 'Occitania', 'polylang' ), 'om' => __( 'Oman', 'polylang' ), 'pa' => __( 'Panama', 'polylang' ), 'pe' => __( 'Peru', 'polylang' ), 'pf' => __( 'French Polynesia', 'polylang' ), 'pg' => __( 'Papua New Guinea', 'polylang' ), 'ph' => __( 'Philippines', 'polylang' ), 'pk' => __( 'Pakistan', 'polylang' ), 'pl' => __( 'Poland', 'polylang' ), 'pm' => __( 'Saint Pierre and Miquelon', 'polylang' ), 'pn' => __( 'Pitcairn', 'polylang' ), 'pr' => __( 'Puerto Rico', 'polylang' ), 'ps' => __( 'Palestinian Territory', 'polylang' ), 'pt' => __( 'Portugal', 'polylang' ), 'pw' => __( 'Belau', 'polylang' ), 'py' => __( 'Paraguay', 'polylang' ), 'qa' => __( 'Qatar', 'polylang' ), 'quebec' => __( 'Quebec', 'polylang' ), 'ro' => __( 'Romania', 'polylang' ), 'rs' => __( 'Serbia', 'polylang' ), 'ru' => __( 'Russia', 'polylang' ), 'rw' => __( 'Rwanda', 'polylang' ), 'sa' => __( 'Saudi Arabia', 'polylang' ), 'sb' => __( 'Solomon Islands', 'polylang' ), 'sc' => __( 'Seychelles', 'polylang' ), 'scotland' => __( 'Scotland', 'polylang' ), 'sd' => __( 'Sudan', 'polylang' ), 'se' => __( 'Sweden', 'polylang' ), 'sg' => __( 'Singapore', 'polylang' ), 'sh' => __( 'Saint Helena', 'polylang' ), 'si' => __( 'Slovenia', 'polylang' ), 'sk' => __( 'Slovakia', 'polylang' ), 'sl' => __( 'Sierra Leone', 'polylang' ), 'sm' => __( 'San Marino', 'polylang' ), 'sn' => __( 'Senegal', 'polylang' ), 'so' => __( 'Somalia', 'polylang' ), 'sr' => __( 'Suriname', 'polylang' ), 'ss' => __( 'South Sudan', 'polylang' ), 'st' => __( 'São Tomé and Príncipe', 'polylang' ), 'sv' => __( 'El Salvador', 'polylang' ), 'sy' => __( 'Syria', 'polylang' ), 'sz' => __( 'Swaziland', 'polylang' ), 'tc' => __( 'Turks and Caicos Islands', 'polylang' ), 'td' => __( 'Chad', 'polylang' ), 'tf' => __( 'French Southern Territories', 'polylang' ), 'tg' => __( 'Togo', 'polylang' ), 'th' => __( 'Thailand', 'polylang' ), 'tibet' => __( 'Tibet', 'polylang' ), 'tj' => __( 'Tajikistan', 'polylang' ), 'tk' => __( 'Tokelau', 'polylang' ), 'tl' => __( 'Timor-Leste', 'polylang' ), 'tm' => __( 'Turkmenistan', 'polylang' ), 'tn' => __( 'Tunisia', 'polylang' ), 'to' => __( 'Tonga', 'polylang' ), 'tr' => __( 'Turkey', 'polylang' ), 'tt' => __( 'Trinidad and Tobago', 'polylang' ), 'tv' => __( 'Tuvalu', 'polylang' ), 'tw' => __( 'Taiwan', 'polylang' ), 'tz' => __( 'Tanzania', 'polylang' ), 'ua' => __( 'Ukraine', 'polylang' ), 'ug' => __( 'Uganda', 'polylang' ), 'us' => __( 'United States', 'polylang' ), 'uy' => __( 'Uruguay', 'polylang' ), 'uz' => __( 'Uzbekistan', 'polylang' ), 'va' => __( 'Vatican', 'polylang' ), 'vc' => __( 'Saint Vincent and the Grenadines', 'polylang' ), 've' => __( 'Venezuela', 'polylang' ), 'veneto' => __( 'Veneto', 'polylang' ), 'vg' => __( 'British Virgin Islands', 'polylang' ), 'vi' => __( 'United States Virgin Islands', 'polylang' ), 'vn' => __( 'Vietnam', 'polylang' ), 'vu' => __( 'Vanuatu', 'polylang' ), 'wales' => __( 'Wales', 'polylang' ), 'wf' => __( 'Wallis and Futuna', 'polylang' ), 'ws' => __( 'Western Samoa', 'polylang' ), 'ye' => __( 'Yemen', 'polylang' ), 'yt' => __( 'Mayotte', 'polylang' ), 'za' => __( 'South Africa', 'polylang' ), 'zm' => __( 'Zambia', 'polylang' ), 'zw' => __( 'Zimbabwe', 'polylang' ), ); /** * Filter the list of predefined flags * * @since 1.8 * * @param array $flags */ $flags = apply_filters( 'pll_predefined_flags', $flags ); PK!\YOOsettings-licenses.phpnuW+A 'licenses', 'title' => __( 'License keys', 'polylang' ), 'description' => __( 'Manage licenses for Polylang Pro or addons.', 'polylang' ), ) ); $this->buttons['cancel'] = sprintf( '', __( 'Close' ) ); $this->items = apply_filters( 'pll_settings_licenses', array() ); add_action( 'wp_ajax_pll_deactivate_license', array( $this, 'deactivate_license' ) ); } /** * Tells if the module is active * * @since 1.9 * * @return bool */ public function is_active() { return ! empty( $this->items ); } /** * Displays the settings form * * @since 1.9 */ protected function form() { if ( ! empty( $this->items ) ) { ?> items as $item ) { echo $this->get_row( $item ); } ?>
license_data ) ) { $license = $item->license_data; } $class = 'license-null'; $out = sprintf( '' . '', esc_attr( $item->id ), esc_attr( $item->name ), esc_html( $item->license_key ) ); if ( ! empty( $license ) && is_object( $license ) ) { $now = current_time( 'timestamp' ); $expiration = strtotime( $license->expires, $now ); // Special case: the license expired after the last check if ( $license->success && $expiration < $now ) { $license->success = false; $license->error = 'expired'; } if ( false === $license->success ) { $class = 'notice-error notice-alt'; switch ( $license->error ) { case 'expired': $message = sprintf( /* translators: %1$s is a date, %2$s and %3$s are html tags */ __( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'polylang' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), sprintf( '', 'https://polylang.pro/checkout/?edd_license_key=' . $item->license_key ), '' ); break; case 'missing': $message = sprintf( /* translators: %s are html tags */ __( 'Invalid license. Please %svisit your account page%s and verify it.', 'polylang' ), sprintf( '', 'https://polylang.pro/account' ), '' ); break; case 'invalid': case 'site_inactive': $message = sprintf( /* translators: %1$s is a product name, %2$s and %3$s are html tags */ __( 'Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license key URLs.', 'polylang' ), $item->name, sprintf( '', 'https://polylang.pro/account' ), '' ); break; case 'item_name_mismatch': /* translators: %s is a product name */ $message = sprintf( __( 'This is not a %s license key.', 'polylang' ), $item->name ); break; case 'no_activations_left': $message = sprintf( /* translators: %s are html tags */ __( 'Your license key has reached its activation limit. %sView possible upgrades%s now.', 'polylang' ), sprintf( '', 'https://polylang.pro/account' ), '' ); break; } } else { $class = 'license-valid'; $out .= sprintf( '', $item->id, __( 'Deactivate', 'polylang' ) ); if ( 'lifetime' === $license->expires ) { $message = __( 'The license key never expires.', 'polylang' ); } elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { $class = 'notice-warning notice-alt'; $message = sprintf( /* translators: %1$s is a date, %2$s and %3$s are html tags */ __( 'Your license key expires soon! It expires on %1$s. %2$sRenew your license key%3$s.', 'polylang' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, $now ) ), sprintf( '', 'https://polylang.pro/checkout/?edd_license_key=' . $item->license_key ), '' ); } else { $message = sprintf( /* translators: %s is a date */ __( 'Your license key expires on %s.', 'polylang' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, $now ) ) ); } } } if ( ! empty( $message ) ) { $out .= '

' . $message . '

'; } return sprintf( '%s', $item->id, $class, $out ); } /** * Ajax method to save the license keys and activate the licenses at the same time * Overrides parent's method * * @since 1.9 */ public function save_options() { check_ajax_referer( 'pll_options', '_pll_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_die( -1 ); } if ( $this->module === $_POST['module'] && ! empty( $_POST['licenses'] ) ) { $x = new WP_Ajax_Response(); foreach ( $this->items as $item ) { $updated_item = $item->activate_license( sanitize_text_field( $_POST['licenses'][ $item->id ] ) ); $x->Add( array( 'what' => 'license-update', 'data' => $item->id, 'supplemental' => array( 'html' => $this->get_row( $updated_item ) ) ) ); } // Updated message add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' ); ob_start(); settings_errors(); $x->Add( array( 'what' => 'success', 'data' => ob_get_clean() ) ); $x->send(); } } /** * Ajax method to deactivate a license * * @since 1.9 */ public function deactivate_license() { check_ajax_referer( 'pll_options', '_pll_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_die( -1 ); } $id = sanitize_text_field( substr( $_POST['id'], 11 ) ); wp_send_json( array( 'id' => $id, 'html' => $this->get_row( $this->items[ $id ]->deactivate_license() ), ) ); } } PK!\SSview-tab-settings.phpnuW+A
prepare_items( $this->modules ); $list_table->display(); ?>
PKg"\validations.phpnuW+Afiles_manager->clear_cache(); return $input; } } PKg"\RGI controls.phpnuW+A '', 'attributes' => [], 'std' => '', 'desc' => '', ]; $field = array_merge( $defaults, $field ); $method_name = $field['type']; if ( ! method_exists( __CLASS__, $method_name ) ) { $method_name = 'text'; } self::$method_name( $field ); } /** * Render text control. * * Generates the final HTML for text controls. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function text( array $field ) { if ( empty( $field['attributes']['class'] ) ) { $field['attributes']['class'] = 'regular-text'; } $attributes = Utils::render_html_attributes( $field['attributes'] ); ?> />

$option_value ) : ?>

[], ]; $field = array_merge( $defaults, $field ); $post_types_objects = get_post_types( [ 'public' => true, ], 'objects' ); /** * Filters the list of post type objects used by Elementor. * * @since 2.8.0 * * @param array $post_types_objects List of post type objects used by Elementor. */ $post_types_objects = apply_filters( 'elementor/settings/controls/checkbox_list_cpt/post_type_objects', $post_types_objects ); $field['options'] = []; foreach ( $post_types_objects as $cpt_slug => $post_type ) { if ( in_array( $cpt_slug, $field['exclude'], true ) ) { continue; } $field['options'][ $cpt_slug ] = $post_type->labels->name; } self::checkbox_list( $field ); } /** * Render checkbox list control for user roles. * * Generates the final HTML for checkbox list controls populated with user roles. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function checkbox_list_roles( array $field ) { $defaults = [ 'exclude' => [], ]; $field = array_merge( $defaults, $field ); $field['options'] = []; $roles = get_editable_roles(); if ( is_multisite() ) { $roles = [ 'super_admin' => [ 'name' => __( 'Super Admin', 'elementor' ), ], ] + $roles; } foreach ( $roles as $role_slug => $role_data ) { if ( in_array( $role_slug, $field['exclude'] ) ) { continue; } $field['options'][ $role_slug ] = $role_data['name']; } self::checkbox_list( $field ); } /** * Render raw HTML control. * * Generates the final HTML for raw HTML controls. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function raw_html( array $field ) { if ( empty( $field['html'] ) ) { return; } ?>

ensure_tabs(); return $this->tabs; } /** * Add tab. * * Register a new tab to a settings page. * * @since 1.5.0 * @access public * * @param string $tab_id Tab ID. * @param array $tab_args Optional. Tab arguments. Default is an empty array. */ final public function add_tab( $tab_id, array $tab_args = [] ) { $this->ensure_tabs(); if ( isset( $this->tabs[ $tab_id ] ) ) { // Don't override an existing tab return; } if ( ! isset( $tab_args['sections'] ) ) { $tab_args['sections'] = []; } $this->tabs[ $tab_id ] = $tab_args; } /** * Add section. * * Register a new section to a tab. * * @since 1.5.0 * @access public * * @param string $tab_id Tab ID. * @param string $section_id Section ID. * @param array $section_args Optional. Section arguments. Default is an * empty array. */ final public function add_section( $tab_id, $section_id, array $section_args = [] ) { $this->ensure_tabs(); if ( ! isset( $this->tabs[ $tab_id ] ) ) { // If the requested tab doesn't exists, use the first tab $tab_id = key( $this->tabs ); } if ( isset( $this->tabs[ $tab_id ]['sections'][ $section_id ] ) ) { // Don't override an existing section return; } if ( ! isset( $section_args['fields'] ) ) { $section_args['fields'] = []; } $this->tabs[ $tab_id ]['sections'][ $section_id ] = $section_args; } /** * Add field. * * Register a new field to a section. * * @since 1.5.0 * @access public * * @param string $tab_id Tab ID. * @param string $section_id Section ID. * @param string $field_id Field ID. * @param array $field_args Field arguments. */ final public function add_field( $tab_id, $section_id, $field_id, array $field_args ) { $this->ensure_tabs(); if ( ! isset( $this->tabs[ $tab_id ] ) ) { // If the requested tab doesn't exists, use the first tab $tab_id = key( $this->tabs ); } if ( ! isset( $this->tabs[ $tab_id ]['sections'][ $section_id ] ) ) { // If the requested section doesn't exists, use the first section $section_id = key( $this->tabs[ $tab_id ]['sections'] ); } if ( isset( $this->tabs[ $tab_id ]['sections'][ $section_id ]['fields'][ $field_id ] ) ) { // Don't override an existing field return; } $this->tabs[ $tab_id ]['sections'][ $section_id ]['fields'][ $field_id ] = $field_args; } /** * Add fields. * * Register multiple fields to a section. * * @since 1.5.0 * @access public * * @param string $tab_id Tab ID. * @param string $section_id Section ID. * @param array $fields { * An array of fields. * * @type string $field_id Field ID. * @type array $field_args Field arguments. * } */ final public function add_fields( $tab_id, $section_id, array $fields ) { foreach ( $fields as $field_id => $field_args ) { $this->add_field( $tab_id, $section_id, $field_id, $field_args ); } } /** * Register settings fields. * * In each tab register his inner sections, and in each section register his * inner fields. * * @since 1.5.0 * @access public */ final public function register_settings_fields() { $controls_class_name = __NAMESPACE__ . '\Settings_Controls'; $tabs = $this->get_tabs(); foreach ( $tabs as $tab_id => $tab ) { foreach ( $tab['sections'] as $section_id => $section ) { $full_section_id = 'elementor_' . $section_id . '_section'; $label = isset( $section['label'] ) ? $section['label'] : ''; $section_callback = isset( $section['callback'] ) ? $section['callback'] : '__return_empty_string'; add_settings_section( $full_section_id, $label, $section_callback, static::PAGE_ID ); foreach ( $section['fields'] as $field_id => $field ) { $full_field_id = ! empty( $field['full_field_id'] ) ? $field['full_field_id'] : 'elementor_' . $field_id; $field['field_args']['id'] = $full_field_id; $field_classes = [ $full_field_id ]; if ( ! empty( $field['class'] ) ) { $field_classes[] = $field['field_args']['class']; } $field['field_args']['class'] = implode( ' ', $field_classes ); add_settings_field( $full_field_id, isset( $field['label'] ) ? $field['label'] : '', [ $controls_class_name, 'render' ], static::PAGE_ID, $full_section_id, $field['field_args'] ); $setting_args = []; if ( ! empty( $field['setting_args'] ) ) { $setting_args = $field['setting_args']; } register_setting( static::PAGE_ID, $full_field_id, $setting_args ); } } } } /** * Display settings page. * * Output the content for the settings page. * * @since 1.5.0 * @access public */ public function display_settings_page() { $this->register_settings_fields(); $tabs = $this->get_tabs(); ?>

get_page_title(); ?>

$tab ) { if ( empty( $tab['sections'] ) ) { continue; } $active_class = ''; if ( 'general' === $tab_id ) { $active_class = ' elementor-active'; } echo "
"; foreach ( $tab['sections'] as $section_id => $section ) { $full_section_id = 'elementor_' . $section_id . '_section'; if ( ! empty( $section['label'] ) ) { echo "

{$section['label']}

"; } if ( ! empty( $section['callback'] ) ) { $section['callback'](); } echo ''; do_settings_fields( static::PAGE_ID, $full_section_id ); echo '
'; } echo '
'; } submit_button(); ?>
tabs ) { $this->tabs = $this->create_tabs(); $page_id = static::PAGE_ID; /** * After create settings. * * Fires after the settings are created in Elementor admin page. * * The dynamic portion of the hook name, `$page_id`, refers to the current page ID. * * @since 1.0.0 * * @param Settings_Page $this The settings page. */ do_action( "elementor/admin/after_create_settings/{$page_id}", $this ); } } } PKg"\ɹ(( tools.phpnuW+Afiles_manager->clear_cache(); wp_send_json_success(); } /** * Replace URLs. * * Sends an ajax request to replace old URLs to new URLs. This method also * updates all the Elementor data. * * Fired by `wp_ajax_elementor_replace_url` action. * * @since 1.1.0 * @access public */ public function ajax_elementor_replace_url() { check_ajax_referer( 'elementor_replace_url', '_nonce' ); $from = ! empty( $_POST['from'] ) ? $_POST['from'] : ''; $to = ! empty( $_POST['to'] ) ? $_POST['to'] : ''; try { $results = Utils::replace_urls( $from, $to ); wp_send_json_success( $results ); } catch ( \Exception $e ) { wp_send_json_error( $e->getMessage() ); } } /** * Elementor version rollback. * * Rollback to previous Elementor version. * * Fired by `admin_post_elementor_rollback` action. * * @since 1.5.0 * @access public */ public function post_elementor_rollback() { check_admin_referer( 'elementor_rollback' ); $rollback_versions = $this->get_rollback_versions(); if ( empty( $_GET['version'] ) || ! in_array( $_GET['version'], $rollback_versions ) ) { wp_die( __( 'Error occurred, The version selected is invalid. Try selecting different version.', 'elementor' ) ); } $plugin_slug = basename( ELEMENTOR__FILE__, '.php' ); $rollback = new Rollback( [ 'version' => $_GET['version'], 'plugin_name' => ELEMENTOR_PLUGIN_BASE, 'plugin_slug' => $plugin_slug, 'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $_GET['version'] ), ] ); $rollback->run(); wp_die( '', __( 'Rollback to Previous Version', 'elementor' ), [ 'response' => 200, ] ); } /** * Tools page constructor. * * Initializing Elementor "Tools" page. * * @since 1.0.0 * @access public */ public function __construct() { parent::__construct(); add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 205 ); if ( ! empty( $_POST ) ) { add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] ); add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] ); } add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] ); } private function get_rollback_versions() { $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION ); if ( false === $rollback_versions ) { $max_versions = 30; require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $plugin_information = plugins_api( 'plugin_information', [ 'slug' => 'elementor', ] ); if ( empty( $plugin_information->versions ) || ! is_array( $plugin_information->versions ) ) { return []; } krsort( $plugin_information->versions ); $rollback_versions = []; $current_index = 0; foreach ( $plugin_information->versions as $version => $download_link ) { if ( $max_versions <= $current_index ) { break; } if ( preg_match( '/(trunk|beta|rc)/i', strtolower( $version ) ) ) { continue; } if ( version_compare( $version, ELEMENTOR_VERSION, '>=' ) ) { continue; } $current_index++; $rollback_versions[] = $version; } set_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION, $rollback_versions, WEEK_IN_SECONDS ); } return $rollback_versions; } /** * Create tabs. * * Return the tools page tabs, sections and fields. * * @since 1.5.0 * @access protected * * @return array An array with the page tabs, sections and fields. */ protected function create_tabs() { $rollback_html = ''; return [ 'general' => [ 'label' => __( 'General', 'elementor' ), 'sections' => [ 'tools' => [ 'fields' => [ 'clear_cache' => [ 'label' => __( 'Regenerate CSS', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( '', wp_create_nonce( 'elementor_clear_cache' ), __( 'Regenerate Files', 'elementor' ) ), 'desc' => __( 'Styles set in Elementor are saved in CSS files in the uploads folder. Recreate those files, according to the most recent settings.', 'elementor' ), ], ], 'reset_api_data' => [ 'label' => __( 'Sync Library', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( '', wp_create_nonce( 'elementor_reset_library' ), __( 'Sync Library', 'elementor' ) ), 'desc' => __( 'Elementor Library automatically updates on a daily basis. You can also manually update it by clicking on the sync button.', 'elementor' ), ], ], ], ], ], ], 'replace_url' => [ 'label' => __( 'Replace URL', 'elementor' ), 'sections' => [ 'replace_url' => [ 'callback' => function() { $intro_text = sprintf( /* translators: %s: Codex URL */ __( 'Important: It is strongly recommended that you backup your database before using Replace URL.', 'elementor' ), 'https://codex.wordpress.org/WordPress_Backups' ); $intro_text = '
' . $intro_text . '
'; echo '

' . esc_html__( 'Replace URL', 'elementor' ) . '

'; echo $intro_text; }, 'fields' => [ 'replace_url' => [ 'label' => __( 'Update Site Address (URL)', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( '', wp_create_nonce( 'elementor_replace_url' ), __( 'Replace URL', 'elementor' ) ), 'desc' => __( 'Enter your old and new URLs for your WordPress installation, to update all Elementor data (Relevant for domain transfers or move to \'HTTPS\').', 'elementor' ), ], ], ], ], ], ], 'versions' => [ 'label' => __( 'Version Control', 'elementor' ), 'sections' => [ 'rollback' => [ 'label' => __( 'Rollback to Previous Version', 'elementor' ), 'callback' => function() { $intro_text = sprintf( /* translators: %s: Elementor version */ __( 'Experiencing an issue with Elementor version %s? Rollback to a previous version before the issue appeared.', 'elementor' ), ELEMENTOR_VERSION ); $intro_text = '

' . $intro_text . '

'; echo $intro_text; }, 'fields' => [ 'rollback' => [ 'label' => __( 'Rollback Version', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( $rollback_html . '%s', wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ), __( 'Reinstall', 'elementor' ) ), 'desc' => '' . __( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '', ], ], ], ], 'beta' => [ 'label' => __( 'Become a Beta Tester', 'elementor' ), 'callback' => function() { $intro_text = __( 'Turn-on Beta Tester, to get notified when a new beta version of Elementor or Elementor Pro is available. The Beta version will not install automatically. You always have the option to ignore it.', 'elementor' ); $intro_text = '

' . $intro_text . '

'; $newsletter_opt_in_text = sprintf( __( 'Click here to join our first-to-know email updates.', 'elementor' ), '#' ); echo $intro_text; echo $newsletter_opt_in_text; }, 'fields' => [ 'beta' => [ 'label' => __( 'Beta Tester', 'elementor' ), 'field_args' => [ 'type' => 'select', 'default' => 'no', 'options' => [ 'no' => __( 'Disable', 'elementor' ), 'yes' => __( 'Enable', 'elementor' ), ], 'desc' => '' . __( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '', ], ], ], ], ], ], ]; } /** * Get tools page title. * * Retrieve the title for the tools page. * * @since 1.5.0 * @access protected * * @return string Tools page title. */ protected function get_page_title() { return __( 'Tools', 'elementor' ); } } PK4\OMM manager.phpnuW+Aget_name() ] = $manager; } /** * Get settings managers. * * Retrieve registered settings manager(s). * * If no parameter passed, it will retrieve all the settings managers. For * any given parameter it will retrieve a single settings manager if one * exist, or `null` otherwise. * * @since 1.6.0 * @access public * @static * * @param string $manager_name Optional. Settings manager name. Default is * null. * * @return Base\Manager|Base\Manager[] Single settings manager, if it exists, * null if it doesn't exists, or the all * the settings managers if no parameter * defined. */ public static function get_settings_managers( $manager_name = null ) { if ( $manager_name ) { if ( isset( self::$settings_managers[ $manager_name ] ) ) { return self::$settings_managers[ $manager_name ]; } return null; } return self::$settings_managers; } /** * Register default settings managers. * * Register builtin Elementor settings managers. * * @since 1.6.0 * @access private * @static */ private static function register_default_settings_managers() { foreach ( self::$builtin_settings_managers_names as $manager_name ) { $manager_class = __NAMESPACE__ . '\\' . ucfirst( $manager_name ) . '\Manager'; self::add_settings_manager( new $manager_class() ); } } /** * Get settings managers config. * * Retrieve the settings managers configuration. * * @since 1.6.0 * @access public * @static * * @return array The settings managers configuration. */ public static function get_settings_managers_config() { $config = []; $user_can = Plugin::instance()->role_manager->user_can( 'design' ); foreach ( self::$settings_managers as $name => $manager ) { $settings_model = $manager->get_model_for_config(); $tabs = $settings_model->get_tabs_controls(); if ( ! $user_can ) { unset( $tabs['style'] ); } $config[ $name ] = [ 'name' => $manager->get_name(), 'panelPage' => $settings_model->get_panel_page_settings(), 'controls' => $settings_model->get_controls(), 'tabs' => $tabs, 'settings' => $settings_model->get_settings(), ]; if ( $settings_model instanceof CSS_Model ) { $config[ $name ]['cssWrapperSelector'] = $settings_model->get_css_wrapper_selector(); } } return $config; } /** * Get settings frontend config. * * Retrieve the settings managers frontend configuration. * * @since 1.6.0 * @access public * @static * * @return array The settings managers frontend configuration. */ public static function get_settings_frontend_config() { $config = []; foreach ( self::$settings_managers as $name => $manager ) { $settings_model = $manager->get_model_for_config(); if ( $settings_model ) { $config[ $name ] = $settings_model->get_frontend_settings(); } } return $config; } /** * Run settings managers. * * Register builtin Elementor settings managers. * * @since 1.6.0 * @access public * @static */ public static function run() { self::register_default_settings_managers(); } } PK4\cH H base/css-manager.phpnuW+Aget_css_file_name(); add_action( "elementor/css-file/{$name}/parse", [ $this, 'add_settings_css_rules' ] ); } /** * Save settings. * * Save settings to the database and update the CSS file. * * @since 2.8.0 * @access public * * @param array $settings Settings. * @param int $id Optional. Post ID. Default is `0`. */ public function save_settings( array $settings, $id = 0 ) { parent::save_settings( $settings, $id ); $css_file = $this->get_css_file_for_update( $id ); if ( $css_file ) { $css_file->update(); } } /** * Add settings CSS rules. * * Add new CSS rules to the settings manager. * * Fired by `elementor/css-file/{$name}/parse` action. * * @since 2.8.0 * @access public * * @param CSS_File $css_file The requested CSS file. * */ public function add_settings_css_rules( CSS_File $css_file ) { $model = $this->get_model_for_css_file( $css_file ); $css_file->add_controls_stack_style_rules( $model, $model->get_style_controls(), $model->get_settings(), [ '{{WRAPPER}}' ], [ $model->get_css_wrapper_selector() ] ); } } PK4\]]base/model.phpnuW+Aget_name(); $ajax_manager->register_ajax_action( "save_{$name}_settings", [ $this, 'ajax_save_settings' ] ); } /** * Get model for config. * * Retrieve the model for settings configuration. * * @since 1.6.0 * @access public * @abstract * * @return Model The model object. */ abstract public function get_model_for_config(); /** * Get manager name. * * Retrieve settings manager name. * * @since 1.6.0 * @access public * @abstract */ abstract public function get_name(); /** * Get model. * * Retrieve the model for any given model ID. * * @since 1.6.0 * @access public * * @param int $id Optional. Model ID. Default is `0`. * * @return Model The model. */ final public function get_model( $id = 0 ) { if ( ! isset( $this->models_cache[ $id ] ) ) { $this->create_model( $id ); } return $this->models_cache[ $id ]; } /** * Ajax request to save settings. * * Save settings using an ajax request. * * @since 1.6.0 * @access public * * @param array $request Ajax request. * * @return array Ajax response data. */ final public function ajax_save_settings( $request ) { $data = $request['data']; $id = 0; if ( ! empty( $request['id'] ) ) { $id = $request['id']; } $this->ajax_before_save_settings( $data, $id ); $this->save_settings( $data, $id ); $settings_name = $this->get_name(); $success_response_data = []; /** * Settings success response data. * * Filters the success response data when saving settings using ajax. * * The dynamic portion of the hook name, `$settings_name`, refers to the settings name. * * @since 1.6.0 * @deprecated 2.0.0 Use `elementor/settings/{$settings_name}/success_response_data` filter. * * @param array $success_response_data Success response data. * @param int $id Settings ID. * @param array $data Settings data. */ $success_response_data = apply_filters_deprecated( "elementor/{$settings_name}/settings/success_response_data", [ $success_response_data, $id, $data ], '2.0.0', "elementor/settings/{$settings_name}/success_response_data" ); /** * Settings success response data. * * Filters the success response data when saving settings using ajax. * * The dynamic portion of the hook name, `$settings_name`, refers to the settings name. * * @since 2.0.0 * * @param array $success_response_data Success response data. * @param int $id Settings ID. * @param array $data Settings data. */ $success_response_data = apply_filters( "elementor/settings/{$settings_name}/success_response_data", $success_response_data, $id, $data ); return $success_response_data; } /** * Save settings. * * Save settings to the database. * * @since 1.6.0 * @access public * * @param array $settings Settings. * @param int $id Optional. Post ID. Default is `0`. */ public function save_settings( array $settings, $id = 0 ) { $special_settings = $this->get_special_settings_names(); $settings_to_save = $settings; foreach ( $special_settings as $special_setting ) { if ( isset( $settings_to_save[ $special_setting ] ) ) { unset( $settings_to_save[ $special_setting ] ); } } $this->save_settings_to_db( $settings_to_save, $id ); // Clear cache after save. if ( isset( $this->models_cache[ $id ] ) ) { unset( $this->models_cache[ $id ] ); } } /** * On Elementor init. * * Add editor template for the settings * * Fired by `elementor/init` action. * * @since 2.3.0 * @access public */ public function on_elementor_editor_init() { Plugin::$instance->common->add_template( $this->get_editor_template(), 'text' ); } /** * Get saved settings. * * Retrieve the saved settings from the database. * * @since 1.6.0 * @access protected * @abstract * * @param int $id Post ID. */ abstract protected function get_saved_settings( $id ); /** * Save settings to DB. * * Save settings to the database. * * @since 1.6.0 * @access protected * @abstract * * @param array $settings Settings. * @param int $id Post ID. */ abstract protected function save_settings_to_db( array $settings, $id ); /** * Get special settings names. * * Retrieve the names of the special settings that are not saved as regular * settings. Those settings have a separate saving process. * * @since 1.6.0 * @access protected * * @return array Special settings names. */ protected function get_special_settings_names() { return []; } /** * Ajax before saving settings. * * Validate the data before saving it and updating the data in the database. * * @since 1.6.0 * @access public * * @param array $data Post data. * @param int $id Post ID. */ public function ajax_before_save_settings( array $data, $id ) {} /** * Print the setting template content in the editor. * * Used to generate the control HTML in the editor using Underscore JS * template. The variables for the class are available using `data` JS * object. * * @since 1.6.0 * @access protected * * @param string $name Settings panel name. */ protected function print_editor_template_content( $name ) { ?> <# const tabs = elementor.config.settings..tabs; if ( Object.values( tabs ).length > 1 ) { #>
<# _.each( tabs, function( tabTitle, tabSlug ) { $e.bc.ensureTab( 'panel/-settings', tabSlug ); #> <# } ); #>
<# } #>
models_cache[ $id ] = new $class_name( [ 'id' => $id, 'settings' => $this->get_saved_settings( $id ), ] ); } /** * Get editor template. * * Retrieve the final HTML for the editor. * * @since 1.6.0 * @access private * * @return string Settings editor template. */ private function get_editor_template() { $name = $this->get_name(); ob_start(); ?> __( 'Global Settings', 'elementor' ), ]; } /** * Get controls list. * * Retrieve the global settings model controls list. * * @since 1.6.0 * @access public * @static * * @return array Controls list. */ public static function get_controls_list() { return [ Controls_Manager::TAB_STYLE => [ 'style' => [ 'label' => __( 'Style', 'elementor' ), 'controls' => [ 'elementor_default_generic_fonts' => [ 'label' => __( 'Default Generic Fonts', 'elementor' ), 'type' => Controls_Manager::TEXT, 'default' => 'Sans-serif', 'description' => __( 'The list of fonts used if the chosen font is not available.', 'elementor' ), 'label_block' => true, ], 'elementor_container_width' => [ 'label' => __( 'Content Width', 'elementor' ) . ' (px)', 'type' => Controls_Manager::NUMBER, 'min' => 300, 'description' => __( 'Sets the default width of the content area (Default: 1140)', 'elementor' ), 'selectors' => [ '.elementor-section.elementor-section-boxed > .elementor-container' => 'max-width: {{VALUE}}px', ], ], 'elementor_space_between_widgets' => [ 'label' => __( 'Widgets Space', 'elementor' ) . ' (px)', 'type' => Controls_Manager::NUMBER, 'min' => 0, 'placeholder' => '20', 'description' => __( 'Sets the default space between widgets (Default: 20)', 'elementor' ), 'selectors' => [ '.elementor-widget:not(:last-child)' => 'margin-bottom: {{VALUE}}px', ], ], 'elementor_stretched_section_container' => [ 'label' => __( 'Stretched Section Fit To', 'elementor' ), 'type' => Controls_Manager::TEXT, 'placeholder' => 'body', 'description' => __( 'Enter parent element selector to which stretched sections will fit to (e.g. #primary / .wrapper / main etc). Leave blank to fit to page width.', 'elementor' ), 'label_block' => true, 'frontend_available' => true, ], 'elementor_page_title_selector' => [ 'label' => __( 'Page Title Selector', 'elementor' ), 'type' => Controls_Manager::TEXT, 'placeholder' => 'h1.entry-title', 'description' => __( 'Elementor lets you hide the page title. This works for themes that have "h1.entry-title" selector. If your theme\'s selector is different, please enter it above.', 'elementor' ), 'label_block' => true, ], ], ], ], Manager::PANEL_TAB_LIGHTBOX => [ 'lightbox' => [ 'label' => __( 'Lightbox', 'elementor' ), 'controls' => [ 'elementor_global_image_lightbox' => [ 'label' => __( 'Image Lightbox', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'description' => __( 'Open all image links in a lightbox popup window. The lightbox will automatically work on any link that leads to an image file.', 'elementor' ), 'frontend_available' => true, ], 'elementor_lightbox_enable_counter' => [ 'label' => __( 'Counter', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ], 'elementor_lightbox_enable_fullscreen' => [ 'label' => __( 'Fullscreen', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ], 'elementor_lightbox_enable_zoom' => [ 'label' => __( 'Zoom', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ], 'elementor_lightbox_enable_share' => [ 'label' => __( 'Share', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'frontend_available' => true, ], 'elementor_lightbox_title_src' => [ 'label' => __( 'Title', 'elementor' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => __( 'None', 'elementor' ), 'title' => __( 'Title', 'elementor' ), 'caption' => __( 'Caption', 'elementor' ), 'alt' => __( 'Alt', 'elementor' ), 'description' => __( 'Description', 'elementor' ), ], 'default' => 'title', 'frontend_available' => true, ], 'elementor_lightbox_description_src' => [ 'label' => __( 'Description', 'elementor' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => __( 'None', 'elementor' ), 'title' => __( 'Title', 'elementor' ), 'caption' => __( 'Caption', 'elementor' ), 'alt' => __( 'Alt', 'elementor' ), 'description' => __( 'Description', 'elementor' ), ], 'default' => 'description', 'frontend_available' => true, ], 'elementor_lightbox_color' => [ 'label' => __( 'Background Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.elementor-lightbox' => 'background-color: {{VALUE}}', ], ], 'elementor_lightbox_ui_color' => [ 'label' => __( 'UI Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.elementor-lightbox' => '--lightbox-ui-color: {{VALUE}}', ], ], 'elementor_lightbox_ui_color_hover' => [ 'label' => __( 'UI Hover Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.elementor-lightbox' => '--lightbox-ui-color-hover: {{VALUE}}', ], ], 'elementor_lightbox_text_color' => [ 'label' => __( 'Text Color', 'elementor' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.elementor-lightbox' => '--lightbox-text-color: {{VALUE}}', ], ], 'lightbox_icons_size' => [ 'label' => __( 'Toolbar Icons Size', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'selectors' => [ '.elementor-lightbox' => '--lightbox-header-icons-size: {{SIZE}}{{UNIT}}', ], 'separator' => 'before', ], 'lightbox_slider_icons_size' => [ 'label' => __( 'Navigation Icons Size', 'elementor' ), 'type' => Controls_Manager::SLIDER, 'selectors' => [ '.elementor-lightbox' => '--lightbox-navigation-icons-size: {{SIZE}}{{UNIT}}', ], 'separator' => 'before', ], ], ], ], ]; } /** * Register model controls. * * Used to add new controls to the global settings model. * * @since 1.6.0 * @access protected */ protected function _register_controls() { $controls_list = self::get_controls_list(); foreach ( $controls_list as $tab_name => $sections ) { foreach ( $sections as $section_name => $section_data ) { $this->start_controls_section( $section_name, [ 'label' => $section_data['label'], 'tab' => $tab_name, ] ); foreach ( $section_data['controls'] as $control_name => $control_data ) { $this->add_control( $control_name, $control_data ); } $this->end_controls_section(); } } } } PK4\$``general/manager.phpnuW+Aadd_panel_tabs(); } /** * Get manager name. * * Retrieve general settings manager name. * * @since 1.6.0 * @access public * * @return string Manager name. */ public function get_name() { return 'general'; } /** * Get model for config. * * Retrieve the model for settings configuration. * * @since 1.6.0 * @access public * * @return BaseModel The model object. */ public function get_model_for_config() { return $this->get_model(); } /** * Get saved settings. * * Retrieve the saved settings from the site options. * * @since 1.6.0 * @access protected * * @param int $id Post ID. * * @return array Saved settings. */ protected function get_saved_settings( $id ) { $model_controls = Model::get_controls_list(); $settings = []; foreach ( $model_controls as $tab_name => $sections ) { foreach ( $sections as $section_name => $section_data ) { foreach ( $section_data['controls'] as $control_name => $control_data ) { $saved_setting = get_option( $control_name, null ); if ( null !== $saved_setting ) { $settings[ $control_name ] = $saved_setting; } } } } return $settings; } /** * Get CSS file name. * * Retrieve CSS file name for the general settings manager. * * @since 1.6.0 * @access protected * @return string * * @return string CSS file name. */ protected function get_css_file_name() { return 'global'; } /** * Save settings to DB. * * Save general settings to the database, as site options. * * @since 1.6.0 * @access protected * * @param array $settings Settings. * @param int $id Post ID. */ protected function save_settings_to_db( array $settings, $id ) { $model_controls = Model::get_controls_list(); $one_list_settings = []; foreach ( $model_controls as $tab_name => $sections ) { foreach ( $sections as $section_name => $section_data ) { foreach ( $section_data['controls'] as $control_name => $control_data ) { if ( isset( $settings[ $control_name ] ) ) { $one_list_control_name = str_replace( 'elementor_', '', $control_name ); $one_list_settings[ $one_list_control_name ] = $settings[ $control_name ]; update_option( $control_name, $settings[ $control_name ] ); } else { delete_option( $control_name ); } } } } // Save all settings in one list for a future usage if ( ! empty( $one_list_settings ) ) { update_option( self::META_KEY, $one_list_settings ); } else { delete_option( self::META_KEY ); } } /** * Get model for CSS file. * * Retrieve the model for the CSS file. * * @since 1.6.0 * @access protected * * @param Base $css_file The requested CSS file. * * @return BaseModel The model object. */ protected function get_model_for_css_file( Base $css_file ) { return $this->get_model(); } /** * Get CSS file for update. * * Retrieve the CSS file before updating the it. * * @since 1.6.0 * @access protected * * @param int $id Post ID. * * @return Global_CSS The global CSS file object. */ protected function get_css_file_for_update( $id ) { return Global_CSS::create( 'global.css' ); } /** * Add panel tabs. * * Register new panel tab for the lightbox settings. * * @since 1.6.0 * @access private */ private function add_panel_tabs() { Controls_Manager::add_tab( self::PANEL_TAB_LIGHTBOX, __( 'Lightbox', 'elementor' ) ); } } PK4\jcS|jjpage/model.phpnuW+Apost = get_post( $data['id'] ); if ( ! $this->post ) { $this->post = new \WP_Post( (object) [] ); } if ( wp_is_post_revision( $this->post->ID ) ) { $this->post_parent = get_post( $this->post->post_parent ); } else { $this->post_parent = $this->post; } parent::__construct( $data ); } /** * Get model name. * * Retrieve page settings model name. * * @since 1.6.0 * @access public * * @return string Model name. */ public function get_name() { return 'page-settings'; } /** * Get model unique name. * * Retrieve page settings model unique name. * * @since 1.6.0 * @access public * * @return string Model unique name. */ public function get_unique_name() { return $this->get_name() . '-' . $this->post->ID; } /** * Get CSS wrapper selector. * * Retrieve the wrapper selector for the page settings model. * * @since 1.6.0 * @access public * * @return string CSS wrapper selector. */ public function get_css_wrapper_selector() { $document = Plugin::$instance->documents->get( $this->post_parent->ID ); return $document->get_css_wrapper_selector(); } /** * Get panel page settings. * * Retrieve the panel setting for the page settings model. * * @since 1.6.0 * @access public * * @return array { * Panel settings. * * @type string $title The panel title. * } */ public function get_panel_page_settings() { $document = Plugin::$instance->documents->get( $this->post->ID ); return [ /* translators: %s: Document title */ 'title' => sprintf( __( '%s Settings', 'elementor' ), $document::get_title() ), ]; } /** * On export post meta. * * When exporting data, check if the post is not using page template and * exclude it from the exported Elementor data. * * @since 1.6.0 * @access public * * @param array $element_data Element data. * * @return array Element data to be exported. */ public function on_export( $element_data ) { if ( ! empty( $element_data['settings']['template'] ) ) { /** * @var \Elementor\Modules\PageTemplates\Module $page_templates_module */ $page_templates_module = Plugin::$instance->modules_manager->get_modules( 'page-templates' ); $is_elementor_template = ! ! $page_templates_module->get_template_path( $element_data['settings']['template'] ); if ( ! $is_elementor_template ) { unset( $element_data['settings']['template'] ); } } return $element_data; } /** * Register model controls. * * Used to add new controls to the page settings model. * * @since 1.6.0 * @access protected */ protected function _register_controls() { // Check if it's a real model, or abstract (for example - on import ) if ( $this->post->ID ) { $document = Plugin::$instance->documents->get_doc_or_auto_save( $this->post->ID ); if ( $document ) { $controls = $document->get_controls(); foreach ( $controls as $control_id => $args ) { $this->add_control( $control_id, $args ); } } } } } PK4\p>!!page/manager.phpnuW+Aeditor->is_edit_mode() ) { return null; } if ( Plugin::$instance->editor->is_edit_mode() ) { $post_id = Plugin::$instance->editor->get_post_id(); $document = Plugin::$instance->documents->get_doc_or_auto_save( $post_id ); } else { $post_id = get_the_ID(); $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id ); } if ( ! $document ) { return null; } $model = $this->get_model( $document->get_post()->ID ); if ( $document->is_autosave() ) { $model->set_settings( 'post_status', $document->get_main_post()->post_status ); } return $model; } /** * Ajax before saving settings. * * Validate the data before saving it and updating the data in the database. * * @since 1.6.0 * @access public * * @param array $data Post data. * @param int $id Post ID. * * @throws \Exception If invalid post returned using the `$id`. * @throws \Exception If current user don't have permissions to edit the post. */ public function ajax_before_save_settings( array $data, $id ) { $post = get_post( $id ); if ( empty( $post ) ) { throw new \Exception( 'Invalid post.', Exceptions::NOT_FOUND ); } if ( ! current_user_can( 'edit_post', $id ) ) { throw new \Exception( 'Access denied.', Exceptions::FORBIDDEN ); } // Avoid save empty post title. if ( ! empty( $data['post_title'] ) ) { $post->post_title = $data['post_title']; } if ( isset( $data['post_excerpt'] ) && post_type_supports( $post->post_type, 'excerpt' ) ) { $post->post_excerpt = $data['post_excerpt']; } if ( isset( $data['post_status'] ) ) { $this->save_post_status( $id, $data['post_status'] ); unset( $post->post_status ); } wp_update_post( $post ); // Check updated status if ( DB::STATUS_PUBLISH === get_post_status( $id ) ) { $autosave = wp_get_post_autosave( $post->ID ); if ( $autosave ) { wp_delete_post_revision( $autosave->ID ); } } if ( isset( $data['post_featured_image'] ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { if ( empty( $data['post_featured_image']['id'] ) ) { delete_post_thumbnail( $post->ID ); } else { set_post_thumbnail( $post->ID, $data['post_featured_image']['id'] ); } } if ( Utils::is_cpt_custom_templates_supported() ) { $template = get_metadata( 'post', $post->ID, '_wp_page_template', true ); if ( isset( $data['template'] ) ) { $template = $data['template']; } if ( empty( $template ) ) { $template = 'default'; } // Use `update_metadata` in order to save also for revisions. update_metadata( 'post', $post->ID, '_wp_page_template', $template ); } } /** * @inheritDoc * * Override parent because the page setting moved to document.settings. */ protected function print_editor_template_content( $name ) { ?> <# const tabs = elementor.config.document.settings.tabs; if ( Object.values( tabs ).length > 1 ) { #>
<# _.each( tabs, function( tabTitle, tabSlug ) { #> <# } ); #>
<# } #>
get_post_id(); if ( $css_file instanceof Post_Preview ) { $autosave = Utils::get_post_autosave( $post_id ); if ( $autosave ) { $post_id = $autosave->ID; } } return $this->get_model( $post_id ); } /** * Get special settings names. * * Retrieve the names of the special settings that are not saved as regular * settings. Those settings have a separate saving process. * * @since 1.6.0 * @access protected * * @return array Special settings names. */ protected function get_special_settings_names() { return [ 'id', 'post_title', 'post_status', 'template', 'post_excerpt', 'post_featured_image', ]; } /** * @since 2.0.0 * @access public * * @param $post_id * @param $status */ public function save_post_status( $post_id, $status ) { $parent_id = wp_is_post_revision( $post_id ); if ( $parent_id ) { // Don't update revisions post-status return; } $parent_id = $post_id; $post = get_post( $parent_id ); $allowed_post_statuses = get_post_statuses(); if ( isset( $allowed_post_statuses[ $status ] ) ) { $post_type_object = get_post_type_object( $post->post_type ); if ( 'publish' !== $status || current_user_can( $post_type_object->cap->publish_posts ) ) { $post->post_status = $status; } } wp_update_post( $post ); } } PK4\a ``editor-preferences/model.phpnuW+A __( 'Editor Preferences', 'elementor' ), ]; } /** * @since 2.8.0 * @access protected */ protected function _register_controls() { $this->start_controls_section( 'preferences', [ 'tab' => Controls_Manager::TAB_SETTINGS, 'label' => __( 'Preferences', 'elementor' ), ] ); $this->add_control( 'ui_theme', [ 'label' => __( 'UI Theme', 'elementor' ), 'type' => Controls_Manager::SELECT, 'description' => __( 'Set light or dark mode, or use Auto Detect to sync it with your OS setting.', 'elementor' ), 'default' => 'auto', 'options' => [ 'auto' => __( 'Auto Detect', 'elementor' ), 'light' => __( 'Light', 'elementor' ), 'dark' => __( 'Dark', 'elementor' ), ], ] ); $this->add_control( 'edit_buttons', [ 'label' => __( 'Editing Handles', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'description' => __( 'Show editing handles when hovering over the element edit button.', 'elementor' ), ] ); $this->add_control( 'lightbox_in_editor', [ 'label' => __( 'Enable Lightbox In Editor', 'elementor' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->end_controls_section(); } } PK4\SԲeditor-preferences/manager.phpnuW+Aget_model(); } /** * Get manager name. * * Retrieve settings manager name. * * @since 2.8.0 * @access public */ public function get_name() { return 'editorPreferences'; } /** * Get saved settings. * * Retrieve the saved settings from the database. * * @since 2.8.0 * @access protected * * @param int $id. * @return array * */ protected function get_saved_settings( $id ) { $settings = get_user_meta( get_current_user_id(), self::META_KEY, true ); if ( ! $settings ) { $settings = []; } return $settings; } /** * Save settings to DB. * * Save settings to the database. * * @param array $settings Settings. * @param int $id Post ID. * @since 2.8.0 * @access protected * */ protected function save_settings_to_db( array $settings, $id ) { update_user_meta( get_current_user_id(), self::META_KEY, $settings ); } } PK^\|MXBXBclass-ld-settings-pages.phpnuW+A string * * @var string $settings_page_title */ protected $settings_page_title = ''; /** * Title for tab string * * @var string $settings_tab_title */ protected $settings_tab_title = ''; /** * Priority for tab * * @var integer $settings_tab_priority */ protected $settings_tab_priority = 30; /** * The number of columns to show. Most admin screens will be 2. But we set to 1 for the initial. * * @var integer $settings_columns */ protected $settings_columns = 2; /** * Wether to show the Submit metabox. * * @var boolean $show_submit_meta */ protected $show_submit_meta = true; /** * Wether to show the Quick Links metabox. * * @var boolean $show_quick_links_meta */ protected $show_quick_links_meta = true; /** * Wether to show wrap all settings in a
. * * @var boolean $settings_form_wrap */ protected $settings_form_wrap = true; /** * Public constructor for class */ public function __construct() { global $learndash_pages; add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'learndash_admin_tabs_set', array( $this, 'admin_tabs' ), 10 ); if ( empty( $this->settings_tab_title ) ) { $this->settings_tab_title = $this->settings_page_title; } if ( ( ! empty( $this->settings_page_id ) ) && ( ! isset( $learndash_pages[ $this->settings_page_id ] ) ) ) { $learndash_pages[] = $this->settings_page_id; } } /** * Function to get a specific setting page instance. * * @since 2.4.0 * * @param string $page_key Page key to get instance of. * * @return object page instance */ final public static function get_page_instance( $page_key = '' ) { if ( ! empty( $page_key ) ) { if ( isset( self::$_instances[ $page_key ] ) ) { return self::$_instances[ $page_key ]; } } } /** * Function to set/add setting page to instances array. * * @since 2.4.0 */ final public static function add_page_instance() { $section_class = get_called_class(); if ( ! isset( self::$_instances[ $section_class ] ) ) { self::$_instances[ $section_class ] = new $section_class(); } } /** * Action hook to handle admin_init processing from WP. */ public function admin_init() { do_action( 'learndash_settings_page_init', $this->settings_page_id ); if ( true === $this->show_submit_meta ) { $submit_obj = new LearnDash_Settings_Section_Side_Submit( array( 'settings_screen_id' => $this->settings_screen_id, 'settings_page_id' => $this->settings_page_id, ) ); } if ( true === $this->show_quick_links_meta ) { $ql_obj = new LearnDash_Settings_Section_Side_Quick_Links( array( 'settings_screen_id' => $this->settings_screen_id, 'settings_page_id' => $this->settings_page_id, ) ); } } /** * Action hook to handle admin_menu processing from WP. */ public function admin_menu() { if ( ! $this->settings_screen_id ) { $this->settings_screen_id = add_submenu_page( $this->parent_menu_page_url, $this->settings_page_title, $this->settings_page_title, $this->menu_page_capability, $this->settings_page_id, array( $this, 'show_settings_page' ) ); } add_action( 'load-' . $this->settings_screen_id, array( $this, 'load_settings_page' ) ); } /** * Action hook to handle admin_tabs processing from LearnDash. * * @param string $admin_menu_section Current admin menu section. */ public function admin_tabs( $admin_menu_section ) { if ( $admin_menu_section === $this->parent_menu_page_url ) { learndash_add_admin_tab_item( $this->parent_menu_page_url, array( 'id' => $this->settings_screen_id, 'link' => add_query_arg( array( 'page' => $this->settings_page_id ), 'admin.php' ), 'cap' => $this->menu_page_capability, 'name' => ! empty( $this->settings_tab_title ) ? $this->settings_tab_title : $this->settings_page_title, ), $this->settings_tab_priority ); } } /** * Action hook to handle current settings page load. */ public function load_settings_page() { global $learndash_assets_loaded; if ( defined( 'LEARNDASH_SETTINGS_SECTION_TYPE' ) && ( 'metabox' === LEARNDASH_SETTINGS_SECTION_TYPE ) ) { wp_enqueue_script( 'common' ); wp_enqueue_script( 'wp-lists' ); wp_enqueue_script( 'postbox' ); do_action( 'learndash_add_meta_boxes', $this->settings_screen_id ); add_action( 'admin_footer-' . $this->settings_screen_id, array( $this, 'load_footer_scripts' ) ); add_filter( 'screen_layout_columns', array( $this, 'screen_layout_column' ), 10, 2 ); } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_media(); wp_enqueue_style( 'learndash_style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/style' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash_style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash_style'] = __FUNCTION__; wp_enqueue_style( 'sfwd-module-style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/sfwd_module' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'sfwd-module-style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['sfwd-module-style'] = __FUNCTION__; wp_enqueue_script( 'sfwd-module-script', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/sfwd_module' . leardash_min_asset() . '.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['sfwd-module-script'] = __FUNCTION__; wp_localize_script( 'sfwd-module-script', 'sfwd_data', array() ); learndash_admin_settings_page_assets(); if ( isset( $_GET['ld_reset_metaboxes'] ) ) { delete_user_meta( get_current_user_id(), 'closedpostboxes_' . $this->settings_screen_id ); delete_user_meta( get_current_user_id(), 'metaboxhidden_' . $this->settings_screen_id ); delete_user_meta( get_current_user_id(), 'meta-box-order_' . $this->settings_screen_id ); } do_action( 'learndash-settings-page-load', $this->settings_screen_id, $this->settings_page_id ); } /** * Action hook to handle current settings page layout columns. * * @param integer $columns Number of columns to show. * @param Object $screen Current screen object. * * @return integer $columns */ public function screen_layout_column( $columns = false, $screen_id = '' ) { if ( $screen_id == $this->settings_screen_id ) { $columns[ $screen_id ] = $this->settings_columns; } /** * Add this filter to override the get user option logic. This is to force * the screen layout option for user who don't have this defined. * * @since 2.6.0 */ add_filter( "get_user_option_screen_layout_{$screen_id}", function( $option_value = '', $option_key = '' ) { if ( "screen_layout_{$this->settings_screen_id}" === $option_key ) { $option_value = $this->settings_columns; } return $option_value; }, 1, 2 ); return $columns; } /** * Action hook to handle footer JS/CSS added footer */ public function load_footer_scripts() { ?> settings_screen_id, $this->settings_page_id ); } /** * Fucntion to handle showing of Settings page. This is the main function for all visible * output. Extending classes can implement its own function. */ public function show_settings_page() { if ( defined( 'LEARNDASH_SETTINGS_SECTION_TYPE' ) && ( 'metabox' === LEARNDASH_SETTINGS_SECTION_TYPE ) ) { ?>
settings_screen_id, $this->settings_page_id ); ?> get_admin_page_title(); ?> settings_screen_id, $this->settings_page_id ); ?> settings_screen_id, $this->settings_page_id ); ?> get_admin_page_form( true ); ?> settings_screen_id, $this->settings_page_id ); ?> settings_page_id ); ?>
settings_screen_id, 'side', null ); ?>
settings_screen_id, $this->settings_page_id ); ?> settings_screen_id, 'normal', null ); ?> settings_screen_id, 'advanced', null ); ?> settings_screen_id, $this->settings_page_id ); ?>

settings_screen_id, $this->settings_page_id ); ?> get_admin_page_form( false ); ?> settings_screen_id, $this->settings_page_id ); ?>
get_admin_page_title(); ?> get_admin_page_form( true ); ?> settings_page_id ); do_settings_sections( $this->settings_page_id ); ?> get_admin_page_form( false ); ?>
' . esc_html( get_admin_page_title() ) . '' ); } else { return '

'; } } /** * Class utility function to return the form wrapper. Supports * the beginning
an ending
. * * @param boolean $start Flag to indicate if showing start or end of form. * * @return string form HTML. */ public function get_admin_page_form( $start = true ) { if ( true === $this->settings_form_wrap ) { if ( true === $start ) { return apply_filters( 'learndash_admin_page_form', '
', $start ); } else { return apply_filters( 'learndash_admin_page_form', '
', $start ); } } } // End of functions. } } function learndash_admin_settings_page_assets() { global $learndash_assets_loaded; if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { if ( ! isset( $learndash_assets_loaded['styles']['learndash-select2-jquery-style'] ) ) { wp_enqueue_style( 'learndash-select2-jquery-style', LEARNDASH_LMS_PLUGIN_URL . 'assets/vendor/select2-jquery/css/select2.min.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); //wp_style_add_data( 'learndash-select2-jquery-style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-select2-jquery-style'] = __FUNCTION__; } if ( ! isset( $learndash_assets_loaded['scripts']['learndash-select2-jquery-script'] ) ) { wp_enqueue_script( 'learndash-select2-jquery-script', LEARNDASH_LMS_PLUGIN_URL . 'assets/vendor/select2-jquery/js/select2.min.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['learndash-select2-jquery-script'] = __FUNCTION__; } } if ( ! isset( $learndash_assets_loaded['styles']['learndash-admin-settings-page'] ) ) { wp_enqueue_style( 'learndash-admin-settings-page', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-settings-page' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash-admin-settings-page', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-admin-settings-page'] = __FUNCTION__; } if ( ! isset( $learndash_assets_loaded['scripts']['learndash-admin-settings-page'] ) ) { wp_enqueue_script( 'learndash-admin-settings-page', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-settings-page' . leardash_min_asset() . '.js', array( 'jquery', 'wp-color-picker' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['learndash-admin-settings-page'] = __FUNCTION__; $script_data = array(); $script_data = apply_filters( 'learndash_admin_settings_data', $script_data ); if ( ( empty( $script_data ) ) || ( ! is_array( $script_data ) ) ) { $script_data = array(); } if ( ! isset( $script_data['ajaxurl'] ) ) { $script_data['ajaxurl'] = admin_url( 'admin-ajax.php' ); } if ( ! isset( $script_data['admin_notice_settings_fields_errors'] ) ) { $script_data['admin_notice_settings_fields_errors_container'] = '

' . esc_html__( 'You have errors on the following settings', 'learndash' ) . '

'; } $script_data = array( 'json' => json_encode( $script_data ) ); wp_localize_script( 'learndash-admin-settings-page', 'learndash_admin_settings_data', $script_data ); } }PK^\>+66 class-ld-shortcodes-sections.phpnuW+Ainit_shortcodes_section_fields(); } /** * Initialize the Shortcodes Fields. */ public function init_shortcodes_section_fields() { foreach ( $this->shortcodes_option_fields as $field_id => $setting_option_field ) { if ( ! isset( $setting_option_field['label_for'] ) ) { $setting_option_field['label_for'] = $setting_option_field['id']; } if ( ! isset( $setting_option_field['label_for'] ) ) { $setting_option_field['label_for'] = $setting_option_field['id']; } $setting_option_field['setting_option_key'] = $setting_option_field['id']; if ( ! isset( $setting_option_field['display_callback'] ) ) { $display_ref = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] ); if ( ! $display_ref ) { $setting_option_field['display_callback'] = array( $this, 'field_element_create' ); } else { $setting_option_field['display_callback'] = array( $display_ref, 'create_section_field' ); } } $this->shortcodes_settings_fields[ $field_id ] = array( 'id' => $setting_option_field['id'], 'title' => $setting_option_field['label'], 'callback' => $setting_option_field['display_callback'], 'args' => $setting_option_field, ); } } /** * Section Fields Create. * * @param array $fields_args Field Args. */ public function field_element_create( $field_args = array() ) { $field_html = ''; if ( ( isset( $field_args['display_func'] ) ) && ( ! empty( $field_args['display_func'] ) ) && ( is_callable( $field_args['display_func'] ) ) ) { call_user_func( $field_args['display_func'], $field_args, $this->setting_field_prefix ); } } /** * Show Section Fields. */ public function show_section_fields() { $this->show_shortcodes_section_header(); echo LearnDash_Settings_Fields::show_section_fields( $this->shortcodes_settings_fields ); $this->show_shortcodes_section_footer(); } /** * Show Section Header. */ public function show_shortcodes_section_header() { ?>
show_shortcodes_section_title(); ?> show_shortcodes_section_description(); ?>
show_shortcodes_section_footer_extra(); ?>

to allow adding JS/CSS } /** * Get Section Key. */ public function get_shortcodes_section_key() { return $this->shortcodes_section_key; } /** * Get Section Title. */ public function get_shortcodes_section_title() { return $this->shortcodes_section_title; } /** * Show Section Key. */ public function show_shortcodes_section_title() { if ( ! empty( $this->shortcodes_section_title ) ) { ?>

shortcodes_section_title; ?> [shortcodes_section_key; ?>]

shortcodes_section_description; } /** * Show Section Description. */ public function show_shortcodes_section_description() { if ( ! empty( $this->shortcodes_section_description ) ) { echo wpautop( $this->shortcodes_section_description ); } } /** * Get Shortcode field by key; */ public function get_shortcodes_section_field( $field_key = '' ) { if ( ( ! empty( $field_key ) ) && ( isset( $this->shortcodes_option_fields[ $field_key ] ) ) ) { return $this->shortcodes_option_fields[ $field_key ]; } } } } PK^\s7settings-pages/class-ld-settings-page-data-upgrades.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_data_upgrades'; $this->settings_page_title = esc_html__( 'Data Upgrades', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 30; $this->settings_columns = 1; $this->show_submit_meta = false; $this->show_quick_links_meta = false; parent::__construct(); } /** * Action function called when Add-ons page is loaded. * * @since 2.5.5 */ public function load_settings_page() { global $learndash_assets_loaded; parent::load_settings_page(); wp_enqueue_style( 'learndash-admin-style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-style' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash-admin-style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-admin-style'] = __FUNCTION__; wp_enqueue_script( 'learndash-admin-settings-data-upgrades-script', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-settings-data-upgrades' . leardash_min_asset() . '.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['learndash-admin-settings-data-upgrades-script'] = __FUNCTION__; } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Data_Upgrades::add_page_instance(); } ); PK^\Aź9settings-pages/class-ld-settings-page-quizzes-options.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-quiz'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'quizzes-options'; $this->settings_tab_priority = 10; $this->settings_page_title = esc_html_x( 'Settings', 'Quiz Settings', 'learndash' ); $this->show_submit_meta = true; $this->show_quick_links_meta = true; parent::__construct(); } /** * Action hook to handle admin_tabs processing from LearnDash. * * @param string $admin_menu_section Current admin menu section. */ public function admin_tabs( $admin_menu_section ) { if ( ( $admin_menu_section === $this->parent_menu_page_url ) || ( 'edit.php?post_type=sfwd-essays' ) ) { learndash_add_admin_tab_item( $this->parent_menu_page_url, array( 'id' => $this->settings_screen_id, 'link' => add_query_arg( array( 'page' => $this->settings_page_id ), 'admin.php' ), 'name' => ! empty( $this->settings_tab_title ) ? $this->settings_tab_title : $this->settings_page_title, ), $this->settings_tab_priority ); } } // End of functions. } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Quizzes_Options::add_page_instance(); } ); PK^\ir3||@settings-pages/class-ld-settings-page-quizzes-builder-single.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-quiz'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'quizzes-builder'; $this->settings_page_title = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Builder', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->settings_tab_title = $this->settings_page_title; add_action( 'load-sfwd-quiz_page_quizzes-builder', array( $this, 'on_load' ) ); add_filter( 'post_row_actions', array( $this, 'learndash_quiz_row_actions' ), 20, 2 ); add_filter( 'learndash_admin_tab_sets', array( $this, 'admin_tab_sets' ), 15, 2 ); add_action( 'admin_notices', array( $this, 'admin_notice' ) ); parent::__construct(); } /** * Action function called after title is displayed. * * @since 2.4.0 * * @param string $settings_screen_id Current screen ID. */ public function settings_page_after_title( $settings_screen_id = '' ) { if ( $this->settings_screen_id == $settings_screen_id ) { if ( ( isset( $_GET['quiz_id'] ) ) && ( ! empty( $_GET['quiz_id'] ) ) ) { $quiz_id = intval( $_GET['quiz_id'] ); $quiz_post = get_post( $quiz_id ); if ( ( $quiz_post ) && ( is_a( $quiz_post, 'WP_Post' ) ) && ( learndash_get_post_type_slug( 'quiz' ) === $quiz_post->post_type ) ) { ?>

post_title; ?>

', $start ); } else { return apply_filters( 'learndash_admin_page_form', '', $start ); } } /** * Action hook when settings screen is being shown. */ public function on_load() { if ( is_admin() ) { // If the Course Builder screen is being shown... $current_screen = get_current_screen(); if ( 'sfwd-quiz_page_quizzes-builder' === $current_screen->id ) { // ...but the 'course_id' query parameters is not found... if ( ( ! isset( $_GET['quiz_id'] ) ) || ( empty( $_GET['quiz_id'] ) ) ) { // ...then redirect back to the courses listin screen. $quizzes_list_url = add_query_arg( 'post_type', 'sfwd-quiz', admin_url( 'edit.php' ) ); wp_safe_redirect( $quizzes_list_url ); } else { $this->cb = Learndash_Admin_Metabox_Quiz_Builder::add_instance( 'Learndash_Admin_Metabox_Quiz_Builder' ); $this->save_cb_metabox(); $this->cb->builder_on_load(); } } } } /** * Called when metabox is being saved. */ public function save_cb_metabox() { if ( ( isset( $_GET['quiz_id'] ) ) && ( ! empty( $_GET['quiz_id'] ) ) ) { $quiz_id = intval( $_GET['quiz_id'] ); $quiz_post = get_post( $quiz_id ); if ( ( $quiz_post ) && ( is_a( $quiz_post, 'WP_Post' ) ) && ( learndash_get_post_type_slug( 'quiz' ) === $quiz_post->post_type ) ) { $this->update_success = $this->cb->save_course_builder( $quiz_id, $quiz_post, true ); } } } /** * Function to show admin notices on settings page. */ public function admin_notice() { if ( true === $this->update_success ) { ?>

%s', add_query_arg( array( 'currentTab' => 'learndash_quiz_builder', ), get_edit_post_link( $quiz_post->ID ) ), esc_attr( $quiz_label ), esc_html__( 'Builder', 'learndash' ) ); } } } return $row_actions; } /** * Filter the LearnDash admin menu (tabs). We remove the 'Course Builder' tab until needed. * * @since 2.5.0 * * @param array $admin_menu_set Current Menu set array. * @param string $admin_menu_key Current menu key. * * @return array $admin_menu_set */ public function admin_tab_sets( $admin_menu_set = array(), $admin_menu_key = '' ) { if ( 'edit.php?post_type=' . learndash_get_post_type_slug( 'quiz' ) === $admin_menu_key ) { if ( ( ! isset( $_GET['quiz_id'] ) ) || ( empty( $_GET['quiz_id'] ) ) ) { // If we don't have the 'course_id' URL parameter then we remove the tab. foreach ( $admin_menu_set as $menu_idx => $menu_item ) { if ( 'sfwd-quiz_page_quizzes-builder' === $menu_item['id'] ) { unset( $admin_menu_set[ $menu_idx ] ); break; } } } else { // Else of we do have the 'quiz_id' URL parameter we include this in the tab URL. foreach ( $admin_menu_set as $menu_idx => &$menu_item ) { if ( 'sfwd-quiz_page_quizzes-builder' === $menu_item['id'] ) { $menu_item['link'] = add_query_arg( 'quiz_id', intval( $_GET['quiz_id'] ), $menu_item['link'] ); break; } } } } return $admin_menu_set; } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Quiz_Builder_Single::add_page_instance(); } ); PK^\Fh  7settings-pages/class-ld-settings-page-custom-labels.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_settings_custom_labels'; $this->settings_page_title = esc_html__( 'Custom Labels', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 20; $this->show_quick_links_meta = false; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Custom_Labels::add_page_instance(); } ); PK^\parent_menu_page_url = 'admin.php?page=learndash_lms_addons'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_addons'; $this->settings_page_title = esc_html__( 'LearnDash Add-ons', 'learndash' ); $this->settings_tab_title = esc_html__( 'Add-ons', 'learndash' ); $this->settings_tab_priority = 0; // Override action with custom plugins function for add-ons. add_action( 'install_plugins_pre_plugin-information', array( $this, 'shows_addon_plugin_information' ) ); add_filter( 'learndash_submenu_last', array( $this, 'submenu_item' ), 200 ); add_filter( 'learndash_admin_tab_sets', array( $this, 'learndash_admin_tab_sets' ), 10, 3 ); add_filter( 'learndash_header_data', array( $this, 'admin_header' ), 40, 3 ); parent::__construct(); } /** * Control visibility of submenu items based on lisence status * * @since 2.5.5 * * @param array $submenu Submenu item to check. * @return array $submenu */ public function submenu_item( $submenu ) { if ( ! isset( $submenu[ $this->settings_page_id ] ) ) { if ( is_learndash_license_valid() ) { $submenu[ $this->settings_page_id ] = array( 'name' => $this->settings_tab_title, 'cap' => $this->menu_page_capability, 'link' => $this->parent_menu_page_url, ); } } return $submenu; } /** * Filter the admin header data. We don't want to show the header panel on the Overview page. * * @since 3.0 * @param array $header_data Array of header data used by the Header Panel React app. * @param string $menu_key The menu key being displayed. * @param array $menu_items Array of menu/tab items. * * @return array $header_data. */ public function admin_header( $header_data = array(), $menu_key = '', $menu_items = array() ) { // Clear out $header_data if we are showing our page. if ( $menu_key === $this->parent_menu_page_url ) { $header_data = array(); } return $header_data; } /** * Filter for page title wrapper. * * @since 2.5.5 */ public function get_admin_page_title() { return apply_filters( 'learndash_admin_page_title', '

' . $this->settings_page_title . '

' ); } /** * Action function called when Add-ons page is loaded. * * @since 2.5.5 */ public function load_settings_page() { $license_status = get_option( 'nss_plugin_remote_license_sfwd_lms' ); if ( isset( $license_status['value'] ) ) { $license_status = $license_status['value']; if ( ! empty( $license_status ) && ( 'false' !== $license_status ) && ( 'not_found' !== $license_status ) ) { require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/admin/class-learndash-admin-addons-list-table.php'; wp_enqueue_style( 'plugin-install' ); wp_enqueue_script( 'plugin-install' ); wp_enqueue_script( 'updates' ); add_thickbox(); return; } } $overview_url = add_query_arg( 'page', 'learndash_lms_overview', admin_url( 'admin.php' ) ); wp_safe_redirect( $overview_url ); exit(); } /** * Hide the tab menu items if on add-one page. * * @since 2.5.5 * * @param array $tab_set Tab Set. * @param string $tab_key Tab Key. * @param string $current_page_id ID of shown page. * * @return array $tab_set */ public function learndash_admin_tab_sets( $tab_set = array(), $tab_key = '', $current_page_id = '' ) { if ( ( ! empty( $tab_set ) ) && ( ! empty( $tab_key ) ) && ( ! empty( $current_page_id ) ) ) { if ( 'admin_page_learndash_lms_addons' === $current_page_id ) { ?>
settings_screen_id ); ?> get_admin_page_title(); ?> settings_screen_id ); ?> settings_screen_id ); ?>
get_admin_page_form( true ); ?> settings_screen_id ); ?> prepare_items(); $wp_list_table->views(); $wp_list_table->display(); ?> settings_screen_id ); ?> get_admin_page_form( false ); ?>
settings_screen_id ); ?>
get_plugin_information( esc_attr( $_REQUEST['plugin'] ) ); if ( empty( $plugin_readme_information ) ) { return; } $api = new StdClass(); foreach ( $plugin_readme_information as $_k => $_s ) { $api->$_k = $_s; } $plugins_allowedtags = array( 'a' => array( 'href' => array(), 'title' => array(), 'target' => array(), ), 'abbr' => array( 'title' => array(), ), 'acronym' => array( 'title' => array(), ), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'div' => array( 'class' => array(), ), 'span' => array( 'class' => array(), ), 'p' => array(), 'br' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array(), ), 'blockquote' => array( 'cite' => true, ), ); $plugins_section_titles = array( 'description' => _x( 'Description', 'Plugin installer section title', 'learndash' ), 'installation' => _x( 'Installation', 'Plugin installer section title', 'learndash' ), 'faq' => _x( 'FAQ', 'Plugin installer section title', 'learndash' ), 'screenshots' => _x( 'Screenshots', 'Plugin installer section title', 'learndash' ), 'changelog' => _x( 'Changelog', 'Plugin installer section title', 'learndash' ), 'reviews' => _x( 'Reviews', 'Plugin installer section title', 'learndash' ), 'other_notes' => _x( 'Other Notes', 'Plugin installer section title', 'learndash' ), ); // Sanitize HTML. foreach ( (array) $api->sections as $section_name => $content ) { $api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags ); } foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { if ( isset( $api->$key ) ) { $api->$key = wp_kses( $api->$key, $plugins_allowedtags ); } } $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { $section_titles = array_keys( (array) $api->sections ); $section = reset( $section_titles ); } if ( ( isset( $_GET['tab'] ) ) && ( ! empty( $_GET['tab'] ) ) ) { $tab = esc_attr( $_GET['tab'] ); } else { $tab = 'plugin-information'; } $_tab = $tab; $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { $section_titles = array_keys( (array) $api->sections ); $section = reset( $section_titles ); } iframe_header( __( 'Plugin Installation', 'learndash' ) ); $_with_banner = ''; if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { $_with_banner = 'with-banner'; $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; ?> '; echo "

{$api->name}

"; echo "
\n"; foreach ( (array) $api->sections as $section_name => $content ) { if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { continue; } if ( isset( $plugins_section_titles[ $section_name ] ) ) { $title = $plugins_section_titles[ $section_name ]; } else { $title = ucwords( str_replace( '_', ' ', $section_name ) ); } $class = ( $section_name === $section ) ? ' class="current"' : ''; $href = add_query_arg( array( 'tab' => $tab, 'section' => $section_name, ) ); $href = esc_url( $href ); $san_section = esc_attr( $section_name ); echo "\t$title\n"; } echo "
\n"; ?>
    version ) ) { ?>
  • version; ?>
  • author ) ) { ?>
  • author, '_blank' ); ?>
  • last_updated ) ) { ?>
  • last_updated ) ) ); ?>
  • requires ) ) { ?>
  • requires ); ?>
  • tested ) ) { ?>
  • tested; ?>
  • active_installs ) ) { ?>
  • active_installs >= 1000000 ) { _ex( '1+ Million', 'Active plugin installations', 'default' ); } elseif ( 0 == $api->active_installs ) { _ex( 'Less Than 10', 'Active plugin installations', 'default' ); } else { echo number_format_i18n( $api->active_installs ) . '+'; } ?>
  • slug ) && empty( $api->external ) ) { ?>
  • homepage ) ) { ?>
  • donate_link ) && empty( $api->contributors ) ) { ?>
rating ) ) { ?>

$api->rating, 'type' => 'percent', 'number' => $api->num_ratings, ) ); ?> ratings ) && array_sum( (array) $api->ratings ) > 0 ) { ?>

ratings as $key => $ratecount ) { // Avoid div-by-zero. $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; /* translators: 1: number of stars (used to determine singular/plural), 2: number of reviews */ $aria_label = esc_attr( sprintf( _n( 'Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key ), $key, number_format_i18n( $ratecount ), 'default' ) ); ?>
contributors ) ) { ?>

    contributors as $contrib_username => $contrib_profile ) { if ( empty( $contrib_username ) && empty( $contrib_profile ) ) { continue; } if ( empty( $contrib_username ) ) { $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile ); } $contrib_username = sanitize_user( $contrib_username ); if ( empty( $contrib_profile ) ) { echo "
  • {$contrib_username}
  • "; } else { echo "
  • {$contrib_username}
  • "; } } ?>
donate_link ) ) { ?>
tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { echo '

' . __( 'Warning: This plugin has not been tested with your current version of WordPress.', 'default' ) . '

'; } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { echo '

' . __( 'Warning: This plugin has not been marked as compatible with your version of WordPress.', 'default' ) . '

'; } foreach ( (array) $api->sections as $section_name => $content ) { $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); $content = links_add_target( $content, '_blank' ); $san_section = esc_attr( $section_name ); $display = ( $section_name === $section ) ? 'block' : 'none'; echo "\t
\n"; echo $content; echo "\t
\n"; } echo "
\n"; echo "
\n"; echo "\n"; // #plugin-information-scrollable echo "\n"; iframe_footer(); exit; } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Addons::add_page_instance(); } ); PK^\s _ _<settings-pages/class-ld-settings-page-courses-shortcodes.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-courses'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'courses-shortcodes'; // translators: Course Shortcodes Label $this->settings_page_title = esc_html_x( 'Shortcodes', 'Course Shortcodes Label', 'learndash' ); $this->settings_columns = 1; $this->show_quick_links_meta = false; parent::__construct(); } /** * Show settiings page output. */ public function show_settings_page() { ?>

' . esc_html__( 'Shortcode Options', 'learndash' ) . '

' . sprintf( // translators: placeholders: course, lesson, quiz. esc_html_x( 'You may use shortcodes to add information to any page/%1$s/%2$s/%3$s. Here are built-in shortcodes for displaying relavent user information.', 'placeholders: course, lesson, quiz', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'quiz' ) ) . '

[ld_profile]

' . sprintf( // translators: placeholder: courses, course, quiz. esc_html_x( 'Displays user\'s enrolled %1$s, %2$s progress, %3$s scores, and achieved certificates. This shortcode can take following parameters:', 'placeholder: courses, course, quiz', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quiz' ) ) . '

  • order: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'sets order of %1$s. Default value DESC. Possible values: DESC, ASC. Example: [ld_profile order="ASC"] shows %2$s in ascending order.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • orderby: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'sets what the list of ordered by. Default value ID. Possible values: ID, title. Example: [ld_profile orderby="title" order="ASC"] shows %s in ascending order by title.', 'placeholders: courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ) ) . '

' . wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ) . '


[ld_course_list]

' . sprintf( wp_kses_post( // translators: placeholders: courses, courses (URL slug). _x( 'This shortcode shows list of %1$s. You can use this shortcode on any page if you dont want to use the default /%2$s page. This shortcode can take following parameters:', 'placeholders: courses, courses (URL slug)', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'courses' ) ) . '

  • num: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'limits the number of %1$s displayed. Example: [ld_course_list num="10"] shows 10 %2$s.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • order: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'sets order of %1$s. Possible values: DESC, ASC. Example: [ld_course_list order="ASC"] shows %2$s in ascending order.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • orderby: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'sets what the list of ordered by. Example: [ld_course_list order="ASC" orderby="title"] shows %s in ascending order by title.', 'placeholders: courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • mycourses: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'show current user\'s %1$s. Example: [ld_course_list mycourses="true"] shows %2$s the current user has access to.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • col: ' . wp_kses_post( __( 'number of columns to show when using course grid addon. Example: [ld_course_list col="2"] shows 2 columns.', 'learndash' ) ) . '
  • '; if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'wp_post_category' ) == 'yes' ) { echo '
  • cat: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned category id. Example: [ld_course_list cat="10"] shows %2$s having category with category id 10.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • category_name: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned category slug. Example: [ld_course_list category_name="math"] shows %2$s having category slug math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • '; echo '
  • categoryselector: ' . wp_kses_post( __( 'shows a course category dropdown. Example: [ld_course_list categoryselector="true"].', 'learndash' ) ) . '
  • '; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'wp_post_tag' ) == 'yes' ) { echo '
  • tag: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'shows %1$s with mentioned tag. Example: [ld_course_list tag="math"] shows %2$s having tag math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • tag_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned tag_id. Example: [ld_course_list tag_id="30"] shows %2$s having tag with tag_id 30.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • '; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'ld_course_category' ) == 'yes' ) { echo '
  • course_cat: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course category id. Example: [ld_course_list course_cat="10"] shows %2$s having course category with category id 10.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • course_category_name: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course category slug. Example: [ld_course_list course_category_name="math"] shows %2$s having course category slug math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • '; echo '
  • course_categoryselector: ' . wp_kses_post( __( 'shows a category dropdown. Example: [ld_course_list course_categoryselector="true"].', 'learndash' ) ) . '
  • '; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'ld_course_tag' ) == 'yes' ) { echo '
  • course_tag: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses _x( 'shows %1$s with mentioned course tag. Example: [ld_course_list course_tag="math"] shows %2$s having course tag math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • course_tag_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course_tag_id. Example: [ld_course_list course_tag_id="30"] shows %2$s having course tag with tag_id 30.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '
  • '; } echo '

' . wp_kses_post( __( 'See the full list of Category and Tag filtering options.', 'learndash' ) ) . '


[ld_lesson_list]

' . sprintf( wp_kses_post( // translators: placeholders: lessons. _x( 'This shortcode shows list of %s. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby, tag, tag_id, cat, category_name lesson_tag, lesson_tag_id, lesson_cat, lesson_category_name, lesson_categoryselector. See [ld_course_list] above details on using the shortcode parameters.', 'placeholders: lessons', 'learndash' ) ), learndash_get_custom_label_lower( 'lessons' ) ) . '


[ld_topic_list]

' . sprintf( wp_kses_post( // translators: placeholders: topics. _x( 'This shortcode shows list of %s. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby, tag, tag_id, cat, category_name, topic_tag, topic_tag_id, topic_cat, topic_category_name, topic_categoryselector. See [ld_course_list] above details on using the shortcode parameters.', 'placeholders: topics', 'learndash' ) ), learndash_get_custom_label_lower( 'topics' ) ) . '


[ld_quiz_list]

' . sprintf( wp_kses_post( // translators: placeholders: quizzes. _x( 'This shortcode shows list of %s. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby. See [ld_course_list] above details on using the shortcode parameters.', 'placeholders: quizzes', 'learndash' ) ), learndash_get_custom_label_lower( 'quizzes' ) ) . '


[learndash_course_progress]

' . sprintf( wp_kses_post( // translators: placeholders: course, course, lesson, quiz. _x( 'This shortcode displays users progress bar for the %1$s in any %2$s/%3$s/%4$s pages.', 'placeholders: course, course, lesson, quiz', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'quiz' ) ) . '


[visitor]

' . sprintf( wp_kses_post( // translators: placeholders: course. _x( 'This shortcode shows the content if the user is not enrolled in the %s. The shortcode can be used on any page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student does not have access to a specific %s. Example: [visitor course_id="10"]insert any content[/visitor]', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

[student]

' . sprintf( wp_kses_post( // translators: placeholders: course. _x( 'This shortcode shows the content if the user is enrolled in the %s. The shortcode can be used on any page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: [student course_id="10"]insert any content[/student]', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

[course_complete]

' . sprintf( wp_kses_post( // translators: placeholders: course. _x( 'This shortcode shows the content if the user has completed the %s. The shortcode can be used on any page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: [course_complete course_id="10"]insert any content[/course_complete]', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '
  • user_id: ' . wp_kses_post( __( 'Optional. If not provided will use current logged in user. Example: [course_complete course_id="10" user_id="456"]insert any content[/course_complete]', 'learndash' ) ) . '

[course_inprogress]

' . sprintf( wp_kses_post( // translators: placeholders: course. _x( 'This shortcode shows the content if the user has started but not completed the %s. The shortcode can be used on any page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: [course_inprogress course_id="10"]insert any content[/course_inprogress]', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '
  • user_id: ' . __( 'Optional. If not provided will use current logged in user. Example: [course_inprogress course_id="10" user_id="456"]insert any content[/course_inprogress]', 'learndash' ) . '

[course_notstarted]

' . sprintf( wp_kses_post( // translators: placeholders: course. _x( 'This shortcode shows the content if the user has access to the %s but not yet started. The shortcode can be used on any page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: [course_notstarted course_id="10"]insert any content[/course_notstarted]', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '
  • user_id: ' . wp_kses_post( __( 'Optional. If not provided will use current logged in user. Example: [course_notstarted course_id="10" user_id="456"]insert any content[/course_notstarted]', 'learndash' ) ) . '

[ld_course_info]

' . sprintf( wp_kses_post( // translators: placeholders: course, course. _x( 'This shortcode shows the %1$s for the user. This shortcode can take following parameters: user_id if not provided will assume current user. Example usage: [ld_course_info user_id="123"] will show the %2$s for the user 123', 'placeholders: course, course', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '


[ld_user_course_points]

' . sprintf( wp_kses_post( // translators: placeholders: course, course. _x( 'This shortcode shows the earned %s points for the user. This shortcode can take following parameters: user_id if not provided will assume current user. Example usage: [ld_user_course_points]', 'placeholders: course, course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '


[user_groups]

' . esc_html__( 'This shortcode displays the list of groups users are assigned to as users or leaders.', 'learndash' ) . '


[ld_group]

' . __( 'This shortcode shows the content if the user is enrolled in a specific group. Example usage: [ld_group]Welcome to the Group![/ld_group] This shortcode takes the following parameters:', 'learndash' ) . '

  • group_id: ' . wp_kses_post( __( 'Required. Show content if the student has access to a specific group. Example: [ld_group group_id="16"]insert any content[/ld_group]', 'learndash' ) ) . '

[ld_video]

' . sprintf( wp_kses_post( // translators: placeholders: Lessons, Topics _x( 'This shortcode is used on %1$s and %2$s where Video Progression is enabled. The video player will be added above the content. This shortcode allows positioning the player elsewhere within the content. This shortcode does not take any parameters.', 'placeholders: Lessons, Topics', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Custom_Label::get_label( 'topics' ) ) . '


[learndash_payment_buttons]

' . sprintf( wp_kses_post( // translators: placeholders: course, Courses. _x( 'This shortcode can show the payment buttons on any page. Example: [learndash_payment_buttons course_id="123"] shows the payment buttons for %1$s with %2$s ID: 123', 'placeholders: course, Courses','learndash' ) ), learndash_get_custom_label_lower( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ) ) . '


[course_content]

' . sprintf( wp_kses_post( // translators: placeholders: Course, lessons, topics, quizzes, course, course, course. _x( 'This shortcode displays the %1$s Content table (%2$s, %3$s, and %4$s) when inserted on a page or post. Example: [course_content course_id="123"] shows the %5$s content for %6$s with %7$s ID: 123', 'placeholders: Course, lesson, topics, quizzes, course, course, Course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'lessons' ), learndash_get_custom_label_lower( 'topics' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ) . '


[ld_course_expire_status]

' . sprintf( wp_kses_post( // translators: placeholders: course, Course, Course. _x( 'This shortcode displays the user %1$s access expire date. Example: [ld_course_expire_status course_id="111" user="222" label_before="%2$s access will expire on:" label_after="%3$s access expired on:" format="F j, Y g:i a"].', 'placeholders: course, Course, Course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ) . '

  • course_id: ' . sprintf( wp_kses_post( // translators: plaeholders: course _x( 'The ID of the %s to check. If not provided will attempt to user current post. Example: [ld_course_expire_status course_id="111"] ', 'plaeholders: course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ) ) . '
  • user_id: ' . wp_kses_post( __( 'The ID of the user to check. If not provided the current logged in user ID will be used. Example: [ld_course_expire_status user_id="222"]', 'learndash' ) ) . '
  • label_before: ' . sprintf( wp_kses_post( // translators: placeholders: Course, course _x( 'The label prefix shown before the access expires. Default label is "%1$s access will expire on:" Example: [ld_course_expire_status label_before="Your access to this %2$s will expire on:"]', 'placeholders: Course, course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'course' ) ) . '
  • label_after: ' . sprintf( wp_kses_post( // translators: placeholders: Course, course _x( 'The label prefix shown after access has expired. Default label is "%1$s access expired on:" Example: [ld_course_expire_status label_after="Your access to this %2$s expired on:"]', 'placeholders: Course, course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'course' ) ) . '
  • format: ' . wp_kses_post( __( 'This parameter controls the format of the date/time value shown to the user. If not provided the date/time format from your WordPress sytem will be used. Example: [ld_course_expire_status format="F j, Y g:i a"]', 'learndash' ) ) . '
'; ?>
mm8settings-pages/class-ld-settings-page-topics-options.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-topic'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'topics-options'; $this->settings_page_title = esc_html_x( 'Settings', 'Topic Settings', 'learndash' ); parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Topics_Options::add_page_instance(); } ); PK^\مi0settings-pages/class-ld-settings-page-paypal.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_settings_paypal'; $this->settings_page_title = esc_html__( 'PayPal Settings', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 20; $this->show_quick_links_meta = false; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_PayPal::add_page_instance(); } ); PK^\Hi@settings-pages/class-ld-settings-page-courses-builder-single.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-courses'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'courses-builder'; $this->settings_page_title = sprintf( // translators: placeholder: Course. esc_html_x( '%s Builder', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->settings_tab_title = $this->settings_page_title; add_action( 'load-sfwd-courses_page_courses-builder', array( $this, 'on_load' ) ); add_filter( 'post_row_actions', array( $this, 'learndash_course_row_actions' ), 20, 2 ); add_filter( 'learndash_admin_tab_sets', array( $this, 'admin_tab_sets' ), 15, 2 ); add_action( 'admin_notices', array( $this, 'admin_notice' ) ); parent::__construct(); } /** * Override the settings form as we are not really handling settings to be sent through options.php * * @since 2.4.0 * * @param boolean $start Start. * * @return boolean $start */ public function get_admin_page_form( $start = true ) { if ( true === $start ) { return apply_filters( 'learndash_admin_page_form', '
', $start ); } else { return apply_filters( 'learndash_admin_page_form', '
', $start ); } } /** * Action hook when settings screen is being shown. */ public function on_load() { if ( is_admin() ) { // If the Course Builder screen is being shown... $current_screen = get_current_screen(); if ( 'sfwd-courses_page_courses-builder' == $current_screen->id ) { // ...but the 'course_id' query parameters is not found... if ( ( ! isset( $_GET['course_id'] ) ) || ( empty( $_GET['course_id'] ) ) ) { // ...then redirect back to the courses listin screen. $courses_list_url = add_query_arg( 'post_type', 'sfwd-courses', admin_url( 'edit.php' ) ); wp_redirect( $courses_list_url ); } else { $this->cb = Learndash_Admin_Metabox_Course_Builder::add_instance( 'Learndash_Admin_Metabox_Course_Builder' ); $this->save_cb_metabox(); $this->cb->builder_on_load(); } } } } /** * Called when metabox is being saved. */ public function save_cb_metabox() { if ( ( isset( $_GET['course_id'] ) ) && ( ! empty( $_GET['course_id'] ) ) ) { $course_id = intval( $_GET['course_id'] ); $course_post = get_post( $course_id ); if ( ( ! empty( $_POST['action'] ) && 'update' === wp_unslash( $_POST['action'] ) ) && ( $course_post ) && ( is_a( $course_post, 'WP_Post' ) ) && ( 'sfwd-courses' == $course_post->post_type ) ) { $this->cb->save_course_builder( $course_id, $course_post, true ); $this->update_success = true; } } return; } /** * Function to show admin notices on settings page. */ public function admin_notice() { if ( true === $this->update_success ) { ?>

%s', add_query_arg( array( 'currentTab' => 'learndash_course_builder', ), get_edit_post_link( $course_post->ID ) ), esc_attr( $course_label ), esc_html__( 'Builder', 'learndash' ) ); } } } return $row_actions; } /** * Filter the LearnDash admin menu (tabs). We remove the 'Course Builder' tab until needed. * * @since 2.5.0 * * @param array $admin_menu_set Current Menu set array. * @param string $admin_menu_key Current menu key. * * @return array $admin_menu_set */ public function admin_tab_sets( $admin_menu_set = array(), $admin_menu_key = '' ) { if ( 'edit.php?post_type=sfwd-courses' == $admin_menu_key ) { if ( ( ! isset( $_GET['course_id'] ) ) || ( empty( $_GET['course_id'] ) ) ) { // If we don't have the 'course_id' URL parameter then we remove the tab. foreach ( $admin_menu_set as $menu_idx => $menu_item ) { if ( 'sfwd-courses_page_courses-builder' === $menu_item['id'] ) { unset( $admin_menu_set[ $menu_idx ] ); break; } } } else { // Else of we do have the 'course_id' URL parameter we include this in the tab URL. foreach ( $admin_menu_set as $menu_idx => &$menu_item ) { if ( 'sfwd-courses_page_courses-builder' === $menu_item['id'] ) { $menu_item['link'] = add_query_arg( 'course_id', intval( $_GET['course_id'] ), $menu_item['link'] ); break; } } } } return $admin_menu_set; } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Course_Builder_Single::add_page_instance(); } ); PK^\nR1settings-pages/class-ld-settings-page-general.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_settings'; $this->settings_page_title = esc_html__( 'General', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 0; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_General::add_page_instance(); } ); PK^\) 556settings-pages/class-ld-settings-page-translations.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_translations'; $this->settings_page_title = esc_html__( 'Translations', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 40; $this->show_submit_meta = false; parent::__construct(); } /** * On load function to load resources needed to page functionality. */ public function load_settings_page() { global $learndash_assets_loaded; wp_enqueue_style( 'learndash-admin-settings-page-translations-style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-settings-page-translations' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash-admin-settings-page-translations-style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-admin-settings-page-translations-style'] = __FUNCTION__; wp_enqueue_script( 'learndash-admin-settings-page-translations-script', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-settings-page-translations' . leardash_min_asset() . '.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['learndash-admin-settings-page-translations-script'] = __FUNCTION__; $this->handle_translation_message(); $this->handle_translation_actions(); parent::load_settings_page(); } /** * Show translation status message before title. */ public function settings_page_before_title() { $this->handle_translation_message(); } public function get_admin_page_form( $start = true ) { if ( true === $start ) { return ''; } else { return ''; } } public function handle_translation_message() { $reply = get_option( $this->ld_options_key, array() ); if ( ! empty( $reply ) ) { // Delete the option we don't need anymore delete_option( $this->ld_options_key ); if ( ( isset( $reply['status'] ) ) && ( isset( $reply['message'] ) ) ) { if ( true === $reply['status'] ) { ?>
ld_options_key, $reply ); } $redirect_url = remove_query_arg( array( 'action', 'project', 'locale', 'ld-translation-nonce' ) ); if ( ! empty( $redirect_url ) ) { wp_safe_redirect( $redirect_url ); } } } // End of functions. } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Translations::add_page_instance(); } ); PK^\S;settings-pages/class-ld-settings-page-questions-options.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-question'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'questions-options'; $this->settings_tab_priority = 10; $this->settings_page_title = esc_html_x( 'Settings', 'Question Settings', 'learndash' ); $this->show_submit_meta = true; $this->show_quick_links_meta = true; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Questions_Options::add_page_instance(); } ); PK^\ orr(settings-pages/settings-pages-loader.phpnuW+A9settings-pages/class-ld-settings-page-courses-options.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-courses'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'courses-options'; $this->settings_page_title = esc_html_x( 'Settings', 'Course Settings', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Courses_Options::add_page_instance(); } ); PK^\1\1settings-pages/class-ld-settings-page-license.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_settings_license'; $this->settings_page_title = esc_html__( 'License Settings', 'learndash' ); $this->settings_tab_title = esc_html__( 'LMS License', 'learndash' ); $this->settings_tab_priority = 90; parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_License::add_page_instance(); } ); PK^\(Zzz=settings-pages/class-ld-settings-page-assignments-options.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-assignment'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'assignments-options'; $this->settings_page_title = esc_html__( 'Settings', 'learndash' ); parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Assignments_Options::add_page_instance(); } ); PK^\i$1settings-pages/class-ld-settings-page-support.phpnuW+Aparent_menu_page_url = 'admin.php?page=learndash_lms_settings'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_support'; $this->settings_page_title = esc_html__( 'Support', 'learndash' ); $this->settings_tab_title = $this->settings_page_title; $this->settings_tab_priority = 30; $this->settings_form_wrap = false; $this->show_submit_meta = false; $this->show_quick_links_meta = true; add_action( 'learndash-settings-page-load', array( $this, 'learndash_settings_page_load' ) ); parent::__construct(); } function learndash_settings_page_load( $settings_screen_id = '' ) { global $sfwd_lms; if ( $settings_screen_id === $this->settings_screen_id ) { $this->gather_system_details(); // download-system-info. if ( ( isset( $_GET['ld_download_system_info_nonce'] ) ) && ( ! empty( $_GET['ld_download_system_info_nonce'] ) ) && ( wp_verify_nonce( $_GET['ld_download_system_info_nonce'], 'ld_download_system_info_' . get_current_user_id() ) ) ) { header( 'Content-type: text/plain' ); header( 'Content-Disposition: attachment; filename=ld_system_info-' . date( 'Ymd' ) . '.txt' ); $this->show_system_info( 'text' ); die(); } // Load JS/CSS as needed for page. wp_enqueue_style( 'learndash-admin-support-page', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-support-page' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash-admin-support-page', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-admin-support-page'] = __FUNCTION__; } } /** * Used to collect all needed display elements. Many filters by section as well as a final filter * * @since v2.5.4 */ public function gather_system_details() { $this->system_info = apply_filters( 'learndash_support_sections_init', $this->system_info ); // Finally a filter for all sections. This is where some external process will add new sections etc. $this->system_info = apply_filters( 'learndash_support_sections', $this->system_info ); } public function get_support_sections() { return $this->system_info; } /** * Show System Info section * * @since 2.3 * * @param string $output_type Controls formatting. 'html' or 'text'. */ public function show_support_section( $section_key = '', $output_type = 'html' ) { if ( isset( $this->system_info[ $section_key ] ) ) { $_set = $this->system_info[ $section_key ]; $_key = $section_key; switch ( $output_type ) { case 'text': if ( ( isset( $_set['header']['text'] ) ) && ( ! empty( $_set['header']['text'] ) ) ) { echo strtoupper( $_set['header']['text'] ) . "\r\n"; } if ( ( isset( $_set['columns'] ) ) && ( ! empty( $_set['columns'] ) ) && ( isset( $_set['settings'] ) ) && ( ! empty( $_set['settings'] ) ) ) { foreach ( $_set['settings'] as $setting_key => $setting_set ) { $_SHOW_FIRST = false; foreach ( $_set['columns'] as $column_key => $column_set ) { $value = strip_tags( str_replace( array( '
', '
', '
' ), "\r\n", $setting_set[ $column_key ] ) ); // Add some format spacing to make the raw txt version easier to read. $spaces_needed = 50 - strlen( $value ); if ( $spaces_needed > 0 ) { $value .= str_repeat( ' ', $spaces_needed ); } echo $value; } echo "\r\n"; } } echo "\r\n"; break; case 'html': default: if ( ( isset( $_set['desc'] ) ) & ( ! empty( $_set['desc'] ) ) ) { ?>
$column_set ) { $column_class = ''; if ( isset( $column_set['class'] ) ) { $column_class = $column_set['class']; } $column_class = apply_filters( 'learndash_support_column_class', $column_class, $column_key, $_key ); ?> $setting_set ) { ?> $column_set ) { ?>
parent_menu_page_url = 'admin.php?page=learndash_lms_overview'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_overview'; $this->settings_page_title = esc_html__( 'LearnDash Overview', 'learndash' ); $this->settings_tab_title = esc_html__( 'Overview', 'learndash' ); $this->settings_tab_priority = 0; // Override action with custom plugins function for add-ons. // add_action( 'install_plugins_pre_plugin-information', array( $this, 'shows_addon_plugin_information' ) ); add_filter( 'learndash_submenu', array( $this, 'submenu_item' ), 200 ); add_filter( 'learndash_admin_tab_sets', array( $this, 'learndash_admin_tab_sets' ), 10, 3 ); add_filter( 'learndash_header_data', array( $this, 'admin_header' ), 40, 3 ); add_action( 'wp_ajax_save_bootcamp_toggle_state', array( $this, 'save_bootcamp_toggle_state' ) ); add_action( 'wp_ajax_save_bootcamp_mark_complete_state', array( $this, 'save_bootcamp_mark_complete_state' ) ); parent::__construct(); } /** * Control visibility of submenu items based on lisence status * * @since 3.0.0 * * @param array $submenu Submenu item to check. * @return array $submenu */ public function submenu_item( $submenu ) { if ( ! isset( $submenu[ $this->settings_page_id ] ) ) { $submenu_save = $submenu; $submenu = array(); $submenu[ $this->settings_page_id ] = array( 'name' => $this->settings_tab_title, 'cap' => $this->menu_page_capability, 'link' => $this->parent_menu_page_url, 'class' => 'submenu-ldlms-overview', ); $submenu = array_merge( $submenu, $submenu_save ); } return $submenu; } /** * Filter the admin header data. We don't want to show the header panel on the Overview page. * * @since 3.0 * @param array $header_data Array of header data used by the Header Panel React app. * @param string $menu_key The menu key being displayed. * @param array $menu_items Array of menu/tab items. * * @return array $header_data. */ public function admin_header( $header_data = array(), $menu_key = '', $menu_items = array() ) { // Clear out $header_data if we are showing our page. if ( $menu_key === $this->parent_menu_page_url ) { $header_data = array(); } return $header_data; } /** * Filter for page title wrapper. * * @since 3.0.0 */ public function get_admin_page_title() { return apply_filters( 'learndash_admin_page_title', '

' . $this->settings_page_title . '

' ); } /** * Action function called when Add-ons page is loaded. * * @since 3.0.0 */ public function load_settings_page() { global $learndash_assets_loaded; wp_enqueue_style( 'learndash-admin-overview-page-style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-overview-page' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash-admin-overview-page-style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash-admin-overview-page-style'] = __FUNCTION__; wp_enqueue_script( 'learndash-admin-overview-page-script', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-overview-page' . leardash_min_asset() . '.js', array(), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['scripts']['learndash-admin-overview-page-script'] = __FUNCTION__; $learndash_admin_overview_page_strings = [ 'mark_complete' => esc_html__( 'Mark Complete', 'learndash' ), 'mark_incomplete' => esc_html__( 'Mark Incomplete', 'learndash' ), ]; wp_localize_script( 'learndash-admin-overview-page-script', 'LearnDashOverviewPageData', $learndash_admin_overview_page_strings ); } /** * Hide the tab menu items if on add-on page. * * @since 3.0.0 * * @param array $tab_set Tab Set. * @param string $tab_key Tab Key. * @param string $current_page_id ID of shown page. * * @return array $tab_set */ public function learndash_admin_tab_sets( $tab_set = array(), $tab_key = '', $current_page_id = '' ) { if ( ( ! empty( $tab_set ) ) && ( ! empty( $tab_key ) ) && ( ! empty( $current_page_id ) ) ) { if ( 'admin_page_learndash_lms_overview' === $current_page_id ) { ?> rss_announcements_posts = $rss_announcements->get_items( 0, $rss_announcements->get_item_quantity( 4 ) ); } $rss_sell = fetch_feed( 'https://www.learndash.com/category/sell-online-courses/feed' ); if ( ! is_wp_error( $rss_sell ) ) { $this->rss_sell_posts = $rss_sell->get_items( 0, $rss_sell->get_item_quantity( 4 ) ); } $rss_tips = fetch_feed( 'https://www.learndash.com/category/learndash-tips/feed' ); if ( ! is_wp_error( $rss_tips ) ) { $this->rss_tips_posts = $rss_tips->get_items( 0, $rss_tips->get_item_quantity( 4 ) ); } } /** * Check and update license information * * @since 3.0.0 */ private function check_and_update_license() { $updater = learndash_get_updater_instance(); if ( ( $updater ) && ( is_a( $updater, 'nss_plugin_updater_sfwd_lms' ) ) ) { // Check if we have new user input. if ( ( isset( $_POST['update_nss_plugin_license_sfwd_lms'], $_POST['ld_bootcamp_license_form_nonce'] ) ) && ( wp_verify_nonce( sanitize_key( $_POST['ld_bootcamp_license_form_nonce'] ), 'ld_bootcamp_license_form_nonce' ) ) ) { // Read their posted value. $license = isset( $_POST['nss_plugin_license_sfwd_lms'] ) ? sanitize_text_field( wp_unslash( $_POST['nss_plugin_license_sfwd_lms'] ) ) : ''; $email = isset( $_POST['nss_plugin_license_email_sfwd_lms'] ) ? sanitize_email( wp_unslash( $_POST['nss_plugin_license_email_sfwd_lms'] ) ) : ''; // Save the posted value in the database. update_option( 'nss_plugin_license_sfwd_lms', $license ); update_option( 'nss_plugin_license_email_sfwd_lms', $email ); $updater->reset(); ?>

" . esc_html__( 'buy', 'learndash' ) . '' ); ?>

time_to_recheck() ) { $license_status = $updater->getRemote_license(); /** * NOTE: The getRemote_license() does not update the option. * So we need to do it. And it needs to be set as an array structure. */ update_option( 'nss_plugin_remote_license_sfwd_lms', array( 'value' => $license_status ) ); // Then re-update the licens using new utility function. // Plus this provides simpler true/false boolean. $license_status = is_learndash_license_valid(); } } $this->license_info['license'] = $license; $this->license_info['email'] = $email; $this->license_info['status'] = $license_status; } } } } /** * Utility function to maybe display the Bootcamp * * @since 3.0.0 * * @param $toggle_state string Option value. * * @return string */ public function maybe_display_bootcamp( $toggle_state ) { if ( ! $toggle_state || 'show' === $toggle_state ) { return 'block'; } else { return 'none'; } } /** * Custom display function for page content. * * @since 3.0.0 */ public function show_settings_page() { $toggle_state = get_option( 'learndash_bootcamp_toggle_state' ); $this->get_feeds(); if ( learndash_is_admin_user() ) : $this->check_and_update_license(); endif; ?>

settings_tab_title; ?>

rss_sell_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo ''; } ?>

rss_tips_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo ''; } ?>

rss_announcements_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo ''; } ?>

parent_menu_page_url = 'admin.php?page=learndash_lms_import_export'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash_lms_import_export'; $this->settings_page_title = esc_html__( 'LearnDash Import/Export', 'learndash' ); $this->settings_tab_title = esc_html__( 'Import/Export', 'learndash' ); $this->settings_tab_priority = 0; add_filter( 'learndash_submenu_last', array( $this, 'submenu_item' ), 200 ); add_filter( 'learndash_admin_tab_sets', array( $this, 'learndash_admin_tab_sets' ), 10, 3 ); parent::__construct(); } /** * Control visibility of submenu items based on lisence status * * @since 2.5.5 * * @param array $submenu Submenu item to check. * @return array $submenu */ public function submenu_item( $submenu ) { $submenu[ $this->settings_page_id ] = array( 'name' => $this->settings_tab_title, 'cap' => $this->menu_page_capability, 'link' => $this->parent_menu_page_url, ); return $submenu; } /** * Filter for page title wrapper. * * @since 2.5.5 */ public function get_admin_page_title() { return apply_filters( 'learndash_admin_page_title', '

' . $this->settings_page_title . '

' ); } /** * Action function called when Add-ons page is loaded. * * @since 2.5.5 */ public function load_settings_page() { add_thickbox(); if ( ! class_exists( 'Learndash_Admin_Import_Export' ) ) { require_once LEARNDASH_LMS_PLUGIN_DIR . 'includes/admin/class-learndash-admin-import-export.php'; } $this->import_export = new Learndash_Admin_Import_Export(); } /** * Hide the tab menu items if on add-one page. * * @since 2.5.5 * * @param array $tab_set Tab Set. * @param string $tab_key Tab Key. * @param string $current_page_id ID of shown page. * * @return array $tab_set */ public function learndash_admin_tab_sets( $tab_set = array(), $tab_key = '', $current_page_id = '' ) { if ( ( ! empty( $tab_set ) ) && ( ! empty( $tab_key ) ) && ( ! empty( $current_page_id ) ) ) { if ( 'admin_page_' . $this->settings_page_id === $current_page_id ) { ?>
settings_screen_id ); ?> get_admin_page_title(); ?> settings_screen_id ); ?> settings_screen_id ); ?> import_export->show(); ?> settings_screen_id ); ?>
parent_menu_page_url = 'edit.php?post_type=sfwd-lessons'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'lessons-options'; $this->settings_page_title = esc_html_x( 'Settings', 'Lesson Settings', 'learndash' ); parent::__construct(); } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Lessons_Options::add_page_instance(); } ); PK^\>53@settings-pages/class-ld-settings-page-certificate-shortcodes.phpnuW+Aparent_menu_page_url = 'edit.php?post_type=sfwd-certificates'; $this->menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; $this->settings_page_id = 'learndash-lms-certificate_shortcodes'; $this->settings_page_title = esc_html__( 'Shortcodes', 'learndash' ); $this->settings_columns = 1; parent::__construct(); } /** * Custom function to show settings page output * * @since 2.4.0 */ public function show_settings_page() { $fields_args = array( 'typenow' => '', 'pagenow' => '', 'nonce' => '', ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/class-ld-shortcodes-sections.php'; require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/courseinfo.php'; $shortcode_sections['courseinfo'] = new LearnDash_Shortcodes_Section_courseinfo( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/quizinfo.php'; $shortcode_sections['quizinfo'] = new LearnDash_Shortcodes_Section_quizinfo( $fields_args ); $courseinfo_show_field = $shortcode_sections['courseinfo']->get_shortcodes_section_field( 'show' ); $courseinfo_show_options = ''; if ( ( isset( $courseinfo_show_field['options'] ) ) && ( ! empty( $courseinfo_show_field['options'] ) ) ) { foreach( $courseinfo_show_field['options'] as $key => $label ) { $courseinfo_show_options .= '
  • ' . $key . ''; if ( ! empty( $label ) ) { $courseinfo_show_options .= ' - ' . $label; } $courseinfo_show_options .= '
  • '; } } $quizinfo_show_field = $shortcode_sections['quizinfo']->get_shortcodes_section_field( 'show' ); $quizinfo_show_options = ''; if ( ( isset( $quizinfo_show_field['options'] ) ) && ( ! empty( $quizinfo_show_field['options'] ) ) ) { foreach( $quizinfo_show_field['options'] as $key => $label ) { $quizinfo_show_options .= '
  • ' . $key . ''; if ( ! empty( $label ) ) { $quizinfo_show_options .= ' - ' . $label; } $quizinfo_show_options .= '
  • '; } } ?>

    Shortcode Options

    You may use shortcodes to customize the display of your certificates. Provided is a built-in shortcode for displaying user information.


    [usermeta]

    This shortcode takes a parameter named field, which is the name of the user meta data field to be displayed.

    Example: [usermeta field="display_name"] would display the user\'s Display Name.

    See the full list of available fields here.', 'learndash' ) ) . '


    [quizinfo]

    ' . sprintf( // translators: placeholder: quiz. esc_html_x( 'This shortcode displays information regarding %s attempts on the certificate. This shortcode can use the following parameters:', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ) . '

    • SHOW: ' . sprintf( wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode. Possible values are:
        ' . $quizinfo_show_options . '

      Example: [quizinfo show="percentage"] shows the percentage score of the user in the %s.', 'placeholder: quiz', 'learndash' ) ), learndash_get_custom_label_lower( 'quiz' ) ) . '

    • FORMAT: ' . wp_kses_post( __( 'This can be used to change the timestamp format. Default: "F j, Y, g:i a" shows as March 10, 2001, 5:16 pm.
      Example: [quizinfo show="timestamp" format="Y-m-d H:i:s"] will show as 2001-03-10 17:16:18', 'learndash' ) ) . '

    ' . wp_kses_post( __( 'See the full list of available date formatting strings here.', 'learndash' ) ) . '


    [courseinfo]

    '. esc_html__( 'This shortcode displays course related information on the certificate. This shortcode can use the following parameters:', 'learndash' ) . '

    • SHOW: ' . sprintf( wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode. Possible values are:
        ' . $courseinfo_show_options . '
      cumulative is average for all %s of the %s.
      aggregate is sum for all %s of the %s.

      Example: [courseinfo show="cumulative_score"] shows average points scored across all quizzes on the course.', 'placeholders: quizzes, course, quizzes, course', 'learndash' ) ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' )) . '

    • FORMAT: ' . wp_kses_post( __( 'This can be used to change the date format. Default: "F j, Y, g:i a" shows as March 10, 2001, 5:16 pm.
      Example: [courseinfo show="completed_on" format="Y-m-d H:i:s"] will show as 2001-03-10 17:16:18', 'learndash' ) ) . '

    ' . wp_kses_post( __( 'See the full list of available date formatting strings here.', 'learndash' ) ) . '

    '; ?>
    fields_args = $fields_args; $this->shortcodes_section_key = 'course_notstarted'; // translators: placeholder: Course. $this->shortcodes_section_title = sprintf( esc_html_x( '%s Not Started', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 2; // translators: placeholders: course. $this->shortcodes_section_description = sprintf( wp_kses_post( _x( 'This shortcode shows the content if the user has access to the %s but not yet started. The shortcode can be used on any page or widget area.', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', // translators: placeholder: Course. 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholders: Course, Course. 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( 'sfwd-courses' !== $this->fields_args['post_type'] ) && ( 'sfwd-lessons' !== $this->fields_args['post_type'] ) && ( 'sfwd-topic' !== $this->fields_args['post_type'] ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; // translators: placeholders: Course. $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\D,,'shortcodes-sections/course_complete.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'course_complete'; $this->shortcodes_section_title = sprintf( // translators: placeholder: Course. esc_html_x( '%s Complete', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = sprintf( // translators: placeholders: course. esc_html_x( 'This shortcode shows the content if the user has completed the %s. The shortcode can be used on any page or widget area.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } /** * Initialize the shortcode fields. */ public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course, Course. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( 'sfwd-courses' !== $this->fields_args['post_type'] ) && ( 'sfwd-lessons' !== $this->fields_args['post_type'] ) && ( 'sfwd-topic' !== $this->fields_args['post_type'] ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( // translators: placeholders: Course. esc_html_x( 'Enter single %s ID.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\fJ J &shortcodes-sections/course_content.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'course_content'; $this->shortcodes_section_title = sprintf( // translators: placeholder: Course. esc_html_x( '%s Content', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( // translators: placeholders: Course, lesson, topics, quizzes. esc_html_x( 'This shortcode displays the %1$s Content table (%2$s, %3$s, and %4$s) when inserted on a page or post.', 'placeholders: Course, lesson, topics, quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'lessons' ), learndash_get_custom_label_lower( 'topics' ), learndash_get_custom_label_lower( 'quizzes' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course. esc_html_x( 'Enter single %s ID', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', 'required' => 'required', ), 'num' => array( 'id' => $this->shortcodes_section_key . '_num', 'name' => 'num', 'type' => 'number', 'label' => sprintf( // translators: placeholders: lessons. esc_html_x( '%s Per Page', 'placeholders: lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ), 'help_text' => sprintf( // translators: placeholders: default per page. esc_html_x( 'Default %d. Set to zero for all.', 'placeholders: default per page', 'learndash' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1, ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( 'sfwd-courses' !== $this->fields_args['post_type'] ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\89"shortcodes-sections/ld_profile.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_profile'; $this->shortcodes_section_title = esc_html__( 'Profile', 'learndash' ); $this->shortcodes_section_type = 1; // translators: placeholder: placeholder: placeholder: courses, course, quiz. $this->shortcodes_section_description = sprintf( esc_html_x( 'Displays user\'s enrolled %1$s, %2$s progress, %3$s scores, and achieved certificates.', 'placeholder: courses, course, quiz', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quiz' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'per_page' => array( 'id' => $this->shortcodes_section_key . '_per_page', 'name' => 'per_page', 'type' => 'number', // translators: placeholder: Courses. 'label' => sprintf( esc_html_x( '%s per page', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'Courses' ) ), // translators: placeholder: placeholder: Courses, default per page. 'help_text' => sprintf( esc_html_x( '%1$s per page. Default is %2$d. Set to zero for all.', 'placeholder: Courses, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'Courses' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => false, 'class' => 'small-text', ), 'orderby' => array( 'id' => $this->shortcodes_section_key . '_orderby', 'name' => 'orderby', 'type' => 'select', 'label' => esc_html__( 'Order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => 'ID', 'options' => array( '' => esc_html__( 'ID - Order by post id. (default)', 'learndash' ), 'title' => esc_html__( 'Title - Order by post title', 'learndash' ), 'date' => esc_html__( 'Date - Order by post date', 'learndash' ), 'menu_order' => esc_html__( 'Menu - Order by Page Order Value', 'learndash' ), ), ), 'order' => array( 'id' => $this->shortcodes_section_key . '_order', 'name' => 'order', 'type' => 'select', 'label' => esc_html__( 'Order', 'learndash' ), 'help_text' => esc_html__( 'Order', 'learndash' ), 'value' => 'ID', 'options' => array( '' => esc_html__( 'DESC - highest to lowest values (default)', 'learndash' ), 'ASC' => esc_html__( 'ASC - lowest to highest values', 'learndash' ), ), ), 'show_search' => array( 'id' => $this->shortcodes_section_key . 'show_search', 'name' => 'show_search', 'type' => 'select', 'label' => esc_html__( 'Show Search', 'learndash' ), 'help_text' => esc_html__( 'Show Search', 'learndash' ), 'value' => 'yes', 'options' => array( '' => esc_html__( 'Yes', 'learndash' ), 'no' => esc_html__( 'No', 'learndash' ), ), 'help_text' => esc_html__( 'LD30 template only', 'learndash' ), ), 'show_header' => array( 'id' => $this->shortcodes_section_key . 'show_header', 'name' => 'show_header', 'type' => 'select', // translators: placeholder: Course. 'label' => esc_html__( 'Show Profile Header', 'learndash' ), // translators: placeholder: Course. 'help_text' => esc_html__( 'show_header', 'learndash' ), 'value' => '', 'options' => array( '' => esc_html__( 'Yes', 'learndash' ), 'no' => esc_html__( 'No', 'learndash' ), ), ), 'course_points_user' => array( 'id' => $this->shortcodes_section_key . 'course_points_user', 'name' => 'course_points_user', 'type' => 'select', // translators: placeholder: Course. 'label' => sprintf( esc_html_x( 'Show Earned %s Points', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'help_text' => sprintf( esc_html_x( 'Show Earned %s Points', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'options' => array( '' => esc_html__( 'Yes', 'learndash' ), 'no' => esc_html__( 'No', 'learndash' ), ), ), 'profile_link' => array( 'id' => $this->shortcodes_section_key . 'profile_link', 'name' => 'profile_link', 'type' => 'select', 'label' => esc_html__( 'Show Profile Link', 'learndash' ), 'help_text' => esc_html__( 'Show Profile Link', 'learndash' ), 'value' => 'yes', 'options' => array( '' => esc_html__( 'Yes', 'learndash' ), 'no' => esc_html__( 'No', 'learndash' ), ), ), 'show_quizzes' => array( 'id' => $this->shortcodes_section_key . 'show_quizzes', 'name' => 'show_quizzes', 'type' => 'select', 'label' => esc_html__( 'Show User Quiz Attempts', 'learndash' ), 'help_text' => esc_html__( 'Show User Quiz Attempts', 'learndash' ), 'value' => 'yes', 'options' => array( '' => esc_html__( 'Yes', 'learndash' ), 'no' => esc_html__( 'No', 'learndash' ), ), ), 'expand_all' => array( 'id' => $this->shortcodes_section_key . 'expand_all', 'name' => 'expand_all', 'type' => 'select', // translators: placeholder: Course. 'label' => sprintf( esc_html_x( 'Expand All %s Sections', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'help_text' => sprintf( esc_html_x( 'Expand All %s sections', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => 'no', 'options' => array( '' => esc_html__( 'No', 'learndash' ), 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\L ##&shortcodes-sections/ld_course_info.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_course_info'; $this->shortcodes_section_title = sprintf( esc_html_x( 'LD %s Info', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode shows the %s and progress for the user.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text' ), 'registered_show_thumbnail' => array( 'id' => $this->shortcodes_section_key . '_registered_show_thumbnail', 'name' => 'registered_show_thumbnail', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Thumbnail', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s thumbnail.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), 'registered_num' => array( 'id' => $this->shortcodes_section_key . '_registered_num', 'name' => 'registered_num', 'type' => 'number', 'label' => esc_html__( 'Registered per page', 'learndash' ), 'help_text' => sprintf( esc_html_x( 'Registered %1$s per page. Default is %2$d. Set to zero for all.', 'placeholders: courses, default per page', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'registered_orderby' => array( 'id' => $this->shortcodes_section_key . '_registered_orderby', 'name' => 'registered_orderby', 'type' => 'select', 'label' => esc_html__( 'Registered order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => '', 'options' => array( '' => esc_html__('Title (default) - Order by post title', 'learndash'), 'ID' => esc_html__('ID - Order by post id', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'registered_order' => array( 'id' => $this->shortcodes_section_key . '_registered_order', 'name' => 'registered_order', 'type' => 'select', 'label' => esc_html__( 'Progress Order', 'learndash' ), 'help_text' => sprintf( esc_html_x( 'Order of %s displayed', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'options' => array( '' => esc_html__('ASC (default) - lowest to highest values', 'learndash'), 'DESC' => esc_html__('DESC - highest to lowest values', 'learndash'), ) ), 'progress_num' => array( 'id' => $this->shortcodes_section_key . '_progress_num', 'name' => 'progress_num', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s per page', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'help_text' => sprintf( esc_html_x( '%1$s per page. Default is %2$d. Set to zero for all.', 'placeholders: courses, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'progress_orderby' => array( 'id' => $this->shortcodes_section_key . '_progress_orderby', 'name' => 'progress_orderby', 'type' => 'select', 'label' => sprintf( esc_html_x( '%s order by', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => '', 'options' => array( '' => esc_html__('Title (default) - Order by post title', 'learndash'), 'ID' => esc_html__('ID - Order by post id', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'progress_order' => array( 'id' => $this->shortcodes_section_key . '_progress_order', 'name' => 'progress_order', 'type' => 'select', 'label' => sprintf( esc_html_x( '%s Order', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'help_text' => sprintf( esc_html_x( 'Order of %s displayed', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'options' => array( '' => esc_html__('ASC (default) - lowest to highest values', 'learndash'), 'DESC' => esc_html__('DESC - highest to lowest values', 'learndash'), ) ), 'quiz_num' => array( 'id' => $this->shortcodes_section_key . '_quiz_num', 'name' => 'quiz_num', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s per page', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'help_text' => sprintf( esc_html_x( '%s per page. Default is %d. Set to zero for all.', 'placeholders: quizzes, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'quiz_orderby' => array( 'id' => $this->shortcodes_section_key . '_quiz_orderby', 'name' => 'quiz_orderby', 'type' => 'select', 'label' => sprintf( esc_html_x( '%s order by', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => '', 'options' => array( '' => esc_html__('Date Taken (default) - Order by date taken', 'learndash'), 'title' => esc_html__('Title - Order by post title', 'learndash'), 'ID' => esc_html__('ID - Order by post id', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'quiz_order' => array( 'id' => $this->shortcodes_section_key . '_quiz_order', 'name' => 'quiz_order', 'type' => 'select', 'label' => sprintf( esc_html_x( '%s Order', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'help_text' => sprintf( esc_html_x( 'Order of %s displayed.', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'value' => '', 'options' => array( '' => esc_html__( 'DESC (default) - highest to lowest values', 'learndash' ), 'ASC' => esc_html__('ASC - lowest to highest values', 'learndash' ), ) ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\D  shortcodes-sections/visitor.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'visitor'; $this->shortcodes_section_title = esc_html__( 'Visitor', 'learndash' ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = sprintf( wp_kses_post( _x( 'This shortcode shows the content if the user is not enrolled in the %s. The shortcode can be used on any page or widget area.', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( $this->fields_args['post_type'] !== 'sfwd-courses' ) && ( $this->fields_args['post_type'] != 'sfwd-lessons' ) && ( $this->fields_args['post_type'] != 'sfwd-topic' ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\ 1shortcodes-sections/learndash_course_progress.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'learndash_course_progress'; $this->shortcodes_section_title = sprintf( esc_html_x( '%s Progress', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode displays users progress bar for the %1$s in any %2$s/%3$s/%4$s pages.', 'placeholders: course, course, lesson, quiz', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'quiz' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for all %2$s.', 'placeholders: Course, Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'class' => 'small-text' ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text' ), ); if ( ( !isset( $this->fields_args['post_type'] ) ) || ( ( $this->fields_args['post_type'] != 'sfwd-courses' ) && ( $this->fields_args['post_type'] != 'sfwd-lessons' ) && ( $this->fields_args['post_type'] != 'sfwd-topic' ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\uj1shortcodes-sections/learndash_payment_buttons.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'learndash_payment_buttons'; $this->shortcodes_section_title = esc_html__( 'Payment Buttons', 'learndash' ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = esc_html__( 'This shortcode can show the payment buttons on any page.', 'learndash' ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %s ID', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', 'required' => 'required' ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\7KK#shortcodes-sections/user_groups.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'user_groups'; $this->shortcodes_section_title = esc_html__( 'User Groups', 'learndash' ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = esc_html__( 'This shortcode displays the list of groups users are assigned to as users or leaders.', 'learndash' ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text' ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\Szz(shortcodes-sections/ld_quiz_complete.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_quiz_complete'; // translators: placeholder: Quiz. $this->shortcodes_section_title = sprintf( esc_html_x( '%s Complete', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = sprintf( // translators: placeholders: quiz. esc_html_x( 'This shortcode shows the content if the user has completed the %s. The shortcode can be used on any page or widget area.', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'quiz_id' => array( 'id' => $this->shortcodes_section_key . '_quiz_id', 'name' => 'quiz_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s ID', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholders: Quiz, Quiz. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Quiz, Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => '', //'required' => 'required', 'class' => 'small-text', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course, Course. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', //'required' => 'required', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( learndash_get_post_type_slug( 'quiz' ) !== $this->fields_args['post_type'] ) ) { $this->shortcodes_option_fields['quiz_id']['required'] = 'required'; // translators: placeholders: Quiz. $this->shortcodes_option_fields['quiz_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID.', 'placeholders: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\'܎55&shortcodes-sections/ld_course_list.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_course_list'; $this->shortcodes_section_title = sprintf( esc_html_x( '%s List', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( wp_kses_post( _x( "This shortcode shows list of %s. You can use this shortcode on any page if you don't want to use the default /%s/ page.", 'placeholders: courses, courses (URL slug)', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Section_Permalinks', 'courses' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'orderby' => array( 'id' => $this->shortcodes_section_key . '_orderby', 'name' => 'orderby', 'type' => 'select', 'label' => esc_html__( 'Order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => 'ID', 'options' => array( 'ID' => esc_html__('ID - Order by post id. (default)', 'learndash'), 'title' => esc_html__('Title - Order by post title', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash') ) ), 'order' => array( 'id' => $this->shortcodes_section_key . '_order', 'name' => 'order', 'type' => 'select', 'label' => esc_html__( 'Order', 'learndash' ), 'help_text' => esc_html__( 'Order', 'learndash' ), 'value' => 'ID', 'options' => array( '' => esc_html__('DESC - highest to lowest values (default)', 'learndash'), 'ASC' => esc_html__('ASC - lowest to highest values', 'learndash'), ) ), 'num' => array( 'id' => $this->shortcodes_section_key . '_num', 'name' => 'num', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Per Page', 'placeholders: courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'help_text' => sprintf( esc_html_x( '%s per page. Default is %d. Set to zero for all.', 'placeholders: courses, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'mycourses' => array( 'id' => $this->shortcodes_section_key . '_mycourses', 'name' => 'mycourses', 'type' => 'select', 'label' => sprintf( esc_html_x( 'My %s', 'placeholder: Courses', 'learndash'), LearnDash_Custom_Label::get_label( 'courses' ) ), 'help_text' => sprintf( esc_html_x( 'show current user\'s %s.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', 'options' => array( '' => sprintf( esc_html_x('Show All %s (default)', 'placeholders: courses', 'learndash'), learndash_get_custom_label_lower( 'Courses' ) ), 'enrolled' => sprintf( esc_html_x('Show Enrolled %s only', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'Courses' ) ), 'not-enrolled' => sprintf( esc_html_x('Show not-Enrolled %s only', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'Courses' ) ), ) ), 'status' => array( 'id' => $this->shortcodes_section_key . '_status', 'name' => 'status', 'type' => 'multiselect', 'label' => sprintf( esc_html_x( 'All %s Status', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'filter %s by status.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => array( 'not_started', 'in_progress', 'completed' ), 'options' => array( //'' => esc_html__('All', 'learndash'), 'not_started' => esc_html__( 'Not Started', 'learndash' ), 'in_progress' => esc_html__( 'In Progress', 'learndash' ), 'completed' => esc_html__('Completed', 'learndash' ), ), //'parent_setting' => 'mycourses', ), 'show_content' => array( 'id' => $this->shortcodes_section_key . 'show_content', 'name' => 'show_content', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Content', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s content.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), 'show_thumbnail' => array( 'id' => $this->shortcodes_section_key . '_show_thumbnail', 'name' => 'show_thumbnail', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Thumbnail', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s thumbnail.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), ); if ( defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) { $this->shortcodes_option_fields['col'] = array( 'id' => $this->shortcodes_section_key . '_col', 'name' => 'col', 'type' => 'number', 'label' => esc_html__('Columns','learndash'), 'help_text' => sprintf( esc_html_x( 'number of columns to show when using %s grid addon', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => '', 'class' => 'small-text' ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Taxonomies', 'ld_course_category' ) == 'yes') { $this->shortcodes_option_fields['course_category_name'] = array( 'id' => $this->shortcodes_section_key . 'course_category_name', 'name' => 'course_category_name', 'type' => 'text', 'label' => sprintf( esc_html_x('%s Category Slug', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category slug.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', ); $this->shortcodes_option_fields['course_cat'] = array( 'id' => $this->shortcodes_section_key . 'course_cat', 'name' => 'course_cat', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Category ID', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category id.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['course_categoryselector'] = array( 'id' => $this->shortcodes_section_key . 'course_categoryselector', 'name' => 'course_categoryselector', 'type' => 'checkbox', 'label' => sprintf( esc_html_x('%s Category Selector', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s category dropdown.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Taxonomies', 'ld_course_tag' ) == 'yes') { $this->shortcodes_option_fields['course_tag'] = array( 'id' => $this->shortcodes_section_key . 'course_tag', 'name' => 'course_tag', 'type' => 'text', 'label' => sprintf( esc_html_x( '%s Tag Slug', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag slug.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', ); $this->shortcodes_option_fields['course_tag_id'] = array( 'id' => $this->shortcodes_section_key . 'course_tag_id', 'name' => 'course_tag_id', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Tag ID', 'placeholder: Course', 'learndash'), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag id.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', 'class' => 'small-text' ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Taxonomies', 'wp_post_category' ) == 'yes') { $this->shortcodes_option_fields['category_name'] = array( 'id' => $this->shortcodes_section_key . 'category_name', 'name' => 'category_name', 'type' => 'text', 'label' => esc_html__('WP Category Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category slug.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', ); $this->shortcodes_option_fields['cat'] = array( 'id' => $this->shortcodes_section_key . 'cat', 'name' => 'cat', 'type' => 'number', 'label' => esc_html__('WP Category ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category id.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['categoryselector'] = array( 'id' => $this->shortcodes_section_key . 'categoryselector', 'name' => 'categoryselector', 'type' => 'checkbox', 'label' => esc_html__('WP Category Selector', 'learndash'), 'help_text' => esc_html__( 'shows a WP category dropdown.', 'learndash' ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Taxonomies', 'wp_post_tag' ) == 'yes') { $this->shortcodes_option_fields['tag'] = array( 'id' => $this->shortcodes_section_key . 'tag', 'name' => 'tag', 'type' => 'text', 'label' => esc_html__( 'WP Tag Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag slug.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', ); $this->shortcodes_option_fields['tag_id'] = array( 'id' => $this->shortcodes_section_key . 'tag_id', 'name' => 'tag_id', 'type' => 'number', 'label' => esc_html__('WP Tag ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag id.', 'placeholders: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => '', 'class' => 'small-text' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } function show_shortcodes_section_footer_extra() { ?> fields_args = $fields_args; $this->shortcodes_section_key = 'ld_certificate'; $this->shortcodes_section_title = esc_html__( 'Certificate', 'learndash' ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = esc_html__( 'This shortcode shows a Certificate download link.', 'learndash' ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course, Course. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', //'required' => 'required', 'class' => 'small-text', ), 'quiz_id' => array( 'id' => $this->shortcodes_section_key . '_quiz_id', 'name' => 'quiz_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s ID', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholders: Quiz, Quiz. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Quiz, Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'label' => array( 'id' => $this->shortcodes_section_key . '_label', 'name' => 'label', 'type' => 'text', 'label' => esc_html__( 'Label', 'learndash' ), 'help_text' => esc_html__( 'Label for link shown to user', 'learndash' ), 'value' => '', ), 'class' => array( 'id' => $this->shortcodes_section_key . '_class', 'name' => 'class', 'type' => 'text', 'label' => esc_html__( 'HTML Class', 'learndash' ), 'help_text' => esc_html__( 'HTML class for link element', 'learndash' ), 'value' => '', ), 'context' => array( 'id' => $this->shortcodes_section_key . '_context', 'name' => 'context', 'type' => 'text', 'label' => esc_html__( 'Context', 'learndash' ), 'help_text' => esc_html__( 'User defined value to be passed into shortcode handler', 'learndash' ), 'value' => '', ), 'callback' => array( 'id' => $this->shortcodes_section_key . '_callback', 'name' => 'callback', 'type' => 'text', 'label' => esc_html__( 'Callback', 'learndash' ), 'help_text' => esc_html__( 'Custom callback function to be used instead of default output', 'learndash' ), 'value' => '', ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\3+z/shortcodes-sections/ld_course_expire_status.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_course_expire_status'; // translators: placeholder: Course. $this->shortcodes_section_title = sprintf( esc_html_x( '%s Expire Status', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; // translators: placeholders: course. $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode displays the user %s access expire date.', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', // translators: placeholder: Course 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholders: Course, Course. 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'label_before' => array( 'id' => $this->shortcodes_section_key . '_label_before', 'name' => 'label_before', 'type' => 'text', 'label' => esc_html__( 'Label before', 'learndash' ), 'help_text' => esc_html__( 'The label prefix shown before the access expires', 'learndash' ), 'value' => '', ), 'label_after' => array( 'id' => $this->shortcodes_section_key . '_label_after', 'name' => 'label_after', 'type' => 'text', 'label' => esc_html__( 'Label after', 'learndash' ), 'help_text' => esc_html__( 'The label prefix shown after access has expired', 'learndash' ), 'value' => '', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( 'sfwd-courses' !== $this->fields_args['post_type'] ) && ( 'sfwd-lessons' !== $this->fields_args['post_type'] ) && ( 'sfwd-topic' !== $this->fields_args['post_type'] ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; // translators: placeholders: Course. $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\6[= = shortcodes-sections/ld_group.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_group'; $this->shortcodes_section_title = esc_html__( 'Group', 'learndash' ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = esc_html__( 'This shortcode shows the content if the user is enrolled in a specific group.', 'learndash' ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'group_id' => array( 'id' => $this->shortcodes_section_key . '_group_id', 'name' => 'group_id', 'type' => 'number', 'label' => esc_html__( 'Group ID', 'learndash' ), 'help_text' => esc_html__( 'Enter single Group ID. Leave blank for any Group.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( 'groups' != $this->fields_args['post_type'] ) ) { $this->shortcodes_option_fields['group_id']['required'] = 'required'; $this->shortcodes_option_fields['group_id']['help_text'] = esc_html__( 'Enter single Group ID.', 'learndash' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\ Q0Q0&shortcodes-sections/ld_lesson_list.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_lesson_list'; $this->shortcodes_section_title = sprintf( esc_html_x( '%s List', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( wp_kses_post( _x( "This shortcode shows list of %s. You can use this shortcode on any page if you don't want to use the default /%s/ page.", 'placeholders: lessons, lessons (URL slug)', 'learndash' ) ), learndash_get_custom_label_lower( 'lessons' ), LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Section_Permalinks', 'lessons' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for all %2$s.', 'placeholders: Course, Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'class' => 'small-text' ), 'orderby' => array( 'id' => $this->shortcodes_section_key . '_orderby', 'name' => 'orderby', 'type' => 'select', 'label' => esc_html__( 'Order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order by %s. (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'id' => esc_html__('ID - Order by post id.', 'learndash'), 'title' => esc_html__('Title - Order by post title', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'order' => array( 'id' => $this->shortcodes_section_key . '_order', 'name' => 'order', 'type' => 'select', 'label' => esc_html__( 'Order', 'learndash' ), 'help_text' => esc_html__( 'Order', 'learndash' ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order per %s (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'DESC' => esc_html__('DESC - highest to lowest values', 'learndash'), 'ASC' => esc_html__('ASC - lowest to highest values', 'learndash'), ) ), 'num' => array( 'id' => $this->shortcodes_section_key . '_num', 'name' => 'num', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s Per Page', 'placeholders: lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ), 'help_text' => sprintf( esc_html_x( '%1$s per page. Default is %2$d. Set to zero for all.', 'placeholders: lessons, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'show_content' => array( 'id' => $this->shortcodes_section_key . 'show_content', 'name' => 'show_content', 'type' => 'select', 'label' => sprintf( esc_html_x( 'Show %s Content', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'show %s content.', 'placeholders: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__('No', 'learndash'), ) ), 'show_thumbnail' => array( 'id' => $this->shortcodes_section_key . 'show_thumbnail', 'name' => 'show_thumbnail', 'type' => 'select', 'label' => sprintf( esc_html_x( 'Show %s Thumbnail', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s thumbnail.', 'placeholders: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ) ), ); if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Builder', 'shared_steps' ) != 'yes' ) { foreach( $this->shortcodes_option_fields['orderby']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['orderby']['options'][$option_key] ); } } foreach( $this->shortcodes_option_fields['order']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['order']['options'][$option_key] ); } } } if ( defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) { $this->shortcodes_option_fields['col'] = array( 'id' => $this->shortcodes_section_key . '_col', 'name' => 'col', 'type' => 'number', 'label' => esc_html__('Columns','learndash'), 'help_text' => sprintf( esc_html_x( 'number of columns to show when using %s grid addon', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => '', 'class' => 'small-text' ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Lessons_Taxonomies', 'ld_lesson_category' ) == 'yes') { $this->shortcodes_option_fields['lesson_cat'] = array( 'id' => $this->shortcodes_section_key . '_lesson_cat', 'name' => 'lesson_cat', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Category ID', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category id.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['lesson_category_name'] = array( 'id' => $this->shortcodes_section_key . '_lesson_category_name', 'name' => 'lesson_category_name', 'type' => 'text', 'label' => sprintf( esc_html_x('%s Category Slug', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category slug.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', ); $this->shortcodes_option_fields['lesson_categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_lesson_categoryselector', 'name' => 'lesson_categoryselector', 'type' => 'checkbox', 'label' => sprintf( esc_html_x('%s Category Selector', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s category dropdown.', 'placeholders: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Lessons_Taxonomies', 'ld_lesson_tag' ) == 'yes') { $this->shortcodes_option_fields['lesson_tag_id'] = array( 'id' => $this->shortcodes_section_key . '_lesson_tag_id', 'name' => 'lesson_tag_id', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Tag ID', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'Lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag id.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['lesson_tag'] = array( 'id' => $this->shortcodes_section_key . '_lesson_tag', 'name' => 'lesson_tag', 'type' => 'text', 'label' => sprintf( esc_html_x( '%s Tag Slug', 'placeholder: Lesson', 'learndash'), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag slug.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Lessons_Taxonomies', 'wp_post_category' ) == 'yes') { $this->shortcodes_option_fields['cat'] = array( 'id' => $this->shortcodes_section_key . '_cat', 'name' => 'cat', 'type' => 'number', 'label' => esc_html__('WP Category ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category id.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['category_name'] = array( 'id' => $this->shortcodes_section_key . '_category_name', 'name' => 'category_name', 'type' => 'text', 'label' => esc_html__('WP Category Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category slug.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', ); $this->shortcodes_option_fields['categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_categoryselector', 'name' => 'categoryselector', 'type' => 'checkbox', 'label' => esc_html__('WP Category Selector', 'learndash'), 'help_text' => esc_html__( 'shows a WP category dropdown.', 'learndash' ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Lessons_Taxonomies', 'wp_post_tag' ) == 'yes') { $this->shortcodes_option_fields['tag'] = array( 'id' => $this->shortcodes_section_key . '_tag', 'name' => 'tag', 'type' => 'text', 'label' => esc_html__( 'WP Tag Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag slug.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', ); $this->shortcodes_option_fields['tag_id'] = array( 'id' => $this->shortcodes_section_key . '_tag_id', 'name' => 'tag_id', 'type' => 'number', 'label' => esc_html__('WP Tag ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag id.', 'placeholders: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ), 'value' => '', 'class' => 'small-text' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\BV'shortcodes-sections/learndash_login.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'learndash_login'; $this->shortcodes_section_title = esc_html__( 'LearnDash Login', 'learndash' ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = esc_html__( 'This shortcode adds the login button on any page', 'learndash' ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'login_description' => array( 'id' => $this->shortcodes_section_key . '_login_description', 'name' => 'login_description', 'type' => 'html', 'label' => '', 'label_none' => true, 'input_full' => true, 'value' => wpautop( esc_html__( 'Controls the Login functionality.', 'learndash' ) ), ), 'login_url' => array( 'id' => $this->shortcodes_section_key . '_login_url', 'name' => 'login_url', 'type' => 'text', 'label' => esc_html__( 'Login URL', 'learndash' ), 'value' => '', 'help_text' => esc_html__( 'Override default login URL', 'learndash' ), ), 'login_label' => array( 'id' => $this->shortcodes_section_key . '_login_label', 'name' => 'login_label', 'type' => 'text', 'label' => esc_html__( 'Login Label', 'learndash' ), 'value' => '', 'help_text' => esc_html__( 'Override default label "Login"', 'learndash' ), ), 'login_placement' => array( 'id' => $this->shortcodes_section_key . '_login_placement', 'name' => 'login_placement', 'type' => 'select', 'label' => esc_html__( 'Login Icon Placement', 'learndash' ), 'help_text' => esc_html__( 'Login Icon Placement', 'learndash' ), 'value' => '', 'options' => array( '' => esc_html__( 'Left - To left of label', 'learndash' ), 'right' => esc_html__( 'Right - To right of label', 'learndash' ), 'none' => esc_html__( 'None - No icon', 'learndash' ), ), ), 'login_button' => array( 'id' => $this->shortcodes_section_key . '_login_button', 'name' => 'login_button', 'type' => 'select', 'label' => esc_html__( 'Login Displayed as', 'learndash' ), 'help_text' => esc_html__( 'Display as Button or link', 'learndash' ), 'value' => 'button', 'options' => array( '' => esc_html__( 'Button', 'learndash' ), 'link' => esc_html__( 'Link', 'learndash' ), ), ), /* 'login_url_redirect' => array( 'id' => $this->shortcodes_section_key . '_login_url_redirect', 'name' => 'login_url_redirect', 'type' => 'text', 'label' => esc_html__('Login URL Redirect', 'learndash'), 'value' => '', 'help_text' => esc_html__( 'URL to redirect to after login. Default is the current page URL.', 'learndash' ), ), */ 'logout_description' => array( 'id' => $this->shortcodes_section_key . '_logout_description', 'name' => 'logout_description', 'type' => 'html', 'label' => '', 'label_none' => true, 'input_full' => true, 'value' => wpautop( esc_html__( 'Controls the Logout functionality.', 'learndash' ) ), ), 'logout_url' => array( 'id' => $this->shortcodes_section_key . '_logout_url', 'name' => 'logout_url', 'type' => 'text', 'label' => esc_html__( 'Logout URL Redirect', 'learndash' ), 'value' => '', 'help_text' => esc_html__( 'Override default logout URL.', 'learndash' ), ), 'logout_label' => array( 'id' => $this->shortcodes_section_key . '_logout_label', 'name' => 'logout_label', 'type' => 'text', 'label' => esc_html__( 'Logout Label', 'learndash' ), 'value' => '', 'help_text' => esc_html__( 'Override default label "Logout"', 'learndash' ), ), 'logout_placement' => array( 'id' => $this->shortcodes_section_key . '_logout_placement', 'name' => 'logout_placement', 'type' => 'select', 'label' => esc_html__( 'Logout Icon Placement', 'learndash' ), 'help_text' => esc_html__( 'Logout Icon Placement', 'learndash' ), 'value' => '', 'options' => array( 'left' => esc_html__( 'Left - To left of label', 'learndash' ), '' => esc_html__( 'Right - To right of label', 'learndash' ), 'none' => esc_html__( 'None - No icon', 'learndash' ), ), ), 'logout_button' => array( 'id' => $this->shortcodes_section_key . '_logout_button', 'name' => 'logout_button', 'type' => 'select', 'label' => esc_html__( 'Logout Displayed as Button', 'learndash' ), 'help_text' => esc_html__( 'Display as Button or link', 'learndash' ), 'value' => 'button', 'options' => array( '' => esc_html__( 'Button', 'learndash' ), 'link' => esc_html__( 'Link', 'learndash' ), ), ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\ N (shortcodes-sections/ld_course_resume.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_course_resume'; $this->shortcodes_section_title = sprintf( // translators: placeholders: Course. esc_html_x( '%s Resume', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = sprintf( // translators: placeholders: Course. esc_html_x( 'Return to %s link/button.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course, Course. esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', // 'required' => 'required', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'label' => array( 'id' => $this->shortcodes_section_key . '_label', 'name' => 'label', 'type' => 'text', 'label' => esc_html__( 'Label', 'learndash' ), 'help_text' => esc_html__( 'Label for link shown to user', 'learndash' ), 'value' => '', ), 'button' => array( 'id' => $this->shortcodes_section_key . '_button', 'name' => 'button', 'type' => 'select', 'label' => esc_html__( 'Show as button', 'learndash' ), 'help_text' => esc_html__( 'shows as button content.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), 'html_class' => array( 'id' => $this->shortcodes_section_key . '_html_class', 'name' => 'html_class', 'type' => 'text', 'label' => esc_html__( 'HTML Class', 'learndash' ), 'help_text' => esc_html__( 'HTML class for link element', 'learndash' ), 'value' => '', ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\}qQ6 5 5$shortcodes-sections/ld_quiz_list.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_quiz_list'; $this->shortcodes_section_title = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s List', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( wp_kses_post( // translators: placeholders: quizzes, quizzes (URL slug). _x( 'This shortcode shows list of %1$s. You can use this shortcode on any page if you don\'t want to use the default /%2$s/ page.', 'placeholders: quizzes, quizzes (URL slug)', 'learndash' ) ), learndash_get_custom_label_lower( 'quizzes' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'quizzes' ) ); parent::__construct(); } /** * Initialize shortcode fields. * * @since 2.4.0 */ public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholders: Course, Courses. esc_html_x( 'Enter single %1$s ID. Leave blank for all %2$s.', 'placeholders: Course, Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'class' => 'small-text', ), 'lesson_id' => array( 'id' => $this->shortcodes_section_key . '_lesson_id', 'name' => 'lesson_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'Must be used with course_id. Enter single %1$s or %2$s ID. Leave blank for all step within %3$s. Set zero for global.', 'placeholders: Lesson, Topic, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ), LearnDash_Custom_Label::get_label( 'topic' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => '', 'class' => 'small-text' ), 'orderby' => array( 'id' => $this->shortcodes_section_key . '_orderby', 'name' => 'orderby', 'type' => 'select', 'label' => esc_html__( 'Order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order by %s. (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'id' => esc_html__('ID - Order by post id.', 'learndash'), 'title' => esc_html__('Title - Order by post title', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'order' => array( 'id' => $this->shortcodes_section_key . '_order', 'name' => 'order', 'type' => 'select', 'label' => esc_html__( 'Order', 'learndash' ), 'help_text' => esc_html__( 'Order', 'learndash' ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order per %s (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'DESC' => esc_html__('DESC - highest to lowest values', 'learndash'), 'ASC' => esc_html__('ASC - lowest to highest values', 'learndash'), ) ), 'num' => array( 'id' => $this->shortcodes_section_key . '_num', 'name' => 'num', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s Per Page', 'placeholders: quizzes', 'learndash'), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'help_text' => sprintf( esc_html_x( '%s per page. Default is %d. Set to zero for all.', 'placeholders: quizzes, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'show_content' => array( 'id' => $this->shortcodes_section_key . 'show_content', 'name' => 'show_content', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Content', 'placeholder: Quiz', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s content.', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), 'show_thumbnail' => array( 'id' => $this->shortcodes_section_key . 'show_thumbnail', 'name' => 'show_thumbnail', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Thumbnail', 'placeholder: Quiz', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s thumbnail.', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ) ); if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Builder', 'shared_steps' ) != 'yes' ) { foreach( $this->shortcodes_option_fields['orderby']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['orderby']['options'][$option_key] ); } } foreach( $this->shortcodes_option_fields['order']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['order']['options'][$option_key] ); } } } if ( defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) { $this->shortcodes_option_fields['col'] = array( 'id' => $this->shortcodes_section_key . '_col', 'name' => 'col', 'type' => 'number', 'label' => esc_html__('Columns','learndash'), 'help_text' => sprintf( esc_html_x( 'number of columns to show when using %s grid addon', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => '', 'class' => 'small-text' ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Quizzes_Taxonomies', 'ld_quiz_category' ) == 'yes') { $this->shortcodes_option_fields['quiz_cat'] = array( 'id' => $this->shortcodes_section_key . '_quiz_cat', 'name' => 'quiz_cat', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s Category ID', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category id.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['quiz_category_name'] = array( 'id' => $this->shortcodes_section_key . '_quiz_category_name', 'name' => 'quiz_category_name', 'type' => 'text', 'label' => sprintf( esc_html_x('%s Category Slug', 'placeholder: Quiz', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category slug.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', ); $this->shortcodes_option_fields['quiz_categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_quiz_categoryselector', 'name' => 'quiz_categoryselector', 'type' => 'checkbox', 'label' => sprintf( esc_html_x('%s Category Selector', 'placeholder: Quiz', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s category dropdown.', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Quizzes_Taxonomies', 'ld_quiz_tag' ) == 'yes') { $this->shortcodes_option_fields['quiz_tag_id'] = array( 'id' => $this->shortcodes_section_key . '_quiz_tag_id', 'name' => 'quiz_tag_id', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Tag ID', 'placeholder: Quizzes', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag id.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['quiz_tag'] = array( 'id' => $this->shortcodes_section_key . '_quiz_tag', 'name' => 'quiz_tag', 'type' => 'text', 'label' => sprintf( esc_html_x( '%s Tag Slug', 'placeholder: Quiz', 'learndash'), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag slug.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', ); } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Taxonomies', 'wp_post_category' ) == 'yes' ) { $this->shortcodes_option_fields['cat'] = array( 'id' => $this->shortcodes_section_key . '_cat', 'name' => 'cat', 'type' => 'number', 'label' => esc_html__('WP Category ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category id.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['category_name'] = array( 'id' => $this->shortcodes_section_key . '_category_name', 'name' => 'category_name', 'type' => 'text', 'label' => esc_html__( 'WP Category Slug', 'learndash' ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category slug.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', ); $this->shortcodes_option_fields['categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_categoryselector', 'name' => 'categoryselector', 'type' => 'checkbox', 'label' => esc_html__( 'WP Category Selector', 'learndash' ), 'help_text' => esc_html__( 'shows a WP category dropdown.', 'learndash' ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Quizzes_Taxonomies', 'wp_post_tag' ) == 'yes') { $this->shortcodes_option_fields['tag'] = array( 'id' => $this->shortcodes_section_key . '_tag', 'name' => 'tag', 'type' => 'text', 'label' => esc_html__( 'WP Tag Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag slug.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', ); $this->shortcodes_option_fields['tag_id'] = array( 'id' => $this->shortcodes_section_key . '_tag_id', 'name' => 'tag_id', 'type' => 'number', 'label' => esc_html__('WP Tag ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag id.', 'placeholders: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'value' => '', 'class' => 'small-text' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\,, shortcodes-sections/ld_video.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_video'; $this->shortcodes_section_type = 1; // translators: placeholders: Lessons, Topics $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode is used on %1$s and %2$s where Video Progression is enabled. The video player will be added above the content. This shortcode allows positioning the player elsewhere within the content. This shortcode does not take any parameters.', 'placeholders: Lessons, Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Custom_Label::get_label( 'topics' ) ); if ( learndash_get_post_type_slug( 'lesson' ) == $this->fields_args['post_type'] ) { // translators: placeholder: lesson $this->shortcodes_section_title = sprintf( esc_html_x( '%s Video', 'placeholder: lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ); } elseif ( learndash_get_post_type_slug( 'topic' ) == $this->fields_args['post_type'] ) { // translators: placeholder: topic $this->shortcodes_section_title = sprintf( esc_html_x( '%s Video', 'placeholder: topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ); } parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array(); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\ )shortcodes-sections/course_inprogress.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'course_inprogress'; // translators: placeholder: Course. $this->shortcodes_section_title = sprintf( esc_html_x( '%s In Progress', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 2; // translators: placeholders: course. $this->shortcodes_section_description = sprintf( wp_kses_post( _x( 'This shortcode shows the content if the user has started but not completed the %s. The shortcode can be used on any page or widget area.', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', // translators: placeholder: Course. 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholders: Course, Course. 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: Course, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( 'sfwd-courses' !== $this->fields_args['post_type'] ) && ( 'sfwd-lessons' !== $this->fields_args['post_type'] ) && ( 'sfwd-topic' !== $this->fields_args['post_type'] ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; // translators: placeholders: Course. $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\y9_-shortcodes-sections/ld_user_course_points.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'ld_user_course_points'; $this->shortcodes_section_title = sprintf( esc_html_x( 'User %s Points', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode shows the earned %s points for the user.', 'placeholders: course, course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text' ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\ shortcodes-sections/usermeta.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'usermeta'; $this->shortcodes_section_title = esc_html__( 'User meta', 'learndash' ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = wp_kses_post( __('This shortcode takes a parameter named field, which is the name of the user meta data field to be displayed. See the full list of available fields here. Note for security reasons some fields are not allowed.', 'learndash' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'field' => array( 'id' => $this->shortcodes_section_key . '_field', 'name' => 'field', 'type' => 'select', 'label' => esc_html__( 'Field', 'learndash' ), 'help_text' => esc_html__( 'This parameter determines the information to be shown by the shortcode.', 'learndash' ), 'value' => 'ID', 'options' => learndash_get_usermeta_shortcode_available_fields() ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text' ), ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\&(a shortcodes-sections/quizinfo.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'quizinfo'; $this->shortcodes_section_title = sprintf( esc_html_x( '%s Info', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( esc_html_x( 'This shortcode displays information regarding %s attempts on the certificate. This shortcode can use the following parameters:', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'show' => array( 'id' => $this->shortcodes_section_key . '_show', 'name' => 'show', 'type' => 'select', 'label' => esc_html__( 'Show', 'learndash' ), 'help_text' => sprintf( wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode.
    cumulative - average for all %s of the %s.
    aggregate - sum for all %s of the %s.', 'placeholders: quizzes, course, quizzes, course', 'learndash' ) ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => 'ID', 'options' => array( 'score' => esc_html__( 'Score', 'learndash' ), 'count' => esc_html__( 'Count', 'learndash' ), 'pass' => esc_html__( 'Pass', 'learndash' ), 'timestamp' => esc_html__( 'Timestamp', 'learndash' ), 'points' => esc_html__( 'Points', 'learndash' ), 'total_points' => esc_html__( 'Total Points', 'learndash' ), 'percentage' => esc_html__( 'Percentage', 'learndash' ), 'quiz_title' => sprintf(_x( '%s Title', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'course_title' => sprintf(_x( '%s Title', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'timespent' => esc_html__( 'Time Spent', 'learndash' ), 'field' => esc_html__( 'Custom Field', 'learndash'), ) ), 'format' => array( 'id' => $this->shortcodes_section_key . '_format', 'name' => 'format', 'type' => 'text', 'label' => esc_html__( 'Format', 'learndash'), 'help_text' => wp_kses_post( __( 'This can be used to change the date format. Default: "F j, Y, g:i a" shows as March 10, 2001, 5:16 pm. See the full list of available date formating strings here.', 'learndash' ) ), 'value' => '', ), 'field_id' => array( 'id' => $this->shortcodes_section_key . '_field_id', 'name' => 'field_id', 'type' => 'text', 'label' => esc_html__( 'Custom Field ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'The Field ID is show on the %s Custom Fields table.', 'placeholders: quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => '', ), ); $post_types = array( learndash_get_post_type_slug( 'certificate' ), learndash_get_post_type_slug( 'quiz' ) ); if ( ( ! isset( $this->fields_args['typenow'] ) ) || ( ! in_array( $this->fields_args['typenow'], $post_types ) ) ) { $this->shortcodes_option_fields['quiz'] = array( 'id' => $this->shortcodes_section_key . '_quiz', 'name' => 'quiz', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %s ID', 'placeholders: quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => '', 'class' => 'small-text', 'required' => 'required' ); $this->shortcodes_option_fields['user_id'] = array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__('Enter specific User ID', 'learndash' ), 'value' => '', 'class' => 'small-text', 'required' => 'required' ); $this->shortcodes_option_fields['time'] = array( 'id' => $this->shortcodes_section_key . '_time', 'name' => 'time', 'type' => 'text', 'label' => esc_html__( 'Timestamp', 'learndash'), 'help_text' => sprintf( esc_html_x( 'Enter single %s attempt timestamp', 'placeholders: quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => '', 'required' => 'required' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } function show_shortcodes_section_footer_extra() { ?> fields_args = $fields_args; $this->shortcodes_section_key = 'student'; $this->shortcodes_section_title = esc_html__( 'Student', 'learndash' ); $this->shortcodes_section_type = 2; $this->shortcodes_section_description = sprintf( wp_kses_post( _x( 'This shortcode shows the content if the user is enrolled in the %s. The shortcode can be used on any page or widget area.', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'message' => array( 'id' => $this->shortcodes_section_key . '_message', 'name' => 'message', 'type' => 'textarea', 'label' => esc_html__( 'Message shown to user', 'learndash' ), 'help_text' => esc_html__( 'Message shown to user', 'learndash' ), 'value' => '', 'required' => 'required', ), 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for current %2$s.', 'placeholders: course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', ), 'user_id' => array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ), 'autop' => array( 'id' => $this->shortcodes_section_key . 'autop', 'name' => 'autop', 'type' => 'select', 'label' => esc_html__( 'Auto Paragraph', 'learndash' ), 'help_text' => esc_html__( 'Format shortcode content into proper pararaphs.', 'learndash' ), 'value' => 'true', 'options' => array( '' => esc_html__( 'Yes (default)', 'learndash' ), 'false' => esc_html__( 'No', 'learndash' ), ), ), ); if ( ( ! isset( $this->fields_args['post_type'] ) ) || ( ( $this->fields_args['post_type'] != 'sfwd-courses' ) && ( $this->fields_args['post_type'] != 'sfwd-lessons' ) && ( $this->fields_args['post_type'] != 'sfwd-topic' ) ) ) { $this->shortcodes_option_fields['course_id']['required'] = 'required'; $this->shortcodes_option_fields['course_id']['help_text'] = sprintf( esc_html_x( 'Enter single %s ID', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\+}--"shortcodes-sections/courseinfo.phpnuW+Afields_args = $fields_args; $this->shortcodes_section_key = 'courseinfo'; // translators: placeholder: Course. $this->shortcodes_section_title = sprintf( esc_html_x( '%s Info', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $this->shortcodes_section_type = 1; // translators: placeholder: course, quizzes, course. $this->shortcodes_section_description = sprintf( wp_kses_post( _x( 'This shortcode displays %1$s related information on the certificate. Unless specified otherwise, all points, scores and percentages relate to the %2$s associated with the %3$s.', 'placeholder: course, quizzes, course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } public function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'show' => array( 'id' => $this->shortcodes_section_key . '_show', 'name' => 'show', 'type' => 'select', 'label' => esc_html__( 'Show', 'learndash' ), 'help_text' => sprintf( // translators: placeholders: quizzes, course, quizzes, course. wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode.
    cumulative - average for all %1$s of the %2$s.
    aggregate - sum for all %3$s of the %4$s.', 'placeholders: quizzes, course, quizzes, course', 'learndash' ) ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => 'ID', 'options' => array( // translators: placeholder: Course. 'course_title' => sprintf( esc_html_x( '%s Title', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'course_url' => sprintf( esc_html_x( '%s URL', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'course_points' => sprintf( esc_html_x( '%s Points', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'course_price_type' => sprintf( esc_html_x( '%s Price Type', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course. 'course_price' => sprintf( esc_html_x( '%s Price', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course 'user_course_points' => sprintf( esc_html_x( 'Total User %s Points', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course 'user_course_time' => sprintf( esc_html_x( 'Total User %s Time', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course 'completed_on' => sprintf( esc_html_x( '%s Completed On (date)', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Course 'enrolled_on' => sprintf( esc_html_x( 'Enrolled On (date)', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholder: Quizzes 'cumulative_score' => sprintf( esc_html_x( 'Cumulative %s Score', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'cumulative_points' => sprintf( esc_html_x( 'Cumulative %s Points', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'cumulative_total_points' => sprintf( esc_html_x( 'Possible Cumulative %s Total Points', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'cumulative_percentage' => sprintf( esc_html_x( 'Cumulative %s Percentage', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'cumulative_timespent' => sprintf( esc_html_x( 'Cumulative %s Time Spent', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'aggregate_percentage' => sprintf( esc_html_x( 'Aggregate %s Percentage', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'aggregate_score' => sprintf( esc_html_x( 'Aggregate %s Score', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'aggregate_points' => sprintf( esc_html_x( 'Aggregate %s Points', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'aggregate_total_points' => sprintf( esc_html_x( 'Possible %s Aggregate Total Points', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), // translators: placeholder: Quizzes 'aggregate_timespent' => sprintf( esc_html_x( 'Aggregate %s Time Spent', 'placeholder: Quizzes','learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), ), ), 'format' => array( 'id' => $this->shortcodes_section_key . '_format', 'name' => 'format', 'type' => 'text', 'label' => esc_html__( 'Format', 'learndash' ), 'help_text' => wp_kses_post( __( 'This can be used to change the date format. Default: "F j, Y, g:i a" shows as March 10, 2001, 5:16 pm. See the full list of available date formating strings here.', 'learndash' ) ), 'value' => '', 'placeholder' => 'F j, Y, g:i a', ), 'seconds_format' => array( 'id' => $this->shortcodes_section_key . '_seconds_format', 'name' => 'seconds_format', 'type' => 'select', 'label' => esc_html__( 'Seconds Format', 'learndash' ), 'help_text' => wp_kses_post( __( 'This can be used to change the format of seconds. Default: "time" shows a number of seconds as XXmin YYsec. ', 'learndash' ) ), 'value' => '', 'options' => array( '' => esc_html__( 'Time - 20min 49sec', 'learndash' ), 'seconds' => esc_html__( 'Seconds - 1436', 'learndash' ), ), ), ); $post_types = learndash_get_post_types( 'course' ); $post_types[] = learndash_get_post_type_slug( 'certificate' ); if ( ( ! isset( $this->fields_args['typenow'] ) ) || ( ! in_array( $this->fields_args['typenow'], $post_types ) ) ) { $this->shortcodes_option_fields['course_id'] = array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', // translators: placeholder: Course. 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), // translators: placeholders: Course. 'help_text' => sprintf( esc_html_x( 'Enter single %s ID.', 'placeholders: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '', 'class' => 'small-text', 'required' => 'required', ); $this->shortcodes_option_fields['user_id'] = array( 'id' => $this->shortcodes_section_key . '_user_id', 'name' => 'user_id', 'type' => 'number', 'label' => esc_html__( 'User ID', 'learndash' ), 'help_text' => esc_html__( 'Enter specific User ID. Leave blank for current User.', 'learndash' ), 'value' => '', 'class' => 'small-text', ); } $this->shortcodes_option_fields['decimals'] = array( 'id' => $this->shortcodes_section_key . '_decimals', 'name' => 'decimals', 'type' => 'number', 'label' => esc_html__( 'Decimals', 'learndash' ), 'help_text' => esc_html__( 'Number of decimal places to show. Default is 2.', 'learndash' ), 'value' => '', 'class' => 'small-text', ); $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } public function show_shortcodes_section_footer_extra() { ?> fields_args = $fields_args; $this->shortcodes_section_key = 'ld_topic_list'; $this->shortcodes_section_title = sprintf( esc_html_x( '%s List', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ); $this->shortcodes_section_type = 1; $this->shortcodes_section_description = sprintf( wp_kses_post( _x( "This shortcode shows list of %s. You can use this shortcode on any page if you don't want to use the default /%s/ page.", 'placeholders: topics, topics (URL slug)', 'learndash' ) ), learndash_get_custom_label_lower( 'topics' ), LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Section_Permalinks', 'topics' ) ); parent::__construct(); } function init_shortcodes_section_fields() { $this->shortcodes_option_fields = array( 'course_id' => array( 'id' => $this->shortcodes_section_key . '_course_id', 'name' => 'course_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'help_text' => sprintf( esc_html_x( 'Enter single %1$s ID. Leave blank for all %2$s.', 'placeholders: Course, Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '', 'class' => 'small-text' ), 'lesson_id' => array( 'id' => $this->shortcodes_section_key . '_lesson_id', 'name' => 'lesson_id', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s ID', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'help_text' => sprintf( esc_html_x( 'Must be used with course_id. Enter single %1$s ID. Leave blank for all %2$s within %3$s.', 'placeholders: Lesson, Lessons, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => '', 'class' => 'small-text' ), 'orderby' => array( 'id' => $this->shortcodes_section_key . '_orderby', 'name' => 'orderby', 'type' => 'select', 'label' => esc_html__( 'Order by', 'learndash' ), 'help_text' => wp_kses_post( __( 'See the full list of available orderby options here.', 'learndash' ) ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order by %s. (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'id' => esc_html__('ID - Order by post id.', 'learndash'), 'title' => esc_html__('Title - Order by post title', 'learndash'), 'date' => esc_html__('Date - Order by post date', 'learndash'), 'menu_order' => esc_html__('Menu - Order by Page Order Value', 'learndash'), ) ), 'order' => array( 'id' => $this->shortcodes_section_key . '_order', 'name' => 'order', 'type' => 'select', 'label' => esc_html__( 'Order', 'learndash' ), 'help_text' => esc_html__( 'Order', 'learndash' ), 'value' => 'ID', 'options' => array( '' => sprintf( esc_html_x('Order per %s (default)', 'placeholder: course', 'learndash'), learndash_get_custom_label_lower( 'course' ) ), 'DESC' => esc_html__('DESC - highest to lowest values', 'learndash'), 'ASC' => esc_html__('ASC - lowest to highest values', 'learndash'), ) ), 'num' => array( 'id' => $this->shortcodes_section_key . '_num', 'name' => 'num', 'type' => 'number', 'label' => sprintf( esc_html_x( '%s Per Page', 'placeholders: topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ), 'help_text' => sprintf( esc_html_x( '%s per page. Default is %d. Set to zero for all.', 'placeholders: topics, default per page', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ), LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Per_Page', 'per_page' ) ), 'value' => '', 'class' => 'small-text', 'attrs' => array( 'min' => 0, 'step' => 1 ) ), 'show_content' => array( 'id' => $this->shortcodes_section_key . 'show_content', 'name' => 'show_content', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Content', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s content.', 'placeholders: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), 'show_thumbnail' => array( 'id' => $this->shortcodes_section_key . 'show_thumbnail', 'name' => 'show_thumbnail', 'type' => 'select', 'label' => sprintf( esc_html_x('Show %s Thumbnail', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s thumbnail.', 'placeholders: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => 'true', 'options' => array( '' => esc_html__('Yes (default)', 'learndash'), 'false' => esc_html__('No', 'learndash'), ) ), ); if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Courses_Builder', 'shared_steps' ) != 'yes' ) { foreach( $this->shortcodes_option_fields['orderby']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['orderby']['options'][$option_key] ); } } foreach( $this->shortcodes_option_fields['order']['options'] as $option_key => $option_label ) { if ( empty( $option_key ) ) { unset( $this->shortcodes_option_fields['order']['options'][$option_key] ); } } } if ( defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) { $this->shortcodes_option_fields['col'] = array( 'id' => $this->shortcodes_section_key . '_col', 'name' => 'col', 'type' => 'number', 'label' => esc_html__('Columns','learndash'), 'help_text' => sprintf( esc_html_x( 'number of columns to show when using %s grid addon', 'placeholders: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => '', 'class' => 'small-text' ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Topics_Taxonomies', 'ld_topic_category' ) == 'yes') { $this->shortcodes_option_fields['topic_cat'] = array( 'id' => $this->shortcodes_section_key . '_topic_cat', 'name' => 'topic_cat', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Category ID', 'placeholder: Topics', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category id.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['topic_category_name'] = array( 'id' => $this->shortcodes_section_key . '_topic_category_name', 'name' => 'topic_category_name', 'type' => 'text', 'label' => sprintf( esc_html_x('%s Category Slug', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned category slug.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', ); $this->shortcodes_option_fields['topic_categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_topic_categoryselector', 'name' => 'topic_categoryselector', 'type' => 'checkbox', 'label' => sprintf( esc_html_x('%s Category Selector', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows a %s category dropdown.', 'placeholders: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Topics_Taxonomies', 'ld_topic_tag' ) == 'yes') { $this->shortcodes_option_fields['topic_tag_id'] = array( 'id' => $this->shortcodes_section_key . '_topic_tag_id', 'name' => 'topic_tag_id', 'type' => 'number', 'label' => sprintf( esc_html_x('%s Tag ID', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag id.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['topic_tag'] = array( 'id' => $this->shortcodes_section_key . '_topic_tag', 'name' => 'topic_tag', 'type' => 'text', 'label' => sprintf( esc_html_x( '%s Tag Slug', 'placeholder: Topic', 'learndash'), LearnDash_Custom_Label::get_label( 'topic' ) ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned tag slug.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Topics_Taxonomies', 'wp_post_category' ) == 'yes') { $this->shortcodes_option_fields['cat'] = array( 'id' => $this->shortcodes_section_key . '_cat', 'name' => 'cat', 'type' => 'number', 'label' => esc_html__('WP Category ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category id.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', 'class' => 'small-text' ); $this->shortcodes_option_fields['category_name'] = array( 'id' => $this->shortcodes_section_key . '_category_name', 'name' => 'category_name', 'type' => 'text', 'label' => esc_html__( 'WP Category Slug', 'learndash' ), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP category slug.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', ); $this->shortcodes_option_fields['categoryselector'] = array( 'id' => $this->shortcodes_section_key . '_categoryselector', 'name' => 'categoryselector', 'type' => 'checkbox', 'label' => esc_html__( 'WP Category Selector', 'learndash' ), 'help_text' => esc_html__( 'shows a WP category dropdown.', 'learndash' ), 'value' => '', 'options' => array( 'true' => esc_html__('Yes', 'learndash'), ) ); } if ( LearnDash_Settings_Section::get_section_setting('LearnDash_Settings_Topics_Taxonomies', 'wp_post_tag' ) == 'yes') { $this->shortcodes_option_fields['tag'] = array( 'id' => $this->shortcodes_section_key . '_tag', 'name' => 'tag', 'type' => 'text', 'label' => esc_html__( 'WP Tag Slug', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag slug.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', ); $this->shortcodes_option_fields['tag_id'] = array( 'id' => $this->shortcodes_section_key . '_tag_id', 'name' => 'tag_id', 'type' => 'number', 'label' => esc_html__('WP Tag ID', 'learndash'), 'help_text' => sprintf( esc_html_x( 'shows %s with mentioned WP tag id.', 'placeholders: topics', 'learndash' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => '', 'class' => 'small-text' ); } $this->shortcodes_option_fields = apply_filters( 'learndash_settings_fields', $this->shortcodes_option_fields, $this->shortcodes_section_key ); parent::init_shortcodes_section_fields(); } } } PK^\H_Z!!;settings-sections/class-ld-settings-section-courses-cpt.phpnuW+Asettings_screen_id = 'sfwd-courses_page_courses-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'courses-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_courses_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_courses_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Course. esc_html_x( '%s Custom Post Type Options', 'Course Custom Post Type Options', 'learndash' ), learndash_get_custom_label( 'course' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: Course. esc_html_x( 'Control the LearnDash %s Custom Post Type Options.', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ( false === $this->setting_option_values ) || ( '' === $this->setting_option_values ) ) { if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->setting_option_values = array( 'include_in_search' => 'yes', 'has_archive' => 'yes', 'has_feed' => '', 'supports' => array( 'thumbnail', 'revisions' ), ); } if ( ! isset( $this->setting_option_values['include_in_search'] ) ) { if ( ( isset( $this->setting_option_values['exclude_from_search'] ) ) && ( 'yes' === $this->setting_option_values['exclude_from_search'] ) ) { $this->setting_option_values['include_in_search'] = ''; } else { $this->setting_option_values['include_in_search'] = 'yes'; } } if ( ! isset( $this->setting_option_values['has_archive'] ) ) { $this->setting_option_values['has_archive'] = 'yes'; } if ( ! isset( $this->setting_option_values['has_feed'] ) ) { $this->setting_option_values['has_feed'] = ''; } if ( ! isset( $this->setting_option_values['supports'] ) ) { $this->setting_option_values['supports'] = array( 'thumbnail','revisions' ); } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $cpt_archive_url = home_url( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'courses' ) ); $cpt_rss_url = add_query_arg( 'post_type', 'sfwd-courses', get_post_type_archive_feed_link( 'post' ) ); $this->setting_option_fields = array( 'include_in_search' => array( 'name' => 'include_in_search', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Search', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Includes the %s post type in front end search results', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['include_in_search'], 'options' => array( 'yes' => '', ), ), 'has_archive' => array( 'name' => 'has_archive', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Archive Page', 'learndash' ), 'help_text' => sprintf( // translators: placeholders: courses, link to WP Permalins page. esc_html_x( 'Enables the front end archive page where all %1$s are listed. You must %2$s for the change to take effect.', 'placeholders: courses, link to WP Permalins page', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), '' . esc_html__( 're-save your permalinks', 'learndash' ) . '' ), 'value' => $this->setting_option_values['has_archive'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'Archive URL: %s', 'placeholder: URL for CPT Archive', 'learndash' ), '' . $cpt_archive_url . '' ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['has_archive'] ) ? 'open' : 'closed', ), 'has_feed' => array( 'name' => 'has_feed', 'type' => 'checkbox-switch', 'label' => esc_html__( 'RSS/Atom Feed', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: course esc_html_x( 'Enables an RSS feed for all %1$s posts.', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['has_feed'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'RSS Feed URL: %s', 'placeholder: URL for RSS Feed', 'learndash' ), '' . $cpt_rss_url . '' ), ), 'parent_setting' => 'has_archive', ), 'supports' => array( 'name' => 'supports', 'type' => 'checkbox', 'label' => esc_html__( 'Editor Supported Settings', 'learndash' ), 'help_text' => esc_html__( 'Enables WordPress supported settings within the editor and theme.', 'learndash' ), 'value' => $this->setting_option_values['supports'], 'options' => array( 'thumbnail' => esc_html__( 'Featured image', 'learndash' ), 'comments' => esc_html__( 'Comments', 'learndash' ), 'custom-fields' => esc_html__( 'Custom Fields', 'learndash' ), 'revisions' => esc_html__( 'Revisions', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $new_values = '', $old_values = '', $setting_option_key = '' ) { if ( $setting_option_key === $this->setting_option_key ) { $new_values = parent::section_pre_update_option( $new_values, $old_values, $setting_option_key ); if ( ! isset( $new_values['include_in_search'] ) ) { $new_values['include_in_search'] = ''; } if ( ! isset( $new_values['has_archive'] ) ) { $new_values['has_archive'] = ''; $new_values['has_feed'] = ''; } if ( ! isset( $new_values['has_feed'] ) ) { $new_values['has_feed'] = ''; } if ( ! isset( $new_values['supports'] ) ) { $new_values['supports'] = array(); } if ( $new_values !== $old_values ) { if ( ( ! isset( $old_values['has_archive'] ) ) || ( $new_values['has_archive'] !== $old_values['has_archive'] ) ) { learndash_setup_rewrite_flush(); } //if ( in_array( 'comments', $new_values['supports'] ) ) { // learndash_update_posts_comment_status( 'sfwd-courses', 'open' ); //} else { // learndash_update_posts_comment_status( 'sfwd-courses', 'closed' ); //} } } return $new_values; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Courses_CPT::add_section_instance(); } ); PK^\kff@settings-sections/class-ld-settings-section-general-rest-api.phpnuW+Asettings_page_id = 'learndash_lms_settings'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_rest_api'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_rest_api'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_rest_api'; // Section label/header. $this->settings_section_label = esc_html__( 'REST API Settings', 'learndash' ); $this->settings_section_description = esc_html__( 'Control and customize the REST API endpoints.', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ! isset( $this->setting_option_values['enabled'] ) ) { $this->setting_option_values['enabled'] = 'yes'; } if ( ( ! isset( $this->setting_option_values['sfwd-courses'] ) ) || ( empty( $this->setting_option_values['sfwd-courses'] ) ) ) { $this->setting_option_values['sfwd-courses'] = 'sfwd-courses'; } if ( ( ! isset( $this->setting_option_values['sfwd-lessons'] ) ) || ( empty( $this->setting_option_values['sfwd-lessons'] ) ) ) { $this->setting_option_values['sfwd-lessons'] = 'sfwd-lessons'; } if ( ( ! isset( $this->setting_option_values['sfwd-topic'] ) ) || ( empty( $this->setting_option_values['sfwd-topic'] ) ) ) { $this->setting_option_values['sfwd-topic'] = 'sfwd-topic'; } if ( ( ! isset( $this->setting_option_values['sfwd-quiz'] ) ) || ( empty( $this->setting_option_values['sfwd-quiz'] ) ) ) { $this->setting_option_values['sfwd-quiz'] = 'sfwd-quiz'; } if ( ( ! isset( $this->setting_option_values['sfwd-question'] ) ) || ( empty( $this->setting_option_values['sfwd-question'] ) ) ) { $this->setting_option_values['sfwd-question'] = 'sfwd-question'; } if ( ( ! isset( $this->setting_option_values['users'] ) ) || ( empty( $this->setting_option_values['users'] ) ) ) { $this->setting_option_values['users'] = 'users'; } if ( ( ! isset( $this->setting_option_values['groups'] ) ) || ( empty( $this->setting_option_values['groups'] ) ) ) { $this->setting_option_values['groups'] = 'groups'; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'enabled' => array( 'name' => 'enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Enabled REST API', 'learndash' ), 'help_text' => esc_html__( 'Customize the LearnDash REST API namespace and endpoints. Leave text fields blank to revert to default.', 'learndash' ), 'value' => 'yes', 'options' => array( 'yes' => array( 'label' => '', 'description' => '', 'tooltip' => esc_html__( 'REST API must be enabled', 'learndash' ), ), ), 'attrs' => array( 'disabled' => 'disabled', ), 'child_section_state' => ( 'yes' === $this->setting_option_values['enabled'] ) ? 'open' : 'closed', ), 'sfwd-courses' => array( 'name' => 'sfwd-courses', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Course. _x( '%s Endpoint Slug', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => $this->setting_option_values['sfwd-courses'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'sfwd-lessons' => array( 'name' => 'sfwd-lessons', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Lesson. _x( '%s Endpoint Slug', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => $this->setting_option_values['sfwd-lessons'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'sfwd-topic' => array( 'name' => 'sfwd-topic', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Topic. _x( '%s Endpoint Slug', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => $this->setting_option_values['sfwd-topic'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'sfwd-quiz' => array( 'name' => 'sfwd-quiz', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Quiz. _x( '%s Endpoint Slug', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => $this->setting_option_values['sfwd-quiz'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'sfwd-question' => array( 'name' => 'sfwd-question', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Question. _x( '%s Endpoint Slug', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'value' => $this->setting_option_values['sfwd-question'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'users' => array( 'name' => 'users', 'type' => 'text', 'label' => esc_html__( 'User Endpoint Slug', 'learndash' ), 'value' => $this->setting_option_values['users'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), 'groups' => array( 'name' => 'groups', 'type' => 'text', 'label' => esc_html__( 'Groups Endpoint Slug', 'learndash' ), 'value' => $this->setting_option_values['groups'], 'class' => 'regular-text', 'parent_setting' => 'enabled', ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_General_REST_API::add_section_instance(); } ); PK^\1pAsettings-sections/class-ld-settings-section-support-learndash.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'ld_settings'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_ld_settings'; // Section label/header. $this->settings_section_label = esc_html__( 'LearnDash Settings', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * LearnDash Settings ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Setting', 'learndash' ), 'text' => 'Setting', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Value', 'learndash' ), 'text' => 'Value', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['settings'] = array(); $LEARNDASH_VERSION_value = ''; $LEARNDASH_VERSION_value_html = ''; $ld_version_history = learndash_data_upgrades_setting( 'version_history' ); if ( ! empty( $ld_version_history ) ) { krsort( $ld_version_history ); $ld_version_history = array_slice( $ld_version_history, 0, 5, true ); $_first_item = true; foreach( $ld_version_history as $timestamp => $version ) { $version_date = ' - '; if ( ! empty( $timestamp ) ) { $version_date = learndash_adjust_date_time_display( $timestamp ); } if ( true === $_first_item ) { $_first_item = false; $ld_license_info = get_option( 'nss_plugin_info_sfwd_lms' ); if ( ( $ld_license_info ) && ( property_exists( $ld_license_info, 'new_version' ) ) && ( ! empty( $ld_license_info->new_version ) ) ) { if ( version_compare( $version, $ld_license_info->new_version, 'ne' ) ) { $LEARNDASH_VERSION_value_html = '' . $version . ' ' . ': ' . $version_date . ' - ' . sprintf( // translators: placeholder: version number. esc_html_x( 'Installed version does not match latest (%s).', 'placeholder: version number', 'learndash' ), $ld_license_info->new_version ) . ' ' . esc_html__( 'Please upgrade.', 'learndash' ) . '' . "
    "; $LEARNDASH_VERSION_value = $version . ': ' . $version_date . ' - (X)' . "\r\n"; } else { $LEARNDASH_VERSION_value_html .= '' . $version . '' . ': ' . $version_date . "
    "; $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; } } else { $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; $LEARNDASH_VERSION_value_html .= $version . ': ' . $version_date . "
    "; } } else { $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; $LEARNDASH_VERSION_value_html .= $version . ': ' . $version_date . "
    "; } } } $this->settings_set['settings']['LEARNDASH_VERSION'] = array( 'label' => 'Learndash Version', 'label_html' => esc_html__( 'Learndash Version', 'learndash' ), 'value' => $LEARNDASH_VERSION_value, 'value_html' => $LEARNDASH_VERSION_value_html, ); $ld_license_valid = get_option( 'nss_plugin_remote_license_sfwd_lms' ); $ld_license_check = get_option( 'nss_plugin_check_sfwd_lms' ); if ( ( isset( $ld_license_valid['value'] ) ) && ( '1' === $ld_license_valid['value'] ) ) { $license_value_html = '' . esc_html__( 'Yes', 'learndash' ) . ''; $license_value = 'Yes'; if ( ! empty( $ld_license_check ) ) { $license_value_html .= ' (' . sprintf( // translators: placeholder: date. esc_html_x( 'last check: %s', 'placeholder: date', 'learndash' ), learndash_adjust_date_time_display( $ld_license_check ) ) . ')'; $license_value .= ' (last check: ' . learndash_adjust_date_time_display( $ld_license_check ) . ')'; } } else { $license_value_html = '' . esc_html__( 'No', 'learndash' ) . ''; $license_value = 'No (X)'; } $this->settings_set['settings']['LEARNDASH_license'] = array( 'label' => 'LearnDash License Valid', 'label_html' => esc_html__( 'LearnDash License Valid', 'learndash' ), 'value' => $license_value, 'value_html' => $license_value_html, ); $this->settings_set['settings']['LEARNDASH_SETTINGS_DB_VERSION'] = array( 'label' => 'DB Version', 'label_html' => esc_html__( 'DB Version', 'learndash' ), 'value' => LEARNDASH_SETTINGS_DB_VERSION, ); $data_settings_courses = learndash_data_upgrades_setting( 'user-meta-courses' ); if ( ( ! empty( $data_settings_courses ) ) && ( ! empty( $data_settings_courses ) ) ) { if ( version_compare( $data_settings_courses['version'], LEARNDASH_SETTINGS_DB_VERSION, '<' ) ) { $color = 'red'; $color_text = ' (X)'; } else { $color = 'green'; $color_text = ''; } $data_upgrade_courses_value = $data_settings_courses['version'] . $color_text; $data_upgrade_courses_value_html = '' . $data_settings_courses['version'] . ''; if ( 'red' == $color ) { $data_upgrade_courses_value_html .= ' ' . esc_html__( 'Please run the Data Upgrade.', 'learndash' ) . ''; } elseif ( ( isset( $data_settings_courses['last_run'] ) ) && ( ! empty( $data_settings_courses['last_run'] ) ) ) { $data_upgrade_courses_value .= ' (' . learndash_adjust_date_time_display( $data_settings_courses['last_run'] ) . ')'; $data_upgrade_courses_value_html .= ' (' . sprintf( // translators: placeholder: datetime. esc_html_x( 'last run %s', 'placeholder: datetime', 'learndash' ), learndash_adjust_date_time_display( $data_settings_courses['last_run'] ) ) . ')'; } } else { $data_upgrade_courses_value = ''; $data_upgrade_courses_value_html = ''; } $this->settings_set['settings']['Data Upgrade Courses'] = array( 'label' => 'Data Upgrade Courses', 'label_html' => esc_html__( 'Data Upgrade Courses', 'learndash' ), 'value' => $data_upgrade_courses_value, 'value_html' => $data_upgrade_courses_value_html, ); $data_settings_quizzes = learndash_data_upgrades_setting( 'user-meta-quizzes' ); if ( ( ! empty( $data_settings_quizzes ) ) && ( ! empty( $data_settings_quizzes ) ) ) { if ( version_compare( $data_settings_quizzes['version'], LEARNDASH_SETTINGS_DB_VERSION, '<' ) ) { $color = 'red'; $color_text = ' (X)'; } else { $color = 'green'; $color_text = ''; } $data_upgrade_quizzes_value = $data_settings_quizzes['version'] . $color_text; $data_upgrade_quizzes_value_html = '' . $data_settings_quizzes['version'] . ''; if ( 'red' == $color ) { $data_upgrade_quizzes_value_html .= ' ' . esc_html__( 'Please run the Data Upgrade.', 'learndash' ); } elseif ( ( isset( $data_settings_quizzes['last_run'] ) ) && ( ! empty( $data_settings_quizzes['last_run'] ) ) ) { $data_upgrade_quizzes_value .= ' (' . learndash_adjust_date_time_display( $data_settings_quizzes['last_run'] ) . ')'; $data_upgrade_quizzes_value_html .= ' (' . sprintf( // translators: placeholder: datetime. esc_html_x( 'last run %s', 'placeholder: datetime', 'learndash' ), learndash_adjust_date_time_display( $data_settings_quizzes['last_run'] ) ) . ')'; } } else { $data_upgrade_quizzes_value = ''; $data_upgrade_quizzes_value_html = ''; } $this->settings_set['settings']['Data Upgrade Quizzes'] = array( 'label' => 'Data Upgrade Quizzes', 'label_html' => esc_html__( 'Data Upgrade Quizzes', 'learndash' ), 'value' => $data_upgrade_quizzes_value, 'value_html' => $data_upgrade_quizzes_value_html, ); $data_pro_quiz_questions = learndash_data_upgrades_setting( 'pro-quiz-questions' ); if ( ( ! empty( $data_pro_quiz_questions ) ) && ( ! empty( $data_pro_quiz_questions ) ) ) { if ( version_compare( $data_pro_quiz_questions['version'], LEARNDASH_SETTINGS_DB_VERSION, '<' ) ) { $color = 'red'; $color_text = ' (X)'; } else { $color = 'green'; $color_text = ''; } $data_pro_quiz_questions_value = $data_pro_quiz_questions['version'] . $color_text; $data_pro_quiz_questions_html = '' . $data_pro_quiz_questions['version'] . ''; if ( 'red' == $color ) { $data_pro_quiz_questions_html .= ' ' . esc_html__( 'Please run the Data Upgrade.', 'learndash' ); } elseif ( ( isset( $data_pro_quiz_questions['last_run'] ) ) && ( ! empty( $data_pro_quiz_questions['last_run'] ) ) ) { $data_pro_quiz_questions_value .= ' (' . learndash_adjust_date_time_display( $data_pro_quiz_questions['last_run'] ) . ')'; $data_pro_quiz_questions_html .= ' (' . sprintf( // translators: placeholder: datetime. esc_html_x( 'last run %s', 'placeholder: datetime', 'learndash' ), learndash_adjust_date_time_display( $data_pro_quiz_questions['last_run'] ) ) . ')'; } } else { $data_pro_quiz_questions_value = ''; $data_pro_quiz_questions_html = ''; } $this->settings_set['settings']['Data ProQuiz Questions'] = array( 'label' => 'Data ProQuiz Questions', 'label_html' => esc_html__( 'Data Upgrade ProQuiz Questions', 'learndash' ), 'value' => $data_pro_quiz_questions_value, 'value_html' => $data_pro_quiz_questions_html, ); $data_course_access_lists = learndash_data_upgrades_setting( 'course-access-lists-convert' ); if ( ( ! empty( $data_course_access_lists ) ) && ( ! empty( $data_course_access_lists ) ) ) { if ( version_compare( $data_course_access_lists['version'], LEARNDASH_SETTINGS_DB_VERSION, '<' ) ) { $color = 'red'; $color_text = ' (X)'; } else { $color = 'green'; $color_text = ''; } $data_course_access_lists_value = $data_course_access_lists['version'] . $color_text; $data_course_access_lists_html = '' . $data_course_access_lists['version'] . ''; if ( 'red' == $color ) { $data_course_access_lists_html .= ' ' . esc_html__( 'Please run the Data Upgrade.', 'learndash' ); } elseif ( ( isset( $data_course_access_lists['last_run'] ) ) && ( ! empty( $data_course_access_lists['last_run'] ) ) ) { $data_course_access_lists_value .= ' (' . learndash_adjust_date_time_display( $data_course_access_lists['last_run'] ) . ')'; $data_course_access_lists_html .= ' (' . sprintf( // translators: placeholder: datetime. esc_html_x( 'last run %s', 'placeholder: datetime', 'learndash' ), learndash_adjust_date_time_display( $data_course_access_lists['last_run'] ) ) . ')'; } } else { $data_course_access_lists_value = ''; $data_course_access_lists_html = ''; } $this->settings_set['settings']['Data Course Access Lists Convert'] = array( 'label' => 'Data Course Access Lists Convert', 'label_html' => esc_html__( 'Data Upgrade Course Access Lists Convert', 'learndash' ), 'value' => $data_course_access_lists_value, 'value_html' => $data_course_access_lists_html, ); $courses_count = wp_count_posts( 'sfwd-courses' ); $this->settings_set['settings']['courses_count'] = array( 'label' => 'Courses Count', 'label_html' => esc_html__( 'Courses Count', 'learndash' ), 'value' => $courses_count->publish, ); $lessons_count = wp_count_posts( 'sfwd-lessons' ); $this->settings_set['settings']['lessons_count'] = array( 'label' => 'Lessons Count', 'label_html' => esc_html__( 'Lessons Count', 'learndash' ), 'value' => $lessons_count->publish, ); $topics_count = wp_count_posts( 'sfwd-topic' ); $this->settings_set['settings']['topics_count'] = array( 'label' => 'Topics Count', 'label_html' => esc_html__( 'Topics Count', 'learndash' ), 'value' => $topics_count->publish, ); $quizzes_count = wp_count_posts( 'sfwd-quiz' ); $this->settings_set['settings']['quizzes_count'] = array( 'label' => 'Quizzes Count', 'label_html' => esc_html__( 'Quizzes Count', 'learndash' ), 'value' => $quizzes_count->publish, ); $this->settings_set['settings']['active_theme'] = array( 'label' => 'Active LD Theme', 'label_html' => esc_html__( 'Active LD Theme', 'learndash' ), 'value' => LearnDash_Theme_Register::get_active_theme_name(), ); $this->settings_set['settings']['courses_autoenroll_admin_users'] = array( 'label' => 'Courses Auto-enroll', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Auto-enroll', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'courses_autoenroll_admin_users' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'courses_autoenroll_admin_users' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['bypass_course_limits_admin_users'] = array( 'label' => 'Bypass Course limits', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( 'Bypass %s limits', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'bypass_course_limits_admin_users' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'bypass_course_limits_admin_users' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['reports_include_admin_users'] = array( 'label' => 'Include in Reports', 'label_html' => esc_html__( 'Include in Reports', 'learndash' ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'reports_include_admin_users' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_General_Admin_User', 'reports_include_admin_users' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['course_builder'] = array( 'label' => 'Course Builder Interface', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Builder Interface', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'enabled' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'enabled' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['course_shared_steps'] = array( 'label' => 'Shared Course Steps', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( 'Shared %s Steps', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['nested_urls'] = array( 'label' => 'Nested URLs', 'label_html' => esc_html__( 'Nested URLs', 'learndash' ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'nested_urls' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['courses_permalink_slug'] = array( 'label' => 'Courses Permalink slug', 'label_html' => sprintf( // translators: placeholder: Courses. esc_html_x( '%s Permalink slug', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => '/' . LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'courses' ), ); $this->settings_set['settings']['lessons_permalink_slug'] = array( 'label' => 'Lessons Permalink slug', 'label_html' => sprintf( // translators: placeholder: Lessons. esc_html_x( '%s Permalink slug', 'placeholder: Lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ), 'value' => '/' . LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'lessons' ), ); $this->settings_set['settings']['topics_permalink_slug'] = array( 'label' => 'Topics Permalink slug', 'label_html' => sprintf( // translators: placeholder: Topics. esc_html_x( '%s Permalink slug', 'placeholder: Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ), 'value' => '/' . LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'topics' ), ); $this->settings_set['settings']['quizzes_permalink_slug'] = array( 'label' => 'Quizzes Permalink slug', 'label_html' => sprintf( // translators: placeholder: Quizzes. esc_html_x( '%s Permalink slug', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'value' => '/' . LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'quizzes' ), ); $this->settings_set['settings']['quiz_builder'] = array( 'label' => 'Quiz Builder Interface', 'label_html' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Builder Interface', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Builder', 'enabled' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Builder', 'enabled' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['quiz_shared_questions'] = array( 'label' => 'Quiz Shared Questions', 'label_html' => sprintf( // translators: placeholder: Quiz, Questions. esc_html_x( '%1$s Shared %2$s', 'placeholder: Quiz, Questions', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'questions' ) ), 'value' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Builder', 'shared_questions' ) === 'yes' ) ? 'Yes' : 'No', 'value_html' => ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Builder', 'shared_questions' ) === 'yes' ) ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $learndash_settings_permalinks_taxonomies = get_option( 'learndash_settings_permalinks_taxonomies' ); if ( ! is_array( $learndash_settings_permalinks_taxonomies ) ) { $learndash_settings_permalinks_taxonomies = array(); } $learndash_settings_permalinks_taxonomies = wp_parse_args( $learndash_settings_permalinks_taxonomies, array( 'ld_course_category' => 'course-category', 'ld_course_tag' => 'course-tag', 'ld_lesson_category' => 'lesson-category', 'ld_lesson_tag' => 'lesson-tag', 'ld_topic_category' => 'topic-category', 'ld_topic_tag' => 'topic-tag', ) ); if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'ld_course_category' ) == 'yes' ) { $courses_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-courses', 'taxonomies' ); if ( ( isset( $courses_taxonomies['ld_course_category'] ) ) && ( $courses_taxonomies['ld_course_category']['public'] == true ) ) { $this->settings_set['settings']['ld_course_category'] = array( 'label' => 'Courses Category base', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Category base', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_course_category'], ); } if ( ( isset( $courses_taxonomies['ld_course_tag'] ) ) && ( true == $courses_taxonomies['ld_course_tag']['public'] ) ) { $this->settings_set['settings']['ld_course_tag'] = array( 'label' => 'Courses Tag', 'label_html' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Tag base', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_course_tag'], ); } } if ( 'yes' == LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Lessons_Taxonomies', 'ld_lesson_category' ) ) { $lessons_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-lessons', 'taxonomies' ); if ( ( isset( $lessons_taxonomies['ld_lesson_category'] ) ) && ( $lessons_taxonomies['ld_lesson_category']['public'] == true ) ) { $this->settings_set['settings']['ld_lesson_category'] = array( 'label' => 'Lesson Category base', 'label_html' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Category base', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_lesson_category'], ); } if ( ( isset( $lessons_taxonomies['ld_lesson_tag'] ) ) && ( true == $lessons_taxonomies['ld_lesson_tag']['public'] ) ) { $this->settings_set['settings']['ld_lesson_tag'] = array( 'label' => 'Lessons Tag', 'label_html' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Tag base', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_lesson_tag'], ); } } if ( 'yes' == LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Topics_Taxonomies', 'ld_topic_category' ) ) { $topics_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-topic', 'taxonomies' ); if ( ( isset( $topics_taxonomies['ld_topic_category'] ) ) && ( true == $topics_taxonomies['ld_topic_category']['public'] ) ) { $this->settings_set['settings']['ld_topic_category'] = array( 'label' => 'Topics Category base', 'label_html' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Category base', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_topic_category'], ); } if ( ( isset( $topics_taxonomies['ld_topic_tag'] ) ) && ( $topics_taxonomies['ld_topic_tag']['public'] == true ) ) { $this->settings_set['settings']['ld_topic_tag'] = array( 'label' => 'Topics Tag', 'label_html' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Tag base', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => '/' . $learndash_settings_permalinks_taxonomies['ld_topic_tag'], ); } } // LD Assignment upload path. $upload_dir = wp_upload_dir(); $upload_dir_base = str_replace( '\\', '/', $upload_dir['basedir'] ); $upload_url_base = $upload_dir['baseurl']; $assignment_upload_dir_path = $upload_dir_base . '/assignments'; $assignment_upload_dir_path_r = str_replace( $ABSPATH_tmp, '', $assignment_upload_dir_path ); $this->settings_set['settings']['Assignment Upload Dir'] = array( 'label' => 'Assignment Upload Dir', 'label_html' => esc_html__( 'Assignment Upload Dir', 'learndash' ), 'value' => $assignment_upload_dir_path_r, ); $color = 'green'; if ( ! file_exists( $assignment_upload_dir_path ) ) { $color = 'red'; $this->settings_set['settings']['Assignment Upload Dir']['value_html'] = '' . $assignment_upload_dir_path_r . ''; $this->settings_set['settings']['Assignment Upload Dir']['value_html'] .= ' - ' . esc_html__( 'Directory does not exists', 'learndash' ); $this->settings_set['settings']['Assignment Upload Dir']['value'] .= ' - (X) Directory does not exists'; } elseif ( ! is_writable( $assignment_upload_dir_path ) ) { $color = 'red'; $this->settings_set['settings']['Assignment Upload Dir']['value_html'] = '' . $assignment_upload_dir_path_r . ''; $this->settings_set['settings']['Assignment Upload Dir']['value_html'] .= ' - ' . esc_html__( 'Directory not writable', 'learndash' ); $this->settings_set['settings']['Assignment Upload Dir']['value'] .= ' - (X) Directory not writable'; } else { $this->settings_set['settings']['Assignment Upload Dir']['value_html'] = '' . $assignment_upload_dir_path_r . ''; } $essay_upload_dir_path = $upload_dir_base . '/essays'; $essay_upload_dir_path_r = str_replace( $ABSPATH_tmp, '', $essay_upload_dir_path ); $this->settings_set['settings']['Essay Upload Dir'] = array( 'label' => 'Essay Upload Dir', 'label_html' => esc_html__( 'Essay Upload Dir', 'learndash' ), 'value' => $essay_upload_dir_path_r, ); $color = 'green'; if ( ! file_exists( $essay_upload_dir_path ) ) { $color = 'red'; $this->settings_set['settings']['Essay Upload Dir']['value_html'] = '' . $essay_upload_dir_path_r . ''; $this->settings_set['settings']['Essay Upload Dir']['value_html'] .= ' - ' . esc_html__( 'Directory does not exists', 'learndash' ); $this->settings_set['settings']['Essay Upload Dir']['value'] .= ' - (X) Directory does not exists'; } elseif ( ! is_writable( $essay_upload_dir_path ) ) { $color = 'red'; $this->settings_set['settings']['Essay Upload Dir']['value_html'] = '' . $essay_upload_dir_path_r . ''; $this->settings_set['settings']['Essay Upload Dir']['value_html'] .= ' - ' . esc_html__( 'Directory not writable', 'learndash' ); $this->settings_set['settings']['Essay Upload Dir']['value'] .= ' - (X) Directory not writable'; } else { $this->settings_set['settings']['Essay Upload Dir']['value_html'] = '' . $essay_upload_dir_path_r . ''; } foreach ( apply_filters( 'learndash_support_ld_defines', array( 'LEARNDASH_LMS_PLUGIN_DIR', 'LEARNDASH_LMS_PLUGIN_URL', 'LEARNDASH_SCRIPT_DEBUG', 'LEARNDASH_SCRIPT_VERSION_TOKEN', 'LEARNDASH_GUTENBERG', 'LEARNDASH_ADMIN_CAPABILITY_CHECK', 'LEARNDASH_GROUP_LEADER_CAPABILITY_CHECK', 'LEARNDASH_COURSE_BUILDER', 'LEARNDASH_QUIZ_BUILDER', 'LEARNDASH_LESSON_VIDEO', 'LEARNDASH_ADDONS_UPDATER', 'LEARNDASH_QUIZ_PREREQUISITE_ALT', 'LEARNDASH_LMS_DEFAULT_QUESTION_POINTS', 'LEARNDASH_LMS_DEFAULT_ANSWER_POINTS', 'LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE', 'LEARNDASH_REST_API_ENABLED', 'LEARNDASH_TRANSIENTS_DISABLED' ) ) as $defined_item ) { $defined_value = ( defined( $defined_item ) ) ? constant( $defined_item ) : ''; if ( 'LEARNDASH_LMS_PLUGIN_DIR' == $defined_item ) { $defined_value = str_replace( $ABSPATH_tmp, '', $defined_value ); } $this->settings_set['settings'][ $defined_item ] = array( 'label' => $defined_item, 'label_html' => $defined_item, 'value' => $defined_value, ); } global $l10n; $ld_translation_files = ''; if ( ( isset( $l10n[ LEARNDASH_LMS_TEXT_DOMAIN ] ) ) && ( ! empty( $l10n[ LEARNDASH_LMS_TEXT_DOMAIN ] ) ) ) { $mo_file = $l10n[ LEARNDASH_LMS_TEXT_DOMAIN ]->get_filename(); if ( ! empty( $mo_file ) ) { $mo_files_output = str_replace( ABSPATH, '', $mo_file ); $mo_files_output .= ' ' . learndash_adjust_date_time_display( filectime( $mo_file ) ) . ''; $ld_translation_files .= '' . LEARNDASH_LMS_TEXT_DOMAIN . ' - ' . $mo_files_output . '
    '; } } $this->settings_set['settings']['Translation Files'] = array( 'label' => 'Translation Files', 'label_html' => esc_html__( 'Translation Files', 'learndash' ), 'value' => $ld_translation_files, ); $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_LearnDash::add_section_instance(); } ); PK^\0b㹋 Hsettings-sections/class-ld-settings-section-support-copy-system-info.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'ld_copy_export'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_copy_export'; // Section label/header. $this->settings_section_label = esc_html__( 'Copy System Info', 'learndash' ); $this->metabox_context = 'side'; add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { ?>

    settings-sections/class-ld-settings-section-courses-themes.phpnuW+Asettings_page_id = 'learndash_lms_settings'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_courses_themes'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_courses_themes'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'themes'; // Section label/header. $this->settings_section_label = esc_html__( 'Design & Content Elements', 'learndash' ); // Used to show the section description above the fields. Can be empty $this->settings_section_description = esc_html__( 'Alter the look and feel of your Learning Management System', 'learndash' ); add_action( 'learndash_section_fields_after', array( $this, 'learndash_section_fields_after' ), 10, 2 ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $themes = LearnDash_Theme_Register::get_themes(); $this->themes_list = array(); foreach ( $themes as $theme ) { $this->themes_list[ $theme['theme_key'] ] = $theme['theme_name']; } if ( ( ! isset( $this->setting_option_values['active_theme'] ) ) || ( empty( $this->setting_option_values['active_theme'] ) ) ) { $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['active_theme'] = LEARNDASH_DEFAULT_THEME; } else { $this->setting_option_values['active_theme'] = LEARNDASH_LEGACY_THEME; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'active_theme' => array( 'name' => 'active_theme', 'type' => 'select', 'label' => esc_html__( 'Active Template', 'learndash' ), 'help_text' => esc_html__( 'New front-end design options and settings can be used when the LearnDash 3.0 template is activated.', 'learndash' ), 'value' => $this->setting_option_values['active_theme'], 'options' => $this->themes_list, ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } public function learndash_section_fields_after( $settings_section_key = '', $settings_screen_id ) { if ( $settings_section_key === $this->settings_section_key ) { $themes = LearnDash_Theme_Register::get_themes(); if ( ! empty( $themes ) ) { global $wp_settings_sections; global $wp_settings_fields; $active_theme_key = LearnDash_Theme_Register::get_active_theme_key(); foreach ( $themes as $theme ) { $theme_instance = LearnDash_Theme_Register::get_theme_instance( $theme['theme_key'] ); $theme_settings_sections = $theme_instance->get_theme_settings_sections(); if ( ! empty( $theme_settings_sections ) ) { foreach ( $theme_settings_sections as $section_key => $section_instance ) { if ( isset( $wp_settings_fields[ $section_instance->settings_page_id ][ $section_key ] ) ) { $theme_state = 'closed'; if ( $active_theme_key === $theme_instance->get_theme_key() ) { $theme_state = 'open'; } echo '
    '; $this->show_settings_section_fields( $section_instance->settings_page_id, $section_key ); echo '
    '; } } } } } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Courses_Themes::add_section_instance(); } ); PK^\rZBsettings-sections/class-ld-settings-section-general-admin-user.phpnuW+Asettings_page_id = 'learndash_lms_settings'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_admin_user'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_admin_user'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_admin_user'; // Section label/header. $this->settings_section_label = esc_html__( 'Admin User Settings', 'learndash' ); $this->settings_section_description = sprintf( // translators: placeholder: courses. esc_html_x( 'Controls the admin user-experience navigating %s.', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $_init = true; $this->setting_option_values = array(); } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'courses_autoenroll_admin_users' => ( true === $_init ) ? 'yes' : '', 'bypass_course_limits_admin_users' => ( true === $_init ) ? 'yes' : '', ) ); if ( ! isset( $this->setting_option_values['courses_autoenroll_admin_users'] ) ) { $this->setting_option_values['courses_autoenroll_admin_users'] = ''; } if ( ! isset( $this->setting_option_values['bypass_course_limits_admin_users'] ) ) { $this->setting_option_values['bypass_course_limits_admin_users'] = ''; } if ( ! isset( $this->setting_option_values['reports_include_admin_users'] ) ) { $this->setting_option_values['reports_include_admin_users'] = ''; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'courses_autoenroll_admin_users' => array( 'name' => 'courses_autoenroll_admin_users', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Auto-enrollment', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: courses, course. esc_html_x( 'Allow admin users to have access to %1$s automatically without requiring %2$s enrollment.', 'placeholder: courses, course', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['courses_autoenroll_admin_users'], 'options' => array( '' => sprintf( // translators: placeholder: courses. esc_html_x( 'Admin has access to enrolled %s only', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), 'yes' => sprintf( // translators: placeholder: courses. esc_html_x( 'Admin has access to all %s automatically', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ), ), ), 'bypass_course_limits_admin_users' => array( 'name' => 'bypass_course_limits_admin_users', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( 'Bypass %s limits', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Allow admin users to access %s content in any order bypassing progression and access limitations', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['bypass_course_limits_admin_users'], 'options' => array( '' => esc_html__( 'Admin must follow the progression and access rules', 'learndash' ), 'yes' => sprintf( // translators: placeholder: course. esc_html_x( 'Admin can access %s content in any order', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), ), 'reports_include_admin_users' => array( 'name' => 'reports_include_admin_users', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Include in Reports', 'learndash' ), 'help_text' => esc_html__( ' Include admin users in reports, including ProPanel reporting.', 'learndash' ), 'default' => '', 'value' => $this->setting_option_values['reports_include_admin_users'], 'options' => array( '' => esc_html__( 'Admin is not included in reports', 'learndash' ), 'yes' => esc_html__( 'Admin is included in reports', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_General_Admin_User::add_section_instance(); } ); PK^\1tLLJsettings-sections/class-ld-settings-section-courses-management-display.phpnuW+Asettings_screen_id = 'sfwd-courses_page_courses-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'courses-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_courses_management_display'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_courses_management_display'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'course_management_display'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Course. esc_html_x( 'Global %s Management & Display Settings', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); // Used to show the section description above the fields. Can be empty $this->settings_section_description = sprintf( // translators: placeholder: course. esc_html_x( 'Control settings for %s creation, and visual organization', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); // Define the depreacted Class and Fields $this->settings_deprecated = array( 'LearnDash_Settings_Courses_Builder' => array( 'option_key' => 'learndash_settings_courses_builder', 'fields' => array( 'enabled' => 'course_builder_enabled', 'shared_steps' => 'course_builder_shared_steps', 'per_page' => 'course_builder_per_page', ), ), 'LearnDash_Settings_Section_Lessons_Display_Order' => array( 'option_key' => 'learndash_settings_lessons_display_order', 'fields' => array( 'posts_per_page' => 'course_pagination_lessons', 'order' => 'lesson_topic_order', 'orderby' => 'lesson_topic_orderby', ), ), ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); // If the settings set as a whole is empty then we set a default. if ( ( false === $this->setting_option_values ) || ( '' === $this->setting_option_values ) ) { if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->transition_deprecated_settings(); if ( ! isset( $this->setting_option_values['course_builder_enabled'] ) ) { $this->setting_option_values['course_builder_enabled'] = 'yes'; } } if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } if ( ! isset( $this->setting_option_values['course_builder_enabled'] ) ) { $this->setting_option_values['course_builder_enabled'] = ''; } if ( ! isset( $this->setting_option_values['course_builder_shared_steps'] ) ) { $this->setting_option_values['course_builder_shared_steps'] = ''; } if ( ! isset( $this->setting_option_values['course_builder_per_page'] ) ) { $this->setting_option_values['course_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } $this->setting_option_values['course_builder_per_page'] = absint( $this->setting_option_values['course_builder_per_page'] ); if ( empty( $this->setting_option_values['course_builder_per_page'] ) ) { $this->setting_option_values['course_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( ! isset( $this->setting_option_values['course_pagination_lessons'] ) ) { if ( isset( $this->setting_option_values['lesson_per_page'] ) ) { $this->setting_option_values['course_pagination_lessons'] = absint( $this->setting_option_values['lesson_per_page'] ); } else { $this->setting_option_values['course_pagination_lessons'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } } if ( ! isset( $this->setting_option_values['course_pagination_topics'] ) ) { if ( isset( $this->setting_option_values['course_pagination_lessons'] ) ) { $this->setting_option_values['course_pagination_topics'] = absint( $this->setting_option_values['course_pagination_lessons'] ); } else { $this->setting_option_values['course_pagination_topics'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } } if ( ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $this->setting_option_values['course_pagination_lessons'] ) && ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $this->setting_option_values['course_pagination_topics'] ) ) { $this->setting_option_values['course_pagination_enabled'] = ''; } else { $this->setting_option_values['course_pagination_enabled'] = 'yes'; } if ( ! isset( $this->setting_option_values['lesson_topic_order'] ) ) { $this->setting_option_values['lesson_topic_order'] = 'ASC'; } if ( ! isset( $this->setting_option_values['lesson_topic_orderby'] ) ) { $this->setting_option_values['lesson_topic_orderby'] = 'date'; } if ( ( 'date' === $this->setting_option_values['lesson_topic_orderby'] ) && ( 'ASC' === $this->setting_option_values['lesson_topic_order'] ) ) { $this->setting_option_values['lesson_topic_order_enabled'] = ''; } else { $this->setting_option_values['lesson_topic_order_enabled'] = 'yes'; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array(); if ( ( defined( 'LEARNDASH_COURSE_BUILDER' ) ) && ( LEARNDASH_COURSE_BUILDER === true ) ) { $this->setting_option_fields = array_merge( $this->setting_option_fields, array( 'course_builder_enabled' => array( 'name' => 'course_builder_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Builder', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: Lesson, Topic, Quiz, Course. esc_html_x( 'Manage all %1$s, %2$s, and %3$s associations within the %4$s Builder.', 'placeholder: Lesson, Topic, Quiz, Course.', 'learndash' ), learndash_get_custom_label( 'lesson' ), learndash_get_custom_label( 'topic' ), learndash_get_custom_label( 'quiz' ), learndash_get_custom_label( 'course' ) ), 'value' => $this->setting_option_values['course_builder_enabled'], 'options' => array( 'yes' => '', ), 'child_section_state' => ( 'yes' === $this->setting_option_values['course_builder_enabled'] ) ? 'open' : 'closed', ), 'course_builder_per_page' => array( 'name' => 'course_builder_per_page', 'type' => 'number', 'label' => esc_html__( 'Steps Displayed', 'learndash' ), 'value' => $this->setting_option_values['course_builder_per_page'], 'class' => 'small-text', 'input_label' => esc_html__( 'per page', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'course_builder_enabled', ), 'course_builder_shared_steps' => array( 'name' => 'course_builder_shared_steps', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( 'Shared %s Steps', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( wp_kses_post( // translators: placeholder: lessons, topics, quizzes, courses, course, URL to admin Permalinks. _x( 'Share steps (%1$s, %2$s, %3$s) across multiple %4$s. Progress is maintained on a per-%5$s basis.

    Note: Enabling this option will also enable the
    nested permalinks setting.', 'placeholder: lessons, topics, quizzes, courses, course, URL to admin Permalinks.', 'learndash' ) ), learndash_get_custom_label_lower( 'lessons' ), learndash_get_custom_label_lower( 'topics' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'course' ), admin_url( 'options-permalink.php#learndash_settings_permalinks_nested_urls' ) ), 'value' => $this->setting_option_values['course_builder_shared_steps'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholders: Lesson, topics and quizzes, courses. esc_html_x( '%1$s, %2$s and %3$s can be shared across multiple %4$s', 'placeholders: Lesson, topics and quizzes, courses', 'learndash' ), learndash_get_custom_label( 'lessons' ), learndash_get_custom_label_lower( 'topics' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'courses' ) ), ), 'parent_setting' => 'course_builder_enabled', ), ) ); } $this->setting_option_fields = array_merge( $this->setting_option_fields, array( 'course_pagination_enabled' => array( 'name' => 'course_pagination_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Table Pagination', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: course, course. esc_html_x( 'Customize the pagination options for ALL %1$s content tables and %2$s navigation widgets.', 'placeholder: course, course', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ), 'value' => $this->setting_option_values['course_pagination_enabled'], 'options' => array( '' => sprintf( // translators: placeholder: default per page number. esc_html_x( 'Currently showing default pagination %d', 'placeholder: default per page number', 'learndash' ), LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE ), 'yes' => '', ), 'child_section_state' => ( 'yes' === $this->setting_option_values['course_pagination_enabled'] ) ? 'open' : 'closed', ), 'course_pagination_lessons' => array( 'name' => 'course_pagination_lessons', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Lessons esc_html_x( '%s', 'placeholder: Lessons', 'learndash' ), learndash_get_custom_label( 'lessons' ) ), 'value' => $this->setting_option_values['course_pagination_lessons'], 'class' => 'small-text', 'input_label' => esc_html__( 'per page', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'course_pagination_enabled', ), 'course_pagination_topics' => array( 'name' => 'course_pagination_topics', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Topics esc_html_x( '%s', 'placeholder: Topics', 'learndash' ), learndash_get_custom_label( 'topics' ) ), 'value' => $this->setting_option_values['course_pagination_topics'], 'class' => 'small-text', 'input_label' => esc_html__( 'per page', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'course_pagination_enabled', ), ) ); if ( 'yes' !== $this->setting_option_values['course_builder_shared_steps'] ) { $this->setting_option_fields = array_merge( $this->setting_option_fields, array( 'lesson_topic_order_enabled' => array( 'name' => 'lesson_topic_order_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson, Topic. esc_html_x( '%1$s and %2$s Order', 'placeholder: Lesson, Topic', 'learndash' ), learndash_get_custom_label( 'lesson' ), learndash_get_custom_label( 'topic' ) ), 'help_text' => sprintf( // translators: placeholder: lessons, topics. esc_html_x( 'Customize the display order of %1$s and %2$s.', 'placeholder: lessons, topics', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ), learndash_get_custom_label_lower( 'topics' ) ), 'value' => $this->setting_option_values['lesson_topic_order_enabled'], 'options' => array( '' => array( 'label' => sprintf( // translators: placeholder: Default Order By, Order. esc_html_x( 'Using default sorting by %1$s in %2$s order', 'placeholder: Default Order By, Order', 'learndash' ), 'Date', 'Ascending' ), 'description' => '', ), 'yes' => array( 'label' => '', 'description' => '', ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['lesson_topic_order_enabled'] ) ? 'open' : 'closed', ), 'lesson_topic_orderby' => array( 'name' => 'lesson_topic_orderby', 'type' => 'select', 'label' => esc_html__( 'Sort By', 'learndash' ), 'value' => $this->setting_option_values['lesson_topic_orderby'], 'default' => 'menu_order', 'options' => array( 'menu_order' => esc_html__( 'Menu Order', 'learndash' ), 'date' => esc_html__( 'Date', 'learndash' ), 'title' => esc_html__( 'Title', 'learndash' ), ), 'parent_setting' => 'lesson_topic_order_enabled', ), 'lesson_topic_order' => array( 'name' => 'lesson_topic_order', 'type' => 'select', 'label' => esc_html__( 'Order Direction', 'learndash' ), 'value' => $this->setting_option_values['lesson_topic_order'], 'default' => 'ASC', 'options' => array( 'ASC' => esc_html__( 'Ascending', 'learndash' ), 'DESC' => esc_html__( 'Descending', 'learndash' ), ), 'parent_setting' => 'lesson_topic_order_enabled', ), ) ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); global $wp_rewrite; if ( ! $wp_rewrite->using_permalinks() ) { $this->setting_option_fields['shared_steps']['value'] = ''; $this->setting_option_fields['shared_steps']['attrs'] = array( 'disabled' => 'disabled' ); } parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $current_values = '', $old_values = '', $option = '' ) { if ( $option === $this->setting_option_key ) { $current_values = parent::section_pre_update_option( $current_values, $old_values, $option ); if ( $current_values !== $old_values ) { // Manage Course Builder, Per Page, and Share Steps. if ( ( isset( $current_values['course_builder_enabled'] ) ) && ( 'yes' === $current_values['course_builder_enabled'] ) ) { $current_values['course_builder_per_page'] = absint( $current_values['course_builder_per_page'] ); } else { $current_values['course_builder_shared_steps'] = ''; $current_values['course_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( ( isset( $current_values['course_builder_shared_steps'] ) ) && ( 'yes' === $current_values['course_builder_shared_steps'] ) ) { $current_values['lesson_topic_order_enabled'] = ''; } if ( ( isset( $current_values['course_pagination_enabled'] ) ) && ( 'yes' === $current_values['course_pagination_enabled'] ) ) { $current_values['course_pagination_lessons'] = absint( $current_values['course_pagination_lessons'] ); $current_values['course_pagination_topics'] = absint( $current_values['course_pagination_topics'] ); if ( ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $current_values['course_pagination_topics'] ) && ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $current_values['course_pagination_lessons'] ) ) { $current_values['course_pagination_enabled'] = ''; } } else { $current_values['course_pagination_lessons'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; $current_values['course_pagination_topics'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } // Lessonand Topic Order and Order By if ( ( isset( $current_values['lesson_topic_order_enabled'] ) ) && ( 'yes' === $current_values['lesson_topic_order_enabled'] ) ) { if ( ( ! isset( $current_values['lesson_topic_order'] ) ) || ( empty( $current_values['lesson_topic_order'] ) ) ) { $current_values['lesson_topic_order'] = 'ASC'; } if ( ( ! isset( $current_values['lesson_topic_orderby'] ) ) || ( empty( $current_values['lesson_topic_orderby'] ) ) ) { $current_values['lesson_topic_orderby'] = 'date'; } if ( ( 'ASC' === $current_values['lesson_topic_order'] ) && ( 'date' === $current_values['lesson_topic_orderby'] ) ) { $current_values['lesson_topic_order_enabled'] = ''; } } else { $current_values['lesson_topic_order'] = 'ASC'; $current_values['lesson_topic_orderby'] = 'date'; } } if ( ( isset( $current_values['course_builder_enabled'] ) ) && ( 'yes' === $current_values['course_builder_enabled'] ) && ( isset( $current_values['course_builder_shared_steps'] ) ) && ( 'yes' === $current_values['course_builder_shared_steps'] ) ) { $ld_permalink_options = get_option( 'learndash_settings_permalinks', array() ); if ( ! isset( $ld_permalink_options['nested_urls'] ) ) { $ld_permalink_options['nested_urls'] = 'no'; } if ( 'yes' !== $ld_permalink_options['nested_urls'] ) { $ld_permalink_options['nested_urls'] = 'yes'; update_option( 'learndash_settings_permalinks', $ld_permalink_options ); learndash_setup_rewrite_flush(); } } } return $current_values; } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Courses_Management_Display::add_section_instance(); } ); PK^\ŽLsettings-sections/class-ld-settings-section-questions-management-display.phpnuW+Asettings_screen_id = 'sfwd-question_page_questions-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'questions-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_questions_management_display'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_questions_management_display'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'questions_management_display'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( 'Global %s Management & Display Settings', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ); $this->settings_section_description = sprintf( // translators: placeholder: questions. esc_html_x( 'Control which templates can be used to better organize your LearnDash %s.', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ); parent::__construct(); // Hook to handle the AJAX delete/update actions. add_action( 'wp_ajax_' . $this->setting_field_prefix, array( $this, 'ajax_action' ) ); } /** * Load the field settings values */ public function load_settings_values() { parent::load_settings_values(); $this->setting_option_values = array( 'question_templates' => array( '' => __( 'Select a template', 'learndash' ), ), ); if ( ( is_admin() ) && ( isset( $_GET['page'] ) ) && ( 'questions-options' === $_GET['page'] ) ) { $template_mapper = new WpProQuiz_Model_TemplateMapper(); $quiz_templates = $template_mapper->fetchAll( WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false ); if ( ( ! empty( $quiz_templates ) ) && ( is_array( $quiz_templates ) ) ) { foreach ( $quiz_templates as $template_quiz ) { $template_name = $template_quiz->getName(); $template_id = $template_quiz->getTemplateId(); if ( ! empty( $template_name ) ) { $this->setting_option_values['question_templates'][ $template_id ] = esc_html( $template_name ); } } } } } /** * Load the field settings fields */ public function load_settings_fields() { $this->setting_option_fields = array( 'question_template' => array( 'name' => 'question_template', 'type' => 'select-edit-delete', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s templates', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'help_text' => sprintf( // translators: placeholder: Question. esc_html_x( 'Manage %s templates. Select a template then update the title or delete.', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'value' => '', 'options' => $this->setting_option_values['question_templates'], 'buttons' => array( 'delete' => esc_html__( 'Delete', 'learndash' ), 'update' => esc_html__( 'Update', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * This function handles the AJAX actions from the browser. * * @since 2.5.9 */ public function ajax_action() { $reply_data = array( 'status' => false ); if ( current_user_can( 'wpProQuiz_edit_quiz' ) ) { if ( ( isset( $_POST['field_nonce'] ) ) && ( ! empty( $_POST['field_nonce'] ) ) && ( isset( $_POST['field_key'] ) ) && ( ! empty( $_POST['field_key'] ) ) && ( wp_verify_nonce( esc_attr( $_POST['field_nonce'] ), $_POST['field_key'] ) ) ) { if ( isset( $_POST['field_action'] ) ) { if ( 'update' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) && ( isset( $_POST['field_text'] ) ) && ( ! empty( $_POST['field_text'] ) ) ) { $template_id = intval( $_POST['field_value'] ); $template_new_name = esc_attr( $_POST['field_text'] ); $template_mapper = new WpProQuiz_Model_TemplateMapper(); $template = $template_mapper->fetchById( $template_id ); if ( ( $template ) && ( is_a( $template, 'WpProQuiz_Model_Template' ) ) ) { $template_current_name = $template->getName(); if ( $template_current_name !== $template_new_name ) { $update_ret = $template_mapper->updateName( $template_id, $template_new_name ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Template updated.', 'learndash' ) . ''; } } } } } elseif ( 'delete' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) ) { $template_id = intval( $_POST['field_value'] ); $template_mapper = new WpProQuiz_Model_TemplateMapper(); $template = $template_mapper->fetchById( $template_id ); if ( ( $template ) && ( is_a( $template, 'WpProQuiz_Model_Template' ) ) ) { $update_ret = $template_mapper->delete( $template_id ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Template deleted.', 'learndash' ) . ''; } } } } } } } if ( ! empty( $reply_data ) ) { echo wp_json_encode( $reply_data ); } wp_die(); // This is required to terminate immediately and return a proper response. } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Questions_Management_Display::add_section_instance(); } ); PK^\cHBB.settings-sections/settings-sections-loader.phpnuW+A Permalinks page. require_once __DIR__ . '/class-ld-settings-section-permalinks.php'; require_once __DIR__ . '/class-ld-settings-section-permalinks-taxonomies.php'; PK^\$(uuBsettings-sections/class-ld-settings-section-courses-taxonomies.phpnuW+Asettings_screen_id = 'sfwd-courses_page_courses-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'courses-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_courses_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_courses_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'taxonomies'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Course. esc_html_x( '%s Taxonomies', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: courses. esc_html_x( 'Control which taxonomies can be used to better organize your LearnDash %s.', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $__init = true; $this->setting_option_values = array( 'ld_course_category' => 'yes', 'ld_course_tag' => 'yes', 'wp_post_category' => 'yes', 'wp_post_tag' => 'yes', ); // If this is a new install we want to turn off WP Post Category/Tag. $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['wp_post_category'] = ''; $this->setting_option_values['wp_post_tag'] = ''; } } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'ld_course_category' => '', 'ld_course_tag' => '', 'wp_post_category' => '', 'wp_post_tag' => '', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'ld_course_category' => array( 'name' => 'ld_course_category', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Categories', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'value' => $this->setting_option_values['ld_course_category'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Course. esc_html_x( 'Manage %s Categories via the Actions dropdown', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ), ), 'ld_course_tag' => array( 'name' => 'ld_course_tag', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Tags', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => $this->setting_option_values['ld_course_tag'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Course. esc_html_x( 'Manage %s Tags via the Actions dropdown', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ), ), 'wp_post_category' => array( 'name' => 'wp_post_category', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Categories', 'learndash' ), 'value' => $this->setting_option_values['wp_post_category'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Categories via the Actions dropdown', 'learndash' ), ), ), 'wp_post_tag' => array( 'name' => 'wp_post_tag', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Tags', 'learndash' ), 'value' => $this->setting_option_values['wp_post_tag'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Tags via the Actions dropdown', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Courses_Taxonomies::add_section_instance(); } ); PK^\K}y y Dsettings-sections/class-ld-settings-section-translations-refresh.phpnuW+Asettings_page_id = 'learndash_lms_translations'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'submitdiv'; // Section label/header. $this->settings_section_label = esc_html__( 'Refresh Translations', 'learndash' ); $this->metabox_context = 'side'; $this->metabox_priority = 'high'; parent::__construct(); // We override the parent value set for $this->metabox_key because we want the div ID to match the details WordPress // value so it will be hidden. $this->metabox_key = 'submitdiv'; } /** * Custom function to metabox. * * @since 2.4.0 */ public function show_meta_box() { ?>

    :

    Permalinks * page to allow override of the default slugs * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Permalinks_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Permalinks_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_page_id = 'permalink'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_permalinks_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_permalinks_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'learndash_settings_permalinks_taxonomies'; // Section label/header. $this->settings_section_label = __( 'LearnDash Taxonomy Permalinks', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = __( 'Controls the URL slugs for the custom taxonomies used by LearnDash.', 'learndash' ); add_action( 'admin_init', array( $this, 'admin_init' ) ); global $wp_rewrite; if ( $wp_rewrite->using_permalinks() ) { parent::__construct(); $this->save_settings_fields(); } } /** * Function to hook into WP admin init action. */ public function admin_init() { do_action( 'learndash_settings_page_init', $this->settings_page_id ); } /** * Function to handle metabox init. * * @param string $settings_screen_id Screen ID of current page. */ public function add_meta_boxes( $settings_screen_id = '' ) { global $wp_rewrite; if ( $wp_rewrite->using_permalinks() ) { add_meta_box( $this->metabox_key, $this->settings_section_label, array( $this, 'show_meta_box' ), $this->settings_screen_id, $this->metabox_context, $this->metabox_priority ); } } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( false === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'ld_course_category' => 'course-category', 'ld_course_tag' => 'course-tag', 'ld_lesson_category' => 'lesson-category', 'ld_lesson_tag' => 'lesson-tag', 'ld_topic_category' => 'topic-category', 'ld_topic_tag' => 'topic-tag', 'ld_quiz_category' => 'quiz-category', 'ld_quiz_tag' => 'quiz-tag', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $this->setting_option_fields = array(); // Course Taxonomies. $courses_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-courses', 'taxonomies' ); if ( ( isset( $courses_taxonomies['ld_course_category'] ) ) && ( true === $courses_taxonomies['ld_course_category']['public'] ) ) { $this->setting_option_fields['ld_course_category'] = array( 'name' => 'ld_course_category', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Course. _x( '%s Category base', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => $this->setting_option_values['ld_course_category'], 'class' => 'regular-text', ); } if ( ( isset( $courses_taxonomies['ld_course_tag'] ) ) && ( true === $courses_taxonomies['ld_course_tag']['public'] ) ) { $this->setting_option_fields['ld_course_tag'] = array( 'name' => 'ld_course_tag', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Course. _x( '%s Tag base', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => $this->setting_option_values['ld_course_tag'], 'class' => 'regular-text', ); } // Lesson Taxonomies. $lessons_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-lessons', 'taxonomies' ); if ( ( isset( $lessons_taxonomies['ld_lesson_category'] ) ) && ( true === $lessons_taxonomies['ld_lesson_category']['public'] ) ) { $this->setting_option_fields['ld_lesson_category'] = array( 'name' => 'ld_lesson_category', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Lesson. _x( '%s Category base', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => $this->setting_option_values['ld_lesson_category'], 'class' => 'regular-text', ); } if ( ( isset( $lessons_taxonomies['ld_lesson_tag'] ) ) && ( true === $lessons_taxonomies['ld_lesson_tag']['public'] ) ) { $this->setting_option_fields['ld_lesson_tag'] = array( 'name' => 'ld_lesson_tag', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Lesson. _x( '%s Tag base', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ) ), 'value' => $this->setting_option_values['ld_lesson_tag'], 'class' => 'regular-text', ); } // Topic Taxonomies. $topics_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-topic', 'taxonomies' ); if ( ( isset( $topics_taxonomies['ld_topic_category'] ) ) && ( true === $topics_taxonomies['ld_topic_category']['public'] ) ) { $this->setting_option_fields['ld_topic_category'] = array( 'name' => 'ld_topic_category', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Topic. _x( '%s Category base', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => $this->setting_option_values['ld_topic_category'], 'class' => 'regular-text', ); } if ( ( isset( $topics_taxonomies['ld_topic_tag'] ) ) && ( true === $topics_taxonomies['ld_topic_tag']['public'] ) ) { $this->setting_option_fields['ld_topic_tag'] = array( 'name' => 'ld_topic_tag', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Topic. _x( '%s Tag base', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => $this->setting_option_values['ld_topic_tag'], 'class' => 'regular-text', ); } // Quiz Taxonomies. $quizzes_taxonomies = $sfwd_lms->get_post_args_section( 'sfwd-quiz', 'taxonomies' ); if ( ( isset( $quizzes_taxonomies['ld_quiz_category'] ) ) && ( true === $quizzes_taxonomies['ld_quiz_category']['public'] ) ) { $this->setting_option_fields['ld_quiz_category'] = array( 'name' => 'ld_quiz_category', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Quiz. _x( '%s Category base', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => $this->setting_option_values['ld_quiz_category'], 'class' => 'regular-text', ); } if ( ( isset( $quizzes_taxonomies['ld_quiz_tag'] ) ) && ( true === $quizzes_taxonomies['ld_quiz_tag']['public'] ) ) { $this->setting_option_fields['ld_quiz_tag'] = array( 'name' => 'ld_quiz_tag', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Quiz. _x( '%s Tag base', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => $this->setting_option_values['ld_quiz_tag'], 'class' => 'regular-text', ); } if ( ! empty( $this->setting_option_fields ) ) { $this->setting_option_fields['nonce'] = array( 'name' => 'nonce', 'type' => 'hidden', 'label' => '', 'value' => wp_create_nonce( 'learndash_permalinks_taxonomies_nonce' ), 'class' => 'hidden', ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Save the metabox fields. This is needed due to special processing needs. */ public function save_settings_fields() { if ( isset( $_POST[ $this->setting_field_prefix ] ) ) { if ( ( isset( $_POST[ $this->setting_field_prefix ]['nonce'] ) ) && ( wp_verify_nonce( $_POST[ $this->setting_field_prefix ]['nonce'], 'learndash_permalinks_taxonomies_nonce' ) ) ) { $post_fields = $_POST[ $this->setting_field_prefix ]; foreach ( array( 'course', 'lesson', 'topic', 'quiz' ) as $slug ) { if ( ( isset( $post_fields[ 'ld_' . $slug . '_category' ] ) ) && ( ! empty( $post_fields[ 'ld_' . $slug . '_category' ] ) ) ) { $this->setting_option_values[ 'ld_' . $slug . '_category' ] = $this->esc_url( $post_fields[ 'ld_' . $slug . '_category' ] ); learndash_setup_rewrite_flush(); } if ( ( isset( $post_fields[ 'ld_' . $slug . '_tag' ] ) ) && ( ! empty( $post_fields[ 'ld_' . $slug . '_tag' ] ) ) ) { $this->setting_option_values[ 'ld_' . $slug . '_tag' ] = $this->esc_url( $post_fields[ 'ld_' . $slug . '_tag' ] ); learndash_setup_rewrite_flush(); } } update_option( $this->settings_section_key, $this->setting_option_values ); } } } /** * Class utility function to escape the URL * * @param string $value URL to Escape. * * @return string filtered URL. */ public function esc_url( $value = '' ) { if ( ! empty( $value ) ) { $value = esc_url_raw( trim( $value ) ); $value = str_replace( 'http://', '', $value ); return untrailingslashit( $value ); } } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Permalinks_Taxonomies::add_section_instance(); } ); PK^\{| +]+]Jsettings-sections/class-ld-settings-section-quizzes-management-display.phpnuW+Asettings_screen_id = 'sfwd-quiz_page_quizzes-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'quizzes-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_quizzes_management_display'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_quizzes_management_display'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'quiz_builder'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( 'Global %s Management & Display Settings', 'Quiz Builder', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->settings_section_description = sprintf( // translators: placeholder: Quiz. esc_html_x( 'Control settings for %s creation, and visual organization', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); // Define the depreacted Class and Fields $this->settings_deprecated = array( 'LearnDash_Settings_Quizzes_Builder' => array( 'option_key' => 'learndash_settings_quizzes_builder', 'fields' => array( 'enabled' => 'quiz_builder_enabled', 'shared_questions' => 'quiz_builder_shared_questions', 'per_page' => 'quiz_builder_per_page', 'force_quiz_builder' => 'force_quiz_builder', 'force_shared_questions' => 'force_shared_questions', ), ), 'LearnDash_Settings_Quizzes_Time_Formats' => array( 'option_key' => 'learndash_settings_quizzes_time_formats', 'fields' => array( 'toplist_time_format' => 'statistics_time_format', 'statistics_time_format' => 'toplist_time_format', ), ), ); add_action( 'wp_ajax_' . $this->setting_field_prefix, array( $this, 'ajax_action' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); // If the settings set as a whole is empty then we set a default. if ( empty( $this->setting_option_values ) ) { // If the settings set as a whole is empty then we set a default. if ( false === $this->setting_option_values ) { $this->transition_deprecated_settings(); } if ( true === is_data_upgrade_quiz_questions_updated() ) { $this->setting_option_values['quiz_builder_enabled'] = 'yes'; } else { $this->setting_option_values['quiz_builder_enabled'] = ''; $this->setting_option_values['quiz_builder_shared_questions'] = ''; } } if ( ! isset( $this->setting_option_values['quiz_builder_enabled'] ) ) { $this->setting_option_values['quiz_builder_enabled'] = ''; } if ( ! isset( $this->setting_option_values['quiz_builder_per_page'] ) ) { $this->setting_option_values['quiz_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } else { $this->setting_option_values['quiz_builder_per_page'] = absint( $this->setting_option_values['quiz_builder_per_page'] ); } if ( empty( $this->setting_option_values['quiz_builder_per_page'] ) ) { $this->setting_option_values['quiz_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( empty( $this->setting_option_values['quiz_builder_shared_questions'] ) ) { $this->setting_option_values['quiz_builder_shared_questions'] = ''; } if ( ! isset( $this->setting_option_values['force_quiz_builder'] ) ) { $this->setting_option_values['force_quiz_builder'] = ''; } if ( ! isset( $this->setting_option_values['force_shared_questions'] ) ) { $this->setting_option_values['force_shared_questions'] = ''; } if ( true !== is_data_upgrade_quiz_questions_updated() ) { $this->setting_option_values['quiz_builder_enabled'] = ''; $this->setting_option_values['quiz_builder_shared_questions'] = ''; $this->setting_option_values['force_quiz_builder'] = ''; $this->setting_option_values['force_shared_questions'] = ''; } $wp_date_format = get_option( 'date_format' ); $wp_time_format = get_option( 'time_format' ); $wp_date_time_format = $wp_date_format . ' ' . $wp_time_format; if ( ( ! isset( $this->setting_option_values['toplist_time_format'] ) ) || ( empty( $this->setting_option_values['toplist_time_format'] ) ) ) { $this->setting_option_values['toplist_time_format'] = $wp_date_time_format; } if ( ( ! isset( $this->setting_option_values['statistics_time_format'] ) ) || ( empty( $this->setting_option_values['statistics_time_format'] ) ) ) { $this->setting_option_values['statistics_time_format'] = $wp_date_time_format; } if ( ( $wp_date_time_format === $this->setting_option_values['statistics_time_format'] ) && ( $wp_date_time_format === $this->setting_option_values['toplist_time_format'] ) ) { $this->setting_option_values['quiz_builder_time_formats'] = ''; } else { $this->setting_option_values['quiz_builder_time_formats'] = 'yes'; } $this->setting_option_values['quiz_templates'] = array( '' => __( 'Select a template', 'learndash' ), ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array(); if ( ( defined( 'LEARNDASH_QUIZ_BUILDER' ) ) && ( LEARNDASH_QUIZ_BUILDER === true ) ) { $desc_before_enabled = ''; if ( true !== is_data_upgrade_quiz_questions_updated() ) { // Used to show the section description above the fields. Can be empty. $desc_before_enabled = '' . sprintf( // translators: placeholder: Link to Data Upgrade page. _x( 'The Data Upgrade %s must be run to enable the following settings.', 'placeholder: Link to Data Upgrade page', 'learndash' ), 'Upgrade WPProQuiz Question' ) . ''; } $this->setting_option_fields = array_merge( $this->setting_option_fields, array( 'quiz_builder_enabled' => array( 'name' => 'quiz_builder_enabled', 'type' => 'checkbox-switch', 'desc_before' => $desc_before_enabled, 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Builder', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholder: quizzes, Quiz. esc_html_x( 'Manage and create full %1$s within the %2$s Builder.', 'placeholder: quizzes, Quiz', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label( 'Quiz' ) ), 'value' => $this->setting_option_values['quiz_builder_enabled'], 'options' => array( 'yes' => '', ), 'child_section_state' => ( 'yes' === $this->setting_option_values['quiz_builder_enabled'] ) ? 'open' : 'closed', ), 'quiz_builder_per_page' => array( 'name' => 'quiz_builder_per_page', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Questions. esc_html_x( '%s displayed', 'placeholder: Questions', 'learndash' ), learndash_get_custom_label( 'questions' ) ), 'help_text' => sprintf( // translators: placeholder: questions, Quiz esc_html_x( 'Number of additional %1$s displayed in the %2$s Builder sidebar when clicking the "Load More" link.', 'placeholder: questions, Quiz', 'learndash' ), learndash_get_custom_label_lower( 'questions' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['quiz_builder_per_page'], 'input_label' => esc_html__( 'per page', 'learndash' ), 'class' => 'small-text', 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'quiz_builder_enabled', ), 'quiz_builder_shared_questions' => array( 'name' => 'quiz_builder_shared_questions', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz, Questions. esc_html_x( 'Shared %1$s %2$s', 'placeholder: Quiz, Questions', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'questions' ) ), 'help_text' => sprintf( // translators: placeholder: questions, quizzes, quiz esc_html_x( 'Share %1$s across multiple %2$s. Progress and statistics are maintained on a per-%3$s basis.', 'placeholder: placeholder: questions, quizzes, quiz', 'learndash' ), learndash_get_custom_label_lower( 'questions' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => $this->setting_option_values['quiz_builder_shared_questions'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: questions, quizzes esc_html_x( 'All %1$s can be used across multiple %2$s', 'placeholder: questions, quizzes', 'learndash' ), learndash_get_custom_label_lower( 'questions' ), learndash_get_custom_label_lower( 'quizzes' ) ), ), 'parent_setting' => 'quiz_builder_enabled', ), 'force_quiz_builder' => array( 'name' => 'force_quiz_builder', 'label' => 'force_quiz_builder', 'type' => 'hidden', 'value' => $this->setting_option_values['force_quiz_builder'], ), 'force_shared_questions' => array( 'name' => 'force_shared_questions', 'label' => 'force_shared_questions', 'type' => 'hidden', 'value' => $this->setting_option_values['force_shared_questions'], ), ) ); if ( true !== is_data_upgrade_quiz_questions_updated() ) { $this->setting_option_fields['quiz_builder_enabled']['attrs'] = array( 'disabled' => 'disabled', ); $this->setting_option_fields['quiz_builder_per_page']['attrs'] = array( 'disabled' => 'disabled', ); $this->setting_option_fields['quiz_builder_shared_questions']['attrs'] = array( 'disabled' => 'disabled', ); } if ( 'yes' === $this->setting_option_values['force_quiz_builder'] ) { $this->setting_option_fields['quiz_builder_enabled']['attrs'] = array( 'disabled' => 'disabled', ); } if ( 'yes' === $this->setting_option_values['force_shared_questions'] ) { $this->setting_option_fields['quiz_builder_shared_questions']['attrs'] = array( 'disabled' => 'disabled', ); } } $time_formats_off_state_text = sprintf( // translators: placeholder: Date preview, Time preview, Date format string, Time format string, esc_html_x( 'Default format: %1$s %2$s %3$s %4$s ', '', 'learndash' ), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ), '' . get_option( 'date_format' ) . '', '' . get_option( 'time_format' ) . '' ); $this->setting_option_fields = array_merge( $this->setting_option_fields, array( 'quiz_builder_time_formats' => array( 'name' => 'quiz_builder_time_formats', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Custom %s Time Formats', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholder: Quiz, Quiz. esc_html_x( 'Customize the default time format for the %1$s Leaderboard and %2$s Statistics. ', 'placeholder: Quiz, Quiz', 'learndash' ), learndash_get_custom_label( 'Quiz' ), learndash_get_custom_label( 'Quiz' ) ), 'value' => $this->setting_option_values['quiz_builder_time_formats'], 'options' => array( '' => $time_formats_off_state_text, 'yes' => '', ), 'child_section_state' => ( 'yes' === $this->setting_option_values['quiz_builder_time_formats'] ) ? 'open' : 'closed', ), ) ); $wp_date_format = get_option( 'date_format' ); $wp_time_format = get_option( 'time_format' ); $wp_date_time_format = $wp_date_format . ' ' . $wp_time_format; $date_time_formats = array_unique( apply_filters( 'learndash_quiz_date_time_formats', array( $wp_date_time_format, 'd.m.Y H:i', 'Y/m/d g:i A', 'Y/m/d \a\t g:i A', 'Y/m/d \a\t g:ia', __( 'M j, Y @ G:i' ), ) ) ); if ( ! empty( $date_time_formats ) ) { $options = array( $wp_date_time_format => '' . date_i18n( $wp_date_time_format ) . '' . $wp_date_format . ' ' . $wp_time_format . ' - ' . __( 'WordPress default', 'learndash' ), ); foreach ( $date_time_formats as $format ) { if ( ! isset( $options[ $format ] ) ) { $options[ $format ] = '' . date_i18n( $format ) . '' . $format . ''; } } } $options['custom'] = '' . esc_html__( 'Custom', 'learndash' ) . ''; if ( ! in_array( $this->setting_option_values['statistics_time_format'], $date_time_formats ) ) { $this->setting_option_values['statistics_time_format'] = 'custom'; } $this->setting_option_fields['statistics_time_format'] = array( 'name' => 'statistics_time_format', 'type' => 'radio', 'label' => esc_html__( 'Statistic time format ', 'learndash' ), 'help_text' => esc_html__( 'Statistic time format ', 'learndash' ), 'default' => $wp_date_time_format, 'value' => $this->setting_option_values['statistics_time_format'], 'options' => $options, 'parent_setting' => 'quiz_builder_time_formats', ); $options['custom'] = '' . esc_html__( 'Custom', 'learndash' ) . ''; if ( ! in_array( $this->setting_option_values['toplist_time_format'], $date_time_formats ) ) { $this->setting_option_values['toplist_time_format'] = 'custom'; } $this->setting_option_fields['toplist_time_format'] = array( 'name' => 'toplist_time_format', 'type' => 'radio', 'label' => esc_html__( 'Leaderboard time format', 'learndash' ), 'help_text' => esc_html__( 'Leaderboard time format', 'learndash' ), 'default' => $wp_date_time_format, 'value' => $this->setting_option_values['toplist_time_format'], 'options' => $options, 'parent_setting' => 'quiz_builder_time_formats', ); $template_mapper = new WpProQuiz_Model_TemplateMapper(); $quiz_templates = $template_mapper->fetchAll( WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false ); if ( ( ! empty( $quiz_templates ) ) && ( is_array( $quiz_templates ) ) ) { foreach ( $quiz_templates as $template_quiz ) { $template_name = $template_quiz->getName(); $template_id = $template_quiz->getTemplateId(); if ( ( ! empty( $template_name ) ) && ( ! isset( $this->setting_option_values['quiz_templates'][ $template_id ] ) ) ) { $this->setting_option_values['quiz_templates'][ $template_id ] = esc_html( $template_name ); } } sort( $this->setting_option_values['quiz_templates'] ); } $this->setting_option_fields['quiz_template'] = array( 'name' => 'quiz_template', 'type' => 'select-edit-delete', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Template Management', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'help_text' => esc_html__( 'Select a template to update or delete the title.', 'learndash' ), 'value' => '', 'placeholder' => esc_html__( 'Select a template', 'learndash' ), 'options' => $this->setting_option_values['quiz_templates'], 'buttons' => array( 'delete' => esc_html__( 'Delete', 'learndash' ), 'update' => esc_html__( 'Update', 'learndash' ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $current_values = '', $old_values = '', $option = '' ) { if ( $option === $this->setting_option_key ) { $current_values = parent::section_pre_update_option( $current_values, $old_values, $option ); if ( $current_values !== $old_values ) { //if ( ( isset( $current_values['force_quiz_builder'] ) ) && ( 'yes' === $current_values['force_quiz_builder'] ) ) { // $current_values['quiz_builder_enabled'] = 'yes'; //} //if ( ( isset( $current_values['force_shared_questions'] ) ) && ( 'yes' === $current_values['force_shared_questions'] ) ) { // $current_values['quiz_builder_shared_questions'] = 'yes'; //} //if ( ( isset( $current_values['shared_questions'] ) ) && ( 'yes' === $current_values['shared_questions'] ) ) { // if ( ( ! isset( $current_values['quiz_builder_enabled'] ) ) || ( 'yes' !== $current_values['quiz_builder_enabled'] ) ) { // $current_values['quiz_builder_shared_questions'] = 'no'; // } //} if ( ( isset( $current_values['quiz_builder_enabled'] ) ) && ( 'yes' === $current_values['quiz_builder_enabled'] ) ) { $current_values['quiz_builder_per_page'] = absint( $current_values['quiz_builder_per_page'] ); } else { $current_values['quiz_builder_shared_questions'] = ''; $current_values['quiz_builder_per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } $wp_date_format = get_option( 'date_format' ); $wp_time_format = get_option( 'time_format' ); $wp_date_time_format = $wp_date_format . ' ' . $wp_time_format; if ( ( isset( $current_values['quiz_builder_time_formats'] ) ) && ( 'yes' === $current_values['quiz_builder_time_formats'] ) ) { if ( ( isset( $current_values['statistics_time_format'] ) ) && ( 'custom' === $current_values['statistics_time_format'] ) ) { if ( ( isset( $_POST['statistics_time_format_custom'] ) ) && ( ! empty( $_POST['statistics_time_format_custom'] ) ) ) { $current_values['statistics_time_format'] = esc_attr( $_POST['statistics_time_format_custom'] ); } else { $current_values['statistics_time_format'] = ''; } } if ( $wp_date_time_format === $current_values['statistics_time_format'] ) { $current_values['statistics_time_format'] = ''; } if ( ( isset( $current_values['toplist_time_format'] ) ) && ( 'custom' === $current_values['toplist_time_format'] ) ) { if ( ( isset( $_POST['toplist_date_format_custom'] ) ) && ( ! empty( $_POST['toplist_date_format_custom'] ) ) ) { $current_values['toplist_time_format'] = esc_attr( $_POST['toplist_date_format_custom'] ); } else { $current_values['toplist_time_format'] = ''; } } if ( $wp_date_time_format === $current_values['toplist_time_format'] ) { $current_values['toplist_time_format'] = ''; } } else { $current_values['statistics_time_format'] = ''; $current_values['toplist_time_format'] = ''; } } } return $current_values; } /** * This function handles the AJAX actions from the browser. * * @since 2.5.9 */ public function ajax_action() { $reply_data = array( 'status' => false ); if ( current_user_can( 'wpProQuiz_edit_quiz' ) ) { if ( ( isset( $_POST['field_nonce'] ) ) && ( ! empty( $_POST['field_nonce'] ) ) && ( isset( $_POST['field_key'] ) ) && ( ! empty( $_POST['field_key'] ) ) && ( wp_verify_nonce( esc_attr( $_POST['field_nonce'] ), $_POST['field_key'] ) ) ) { if ( isset( $_POST['field_action'] ) ) { if ( 'update' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) && ( isset( $_POST['field_text'] ) ) && ( ! empty( $_POST['field_text'] ) ) ) { $template_id = intval( $_POST['field_value'] ); $template_new_name = esc_attr( $_POST['field_text'] ); $template_mapper = new WpProQuiz_Model_TemplateMapper(); $template = $template_mapper->fetchById( $template_id ); if ( ( $template ) && ( is_a( $template, 'WpProQuiz_Model_Template' ) ) ) { $template_current_name = $template->getName(); if ( $template_current_name !== $template_new_name ) { $update_ret = $template_mapper->updateName( $template_id, $template_new_name ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Template updated.', 'learndash' ) . ''; } } } } } elseif ( 'delete' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) ) { $template_id = intval( $_POST['field_value'] ); $template_mapper = new WpProQuiz_Model_TemplateMapper(); $template = $template_mapper->fetchById( $template_id ); if ( ( $template ) && ( is_a( $template, 'WpProQuiz_Model_Template' ) ) ) { $update_ret = $template_mapper->delete( $template_id ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Template deleted.', 'learndash' ) . ''; } } } } } } } if ( ! empty( $reply_data ) ) { echo wp_json_encode( $reply_data ); } wp_die(); // This is required to terminate immediately and return a proper response. } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Quizzes_Management_Display::add_section_instance(); } ); PK^\hBt!!Gsettings-sections/class-ld-settings-section-support-database-tables.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'ld_database_tables'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_ld_database_tables'; // Section label/header. $this->settings_section_label = esc_html__( 'Database Tables', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * Learndash Database Tables ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Table Name', 'learndash' ), 'text' => 'Table Name', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Present', 'learndash' ), 'text' => 'Present', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['desc'] = '

    ' . esc_html__( 'When the LearnDash plugin or related add-ons are activated they will create the following tables. If the tables are not present try reactivating the plugin. If the table still do not show check the DB_USER defined in your wp-config.php and ensure it has the proper permissions to create tables. Check with your host for help.', 'learndash' ) . '

    '; $grants = learndash_get_db_user_grants(); if ( ! empty( $grants ) ) { if ( ( array_search( 'ALL PRIVILEGES', $grants ) === false ) && ( array_search( 'CREATE', $grants ) === false ) ) { $this->settings_set['desc'] .= '

    ' . esc_html__( 'The DB_USER defined in your wp-config.php does not have CREATE permission.', 'learndash' ) . '

    '; } } $this->settings_set['settings'] = array(); $this->db_tables = LDLMS_DB::get_tables(); $this->db_tables = apply_filters( 'learndash_support_db_tables', $this->db_tables ); if ( ! empty( $this->db_tables ) ) { sort( $this->db_tables ); $this->db_tables = array_unique( $this->db_tables ); foreach ( $this->db_tables as $db_table ) { $this->settings_set['settings'][ $db_table ] = array( 'label' => $db_table, ); if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $db_table . "'" ) == $db_table ) { if ( true === apply_filters( 'learndash_support_db_tables_rows', true ) ) { $table_rows = $wpdb->get_var( "SELECT table_rows from information_schema.tables WHERE table_schema = '" . DB_NAME . "' AND table_name = '" . $db_table . "'" ); $rows_str = ' - rows(' . $table_rows . ')'; } else { $rows_str = ''; } $this->settings_set['settings'][ $db_table ]['value'] = 'Yes' . $rows_str; $this->settings_set['settings'][ $db_table ]['value_html'] = '' . esc_html__( 'Yes', 'learndash' ) . '' . $rows_str; } else { $this->settings_set['settings'][ $db_table ]['value'] = 'No' . ' - (X)'; $this->settings_set['settings'][ $db_table ]['value_html'] = '' . esc_html__( 'No', 'learndash' ) . ''; } } } $this->system_info['ld_database_tables'] = apply_filters( 'learndash_support_section', $this->settings_set, 'ld_database_tables' ); $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_Database_Tables::add_section_instance(); } ); PK^\_--Asettings-sections/class-ld-settings-section-support-templates.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'ld_templates'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_ld_templates'; // Section label/header. $this->settings_section_label = esc_html__( 'Templates', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * Learndash Templates. ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->load_templates(); $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Template Name', 'learndash' ), 'text' => 'Template Name', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Template Path', 'learndash' ), 'text' => 'Template Path', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['desc'] = ''; $this->settings_set['desc'] .= '

    ' . esc_html__( 'Current Active LD Theme', 'learndash' ) . ': ' . LearnDash_Theme_Register::get_active_theme_name() . '

    '; $template_paths = SFWD_LMS::get_template_paths( 'xxx.php' ); $theme_root = get_theme_root(); $theme_root = str_replace( '\\', '/', $theme_root ); $this->settings_set['desc'] .= '

    ' . esc_html__( 'The following is the search order paths for override templates, relative to site root:', 'learndash' ); $this->settings_set['desc'] .= '

      '; if ( ( isset( $template_paths['theme'] ) ) && ( ! empty( $template_paths['theme'] ) ) ) { foreach ( $template_paths['theme'] as $theme_path ) { $theme_path = dirname( $theme_path ); if ( '.' === $theme_path ) { $theme_path = ''; } else { $theme_path = '/' . $theme_path; } $this->settings_set['desc'] .= '
    1. ' . str_replace( $ABSPATH_tmp, '/', $theme_root ) . '/' . esc_html__( '', 'learndash' ) . $theme_path . '
    2. '; } } if ( ( isset( $template_paths['templates'] ) ) && ( ! empty( $template_paths['templates'] ) ) ) { foreach ( $template_paths['templates'] as $theme_path ) { $theme_path = dirname( $theme_path ); if ( '.' === $theme_path ) { $theme_path = ''; } $this->settings_set['desc'] .= '
    3. ' . str_replace( $ABSPATH_tmp, '/', $theme_path ) . '
    4. '; } } $this->settings_set['desc'] .= '

    '; $this->settings_set['settings'] = array(); $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); $LEARNDASH_LMS_PLUGIN_DIR_tmp = str_replace( '\\', '/', LEARNDASH_LMS_PLUGIN_DIR ); if ( ! empty( $this->template_array ) ) { foreach ( $this->template_array as $template_filename => $template_path ) { if ( ! empty( $template_path ) ) { $template_path = str_replace( '\\', '/', $template_path ); $this->settings_set['settings'][ $template_filename ] = array( 'label' => $template_filename, ); if ( strncmp( $template_path, $LEARNDASH_LMS_PLUGIN_DIR_tmp, strlen( $LEARNDASH_LMS_PLUGIN_DIR_tmp ) ) != 0 ) { $this->settings_set['settings'][ $template_filename ]['value_html'] = '' . str_replace( $ABSPATH_tmp, '', $template_path ) . ''; $this->settings_set['settings'][ $template_filename ]['value'] = str_replace( $ABSPATH_tmp, '', $template_path ) . ' (X)'; } else { $this->settings_set['settings'][ $template_filename ]['value_html'] = str_replace( $ABSPATH_tmp, '', $template_path ); $this->settings_set['settings'][ $template_filename ]['value'] = str_replace( $ABSPATH_tmp, '', $template_path ); } } } } $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } /** * Load template files in preparation for processing. * * @since 2.3 */ public function load_templates() { $this->template_array = array(); $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); $LEARNDASH_LMS_PLUGIN_DIR_tmp = str_replace( '\\', '/', LEARNDASH_LMS_PLUGIN_DIR ); $active_theme_instance = LearnDash_Theme_Register::get_active_theme_instance(); if ( is_a( $active_theme_instance, 'LearnDash_Theme_Register' ) ) { $active_theme_dir = $active_theme_instance->get_theme_template_dir(); $template_files = learndash_scandir_recursive( $active_theme_dir ); if ( ! empty( $template_files ) ) { foreach ( $template_files as $idx => $template_file ) { $template_file = str_replace( '\\', '/', $template_file ); $file_pathinfo = pathinfo( $template_file ); if ( ( ! isset( $file_pathinfo['extension'] ) ) || ( empty( $file_pathinfo['extension'] ) ) ) { continue; } if ( ( ! isset( $file_pathinfo['filename'] ) ) || ( empty( $file_pathinfo['filename'] ) ) ) { continue; } if ( ! in_array( $file_pathinfo['extension'], array( 'php', 'css', 'js' ) ) ) { continue; } if ( '_' === $file_pathinfo['filename'][0] ) { continue; } if ( false !== strpos( $file_pathinfo['filename'], '.min.' ) ) { continue; } if ( ! in_array( $template_file, $this->template_array ) ) { $template_filename = str_replace( $active_theme_dir . '/', '', $template_file ); $template_path = SFWD_LMS::get_template( $template_filename, null, null, true ); if ( ! empty( $template_path ) ) { $this->template_array[ $template_filename ] = $template_path; } } } } } if ( LearnDash_Theme_Register::get_active_theme_key() !== LEARNDASH_LEGACY_THEME ) { $legacy_theme_instance = LearnDash_Theme_Register::get_theme_instance( LEARNDASH_LEGACY_THEME ); if ( is_a( $active_theme_instance, 'LearnDash_Theme_Register' ) ) { $legacy_theme_dir = $legacy_theme_instance->get_theme_template_dir(); if ( ! empty( $legacy_theme_dir ) ) { $template_files = learndash_scandir_recursive( $legacy_theme_dir ); if ( ! empty( $template_files ) ) { foreach ( $template_files as $idx => $template_file ) { $template_file = str_replace( '\\', '/', $template_file ); //$template_file = str_replace( $ABSPATH_tmp, '', $template_file ); $file_pathinfo = pathinfo( $template_file ); if ( ( ! isset( $file_pathinfo['extension'] ) ) || ( empty( $file_pathinfo['extension'] ) ) ) { continue; } if ( ( ! isset( $file_pathinfo['filename'] ) ) || ( empty( $file_pathinfo['filename'] ) ) ) { continue; } if ( ! in_array( $file_pathinfo['extension'], array( 'php', 'css', 'js' ) ) ) { continue; } if ( '_' === $file_pathinfo['filename'][0] ) { continue; } if ( false !== strpos( $file_pathinfo['filename'], '.min.' ) ) { continue; } $template_filename = str_replace( $legacy_theme_dir . '/', '', $template_file ); if ( ! isset( $this->template_array[ $template_filename ] ) ) { $template_path = SFWD_LMS::get_template( $template_filename, null, null, true ); if ( ! empty( $template_path ) ) { $this->template_array[ $template_filename ] = $template_path; } } } } } } } if ( ! empty( $this->template_array ) ) { ksort( $this->template_array ); // We want to reorder the $templates_grouped = array( 'override' => array(), ); $active_theme_dir = ''; $legacy_theme_dir = ''; $active_theme_instance = LearnDash_Theme_Register::get_active_theme_instance(); if ( is_a( $active_theme_instance, 'LearnDash_Theme_Register' ) ) { $templates_grouped['active'] = array(); $active_theme_dir = $active_theme_instance->get_theme_template_dir(); } if ( LearnDash_Theme_Register::get_active_theme_key() !== LEARNDASH_LEGACY_THEME ) { $legacy_theme_instance = LearnDash_Theme_Register::get_theme_instance( LEARNDASH_LEGACY_THEME ); if ( is_a( $active_theme_instance, 'LearnDash_Theme_Register' ) ) { $templates_grouped['legacy'] = array(); $legacy_theme_dir = $legacy_theme_instance->get_theme_template_dir(); } } foreach ( $this->template_array as $template_filename => $template_path ) { if ( strncmp( $template_path, $LEARNDASH_LMS_PLUGIN_DIR_tmp, strlen( $LEARNDASH_LMS_PLUGIN_DIR_tmp ) ) != 0 ) { $templates_grouped['override'][ $template_filename ] = $template_path; } else if ( ( ! empty( $active_theme_dir ) ) && ( strncmp( $template_path, $active_theme_dir, strlen( $active_theme_dir ) ) == 0 ) ) { $templates_grouped['active'][ $template_filename ] = $template_path; } else if ( ( ! empty( $legacy_theme_dir ) ) && ( strncmp( $template_path, $legacy_theme_dir, strlen( $legacy_theme_dir ) ) == 0 ) ) { $templates_grouped['legacy'][ $template_filename ] = $template_path; } } $this->template_array = array(); foreach( $templates_grouped as $template_section => $template_array ) { if ( ! empty( $template_array ) ) { $this->template_array = array_merge( $this->template_array, $template_array ); } } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_Templates::add_section_instance(); } ); PK^\R$Asettings-sections/class-ld-settings-section-support-wordpress.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'wp_settings'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_wp_settings'; // Section label/header. $this->settings_section_label = esc_html__( 'WordPress Settings', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * WordPress Settings. ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Setting', 'learndash' ), 'text' => 'Setting', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Value', 'learndash' ), 'text' => 'Value', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['settings'] = array(); $this->settings_set['settings']['wp_version'] = array( 'label' => 'WordPress Version', 'label_html' => esc_html__( 'WordPress Version', 'learndash' ), 'value' => $wp_version, ); $this->settings_set['settings']['home'] = array( 'label' => 'WordPress Home URL', 'label_html' => esc_html__( 'WordPress Home URL', 'learndash' ), 'value' => get_option( 'home' ), ); $this->settings_set['settings']['siteurl'] = array( 'label' => 'WordPress Site URL', 'label_html' => esc_html__( 'WordPress Site URL', 'learndash' ), 'value' => get_option( 'siteurl' ), ); $this->settings_set['settings']['is_multisite'] = array( 'label' => 'Is Multisite', 'label_html' => esc_html__( 'Is Multisite', 'learndash' ), 'value' => is_multisite() ? 'Yes' : 'No', 'value_html' => is_multisite() ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); $this->settings_set['settings']['Site Language'] = array( 'label' => 'Site Language', 'label_html' => esc_html__( 'Site Language', 'learndash' ), 'value' => get_locale(), ); if ( $wp_rewrite->using_permalinks() ) { $value_html = '' . esc_html__( 'Yes', 'learndash' ) . ''; $value = 'Yes'; } else { $value_html = '' . esc_html__( 'No', 'learndash' ) . ''; $value = 'No (X)'; } $this->settings_set['settings']['using_permalinks'] = array( 'label' => 'Using Permalinks', 'label_html' => esc_html__( 'Using Permalinks', 'learndash' ), 'value_html' => $value_html, 'value' => $value, ); $this->settings_set['settings']['Object Cache'] = array( 'label' => 'Object Cache', 'label_html' => esc_html__( 'Object Cache', 'learndash' ), 'value' => wp_using_ext_object_cache() ? esc_html__( 'Yes', 'learndash' ) : esc_html__( 'No', 'learndash' ), ); foreach ( apply_filters( 'learndash_support_wp_defines', array( 'DISABLE_WP_CRON', 'WP_DEBUG', 'WP_DEBUG_DISPLAY', 'SCRIPT_DEBUG', 'WP_DEBUG_DISPLAY', 'WP_DEBUG_LOG', 'WP_PLUGIN_DIR', 'WP_AUTO_UPDATE_CORE', 'WP_MAX_MEMORY_LIMIT', 'WP_MEMORY_LIMIT', 'DB_CHARSET', 'DB_COLLATE' ) ) as $defined_item ) { $defined_value = ( defined( $defined_item ) ) ? constant( $defined_item ) : ''; $defined_value_html = $defined_value; if ( 'WP_PLUGIN_DIR' == $defined_item ) { $defined_value = str_replace( $ABSPATH_tmp, '', $defined_value ); } elseif ( 'WP_MEMORY_LIMIT' == $defined_item ) { if ( learndash_return_bytes_from_shorthand( $defined_value ) < learndash_return_bytes_from_shorthand( '100M' ) ) { $defined_value .= ' - (X) Recommended at least 100M memory.'; $defined_value_html = '' . $defined_value_html . ' - ' . esc_html__( 'Recommended at least 100M memory.', 'learndash' ) . ''; } else { $defined_value_html = '' . $defined_value_html . ''; } } elseif ( 'WP_MAX_MEMORY_LIMIT' == $defined_item ) { if ( learndash_return_bytes_from_shorthand( $defined_value ) < learndash_return_bytes_from_shorthand( '256M' ) ) { $defined_value .= ' - (X) Recommended at least 256M memory.'; $defined_value_html = '' . $defined_value_html . ' - ' . esc_html__( 'Recommended at least 256M memory.', 'learndash' ) . ''; } else { $defined_value_html = '' . $defined_value_html . ''; } } $this->settings_set['settings'][ $defined_item ] = array( 'label' => $defined_item, 'label_html' => $defined_item, 'value' => $defined_value, 'value_html' => $defined_value_html, ); } $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_WordPress::add_section_instance(); } ); PK^\@JJIsettings-sections/class-ld-settings-section-support-wordpress-plugins.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'wp_active_plugins'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_wp_active_plugins'; // Section label/header. $this->settings_section_label = esc_html__( 'WordPress Active Plugins', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * WordPress Active Plugins. ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Plugin', 'learndash' ), 'text' => 'Plugin', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Details', 'learndash' ), 'text' => 'Details', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['settings'] = array(); $current_plugins = get_site_transient( 'update_plugins' ); $all_plugins = get_plugins(); if ( ! empty( $all_plugins ) ) { foreach ( $all_plugins as $plugin_key => $plugin_data ) { if ( is_plugin_active( $plugin_key ) ) { $plugin_value = 'Version: ' . $plugin_data['Version']; $plugin_value_html = esc_html__( 'Version', 'learndash' ) . ': ' . $plugin_data['Version']; if ( isset( $current_plugins->response[ $plugin_key ] ) ) { if ( version_compare( $plugin_data['Version'], $current_plugins->response[ $plugin_key ]->new_version, '<' ) ) { $plugin_value .= ' Update available: ' . $current_plugins->response[ $plugin_key ]->new_version . ' (X)'; $plugin_value_html .= ' ' . esc_html__( 'Update available', 'learndash' ) . ': ' . $current_plugins->response[ $plugin_key ]->new_version . ''; } } $plugin_value .= ' Path: ' . $plugin_data['PluginURI']; $plugin_value_html .= '
    ' . esc_html__( 'Path', 'learndash' ) . ': ' . $plugin_data['PluginURI']; $this->settings_set['settings'][ $plugin_key ] = array( 'label' => $plugin_data['Name'], 'value' => $plugin_value, 'value_html' => $plugin_value_html, ); } } } $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_WordPress_Plugins::add_section_instance(); } ); PK^\^577Fsettings-sections/class-ld-settings-section-quizzes-email-settings.phpnuW+Asettings_screen_id = 'sfwd-quiz_page_quizzes-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'quizzes-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_quizzes_email'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_quizzes_email'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'quizzes_email'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Email Settings', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $this->settings_section_description = sprintf( // translators: placeholder: Quiz. esc_html_x( 'Control the %s email notification options', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); // Define the depreacted Class and Fields $this->settings_deprecated = array( 'LearnDash_Settings_Quizzes_Admin_Email' => array( 'option_key' => 'learndash_settings_quizzes_admin_email', 'fields' => array( 'mail_to' => 'admin_mail_to', 'mail_from_name' => 'admin_mail_from_name', 'mail_from_email' => 'admin_mail_from_email', 'mail_subject' => 'admin_mail_subject', 'mail_html' => 'admin_mail_html', 'mail_message' => 'admin_mail_message', ), ), 'LearnDash_Settings_Quizzes_User_Email' => array( 'option_key' => 'learndash_settings_quizzes_user_email', 'fields' => array( 'mail_from_name' => 'user_mail_from_name', 'mail_from_email' => 'user_mail_from_email', 'mail_subject' => 'user_mail_subject', 'mail_html' => 'user_mail_html', 'mail_message' => 'user_mail_message', ), ), ); add_filter( 'learndash_settings_row_outside_after', array( $this, 'learndash_settings_row_outside_after' ), 10, 2 ); add_filter( 'learndash_settings_row_outside_before', array( $this, 'learndash_settings_row_outside_before' ), 30, 2 ); parent::__construct(); } /** * Load the field settings values */ public function load_settings_values() { parent::load_settings_values(); // If the settings set as a whole is empty then we set a default. if ( empty( $this->setting_option_values ) ) { // If the settings set as a whole is empty then we set a default. if ( false === $this->setting_option_values ) { $this->transition_deprecated_settings(); } } if ( ! isset( $this->setting_option_values['admin_mail_from_name'] ) ) { $this->setting_option_values['admin_mail_from_name'] = ''; } if ( ! isset( $this->setting_option_values['admin_mail_from_email'] ) ) { $this->setting_option_values['admin_mail_from_email'] = ''; } if ( ! isset( $this->setting_option_values['admin_mail_to'] ) ) { $this->setting_option_values['admin_mail_to'] = ''; } if ( ! isset( $this->setting_option_values['admin_mail_subject'] ) ) { $this->setting_option_values['admin_mail_subject'] = ''; } if ( ! isset( $this->setting_option_values['admin_mail_message'] ) ) { $this->setting_option_values['admin_mail_message'] = ''; } if ( ! isset( $this->setting_option_values['admin_mail_html'] ) ) { $this->setting_option_values['admin_mail_html'] = ''; } } /** * Load the field settings fields */ public function load_settings_fields() { $this->setting_option_fields = array( 'admin_mail_from_name' => array( 'name' => 'admin_mail_from_name', 'type' => 'text', 'label' => esc_html__( 'From Name', 'learndash' ), 'help_text' => esc_html__( 'This is the name of the sender. If not provided will default to the system email name.', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_from_name'] ) ? $this->setting_option_values['admin_mail_from_name'] : '', ), 'admin_mail_from_email' => array( 'name' => 'admin_mail_from_email', 'type' => 'email', 'label' => esc_html__( 'From Email', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: admin email. esc_html_x( 'This is the email address of the sender. If not provided the admin email %s will be used.', 'placeholder: admin email', 'learndash' ), '(' . get_option( 'admin_email' ) . ')' ), 'value' => isset( $this->setting_option_values['admin_mail_from_email'] ) ? $this->setting_option_values['admin_mail_from_email'] : '', ), 'admin_mail_to' => array( 'name' => 'admin_mail_to', 'type' => 'text', 'label' => esc_html__( 'Mail To', 'learndash' ), 'help_text' => esc_html__( 'Separate multiple email addresses with a comma, e.g. wp@test.com, test@test.com.', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_to'] ) ? $this->setting_option_values['admin_mail_to'] : '', ), 'admin_mail_subject' => array( 'name' => 'admin_mail_subject', 'type' => 'text', 'label' => esc_html__( 'Subject', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_subject'] ) ? $this->setting_option_values['admin_mail_subject'] : '', ), 'admin_mail_message' => array( 'name' => 'admin_mail_message', 'type' => 'wpeditor', 'label' => esc_html__( 'Message', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_message'] ) ? stripslashes( $this->setting_option_values['admin_mail_message'] ) : '', 'editor_args' => array( 'textarea_name' => $this->setting_option_key . '[admin_mail_message]', 'textarea_rows' => 5, 'editor_class' => 'learndash_mail_message ' . $this->setting_option_key . '_admin_mail_message', ), 'label_description' => '

    ' . esc_html__( 'Supported variables', 'learndash' ) . ':

    • $userId - ' . esc_html__( 'User-ID', 'learndash' ) . '
    • $username - ' . esc_html__( 'Username', 'learndash' ) . '
    • $quizname - ' . esc_html__( 'Quiz-Name', 'learndash' ) . '
    • $result - ' . esc_html__( 'Result in percent', 'learndash' ) . '
    • $points - ' . esc_html__( 'Reached points', 'learndash' ) . '
    • $ip - ' . esc_html__( 'IP-address of the user', 'learndash' ) . '
    • $categories - ' . esc_html__( 'Category-Overview', 'learndash' ) . '
    ', ), 'admin_mail_html' => array( 'name' => 'admin_mail_html', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Allow HTML', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_html'] ) ? $this->setting_option_values['admin_mail_html'] : '', 'options' => array( 'yes' => '', ), ), 'user_mail_from_name' => array( 'name' => 'user_mail_from_name', 'type' => 'text', 'label' => esc_html__( 'From Name', 'learndash' ), 'help_text' => esc_html__( 'This is the name of the sender. If not provided will default to the system email name.', 'learndash' ), 'value' => isset( $this->setting_option_values['admin_mail_from_name'] ) ? $this->setting_option_values['admin_mail_from_name'] : '', ), 'user_mail_from_email' => array( 'name' => 'user_mail_from_email', 'type' => 'email', 'label' => esc_html__( 'From Email', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: admin email. esc_html_x( 'This is the email address of the sender. If not provided the admin email %s will be used.', 'placeholder: admin email', 'learndash' ), '(' . get_option( 'admin_email' ) . ')' ), 'value' => isset( $this->setting_option_values['user_mail_from_email'] ) ? $this->setting_option_values['user_mail_from_email'] : '', ), 'user_mail_subject' => array( 'name' => 'user_mail_subject', 'type' => 'text', 'label' => esc_html__( 'Subject', 'learndash' ), 'value' => isset( $this->setting_option_values['user_mail_subject'] ) ? $this->setting_option_values['user_mail_subject'] : '', ), 'user_mail_message' => array( 'name' => 'user_mail_message', 'type' => 'wpeditor', 'label' => esc_html__( 'Message', 'learndash' ), 'value' => isset( $this->setting_option_values['user_mail_message'] ) ? stripslashes( $this->setting_option_values['user_mail_message'] ) : '', 'editor_args' => array( 'textarea_name' => $this->setting_option_key . '[user_mail_message]', 'textarea_rows' => 5, 'editor_class' => 'learndash_mail_message ' . $this->setting_option_key . '_user_mail_message', ), 'label_description' => '

    ' . esc_html__( 'Supported variables', 'learndash' ) . ':

    • $userId - ' . esc_html__( 'User-ID', 'learndash' ) . '
    • $username - ' . esc_html__( 'Username', 'learndash' ) . '
    • $quizname - ' . esc_html__( 'Quiz-Name', 'learndash' ) . '
    • $result - ' . esc_html__( 'Result in percent', 'learndash' ) . '
    • $points - ' . esc_html__( 'Reached points', 'learndash' ) . '
    • $ip - ' . esc_html__( 'IP-address of the user', 'learndash' ) . '
    • $categories - ' . esc_html__( 'Category-Overview', 'learndash' ) . '
    ', ), 'user_mail_html' => array( 'name' => 'user_mail_html', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Allow HTML', 'learndash' ), 'value' => isset( $this->setting_option_values['user_mail_html'] ) ? $this->setting_option_values['user_mail_html'] : '', 'options' => array( 'yes' => '', ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Hook into action after the fieldset is output. This allows adding custom content like JS/CSS. * * @since 2.5.9 * * @param string $html This is the field output which will be send to the screen. * @param array $field_args Array of field args used to build the field HTML. * * @return string $html. */ public function learndash_settings_row_outside_after( $html = '', $field_args = array() ) { /** * Here we hook into the bottom of the field HTML output and add some inline JS to handle the * change event on the radio buttons. This is really just to update the 'custom' input field * display. */ if ( ( isset( $field_args['setting_option_key'] ) ) && ( $this->setting_option_key === $field_args['setting_option_key'] ) ) { if ( ( isset( $field_args['name'] ) ) && ( 'admin_mail_html' === $field_args['name'] ) ) { $html .= '
    '; } } return $html; } /** * Add Header and description on email sections. */ public function learndash_settings_row_outside_before( $content = '', $field_args = array() ) { if ( ( isset( $field_args['name'] ) ) && ( in_array( $field_args['name'], array( 'admin_mail_from_name', 'user_mail_from_name' ) ) ) ) { if ( 'admin_mail_from_name' === $field_args['name'] ) { $content .= '
    '; $content .= '
    '; $content .= esc_html__( 'ADMIN NOTIFICATIONS', 'learndash' ); $content .= '
    '; $content .= '
    '; $content .= sprintf( // translators: placeholder: quiz, quiz. esc_html_x( 'Manage the email content that will be sent out to the admin, group leader or other supervisors when a user completes a %1$s. You must enable "Admin Notification" on a per %2$s basis.', 'placeholder: quiz, quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'quiz' ) ); $content .= '
    '; $content .= '
    '; } if ( 'user_mail_from_name' === $field_args['name'] ) { $content .= '
    '; $content .= '
    '; $content .= esc_html__( 'USER NOTIFICATIONS', 'learndash' ); $content .= '
    '; $content .= '
    '; $content .= sprintf( // translators: placeholder: quiz, quiz. esc_html_x( 'Manage the email content that will be sent out to the user when a %1$s is completed. You must enable "User Notification" on a per %2$s basis.', 'placeholder: quiz, quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'quiz' ) ); $content .= '
    '; $content .= '
    '; } } return $content; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Quizzes_Email::add_section_instance(); } ); PK^\8P'  Bsettings-sections/class-ld-settings-section-support-data-reset.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'ld_data_reset'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_data_reset'; // Section label/header. $this->settings_section_label = esc_html__( 'Reset ALL LearnDash Data', 'learndash' ); $this->metabox_context = 'side'; $this->metabox_priority = 'high'; add_action( 'learndash-settings-page-load', array( $this, 'on_settings_page_load' ), 10, 2 ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function on_settings_page_load( $settings_screen_id = '', $settings_page_id = '' ) { global $sfwd_lms; if ( $settings_page_id === $this->settings_page_id ) { if ( learndash_is_admin_user() ) { if ( ( isset( $_POST['ld_data_remove_nonce'] ) ) && ( ! empty( $_POST['ld_data_remove_nonce'] ) ) && ( wp_verify_nonce( $_POST['ld_data_remove_nonce'], 'ld_data_remove_' . get_current_user_id() ) ) ) { if ( ( isset( $_POST['ld_data_remove_verify'] ) ) && ( ! empty( $_POST['ld_data_remove_verify'] ) ) && ( wp_verify_nonce( $_POST['ld_data_remove_verify'], 'ld_data_remove_' . get_current_user_id() ) ) ) { learndash_delete_all_data(); $active_plugins = (array) get_option( 'active_plugins', array() ); if ( ! empty( $active_plugins ) ) { $active_plugins = array_diff( $active_plugins, array( LEARNDASH_LMS_PLUGIN_KEY ) ); update_option( 'active_plugins', $active_plugins ); // Hook into our own deactivate function. $sfwd_lms->deactivate(); // finally redirect the admin to the plugins listing. wp_redirect( admin_url( 'plugins.php' ) ); die(); } } } } } } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { if ( learndash_is_admin_user() ) { $remove_nonce = wp_create_nonce( 'ld_data_remove_' . get_current_user_id() ); ?>

    Warning: This will remove ALL LearnDash data including any custom database tables.', 'learndash' ); ?>




    %s in the above field and click the submit button', 'placeholder: secret generated code', 'learndash' ), $remove_nonce ); ?>

    settings-sections/class-ld-settings-section-support-server.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'server_settings'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_server_settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Server Settings', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * Server Settings. ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Setting', 'learndash' ), 'text' => 'Setting', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Value', 'learndash' ), 'text' => 'Value', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['settings'] = array(); $php_version = phpversion(); $this->settings_set['settings']['phpversion'] = array( 'label' => 'PHP Version', 'label_html' => esc_html__( 'PHP Version', 'learndash' ), 'value' => $php_version, ); $version_compare = version_compare( '7.0', $php_version, '>' ); $color = 'green'; if ( -1 == $version_compare ) { $color = 'red'; } $this->settings_set['settings']['phpversion']['value_html'] = '' . $php_version . ''; if ( -1 == $version_compare ) { $this->settings_set['settings']['phpversion']['value_html'] .= ' - ' . esc_html__( 'WordPress Minimum Requirements', 'learndash' ) . ''; } if ( defined( 'PHP_OS' ) ) { $this->settings_set['settings']['PHP_OS'] = array( 'label' => 'PHP OS', 'label_html' => esc_html__( 'PHP OS', 'learndash' ), 'value' => PHP_OS, ); } if ( defined( 'PHP_OS_FAMILY' ) ) { $this->settings_set['settings']['PHP_OS_FAMILY'] = array( 'label' => 'PHP OS Family', 'label_html' => esc_html__( 'PHP OS Family', 'learndash' ), 'value' => PHP_OS_FAMILY, ); } if ( true == $wpdb->is_mysql ) { global $required_mysql_version; $mysql_version = $wpdb->db_version(); $this->settings_set['settings']['mysql_version'] = array( 'label' => 'MySQL version', 'label_html' => esc_html__( 'MySQL version', 'learndash' ), 'value' => $mysql_version, ); $version_compare = version_compare( $required_mysql_version, $mysql_version, '>' ); $color = 'green'; if ( -1 == $version_compare ) { $color = 'red'; } $this->settings_set['settings']['mysql_version']['value_html'] = '' . $mysql_version . ''; if ( -1 == $version_compare ) { $this->settings_set['settings']['mysql_version']['value_html'] .= ' - ' . esc_html__( 'WordPress Minimum Requirements', 'learndash' ) . ''; } } $this->php_ini_settings = apply_filters( 'learndash_support_php_ini_settings', $this->php_ini_settings ); if ( ! empty( $this->php_ini_settings ) ) { sort( $this->php_ini_settings ); $this->php_ini_settings = array_unique( $this->php_ini_settings ); foreach ( $this->php_ini_settings as $ini_key ) { $this->settings_set['settings'][ $ini_key ] = array( 'label' => $ini_key, 'value' => ini_get( $ini_key ), ); } $this->settings_set['settings']['curl'] = array( 'label' => 'curl', ); if ( ! extension_loaded( 'curl' ) ) { $this->settings_set['settings']['curl']['value'] = 'No'; $this->settings_set['settings']['curl']['value_html'] = '' . esc_html__( 'No', 'learndash' ) . ''; } else { $this->settings_set['settings']['curl']['value'] = 'Yes
    '; $this->settings_set['settings']['curl']['value_html'] = '' . esc_html__( 'Yes', 'learndash' ) . '
    '; $version = curl_version(); $this->settings_set['settings']['curl']['value'] .= 'Version: ' . $version['version'] . '
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Version', 'learndash' ) . ': ' . $version['version'] . '
    '; $this->settings_set['settings']['curl']['value'] .= 'SSL Version: ' . $version['ssl_version'] . '
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'SSL Version', 'learndash' ) . ': ' . $version['ssl_version'] . '
    '; $this->settings_set['settings']['curl']['value'] .= 'Libz Version: ' . $version['libz_version'] . '
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Libz Version', 'learndash' ) . ': ' . $version['libz_version'] . '
    '; $this->settings_set['settings']['curl']['value'] .= 'Protocols: ' . join( ', ', $version['protocols'] ) . '
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Protocols', 'learndash' ) . ': ' . join( ', ', $version['protocols'] ) . '
    '; if ( isset( $_GET['ld_debug'] ) ) { $paypal_email = get_option( 'learndash_settings_paypal' ); $ca_certificates_path = ini_get( 'curl.cainfo' ); if ( ! $ca_certificates_path ) { if ( isset( $paypal_email['paypal_email'] ) && ! empty( $paypal_email['paypal_email'] ) ) { $this->settings_set['settings']['curl']['value'] .= 'Path to the CA certificates not set. Please add it to curl.cainfo in the php.ini file. Otherwise, PayPal may not work. (X)
    '; $this->settings_set['settings']['curl']['value_html'] .= '' . esc_html__( 'Path to the CA certificates not set. Please add it to curl.cainfo in the php.ini file. Otherwise, PayPal may not work.', 'learndash' ) . '
    '; } if ( isset( $paypal_email['paypal_email'] ) && empty( $paypal_email['paypal_email'] ) ) { $this->settings_set['settings']['curl']['value'] .= 'Path to the CA certificates not set. (X)
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Path to the CA certificates not set.', 'learndash' ) . '
    '; } } else { $this->settings_set['settings']['curl']['value'] .= 'Path to the CA certificates: ' . $ca_certificates_path . '
    '; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Path to the CA certificates', 'learndash' ) . ': ' . $ca_certificates_path . '
    '; } } } } $this->php_extensions = apply_filters( 'learndash_support_php_extensions', $this->php_extensions ); if ( ! empty( $this->php_extensions ) ) { sort( $this->php_extensions ); $this->php_extensions = array_unique( $this->php_extensions ); foreach ( $this->php_extensions as $ini_key ) { $this->settings_set['settings'][ $ini_key ] = array( 'label' => $ini_key, 'value' => extension_loaded( $ini_key ) ? 'Yes' : 'No (X)', 'value_html' => extension_loaded( $ini_key ) ? esc_html__( 'Yes', 'learndash' ) : '' . esc_html__( 'No', 'learndash' ) . '', ); } } $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_Server::add_section_instance(); } ); PK^\ZFsettings-sections/class-ld-settings-section-translations-learndash.phpnuW+Asettings_page_id = 'learndash_lms_translations'; $this->setting_option_key = 'learndash'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_translations_' . $this->project_slug; // Section label/header. $this->settings_section_label = esc_html__( 'LearnDash LMS', 'learndash' ); LearnDash_Translations::register_translation_slug( $this->project_slug, LEARNDASH_LMS_PLUGIN_DIR . 'languages/' ); parent::__construct(); } /** * Custom function to metabox. * * @since 2.4.0 */ public function show_meta_box() { $ld_translations = new LearnDash_Translations( $this->project_slug ); $ld_translations->show_meta_box(); } } add_action( 'init', function() { LearnDash_Settings_Section_Translations_LearnDash::add_section_instance(); }, 1 ); } PK^\Nw.Hsettings-sections/class-ld-settings-section-support-wordpress-themes.phpnuW+Asettings_page_id = 'learndash_support'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'wp_active_theme'; // This is the HTML form field prefix used. //$this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_support_wp_active_theme'; // Section label/header. $this->settings_section_label = esc_html__( 'WordPress Active Theme', 'learndash' ); add_filter( 'learndash_support_sections_init', array( $this, 'learndash_support_sections_init' ) ); add_action( 'learndash_section_fields_before', array( $this, 'show_support_section' ), 30, 2 ); parent::__construct(); } public function learndash_support_sections_init( $support_sections = array() ) { global $wpdb, $wp_version, $wp_rewrite; global $sfwd_lms; $ABSPATH_tmp = str_replace( '\\', '/', ABSPATH ); /************************************************************************************************ * WordPress Active Theme. ************************************************************************************************/ if ( ! isset( $support_sections[ $this->setting_option_key ] ) ) { $this->settings_set = array(); $this->settings_set['header'] = array( 'html' => $this->settings_section_label, 'text' => $this->settings_section_label, ); $this->settings_set['columns'] = array( 'label' => array( 'html' => esc_html__( 'Theme', 'learndash' ), 'text' => 'Theme', 'class' => 'learndash-support-settings-left', ), 'value' => array( 'html' => esc_html__( 'Details', 'learndash' ), 'text' => 'Details', 'class' => 'learndash-support-settings-right', ), ); $this->settings_set['settings'] = array(); $current_theme = wp_get_theme(); if ( $current_theme->exists() ) { $theme_stylesheet = $current_theme->get_stylesheet(); $themes_update = get_site_transient( 'update_themes' ); $theme_value = 'Version: ' . $current_theme->get( 'Version' ); $theme_value_html = esc_html__( 'Version', 'learndash' ) . ': ' . $current_theme->get( 'Version' ); if ( isset( $themes_update->response[ $theme_stylesheet ] ) ) { if ( version_compare( $current_theme->get( 'Version' ), $themes_update->response[ $theme_stylesheet ]['new_version'], '<' ) ) { $theme_value .= ' Update available: ' . $themes_update->response[ $theme_stylesheet ]['new_version'] . ' (X)'; $theme_value_html .= ' ' . esc_html__( 'Update available', 'learndash' ) . ': ' . $themes_update->response[ $theme_stylesheet ]['new_version'] . ''; } } $theme_value .= ' Path: ' . $current_theme->get( 'ThemeURI' ); $theme_value_html .= '
    ' . esc_html__( 'Path', 'learndash' ) . ': ' . $current_theme->get( 'ThemeURI' ); $this->settings_set['settings']['active_theme'] = array( 'label' => $current_theme->get( 'Name' ), 'value' => $theme_value, 'value_html' => $theme_value_html, ); } $support_sections[ $this->setting_option_key ] = apply_filters( 'learndash_support_section', $this->settings_set, $this->setting_option_key ); } return $support_sections; } public function show_support_section( $settings_section_key = '', $settings_screen_id = '' ) { if ( $settings_section_key === $this->settings_section_key ) { $support_page_instance = LearnDash_Settings_Page::get_page_instance( 'LearnDash_Settings_Page_Support' ); if ( $support_page_instance ) { $support_page_instance->show_support_section( $this->setting_option_key ); } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_WordPress_Themes::add_section_instance(); } ); PK^\>?settings-sections/class-ld-settings-section-assignments-cpt.phpnuW+Asettings_screen_id = 'sfwd-assignment_page_assignments-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'assignments-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_assignments_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_assignments_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = esc_html__( 'Assignment Custom Post Type Options', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = esc_html__( 'Control the LearnDash Assignment Custom Post Type Options.', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_INITIALIZE = false; if ( false === $this->setting_option_values ) { $_INITIALIZE = true; $this->setting_option_values = array( 'exclude_from_search' => 'yes', 'publicly_queryable' => 'yes', 'comment_status' => 'yes', ); } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'exclude_from_search' => array( 'name' => 'exclude_from_search', 'type' => 'checkbox', 'label' => esc_html__( 'Exclude From Search', 'learndash' ), 'help_text' => esc_html__( 'Exclude From Search', 'learndash' ), 'value' => isset( $this->setting_option_values['exclude_from_search'] ) ? $this->setting_option_values['exclude_from_search'] : '', 'options' => array( 'yes' => esc_html__( 'Exclude', 'learndash' ), ), ), 'publicly_queryable' => array( 'name' => 'publicly_queryable', 'type' => 'checkbox', 'label' => esc_html__( 'Publicly Viewable', 'learndash' ), 'help_text' => esc_html__( 'Controls access to view single Assignments on the front-end.', 'learndash' ), 'value' => isset( $this->setting_option_values['publicly_queryable'] ) ? $this->setting_option_values['publicly_queryable'] : '', 'options' => array( 'yes' => esc_html__( 'Public', 'learndash' ), ), ), 'comment_status' => array( 'name' => 'comment_status', 'type' => 'checkbox', 'label' => esc_html__( 'Comments enabled', 'learndash' ), 'help_text' => esc_html__( 'Controls if comments are enabled.', 'learndash' ), 'value' => isset( $this->setting_option_values['comment_status'] ) ? $this->setting_option_values['comment_status'] : '', 'options' => array( 'yes' => esc_html__( 'Enabled', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Assignments_CPT::add_section_instance(); } ); PK^\IWsLLBsettings-sections/class-ld-settings-section-lessons-taxonomies.phpnuW+Asettings_screen_id = 'sfwd-lessons_page_lessons-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'lessons-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_lessons_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_lessons_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'taxonomies'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Taxonomies', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: lessons. esc_html_x( 'Control which taxonomies can be used to better organize your LearnDash %s.', 'placeholder: Lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $__init = true; $this->setting_option_values = array( 'ld_lesson_category' => 'yes', 'ld_lesson_tag' => 'yes', 'wp_post_category' => 'yes', 'wp_post_tag' => 'yes', ); // If this is a new install we want to turn off WP Post Category/Tag. $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['wp_post_category'] = ''; $this->setting_option_values['wp_post_tag'] = ''; } } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'ld_lesson_category' => '', 'ld_lesson_tag' => '', 'wp_post_category' => '', 'wp_post_tag' => '', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'ld_lesson_category' => array( 'name' => 'ld_lesson_category', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Categories', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'value' => $this->setting_option_values['ld_lesson_category'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Manage %s Categories via the Actions dropdown', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ), ), 'ld_lesson_tag' => array( 'name' => 'ld_lesson_tag', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Tags', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'value' => $this->setting_option_values['ld_lesson_tag'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Manage %s Tags via the Actions dropdown', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ), ), 'wp_post_category' => array( 'name' => 'wp_post_category', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Categories', 'learndash' ), 'value' => $this->setting_option_values['wp_post_category'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Categories via the Actions dropdown', 'learndash' ), ), ), 'wp_post_tag' => array( 'name' => 'wp_post_tag', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Tags', 'learndash' ), 'value' => $this->setting_option_values['wp_post_tag'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Tags via the Actions dropdown', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Lessons_Taxonomies::add_section_instance(); } ); PK^\੆cc=settings-sections/class-ld-settings-section-data-upgrades.phpnuW+Asettings_page_id = 'learndash_data_upgrades'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_data_upgrades'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_data_upgrades'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_data_upgrades'; // Section label/header. $this->settings_section_label = esc_html__( 'Data Upgrades', 'learndash' ); parent::__construct(); } /** * Show Settings Section meta box. */ public function show_meta_box() { $ld_admin_data_upgrades = Learndash_Admin_Data_Upgrades::get_instance(); $ld_admin_data_upgrades->admin_page(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Data_Upgrades::add_section_instance(); } ); PK^\NCPT T @settings-sections/class-ld-settings-section-side-quick-links.phpnuW+Asettings_screen_id = $args['settings_screen_id']; } if ( ( isset( $args['settings_page_id'] ) ) && ( ! empty( $args['settings_page_id'] ) ) ) { $this->settings_page_id = $args['settings_page_id']; } if ( ( ! empty( $this->settings_screen_id ) ) && ( ! empty( $this->settings_page_id ) ) ) { // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'quick_links_div'; // Section label/header. $this->settings_section_label = esc_html__( 'Quick Links', 'learndash' ); $this->metabox_context = 'side'; $this->metabox_priority = 'high'; parent::__construct(); } } /** * Show custom metabox output for Quick Links. * * @since 2.5.9 */ public function show_meta_box() { global $wp_meta_boxes; ?> settings_screen_id = 'sfwd-quiz_page_quizzes-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'quizzes-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_quizzes_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_quizzes_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Custom Post Type Options', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: Quizzes. esc_html_x( 'Control the LearnDash %s Custom Post Type Options.', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ( false === $this->setting_option_values ) || ( '' === $this->setting_option_values ) ) { if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->setting_option_values = array( 'include_in_search' => '', 'has_archive' => '', 'has_feed' => '', 'supports' => array( 'thumbnail', 'revisions' ), ); } if ( ! isset( $this->setting_option_values['include_in_search'] ) ) { if ( ( isset( $this->setting_option_values['exclude_from_search'] ) ) && ( 'yes' === $this->setting_option_values['exclude_from_search'] ) ) { $this->setting_option_values['include_in_search'] = ''; } else { $this->setting_option_values['include_in_search'] = 'yes'; } } if ( ! isset( $this->setting_option_values['has_archive'] ) ) { $this->setting_option_values['has_archive'] = 'yes'; } if ( ! isset( $this->setting_option_values['has_feed'] ) ) { $this->setting_option_values['has_feed'] = ''; } if ( ! isset( $this->setting_option_values['supports'] ) ) { $this->setting_option_values['supports'] = array( 'thumbnail', 'revisions' ); } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $cpt_archive_url = home_url( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'quizzes' ) ); $cpt_rss_url = add_query_arg( 'post_type', 'sfwd-quiz', get_post_type_archive_feed_link( 'post' ) ); $this->setting_option_fields = array( 'include_in_search' => array( 'name' => 'include_in_search', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Search', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholder: quiz. esc_html_x( 'Includes the %s post type in front end search results', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => $this->setting_option_values['include_in_search'], 'options' => array( 'yes' => '', ), ), 'has_archive' => array( 'name' => 'has_archive', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Archive Page', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: quizzes, link to WP Permalins page. esc_html_x( 'Enables the front end archive page where all %1$s are listed. You must %2$s for the change to take effect.', 'placeholder: qizzes, link to WP Permalins page', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ), '' . esc_html__( 're-save your permalinks', 'learndash' ) . '' ), 'value' => $this->setting_option_values['has_archive'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'Archive URL: %s', 'placeholder: URL for CPT Archive', 'learndash' ), '' . $cpt_archive_url . '' ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['has_archive'] ) ? 'open' : 'closed', ), 'has_feed' => array( 'name' => 'has_feed', 'type' => 'checkbox-switch', 'label' => esc_html__( 'RSS/Atom Feed', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: quiz esc_html_x( 'Enables an RSS feed for all %1$s posts.', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => $this->setting_option_values['has_feed'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'RSS Feed URL: %s', 'placeholder: URL for RSS Feed', 'learndash' ), '' . $cpt_rss_url . '' ), ), 'parent_setting' => 'has_archive', ), 'supports' => array( 'name' => 'supports', 'type' => 'checkbox', 'label' => esc_html__( 'Editor Supported Settings', 'learndash' ), 'help_text' => esc_html__( 'Enables WordPress supported settings within the editor and theme.', 'learndash' ), 'value' => $this->setting_option_values['supports'], 'options' => array( 'thumbnail' => esc_html__( 'Featured image', 'learndash' ), 'comments' => esc_html__( 'Comments', 'learndash' ), 'custom-fields' => esc_html__( 'Custom Fields', 'learndash' ), 'revisions' => esc_html__( 'Revisions', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $new_values = '', $old_values = '', $setting_option_key = '' ) { if ( $setting_option_key === $this->setting_option_key ) { $new_values = parent::section_pre_update_option( $new_values, $old_values, $setting_option_key ); if ( ! isset( $new_values['include_in_search'] ) ) { $new_values['include_in_search'] = ''; } if ( ! isset( $new_values['has_archive'] ) ) { $new_values['has_archive'] = ''; $new_values['has_feed'] = ''; } if ( ! isset( $new_values['has_feed'] ) ) { $new_values['has_feed'] = ''; } if ( ! isset( $new_values['supports'] ) ) { $new_values['supports'] = array(); } if ( $new_values !== $old_values ) { if ( ( ! isset( $old_values['has_archive'] ) ) || ( $new_values['has_archive'] !== $old_values['has_archive'] ) ) { learndash_setup_rewrite_flush(); } //if ( in_array( 'comments', $new_values['supports'] ) ) { // learndash_update_posts_comment_status( 'sfwd-quiz', 'open' ); //} else { // learndash_update_posts_comment_status( 'sfwd-quiz', 'closed' ); //} } } return $new_values; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Quizzes_CPT::add_section_instance(); } ); PK^\K @settings-sections/class-ld-settings-section-general-per-page.phpnuW+Asettings_page_id = 'learndash_lms_settings'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_per_page'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_per_page'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_per_page'; // Section label/header. $this->settings_section_label = esc_html__( 'Global Pagination Settings', 'learndash' ); $this->settings_section_description = esc_html__( 'Specify the default number of items displayed per page for various listing outputs.', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ! isset( $this->setting_option_values['progress_num'] ) ) { $this->setting_option_values['progress_num'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( ! isset( $this->setting_option_values['quiz_num'] ) ) { $this->setting_option_values['quiz_num'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $this->setting_option_values['progress_num'] ) && ( LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE === $this->setting_option_values['quiz_num'] ) ) { $this->setting_option_values['profile_enabled'] = ''; } else { $this->setting_option_values['profile_enabled'] = 'yes'; } if ( ! isset( $this->setting_option_values['per_page'] ) ) { $this->setting_option_values['per_page'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } if ( ! isset( $this->setting_option_values['question_num'] ) ) { $this->setting_option_values['question_num'] = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } } /** * Validate settings field. * * @param string $val Value to be validated. * @param string $key settings fields key. * @param array $args Settings field args array. * * @return integer $val. */ public function validate_section_field_per_page( $val, $key, $args = array() ) { // Get the digits only. if ( ( isset( $args['field']['validate_args']['allow_empty'] ) ) && ( true === $args['field']['validate_args']['allow_empty'] ) ) { $val = preg_replace( '/[^0-9]/', '', $val ); } if ( '' === $val ) { switch ( $key ) { case 'per_page': $val = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; break; case 'progress_num': $val = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; break; case 'quiz_num': $val = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; break; case 'question_num': $val = LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; break; } } // IF profile is NOT enabled we make sure to clear the quiz and progress values. if ( ! isset( $args['post_fields']['profile_enabled'] ) ) { if ( ( 'quiz_num' === $key ) || ( 'progress_num' === $key ) ) { return LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE; } } return intval( $val ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'profile_enabled' => array( 'name' => 'profile_enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Profile', 'learndash' ), 'help_text' => esc_html__( 'Controls the pagination for the WordPress Profile LearnDash elements.', 'learndash' ), 'value' => $this->setting_option_values['profile_enabled'], 'options' => array( 'yes' => '', '' => sprintf( // translators: placeholder: default per page number. esc_html_x( 'Pagination defaults to %d', 'placeholder: default per page number', 'learndash' ), LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['profile_enabled'] ) ? 'open' : 'closed', ), 'progress_num' => array( 'name' => 'progress_num', 'type' => 'number', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Progress', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ), 'value' => $this->setting_option_values['progress_num'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'input_label' => sprintf( // translators: placeholder: courses. esc_html_x( '%s per page', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'validate_callback' => array( $this, 'validate_section_field_per_page' ), 'validate_args' => array( 'allow_empty' => 1, ), 'parent_setting' => 'profile_enabled', ), 'quiz_num' => array( 'name' => 'quiz_num', 'type' => 'number', 'label' => sprintf( // translators: placeholders: Quiz. esc_html_x( '%s Attempts', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ), 'value' => $this->setting_option_values['quiz_num'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'input_label' => sprintf( // translators: placeholder: quizzes. esc_html_x( '%s per page', 'placeholder: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'validate_callback' => array( $this, 'validate_section_field_per_page' ), 'validate_args' => array( 'allow_empty' => 1, ), 'parent_setting' => 'profile_enabled', ), 'per_page' => array( 'name' => 'per_page', 'type' => 'number', 'label' => esc_html__( 'Shortcodes & Widgets', 'learndash' ), 'help_text' => esc_html__( 'Controls the global pagination for the LD shortcodes as well as courseinfo widget. These can be overridden individually.', 'learndash' ), 'value' => $this->setting_option_values['per_page'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'validate_callback' => array( $this, 'validate_section_field_per_page' ), 'validate_args' => array( 'allow_empty' => 1, ), ), 'question_num' => array( 'name' => 'question_num', 'type' => 'number', 'label' => sprintf( // translators: placeholders: Question. esc_html_x( 'Backend %s Widget', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'help_text' => sprintf( // translators: placeholders: Questions, quiz, question. esc_html_x( 'Controls the pagination for the %1$s admin widget when editing a %2$s or %3$s.', 'Questions, quiz, question', 'learndash' ), learndash_get_custom_label( 'questions' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'question' ) ), 'value' => $this->setting_option_values['question_num'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'validate_callback' => array( $this, 'validate_section_field_per_page' ), 'validate_args' => array( 'allow_empty' => 1, ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_General_Per_Page::add_section_instance(); } ); PK^\/**Dsettings-sections/class-ld-settings-section-questions-taxonomies.phpnuW+Asettings_screen_id = 'sfwd-question_page_questions-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'questions-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_questions_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_questions_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'taxonomies'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Taxonomies', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: Quiz, Questions. esc_html_x( 'Control which taxonomies can be used with the LearnDash %1$s %2$s.', 'placeholder: Quiz, Questions', 'learndash' ), learndash_get_custom_label( 'quiz' ), learndash_get_custom_label_lower( 'questions' ) ); parent::__construct(); // Hook to handle the AJAX delete/update actions. add_action( 'wp_ajax_' . $this->setting_field_prefix, array( $this, 'ajax_action' ) ); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $_init = true; $this->setting_option_values = array( 'proquiz_question_category' => 'yes', 'ld_question_category' => 'no', 'ld_question_tag' => 'no', 'wp_post_category' => 'no', 'wp_post_tag' => 'no', ); // If this is a new install we want to turn off WP Post Category/Tag. $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['wp_post_category'] = 'no'; $this->setting_option_values['wp_post_tag'] = 'no'; } } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'proquiz_question_category' => 'yes', 'ld_question_category' => 'no', 'ld_question_tag' => 'no', 'wp_post_category' => 'no', 'wp_post_tag' => 'no', 'question_category' => array( '' => esc_html__( 'Select a category', 'learndash' ), ), ) ); if ( ( is_admin() ) && ( isset( $_GET['page'] ) ) && ( 'questions-options' === $_GET['page'] ) ) { $category_mapper = new WpProQuiz_Model_CategoryMapper(); $question_categories = $category_mapper->fetchAll(); if ( ( ! empty( $question_categories ) ) && ( is_array( $question_categories ) ) ) { foreach ( $question_categories as $question_category ) { $category_name = $question_category->getCategoryName(); $category_id = $question_category->getCategoryId(); if ( ! empty( $category_name ) ) { $this->setting_option_values['question_category'][ $category_id ] = esc_html( $category_name ); } } } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( /* 'ld_question_category' => array( 'name' => 'ld_question_category', 'type' => 'checkbox', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( 'LearnDash %s Categories', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'help_text' => sprintf( // translators: placeholder: Question. esc_html_x( 'Enable the builtin LearnDash %s Categories', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'value' => $this->setting_option_values['ld_question_category'], 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), */ /* 'ld_question_tag' => array( 'name' => 'ld_question_tag', 'type' => 'checkbox', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( 'LearnDash %s Tags', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'help_text' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Enable the builtin LearnDash %s Tags', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'value' => $this->setting_option_values['ld_question_tag'], 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), */ /* 'wp_post_category' => array( 'name' => 'wp_post_category', 'type' => 'checkbox', 'label' => esc_html__( 'WordPress Post Categories', 'learndash' ), 'help_text' => esc_html__( 'Enable the builtin WordPress Post Categories', 'learndash' ), 'value' => $this->setting_option_values['wp_post_category'], 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), */ /* 'wp_post_tag' => array( 'name' => 'wp_post_tag', 'type' => 'checkbox', 'label' => esc_html__( 'WordPress Post Tags', 'learndash' ), 'help_text' => esc_html__( 'Enable the builtin WordPress Post Tags', 'learndash' ), 'value' => $this->setting_option_values['wp_post_tag'], 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), */ 'proquiz_question_category' => array( 'name' => 'proquiz_question_category', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Categories', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ), 'value' => $this->setting_option_values['proquiz_question_category'], 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), 'options' => array( 'yes' => array( 'tooltip' => sprintf( // translators: placeholder: Question. esc_html_x( '%s categories cannot be disabled.', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['proquiz_question_category'] ) ? 'open' : 'closed', 'attrs' => array( 'disabled' => 'disabled', ), ), '_question_category' => array( 'name' => 'question_category', 'type' => 'select-edit-delete', 'label' => esc_html__( 'Category management', 'learndash' ), 'help_text' => esc_html__( 'Select a category to update or delete the title.', 'learndash' ), 'value' => '', 'options' => $this->setting_option_values['question_category'], 'buttons' => array( 'delete' => esc_html__( 'Delete', 'learndash' ), 'update' => esc_html__( 'Update', 'learndash' ), ), 'parent_setting' => 'proquiz_question_category', ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * This function handles the AJAX actions from the browser. * * @since 2.5.9 */ public function ajax_action() { $reply_data = array( 'status' => false ); if ( current_user_can( 'wpProQuiz_edit_quiz' ) ) { if ( ( isset( $_POST['field_nonce'] ) ) && ( ! empty( $_POST['field_nonce'] ) ) && ( isset( $_POST['field_key'] ) ) && ( ! empty( $_POST['field_key'] ) ) && ( wp_verify_nonce( esc_attr( $_POST['field_nonce'] ), $_POST['field_key'] ) ) ) { if ( isset( $_POST['field_action'] ) ) { if ( 'update' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) && ( isset( $_POST['field_text'] ) ) && ( ! empty( $_POST['field_text'] ) ) ) { $category_id = intval( $_POST['field_value'] ); $category_new_name = esc_attr( $_POST['field_text'] ); $category_mapper = new WpProQuiz_Model_CategoryMapper(); $category = $category_mapper->fetchById( $category_id ); if ( ( $category ) && ( is_a( $category, 'WpProQuiz_Model_Category' ) ) ) { $category_current_name = $category->getCategoryName(); if ( $category_current_name !== $category_new_name ) { $update_ret = $category_mapper->updateCatgoryName( $category_id, $category_new_name ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Category updated.', 'learndash' ) . ''; } } } } } elseif ( 'delete' === $_POST['field_action'] ) { if ( ( isset( $_POST['field_value'] ) ) && ( ! empty( $_POST['field_value'] ) ) ) { $category_id = intval( $_POST['field_value'] ); $category_mapper = new WpProQuiz_Model_CategoryMapper(); $category = $category_mapper->fetchById( $category_id ); if ( ( $category ) && ( is_a( $category, 'WpProQuiz_Model_Category' ) ) ) { $update_ret = $category_mapper->delete( $category_id ); if ( $update_ret ) { $reply_data['status'] = true; $reply_data['message'] = '' . __( 'Category deleted.', 'learndash' ) . ''; } } } } } } } if ( ! empty( $reply_data ) ) { echo wp_json_encode( $reply_data ); } wp_die(); // This is required to terminate immediately and return a proper response. } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Questions_Taxonomies::add_section_instance(); } ); PK^\QjBsettings-sections/class-ld-settings-section-quizzes-taxonomies.phpnuW+Asettings_screen_id = 'sfwd-quiz_page_quizzes-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'quizzes-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_quizzes_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_quizzes_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'taxonomies'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Taxonomies', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: quizzes. esc_html_x( 'Control which Taxonomies can be used with the LearnDash %s.', 'placeholder: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $_init = true; $this->setting_option_values = array( 'ld_quiz_category' => '', 'ld_quiz_tag' => '', 'wp_post_category' => '', 'wp_post_tag' => '', ); // If this is a new install we want to turn off WP Post Category/Tag. $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['ld_quiz_category'] = ''; $this->setting_option_values['ld_quiz_tag'] = ''; $this->setting_option_values['wp_post_category'] = ''; $this->setting_option_values['wp_post_tag'] = ''; } } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'ld_quiz_category' => '', 'ld_quiz_tag' => '', 'wp_post_category' => '', 'wp_post_tag' => '', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'ld_quiz_category' => array( 'name' => 'ld_quiz_category', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Categories', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['ld_quiz_category'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Manage %s Categories via the Actions dropdown', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ), ), 'ld_quiz_tag' => array( 'name' => 'ld_quiz_tag', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Tags', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['ld_quiz_tag'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Manage %s Tags via the Actions dropdown', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ), ), 'wp_post_category' => array( 'name' => 'wp_post_category', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Categories', 'learndash' ), 'value' => $this->setting_option_values['wp_post_category'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Categories via the Actions dropdown', 'learndash' ), ), ), 'wp_post_tag' => array( 'name' => 'wp_post_tag', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Tags', 'learndash' ), 'value' => $this->setting_option_values['wp_post_tag'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Tags via the Actions dropdown', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Quizzes_Taxonomies::add_section_instance(); } ); PK^\QZ Z =settings-sections/class-ld-settings-section-questions-cpt.phpnuW+Asettings_screen_id = 'sfwd-question_page_questions-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'questions-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_questions_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_questions_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Custom Post Type Options', 'placeholder: Question', 'learndash' ), LearnDash_Custom_Label::get_label( 'question' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( wp_kses_post( // translators: placeholder: Quizzes. _x( '

    Control the LearnDash %s Custom Post Type Options.

    ', 'placeholder: Questions', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'questions' ) ); parent::__construct(); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'exclude_from_search' => array( 'name' => 'exclude_from_search', 'type' => 'checkbox', 'label' => esc_html__( 'Exclude From Search', 'learndash' ), 'help_text' => esc_html__( 'Exclude From Search', 'learndash' ), 'value' => isset( $this->setting_option_values['exclude_from_search'] ) ? $this->setting_option_values['exclude_from_search'] : '', 'options' => array( 'yes' => esc_html__( 'Exclude', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Questions_CPT::add_section_instance(); } ); PK^\,;!!:settings-sections/class-ld-settings-section-topics-cpt.phpnuW+Asettings_screen_id = 'sfwd-topic_page_topics-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'topics-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_topics_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_topics_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Custom Post Type Options', 'placeholder: Lesson', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: Topics. esc_html_x( 'Control the LearnDash %s Custom Post Type Options.', 'placeholder: Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ( false === $this->setting_option_values ) || ( '' === $this->setting_option_values ) ) { if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->setting_option_values = array( 'include_in_search' => 'yes', 'has_archive' => '', 'has_feed' => '', 'supports' => array( 'thumbnail', 'revisions' ), ); } if ( ! isset( $this->setting_option_values['include_in_search'] ) ) { if ( ( isset( $this->setting_option_values['exclude_from_search'] ) ) && ( 'yes' === $this->setting_option_values['exclude_from_search'] ) ) { $this->setting_option_values['include_in_search'] = ''; } else { $this->setting_option_values['include_in_search'] = 'yes'; } } if ( ! isset( $this->setting_option_values['has_archive'] ) ) { $this->setting_option_values['has_archive'] = 'yes'; } if ( ! isset( $this->setting_option_values['has_feed'] ) ) { $this->setting_option_values['has_feed'] = ''; } if ( ! isset( $this->setting_option_values['supports'] ) ) { $this->setting_option_values['supports'] = array( 'thumbnail', 'revisions' ); } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $cpt_archive_url = home_url( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'topics' ) ); $cpt_rss_url = add_query_arg( 'post_type', 'sfwd-topic', get_post_type_archive_feed_link( 'post' ) ); $this->setting_option_fields = array( 'include_in_search' => array( 'name' => 'include_in_search', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Search', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), 'help_text' => sprintf( // translators: placeholder: topic. esc_html_x( 'Includes the %s post type in front end search results', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => $this->setting_option_values['include_in_search'], 'options' => array( 'yes' => '', ), ), 'has_archive' => array( 'name' => 'has_archive', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Archive Page', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: topics, link to WP Permalins page. esc_html_x( 'Enables the front end archive page where all %1$s are listed. You must %2$s for the change to take effect.', 'placeholder: topics, link to WP Permalins page', 'learndash' ), learndash_get_custom_label_lower( 'topics' ), '' . esc_html__( 're-save your permalinks', 'learndash' ) . '' ), 'value' => $this->setting_option_values['has_archive'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'Archive URL: %s', 'placeholder: URL for CPT Archive', 'learndash' ), '' . $cpt_archive_url . '' ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['has_archive'] ) ? 'open' : 'closed', ), 'has_feed' => array( 'name' => 'has_feed', 'type' => 'checkbox-switch', 'label' => esc_html__( 'RSS/Atom Feed', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: topic esc_html_x( 'Enables an RSS feed for all %1$s posts.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => $this->setting_option_values['has_feed'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'RSS Feed URL: %s', 'placeholder: URL for RSS Feed', 'learndash' ), '' . $cpt_rss_url . '' ), ), 'parent_setting' => 'has_archive', ), 'supports' => array( 'name' => 'supports', 'type' => 'checkbox', 'label' => esc_html__( 'Editor Supported Settings', 'learndash' ), 'help_text' => esc_html__( 'Enables WordPress supported settings within the editor and theme.', 'learndash' ), 'value' => $this->setting_option_values['supports'], 'options' => array( 'thumbnail' => esc_html__( 'Featured image', 'learndash' ), 'comments' => esc_html__( 'Comments', 'learndash' ), 'custom-fields' => esc_html__( 'Custom Fields', 'learndash' ), 'revisions' => esc_html__( 'Revisions', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $new_values = '', $old_values = '', $setting_option_key = '' ) { if ( $setting_option_key === $this->setting_option_key ) { $new_values = parent::section_pre_update_option( $new_values, $old_values, $setting_option_key ); if ( ! isset( $new_values['include_in_search'] ) ) { $new_values['include_in_search'] = ''; } if ( ! isset( $new_values['has_archive'] ) ) { $new_values['has_archive'] = ''; $new_values['has_feed'] = ''; } if ( ! isset( $new_values['has_feed'] ) ) { $new_values['has_feed'] = ''; } if ( ! isset( $new_values['supports'] ) ) { $new_values['supports'] = array(); } if ( $new_values !== $old_values ) { if ( ( ! isset( $old_values['has_archive'] ) ) || ( $new_values['has_archive'] !== $old_values['has_archive'] ) ) { learndash_setup_rewrite_flush(); } //if ( in_array( 'comments', $new_values['supports'] ) ) { // learndash_update_posts_comment_status( 'sfwd-topic', 'open' ); //} else { // learndash_update_posts_comment_status( 'sfwd-topic', 'closed' ); //} } } return $new_values; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Topics_CPT::add_section_instance(); } ); PK^\1d =settings-sections/class-ld-settings-section-custom-labels.phpnuW+Asettings_page_id = 'learndash_lms_settings_custom_labels'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_custom_labels'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_custom_labels'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_custom_labels'; // Section label/header. $this->settings_section_label = esc_html__( 'Custom Labels', 'learndash' ); $this->reset_confirm_message = esc_html__( 'Are you sure want to reset the custom labels?', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( false === $this->setting_option_values ) { $this->setting_option_values = get_option( 'learndash_custom_label_settings' ); } if ( ( isset( $_GET['action'] ) ) && ( 'ld_reset_settings' === $_GET['action'] ) && ( isset( $_GET['page'] ) ) && ( $_GET['page'] === $this->settings_page_id ) ) { if ( ( isset( $_GET['ld_wpnonce'] ) ) && ( ! empty( $_GET['ld_wpnonce'] ) ) ) { if ( wp_verify_nonce( $_GET['ld_wpnonce'], get_current_user_id() . '-' . $this->setting_option_key ) ) { if ( ! empty( $this->setting_option_values ) ) { foreach ( $this->setting_option_values as $key => $val ) { $this->setting_option_values[ $key ] = ''; } $this->save_settings_values(); } $reload_url = remove_query_arg( array( 'action', 'ld_wpnonce' ) ); wp_safe_redirect( $reload_url ); die(); } } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'course' => array( 'name' => 'course', 'type' => 'text', 'label' => esc_html__( 'Course', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "course" (singular).', 'learndash' ), 'value' => isset( $this->setting_option_values['course'] ) ? $this->setting_option_values['course'] : '', 'class' => 'regular-text', ), 'courses' => array( 'name' => 'courses', 'type' => 'text', 'label' => esc_html__( 'Courses', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "courses" (plural).', 'learndash' ), 'value' => isset( $this->setting_option_values['courses'] ) ? $this->setting_option_values['courses'] : '', 'class' => 'regular-text', ), 'lesson' => array( 'name' => 'lesson', 'type' => 'text', 'label' => esc_html__( 'Lesson', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "lesson" (singular).', 'learndash' ), 'value' => isset( $this->setting_option_values['lesson'] ) ? $this->setting_option_values['lesson'] : '', 'class' => 'regular-text', ), 'lessons' => array( 'name' => 'lessons', 'type' => 'text', 'label' => esc_html__( 'Lessons', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "lessons" (plural).', 'learndash' ), 'value' => isset( $this->setting_option_values['lessons'] ) ? $this->setting_option_values['lessons'] : '', 'class' => 'regular-text', ), 'topic' => array( 'name' => 'topic', 'type' => 'text', 'label' => esc_html__( 'Topic', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "topic" (singular).', 'learndash' ), 'value' => isset( $this->setting_option_values['topic'] ) ? $this->setting_option_values['topic'] : '', 'class' => 'regular-text', ), 'topics' => array( 'name' => 'topics', 'type' => 'text', 'label' => esc_html__( 'Topics', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "topics" (plural).', 'learndash' ), 'value' => isset( $this->setting_option_values['topics'] ) ? $this->setting_option_values['topics'] : '', 'class' => 'regular-text', ), 'quiz' => array( 'name' => 'quiz', 'type' => 'text', 'label' => esc_html__( 'Quiz', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "quiz" (singular).', 'learndash' ), 'value' => isset( $this->setting_option_values['quiz'] ) ? $this->setting_option_values['quiz'] : '', 'class' => 'regular-text', ), 'quizzes' => array( 'name' => 'quizzes', 'type' => 'text', 'label' => esc_html__( 'Quizzes', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "quizzes" (plural).', 'learndash' ), 'value' => isset( $this->setting_option_values['quizzes'] ) ? $this->setting_option_values['quizzes'] : '', 'class' => 'regular-text', ), 'question' => array( 'name' => 'question', 'type' => 'text', 'label' => esc_html__( 'Question', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "question" (singular).', 'learndash' ), 'value' => isset( $this->setting_option_values['question'] ) ? $this->setting_option_values['question'] : '', 'class' => 'regular-text', ), 'questions' => array( 'name' => 'questions', 'type' => 'text', 'label' => esc_html__( 'Questions', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "questions" (plural).', 'learndash' ), 'value' => isset( $this->setting_option_values['questions'] ) ? $this->setting_option_values['questions'] : '', 'class' => 'regular-text', ), 'button_take_this_course' => array( 'name' => 'button_take_this_course', 'type' => 'text', 'label' => esc_html__( 'Take this Course (Button)', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "Take this Course" button.', 'learndash' ), 'value' => isset( $this->setting_option_values['button_take_this_course'] ) ? $this->setting_option_values['button_take_this_course'] : '', 'class' => 'regular-text', ), 'button_mark_complete' => array( 'name' => 'button_mark_complete', 'type' => 'text', 'label' => esc_html__( 'Mark Complete (Button)', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "Mark Complete" button.', 'learndash' ), 'value' => isset( $this->setting_option_values['button_mark_complete'] ) ? $this->setting_option_values['button_mark_complete'] : '', 'class' => 'regular-text', ), 'button_click_here_to_continue' => array( 'name' => 'button_click_here_to_continue', 'type' => 'text', 'label' => esc_html__( 'Click Here to Continue (Button)', 'learndash' ), 'help_text' => esc_html__( 'Label to replace "Click Here to Continue" button.', 'learndash' ), 'value' => isset( $this->setting_option_values['button_click_here_to_continue'] ) ? $this->setting_option_values['button_click_here_to_continue'] : '', 'class' => 'regular-text', ), ); // Legacy custom labels filter. $this->setting_option_fields = apply_filters( 'learndash_custom_label_fields', $this->setting_option_fields ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Custom_Labels::add_section_instance(); } ); PK^\dJsettings-sections/class-ld-settings-section-general-login-registration.phpnuW+Asettings_page_id = 'learndash_lms_settings'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_login_registration'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_login_registration'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_login_registration'; // Section label/header. $this->settings_section_label = esc_html__( 'Login / Registration Settings', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ! isset( $this->setting_option_values['login_logo'] ) ) { $this->setting_option_values['login_logo'] = 0; } if ( ! isset( $this->setting_option_values['login_logo2'] ) ) { $this->setting_option_values['login_logo2'] = 0; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'login_logo' => array( 'name' => 'login_logo', 'type' => 'media-upload', 'label' => esc_html__( 'Login Logo', 'learndash' ), /* 'help_text' => sprintf( // translators: placeholder: Default per page number. esc_html_x( 'Default per page controls all shortcodes and widget. Default is %d. Set to zero for no pagination.', 'placeholder: Default per page', 'learndash' ), LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE ), */ 'value' => $this->setting_option_values['login_logo'], 'validate_callback' => array( $this, 'validate_section_field_media_upload' ), 'validate_args' => array( 'allow_empty' => 1, ), ), 'login_logo2' => array( 'name' => 'login_logo2', 'type' => 'media-upload', 'label' => esc_html__( 'Login Logo 2', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: Default per page number. esc_html_x( 'Default per page controls all shortcodes and widget. Default is %d. Set to zero for no pagination.', 'placeholder: Default per page', 'learndash' ), LEARNDASH_LMS_DEFAULT_WIDGET_PER_PAGE ), 'value' => $this->setting_option_values['login_logo2'], 'validate_callback' => array( $this, 'validate_section_field_media_upload' ), 'validate_args' => array( 'allow_empty' => 1, ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Validate settings field. * * @param string $val Value to be validated. * @param string $key settings fields key. * @param array $args Settings field args array. * * @return integer $val. */ public function validate_section_field_media_upload( $val, $key, $args = array() ) { // Get the digits only. $val = absint( $val ); if ( ( isset( $args['field']['validate_args']['allow_empty'] ) ) && ( true === $args['field']['validate_args']['allow_empty'] ) && ( empty( $val ) ) ) { $val = ''; } return $val; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_General_Login_Registration::add_section_instance(); } ); PK^\"1==Asettings-sections/class-ld-settings-section-topics-taxonomies.phpnuW+Asettings_screen_id = 'sfwd-topic_page_topics-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'topics-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_topics_taxonomies'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_topics_taxonomies'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'taxonomies'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Topic. esc_html_x( '%s Taxonomies', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: topics. esc_html_x( 'Control which Taxonomies can be used with the LearnDash %s.', 'placeholder: topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $_init = false; if ( false === $this->setting_option_values ) { $__init = true; $this->setting_option_values = array( 'ld_topic_category' => 'yes', 'ld_topic_tag' => 'yes', 'wp_post_category' => '', 'wp_post_tag' => '', ); // If this is a new install we want to turn off WP Post Category/Tag. $ld_prior_version = learndash_data_upgrades_setting( 'prior_version' ); if ( 'new' === $ld_prior_version ) { $this->setting_option_values['wp_post_category'] = ''; $this->setting_option_values['wp_post_tag'] = ''; } } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'ld_topic_category' => '', 'ld_topic_tag' => '', 'wp_post_category' => '', 'wp_post_tag' => '', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'ld_topic_category' => array( 'name' => 'ld_topic_category', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Categories', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => $this->setting_option_values['ld_topic_category'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Topic. esc_html_x( 'Manage %s Categories via the Actions dropdown', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), ), ), 'ld_topic_tag' => array( 'name' => 'ld_topic_tag', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Tags', 'placeholder: Topic', 'learndash' ), LearnDash_Custom_Label::get_label( 'topic' ) ), 'value' => $this->setting_option_values['ld_topic_tag'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: Topic. esc_html_x( 'Manage %s Tags via the Actions dropdown', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), ), ), 'wp_post_category' => array( 'name' => 'wp_post_category', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Categories', 'learndash' ), 'value' => $this->setting_option_values['wp_post_category'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Categories via the Actions dropdown', 'learndash' ), ), ), 'wp_post_tag' => array( 'name' => 'wp_post_tag', 'type' => 'checkbox-switch', 'label' => esc_html__( 'WP Post Tags', 'learndash' ), 'value' => $this->setting_option_values['wp_post_tag'], 'options' => array( '' => '', 'yes' => esc_html__( 'Manage WP Tags via the Actions dropdown', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Topics_Taxonomies::add_section_instance(); } ); PK^\w7''6settings-sections/class-ld-settings-section-paypal.phpnuW+Asettings_page_id = 'learndash_lms_settings_paypal'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_paypal'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_paypal'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'settings_paypal'; // Section label/header. $this->settings_section_label = esc_html__( 'PayPal Settings', 'learndash' ); $this->reset_confirm_message = esc_html__( 'Are you sure want to reset the PayPal values?', 'learndash' ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( false === $this->setting_option_values ) { $sfwd_cpt_options = get_option( 'sfwd_cpt_options' ); if ( ( isset( $sfwd_cpt_options['modules']['sfwd-courses_options'] ) ) && ( ! empty( $sfwd_cpt_options['modules']['sfwd-courses_options'] ) ) ) { foreach ( $sfwd_cpt_options['modules']['sfwd-courses_options'] as $key => $val ) { $key = str_replace( 'sfwd-courses_', '', $key ); if ( 'paypal_sandbox' === $key ) { if ( 'on' === $val ) { $val = 'yes'; } else { $val = 'no'; } } $this->setting_option_values[ $key ] = $val; } } } if ( ( isset( $_GET['action'] ) ) && ( 'ld_reset_settings' === $_GET['action'] ) && ( isset( $_GET['page'] ) ) && ( $_GET['page'] == $this->settings_page_id ) ) { if ( ( isset( $_GET['ld_wpnonce'] ) ) && ( ! empty( $_GET['ld_wpnonce'] ) ) ) { if ( wp_verify_nonce( $_GET['ld_wpnonce'], get_current_user_id() . '-' . $this->setting_option_key ) ) { if ( ! empty( $this->setting_option_values ) ) { foreach ( $this->setting_option_values as $key => $val ) { $this->setting_option_values[ $key ] = ''; } $this->save_settings_values(); } $reload_url = remove_query_arg( array( 'action', 'ld_wpnonce' ) ); wp_redirect( $reload_url ); die(); } } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $wp_rewrite; if ( ( isset( $wp_rewrite ) ) && ( $wp_rewrite->using_permalinks() ) ) { $default_paypal_notifyurl = trailingslashit( get_home_url() ) . 'sfwd-lms/paypal'; } else { $default_paypal_notifyurl = add_query_arg( 'sfwd-lms', 'paypal', get_home_url() ); } $this->setting_option_fields = array( 'paypal_email' => array( 'name' => 'paypal_email', 'type' => 'text', 'label' => esc_html__( 'PayPal Email', 'learndash' ), 'help_text' => esc_html__( 'Enter your PayPal email here.', 'learndash' ), 'value' => ( ( isset( $this->setting_option_values['paypal_email'] ) ) && ( ! empty( $this->setting_option_values['paypal_email'] ) ) ) ? $this->setting_option_values['paypal_email'] : '', 'class' => 'regular-text', 'validate_callback' => array( $this, 'validate_section_paypal_email' ), ), 'paypal_currency' => array( 'name' => 'paypal_currency', 'type' => 'text', 'label' => esc_html__( 'PayPal Currency', 'learndash' ), 'help_text' => sprintf( // translators: placholder: Link to PayPal. esc_html_x( 'Enter the currency code for transactions. See PayPal %s Documentation', 'placeholder: URL to PayPal Currency Codes', 'learndash' ), '' . __( 'Currency Codes', 'learndash' ) . '' ), 'value' => ( ( isset( $this->setting_option_values['paypal_currency'] ) ) && ( ! empty( $this->setting_option_values['paypal_currency'] ) ) ) ? $this->setting_option_values['paypal_currency'] : 'USD', 'class' => 'regular-text', 'validate_callback' => array( $this, 'validate_section_paypal_currency' ), ), 'paypal_country' => array( 'name' => 'paypal_country', 'type' => 'text', 'label' => esc_html__( 'PayPal Country', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: Link to PayPal Country Codes. esc_html_x( 'Enter your country code here. See PayPal %s Documentation', 'placeholder: URL to PayPal Country Codes.', 'learndash' ), '' . __( 'Country Codes', 'learndash' ) . '' ), 'value' => ( ( isset( $this->setting_option_values['paypal_country'] ) ) && ( ! empty( $this->setting_option_values['paypal_country'] ) ) ) ? $this->setting_option_values['paypal_country'] : 'US', 'class' => 'regular-text', 'validate_callback' => array( $this, 'validate_section_paypal_country' ), ), 'paypal_cancelurl' => array( 'name' => 'paypal_cancelurl', 'type' => 'text', 'label' => esc_html__( 'PayPal Cancel URL', 'learndash' ), 'help_text' => esc_html__( 'Enter the URL used for purchase cancellations.', 'learndash' ), 'value' => ( ( isset( $this->setting_option_values['paypal_cancelurl'] ) ) && ( ! empty( $this->setting_option_values['paypal_cancelurl'] ) ) ) ? $this->setting_option_values['paypal_cancelurl'] : get_home_url(), 'class' => 'regular-text', ), 'paypal_returnurl' => array( 'name' => 'paypal_returnurl', 'type' => 'text', 'label' => esc_html__( 'PayPal Return ', 'learndash' ), 'help_text' => esc_html__( 'Enter the URL used for completed purchases (typically a thank you page).', 'learndash' ), 'value' => ( ( isset( $this->setting_option_values['paypal_returnurl'] ) ) && ( ! empty( $this->setting_option_values['paypal_returnurl'] ) ) ) ? $this->setting_option_values['paypal_returnurl'] : get_home_url(), 'class' => 'regular-text', ), 'paypal_notifyurl' => array( 'name' => 'paypal_notifyurl', 'type' => 'text', 'label' => esc_html__( 'PayPal Notify URL', 'learndash' ), 'help_text' => esc_html__( 'Enter the URL used for IPN notifications.', 'learndash' ), 'value' => ( ( isset( $this->setting_option_values['paypal_notifyurl'] ) ) && ( ! empty( $this->setting_option_values['paypal_notifyurl'] ) ) ) ? $this->setting_option_values['paypal_notifyurl'] : $default_paypal_notifyurl, 'class' => 'regular-text', ), 'paypal_sandbox' => array( 'name' => 'paypal_sandbox', 'type' => 'checkbox', 'label' => esc_html__( 'Use PayPal Sandbox', 'learndash' ), 'help_text' => esc_html__( 'Check to enable the PayPal sandbox.', 'learndash' ), 'value' => isset( $this->setting_option_values['paypal_sandbox'] ) ? $this->setting_option_values['paypal_sandbox'] : 'no', 'options' => array( 'yes' => esc_html__( 'Yes', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Validate PayPal Email. * * @param string $val to be validated. * @param string $key Settings key. * @param array $args Settings field args. * * @return string $val. */ public static function validate_section_paypal_email( $val, $key, $args = array() ) { $val = trim( $val ); if ( ( ! empty( $val ) ) && ( ! is_email( $val ) ) ) { add_settings_error( $args['setting_option_key'], $key, esc_html__( 'PayPal Email must be a valid email.', 'learndash' ), 'error' ); } return $val; } /** * Validate Settings Country field. * * @param string $val to be validated. * @param string $key Settings key. * @param array $args Settings field args. * * @return string $val. */ public static function validate_section_paypal_country( $val, $key, $args = array() ) { if ( ( isset( $args['post_fields']['paypal_email'] ) ) && ( ! empty( $args['post_fields']['paypal_email'] ) ) ) { $val = sanitize_text_field( $val ); if ( empty( $val ) ) { add_settings_error( $args['setting_option_key'], $key, esc_html__( 'PayPal Country Code cannot be empty.', 'learndash' ), 'error' ); } elseif ( strlen( $val ) > 2 ) { add_settings_error( $args['setting_option_key'], $key, esc_html__( 'PayPal Country Code should not be longer than 2 letters.', 'learndash' ), 'error' ); } } return $val; } /** * Validate Settings Currency field. * * @param string $val to be validated. * @param string $key Settings key. * @param array $args Settings field args. * * @return string $val. */ public static function validate_section_paypal_currency( $val, $key, $args = array() ) { if ( ( isset( $args['post_fields']['paypal_email'] ) ) && ( ! empty( $args['post_fields']['paypal_email'] ) ) ) { $val = sanitize_text_field( $val ); if ( empty( $val ) ) { add_settings_error( $args['setting_option_key'], $key, esc_html__( 'PayPal Currency Code cannot be empty.', 'learndash' ), 'error' ); } elseif ( strlen( $val ) > 3 ) { add_settings_error( $args['setting_option_key'], $key, esc_html__( 'PayPal Currency Code should not be longer than 3 letters.', 'learndash' ), 'error' ); } } return $val; } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_PayPal::add_section_instance(); } ); PK^\g,,:settings-sections/class-ld-settings-section-permalinks.phpnuW+A Permalinks page.. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Permalinks' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Permalinks extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_page_id = 'permalink'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_permalinks'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_permalinks'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'learndash_settings_permalinks'; // Section label/header. $this->settings_section_label = __( 'LearnDash Permalinks', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = __( 'Controls the URL slugs for the custom posts used by LearnDash.', 'learndash' ); add_action( 'admin_init', array( $this, 'admin_init' ) ); parent::__construct(); $this->save_settings_fields(); } /** * Hook into the admin init action to fire up the LD settings page init processing. * Remember the Permalinks page is not a LD page. */ public function admin_init() { do_action( 'learndash_settings_page_init', $this->settings_page_id ); } /** * Function to handle metabox init. * * @param string $settings_screen_id Screen ID of current page. */ public function add_meta_boxes( $settings_screen_id = '' ) { global $wp_rewrite; if ( $wp_rewrite->using_permalinks() ) { add_meta_box( $this->metabox_key, $this->settings_section_label, array( $this, 'show_meta_box' ), $this->settings_screen_id, $this->metabox_context, $this->metabox_priority ); } } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( false === $this->setting_option_values ) { $this->setting_option_values = array(); // On the initial if we don't have saved values we grab them from the Custom Labels. $custom_label_settings = get_option( 'learndash_custom_label_settings', array() ); if ( ( isset( $custom_label_settings['courses'] ) ) && ( ! empty( $custom_label_settings['courses'] ) ) ) { $this->setting_option_values['courses'] = learndash_get_custom_label_slug( 'courses' ); } if ( ( isset( $custom_label_settings['lessons'] ) ) && ( ! empty( $custom_label_settings['lessons'] ) ) ) { $this->setting_option_values['lessons'] = learndash_get_custom_label_slug( 'lessons' ); } if ( ( isset( $custom_label_settings['topic'] ) ) && ( ! empty( $custom_label_settings['topic'] ) ) ) { $this->setting_option_values['topics'] = learndash_get_custom_label_slug( 'topic' ); } if ( ( isset( $custom_label_settings['quizzes'] ) ) && ( ! empty( $custom_label_settings['quizzes'] ) ) ) { $this->setting_option_values['quizzes'] = learndash_get_custom_label_slug( 'quizzes' ); } // As we don't have existing values we want to save here and force the flush rewrite. update_option( $this->settings_section_key, $this->setting_option_values ); learndash_setup_rewrite_flush(); } $this->setting_option_values = wp_parse_args( $this->setting_option_values, array( 'courses' => 'courses', 'lessons' => 'lessons', 'topics' => 'topic', 'quizzes' => 'quizzes', ) ); } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $wp_rewrite; if ( $wp_rewrite->using_permalinks() ) { $this->setting_option_fields = array( 'courses' => array( 'name' => 'courses', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Courses. esc_html_x( '%s', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ), 'value' => $this->setting_option_values['courses'], 'class' => 'regular-text', ), 'lessons' => array( 'name' => 'lessons', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Lessons. esc_html_x( '%s', 'placeholder: Lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ), 'value' => $this->setting_option_values['lessons'], 'class' => 'regular-text', ), 'topics' => array( 'name' => 'topics', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Topics. esc_html_x( '%s', 'placeholder: Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ), 'value' => $this->setting_option_values['topics'], 'class' => 'regular-text', ), 'quizzes' => array( 'name' => 'quizzes', 'type' => 'text', 'label' => sprintf( // translators: placeholder: Quizzes. esc_html_x( '%s', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ), 'value' => $this->setting_option_values['quizzes'], 'class' => 'regular-text', ) ); } if ( $wp_rewrite->using_permalinks() ) { $example_regular_topic_url = get_option( 'home' ) . '/' . $this->setting_option_values['topics'] . '/topic-slug'; $example_nested_topic_url = get_option( 'home' ) . '/' . $this->setting_option_values['courses'] . '/course-slug/' . $this->setting_option_values['lessons'] . '/lesson-slug/' . $this->setting_option_values['topics'] . '/topic-slug'; } else { $example_regular_topic_url = add_query_arg( learndash_get_post_type_slug( 'topic' ), 'topic-slug', get_option( 'home' ) ); $example_nested_topic_url = get_option( 'home' ); $example_nested_topic_url = add_query_arg( learndash_get_post_type_slug( 'course'), 'course-slug', $example_nested_topic_url ); $example_nested_topic_url = add_query_arg( learndash_get_post_type_slug( 'lesson' ), 'lesson-slug', $example_nested_topic_url ); $example_nested_topic_url = add_query_arg( learndash_get_post_type_slug( 'topic' ), 'topic-slug', $example_nested_topic_url ); } $this->setting_option_fields['nested_urls'] = array( 'name' => 'nested_urls', 'type' => 'checkbox', 'label' => __( 'Enable Nested URLs', 'learndash' ), 'desc' => sprintf( // translators: placeholders: Lesson, Topic, Quiz, Course, Site Home URL, URL to Course Builder Settings. _x( 'This option will restructure %1$s, %2$s and %3$s URLs so they are nested hierarchically within the %4$s URL.
    For example instead of the default topic URL %5$s the nested URL would be %6$s. If Course Builder Share Steps has been enabled this setting is also automatically enabled.', 'placeholders: Lesson, Topic, Quiz, Course, Site Home URL, URL to Course Builder Settings', 'learndash' ), LearnDash_Custom_Label::get_label( 'lesson' ), LearnDash_Custom_Label::get_label( 'topic' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'course' ), $example_regular_topic_url, $example_nested_topic_url, admin_url( 'admin.php?page=courses-options' ) ), 'value' => isset( $this->setting_option_values['nested_urls'] ) ? $this->setting_option_values['nested_urls'] : '', 'options' => array( 'yes' => __( 'Yes', 'learndash' ), ), ); $this->setting_option_fields['nonce'] = array( 'name' => 'nonce', 'type' => 'hidden', 'label' => '', 'value' => wp_create_nonce( 'learndash_permalinks_nonce' ), 'class' => 'hidden', ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Save the metabox fields. This is needed due to special processing needs. */ public function save_settings_fields() { if ( isset( $_POST[ $this->setting_field_prefix ] ) ) { if ( ( isset( $_POST[ $this->setting_field_prefix ]['nonce'] ) ) && ( wp_verify_nonce( $_POST[ $this->setting_field_prefix ]['nonce'], 'learndash_permalinks_nonce' ) ) ) { $post_fields = $_POST[ $this->setting_field_prefix ]; if ( ( isset( $post_fields['courses'] ) ) && ( ! empty( $post_fields['courses'] ) ) ) { $this->setting_option_values['courses'] = $this->esc_url( $post_fields['courses'] ); learndash_setup_rewrite_flush(); } if ( ( isset( $post_fields['lessons'] ) ) && ( ! empty( $post_fields['lessons'] ) ) ) { $this->setting_option_values['lessons'] = $this->esc_url( $post_fields['lessons'] ); learndash_setup_rewrite_flush(); } if ( ( isset( $post_fields['topics'] ) ) && ( ! empty( $post_fields['topics'] ) ) ) { $this->setting_option_values['topics'] = $this->esc_url( $post_fields['topics'] ); learndash_setup_rewrite_flush(); } if ( ( isset( $post_fields['quizzes'] ) ) && ( ! empty( $post_fields['quizzes'] ) ) ) { $this->setting_option_values['quizzes'] = $this->esc_url( $post_fields['quizzes'] ); learndash_setup_rewrite_flush(); } if ( ( isset( $post_fields['nested_urls'] ) ) && ( ! empty( $post_fields['nested_urls'] ) ) ) { $this->setting_option_values['nested_urls'] = $this->esc_url( $post_fields['nested_urls'] ); learndash_setup_rewrite_flush(); } else { // We check the Course Options > Course Builder setting. If this is set to 'yes' then we MUST keep the nested URLs set to true. if ( ! isset( $this->setting_option_values['nested_urls'] ) ) { $this->setting_option_values['nested_urls'] = 'no'; } if ( 'yes' !== $this->setting_option_values['nested_urls'] ) { $learndash_settings_courses_builder = get_option( 'learndash_settings_courses_management_display', array() ); if ( ! isset( $learndash_settings_courses_builder['course_builder_shared_steps'] ) ) { $learndash_settings_courses_builder['course_builder_shared_steps'] = 'no'; } if ( 'yes' === $learndash_settings_courses_builder['course_builder_shared_steps'] ) { $this->setting_option_values['nested_urls'] = 'yes'; learndash_setup_rewrite_flush(); } } } update_option( $this->settings_section_key, $this->setting_option_values ); } } } /** * Class utility function to escape the URL * * @param string $value URL to Escape. * * @return string filtered URL. */ public function esc_url( $value = '' ) { if ( ! empty( $value ) ) { $value = esc_url_raw( trim( $value ) ); $value = str_replace( 'http://', '', $value ); return untrailingslashit( $value ); } } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Permalinks::add_section_instance(); } ); PK^\.g:U!!;settings-sections/class-ld-settings-section-lessons-cpt.phpnuW+Asettings_screen_id = 'sfwd-lessons_page_lessons-options'; // The page ID (different than the screen ID). $this->settings_page_id = 'lessons-options'; // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'learndash_settings_lessons_cpt'; // This is the HTML form field prefix used. $this->setting_field_prefix = 'learndash_settings_lessons_cpt'; // Used within the Settings API to uniquely identify this section. $this->settings_section_key = 'cpt_options'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Custom Post Type Options', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: Lessons. esc_html_x( 'Control options specific to the %s post type', 'placeholder: Lessons', 'learndash' ), learndash_get_custom_label( 'lessons' ) ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( ( false === $this->setting_option_values ) || ( '' === $this->setting_option_values ) ) { if ( '' === $this->setting_option_values ) { $this->setting_option_values = array(); } $this->setting_option_values = array( 'include_in_search' => 'yes', 'has_archive' => 'yes', 'has_feed' => '', 'supports' => array( 'thumbnail', 'revisions' ), ); } if ( ! isset( $this->setting_option_values['include_in_search'] ) ) { if ( ( isset( $this->setting_option_values['exclude_from_search'] ) ) && ( 'yes' === $this->setting_option_values['exclude_from_search'] ) ) { $this->setting_option_values['include_in_search'] = ''; } else { $this->setting_option_values['include_in_search'] = 'yes'; } } if ( ! isset( $this->setting_option_values['has_archive'] ) ) { $this->setting_option_values['has_archive'] = 'yes'; } if ( ! isset( $this->setting_option_values['has_feed'] ) ) { $this->setting_option_values['has_feed'] = ''; } if ( ! isset( $this->setting_option_values['supports'] ) ) { $this->setting_option_values['supports'] = array( 'thumbnail', 'revisions' ); } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $cpt_archive_url = home_url( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Section_Permalinks', 'lessons' ) ); $cpt_rss_url = add_query_arg( 'post_type', 'sfwd-lessons', get_post_type_archive_feed_link( 'post' ) ); $this->setting_option_fields = array( 'include_in_search' => array( 'name' => 'include_in_search', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Search', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'help_text' => sprintf( // translators: placeholder: lesson. esc_html_x( 'Includes the %s post type in front end search results', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => $this->setting_option_values['include_in_search'], 'options' => array( 'yes' => '', ), ), 'has_archive' => array( 'name' => 'has_archive', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Archive Page', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: lessons, link to WP Permalins page. esc_html_x( 'Enables the front end archive page where all %1$s are listed. You must %2$s for the change to take effect.', 'placeholder: , link to WP Permalins page', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ), '' . esc_html__( 're-save your permalinks', 'learndash' ) . '' ), 'value' => $this->setting_option_values['has_archive'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'Archive URL: %s', 'placeholder: URL for CPT Archive', 'learndash' ), '' . $cpt_archive_url . '' ), ), 'child_section_state' => ( 'yes' === $this->setting_option_values['has_archive'] ) ? 'open' : 'closed', ), 'has_feed' => array( 'name' => 'has_feed', 'type' => 'checkbox-switch', 'label' => esc_html__( 'RSS/Atom Feed', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: lesson esc_html_x( 'Enables an RSS feed for all %1$s posts.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => $this->setting_option_values['has_feed'], 'options' => array( '' => '', 'yes' => sprintf( // translators: placeholder: URL for CPT Archive. esc_html_x( 'RSS Feed URL: %s', 'placeholder: URL for RSS Feed', 'learndash' ), '' . $cpt_rss_url . '' ), ), 'parent_setting' => 'has_archive', ), 'supports' => array( 'name' => 'supports', 'type' => 'checkbox', 'label' => esc_html__( 'Editor Supported Settings', 'learndash' ), 'help_text' => esc_html__( 'Enables WordPress supported settings within the editor and theme.', 'learndash' ), 'value' => $this->setting_option_values['supports'], 'options' => array( 'thumbnail' => esc_html__( 'Featured image', 'learndash' ), 'comments' => esc_html__( 'Comments', 'learndash' ), 'custom-fields' => esc_html__( 'Custom Fields', 'learndash' ), 'revisions' => esc_html__( 'Revisions', 'learndash' ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key ); parent::load_settings_fields(); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $new_values = '', $old_values = '', $setting_option_key = '' ) { if ( $setting_option_key === $this->setting_option_key ) { $new_values = parent::section_pre_update_option( $new_values, $old_values, $setting_option_key ); if ( ! isset( $new_values['include_in_search'] ) ) { $new_values['include_in_search'] = ''; } if ( ! isset( $new_values['has_archive'] ) ) { $new_values['has_archive'] = ''; $new_values['has_feed'] = ''; } if ( ! isset( $new_values['has_feed'] ) ) { $new_values['has_feed'] = ''; } if ( ! isset( $new_values['supports'] ) ) { $new_values['supports'] = array(); } if ( $new_values !== $old_values ) { if ( ( ! isset( $old_values['has_archive'] ) ) || ( $new_values['has_archive'] !== $old_values['has_archive'] ) ) { learndash_setup_rewrite_flush(); } //if ( in_array( 'comments', $new_values['supports'] ) ) { // learndash_update_posts_comment_status( 'sfwd-lessons', 'open' ); //} else { // learndash_update_posts_comment_status( 'sfwd-lessons', 'closed' ); //} } } return $new_values; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Lessons_CPT::add_section_instance(); } ); PK^\8b;settings-sections/class-ld-settings-section-side-submit.phpnuW+Asettings_screen_id = $args['settings_screen_id']; } if ( ( isset( $args['settings_page_id'] ) ) && ( ! empty( $args['settings_page_id'] ) ) ) { $this->settings_page_id = $args['settings_page_id']; } if ( ( ! empty( $this->settings_screen_id ) ) && ( ! empty( $this->settings_page_id ) ) ) { // This is the 'option_name' key used in the wp_options table. $this->setting_option_key = 'submitdiv'; // Section label/header. $this->settings_section_label = esc_html__( 'Save Options', 'learndash' ); $this->metabox_context = 'side'; $this->metabox_priority = 'high'; parent::__construct(); // We override the parent value set for $this->metabox_key because we want the div ID to match the details WordPress // value so it will be hidden. $this->metabox_key = 'submitdiv'; } } /** * Primary function to show the metabox output */ public function show_meta_box() { ?>
    $field ) { if ( ( isset( $field['args']['parent_setting'] ) ) && ( ! empty( $field['args']['parent_setting'] ) ) ) { // if we have a 'parent_setting'. Then try and figure out if it was the same as the last one. if ( ( empty( $parents_settings ) ) || ( ! in_array( $field['args']['parent_setting'], $parents_settings ) ) ) { $parent_setting_slug = $field['args']['parent_setting']; if ( ( isset( $section_fields[ $parent_setting_slug ]['args']['child_section_state'] ) ) && ( 'open' === $section_fields[ $parent_setting_slug ]['args']['child_section_state'] ) ) { $child_setting_state = 'open'; } else { $child_setting_state = 'closed'; } $parents_settings[] = $field['args']['parent_setting']; echo '
    '; } else { if ( $parents_settings[ count( $parents_settings ) - 1 ] === $field['args']['parent_setting'] ) { } elseif ( in_array( $field['args']['parent_setting'], $parents_settings ) ) { while ( ! empty( $parents_settings ) ) { $p_set = $parents_settings[ count( $parents_settings ) - 1 ]; if ( $p_set !== $field['args']['parent_setting'] ) { echo '
    '; unset( $parents_settings[ count( $parents_settings ) - 1 ] ); } else { break; } } if ( empty( $parents_settings ) ) { $parents_settings = array(); } else { $parents_settings = array_values( $parents_settings ); } } } } elseif ( ! empty( $parents_settings ) ) { while ( ! empty( $parents_settings ) ) { $p_set = $parents_settings[ count( $parents_settings ) - 1 ]; echo ''; unset( $parents_settings[ count( $parents_settings ) - 1 ] ); } if ( empty( $parents_settings ) ) { $parents_settings = array(); } else { $parents_settings = array_values( $parents_settings ); } } self::show_section_field_row( $field ); } if ( ! empty( $parents_settings ) ) { while ( ! empty( $parents_settings ) ) { $p_set = $parents_settings[ count( $parents_settings ) - 1 ]; echo ''; unset( $parents_settings[ count( $parents_settings ) - 1 ] ); } if ( empty( $parents_settings ) ) { $parents_settings = array(); } } } } /** * Shows the field row * * @since 2.4 * * @param array $field Array of field settings. */ public static function show_section_field_row( $field ) { $field_error_class = ''; if ( ( isset( $field['args']['setting_option_key'] ) ) && ( ! empty( $field['args']['setting_option_key'] ) ) ) { $settings_errors = get_settings_errors( $field['args']['setting_option_key'] ); if ( ! empty( $settings_errors ) ) { foreach ( $settings_errors as $settings_error ) { if ( ( $settings_error['setting'] == $field['args']['setting_option_key'] ) && ( $settings_error['code'] == $field['args']['name'] ) && ( 'error' == $settings_error['type'] ) ) { $field_error_class = 'learndash-settings-field-error'; } } } } $field_class = ''; if ( ( isset( $field['args']['type'] ) ) && ( ! empty( $field['args']['type'] ) ) ) { $field_instance = self::get_field_instance( $field['args']['type'] ); if ( ( ! $field_instance ) || ( 'LearnDash_Settings_Fields' !== get_parent_class( $field_instance ) ) ) { return; } $field_class = 'sfwd_input_type_' . $field['args']['type']; } if ( ( isset( $field['args']['desc_before'] ) ) && ( ! empty( $field['args']['desc_before'] ) ) ) { echo wptexturize( $field['args']['desc_before'] ); } if ( ( isset( $field['args']['row_disabled'] ) ) && ( true === $field['args']['row_disabled'] ) ) { $field_class .= ' learndash-row-disabled'; } if ( ( isset( $field['args']['type'] ) ) && ( 'hidden' !== $field['args']['type'] ) ) { $output = apply_filters( 'learndash_settings_row_outside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; } ?>
    ' . esc_html( $field['args']['row_description_before'] ) . ''; } ?> style="cursor:pointer;" title="" onclick="toggleVisibility('_tip');" >
    >

    ', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> ' . esc_html( $field['args']['row_description_after'] ) . ''; } ?>
    '; $field_legend .= '' . $field_args['label'] . ''; $field_legend .= ''; } return $field_legend; } /** * Create the HTML output from the field args 'type' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_type( $field_args = array() ) { $field_attribute = ''; if ( isset( $field_args['type'] ) ) { $field_attribute .= ' type="' . $field_args['type'] . '" '; } return $field_attribute; } /** * Create the HTML output from the field args 'class' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_class( $field_args = array(), $wrap = true ) { $field_attribute = ''; if ( true === $wrap ) { $field_attribute .= 'class="'; } $field_attribute .= 'learndash-section-field learndash-section-field-' . $this->field_type; if ( ( isset( $field_args['class'] ) ) && ( ! empty( $field_args['class'] ) ) ) { $field_attribute .= ' ' . $field_args['class']; } if ( true === $wrap ) { $field_attribute .= '" '; } return $field_attribute; } /** * Create the HTML output from the field args 'attrs' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_misc( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['attrs'] ) ) && ( ! empty( $field_args['attrs'] ) ) ) { foreach ( $field_args['attrs'] as $key => $val ) { $field_attribute .= ' ' . $key . '="' . $val . '" '; } } return $field_attribute; } /** * Create the HTML output from the field args 'input_label' attribute. * * @since 2.4 * * @param array $field_args main field args array. Should contain element for 'input_label'. * * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_input_label( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['input_label'] ) ) && ( ! empty( $field_args['input_label'] ) ) ) { $field_attribute .= ' ' . $field_args['input_label']; } return $field_attribute; } public function get_field_error_message( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['input_error'] ) ) && ( ! empty( $field_args['input_error'] ) ) ) { $field_attribute .= ''; } return $field_attribute; } public function get_field_attribute_input_description( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['input_description'] ) ) && ( ! empty( $field_args['input_description'] ) ) ) { $field_attribute .= '' . $field_args['input_description'] . ''; } return $field_attribute; } public function get_field_sub_trigger( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['name'] ) ) && ( ! empty( $field_args['name'] ) ) ) { $field_attribute .= ' data-settings-sub-trigger="ld-settings-sub-' . $field_args['name'] . '" '; } return $field_attribute; } public function get_field_inner_trigger( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['name'] ) ) && ( ! empty( $field_args['name'] ) ) ) { $field_attribute .= ' data-settings-inner-trigger="ld-settings-inner-' . $field_args['name'] . '" '; } return $field_attribute; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ! empty( $val ) ) { //if ( isset( $args['field']['type'] ) ) { // switch ( $args['field']['type'] ) { // case 'wpeditor': // case 'html': // //$val = wp_filter_post_kses( $val ); // $val = wp_check_invalid_utf8( $val ); // if ( ! empty( $val ) ) { // //$val = sanitize_post_field( $args['setting_option_key'] . '_' . $key, $val, 0, 'db' ); // $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); // } // break; // // case 'number': // $val = intval( $val ); // break; // // case 'checkbox-switch': // case 'radio': // if ( ( isset( $args['field']['options'] ) ) && ( ! empty( $args['field']['options'] ) ) ) { // if ( ! isset( $args['field']['options'][ $val ] ) ) { // $val = ''; // } // } // break; // // case 'multiselect': // if ( ( is_array( $val ) ) && ( ! empty( $val ) ) ) { // $val = array_map( $args['field']['value_type'], $val ); // } else if ( ! empty( $val ) ) { // $val = call_user_func( $args['field']['value_type'], $val ); // } else { // $val = ''; // } // break; // // default: // //$val = sanitize_text_field( $val ); // if ( ! empty( $val ) ) { // $val = call_user_func( $args['field']['value_type'], $val ); // } // break; //} //} else { //$val = sanitize_text_field( $val ); // if ( ! empty( $val ) ) { $val = call_user_func( $args['field']['value_type'], $val ); // } //} } return $val; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function value_section_field( $val = '', $key = '', $args = array(), $post_args = array() ) { return $val; } } } PK^\`O?QYQYclass-ld-settings-metaboxes.phpnuW+Asettings_screen_id . '_display_settings', array( $this, 'display_settings_filter' ), 100, 3 ); } /** * Get the instance of our class based on the metabox_key * * @since 2.6.0 * * @param string $metabox_key Unique metabox key used to identify instance. */ final public static function get_metabox_instance( $metabox_key = '' ) { if ( ! empty( $metabox_key ) ) { if ( isset( self::$_instances[ $metabox_key ] ) ) { return self::$_instances[ $metabox_key ]; } } } /** * Add instance to static tracking array * * @since 2.4.0 */ final public static function add_metabox_instance() { $metabox_key = get_called_class(); if ( ! isset( self::$_instances[ $metabox_key ] ) ) { self::$_instances[ $metabox_key ] = new $metabox_key(); } return self::$_instances[ $metabox_key ]; } /** * Initialize self */ public function init( $post = null ) { if ( ( ! $post ) || ( ! is_a( $post, 'WP_Post' ) ) ) { return false; } if ( $post->post_type !== $this->settings_screen_id ) { return false; } $this->_post = $post; if ( ! $this->settings_values_loaded ) { $this->load_settings_values(); } if ( ! $this->settings_fields_loaded ) { $this->load_settings_fields(); } } /** * Load the section settings values. */ public function load_settings_values() { $screen = get_current_screen(); if ( $screen->id !== $this->settings_screen_id ) { return false; } if ( ( ! $this->_post ) || ( ! is_a( $this->_post, 'WP_Post' ) ) ) { return false; } if ( $this->_post->post_type !== $this->settings_screen_id ) { return false; } $setting_values = learndash_get_setting( $this->_post ); if ( ! empty( $setting_values ) ) { foreach ( $this->settings_fields_map as $_internal => $_legacy ) { if ( isset( $setting_values[ $_legacy ] ) ) { $this->setting_option_values[ $_internal ] = $setting_values[ $_legacy ]; $this->settings_values_legacy[ $this->settings_screen_id . '_' . $_internal ] = $setting_values[ $_legacy ]; } else { $this->setting_option_values[ $_internal ] = ''; } } } $this->settings_values_loaded = true; return true; } protected function get_save_settings_fields_map_form_post_values( $post_values = array() ) { return $this->settings_fields_map; } /** * Load the section settings fields. */ public function load_settings_fields() { $this->settings_fields_loaded = true; if ( ! empty( $this->setting_option_fields ) ) { foreach ( $this->setting_option_fields as $setting_option_key => &$setting_option_field ) { $setting_option_field = $this->load_settings_field( $setting_option_field ); } } } public function load_settings_field( $setting_option_field = array() ) { if ( ! isset( $setting_option_field['type'] ) ) { return $setting_option_field; } $field_ref = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] ); if ( ! $field_ref ) { return $setting_option_field; } $setting_option_field['setting_option_key'] = $this->settings_metabox_key; if ( ! isset( $setting_option_field['id'] ) ) { $setting_option_field['id'] = $setting_option_field['setting_option_key'] . '_' . $setting_option_field['name']; } if ( ! isset( $setting_option_field['label_for'] ) ) { $setting_option_field['label_for'] = $setting_option_field['id']; } if ( ! isset( $setting_option_field['label_none'] ) ) { $setting_option_field['label_none'] = false; } if ( ! isset( $setting_option_field['label_full'] ) ) { $setting_option_field['label_full'] = false; } if ( ! isset( $setting_option_field['input_show'] ) ) { $setting_option_field['input_show'] = true; } if ( ! isset( $setting_option_field['input_full'] ) ) { $setting_option_field['input_full'] = false; } if ( ! isset( $setting_option_field['default'] ) ) { $setting_option_field['default'] = ''; } if ( ! isset( $setting_option_field['value'] ) ) { $setting_option_field['value'] = ''; } if ( ( ! isset( $setting_option_field['value'] ) ) || ( empty( $setting_option_field['value'] ) ) ) { if ( 'radio' === $setting_option_field['type'] ) { if ( isset( $setting_option_field['default'] ) ) { $setting_option_field['value'] = $setting_option_field['default']; } } } if ( ! isset( $setting_option_field['name_wrap'] ) ) { $setting_option_field['name_wrap'] = true; } if ( ! isset( $setting_option_field['display_callback'] ) ) { $display_ref = $field_ref->get_creation_function_ref(); if ( $display_ref ) { $setting_option_field['display_callback'] = $display_ref; } } if ( ! isset( $setting_option_field['validate_callback'] ) ) { $validate_ref = $field_ref->get_validation_function_ref(); if ( $validate_ref ) { $setting_option_field['validate_callback'] = $validate_ref; } } if ( ! isset( $setting_option_field['value_callback'] ) ) { $value_ref = $field_ref->get_value_function_ref(); if ( $value_ref ) { $setting_option_field['value_callback'] = $value_ref; } } if ( ( ! isset( $setting_option_field['value_type'] ) ) || ( empty( $setting_option_field['value_type'] ) ) ) { $setting_option_field['value_type'] = 'sanitize_text_field'; } if ( ! is_callable( $setting_option_field['value_type'] ) ) { $setting_option_field['value_type'] = 'sanitize_text_field'; } // Now we reorganize the field. if ( ! isset( $setting_option_field['args'] ) ) { $setting_option_field['args'] = array(); foreach ( $setting_option_field as $field_key => $field_val ) { $setting_option_field['args'][ $field_key ] = $field_val; if ( 'label' === $field_key ) { $setting_option_field['title'] = $field_val; } if ( ! in_array( $field_key, array( 'id', 'name', 'args', 'callback' ) ) ) { unset( $setting_option_field[ $field_key ] ); } } } return $setting_option_field; } /** * Show Settings Section Description */ public function show_settings_section_description() { if ( ! empty( $this->settings_section_description ) ) { echo '
    ' . wpautop( wp_kses_post( $this->settings_section_description ) ) . '
    '; } } /** * Added Settings Section meta box. * * @param string $settings_screen_id Settings Screen ID. */ public function add_meta_boxes( $settings_screen_id = '' ) { global $learndash_metaboxes; if ( $settings_screen_id === $this->settings_screen_id ) { if ( apply_filters( 'learndash_show_metabox', true, $this->settings_metabox_key, $this->settings_screen_id ) ) { if ( ! isset( $learndash_metaboxes[ $this->settings_screen_id ] ) ) { $learndash_metaboxes[ $this->settings_screen_id ] = array(); } $learndash_metaboxes[ $this->settings_screen_id ][ $this->settings_metabox_key ] = $this->settings_metabox_key; add_meta_box( $this->settings_metabox_key, $this->settings_section_label, array( $this, 'show_meta_box' ), $this->settings_screen_id, $this->metabox_context, $this->metabox_priority ); } } } /** * Show Settings Section meta box. */ public function show_meta_box( $post = null, $metabox = null ) { if ( $post ) { $this->init( $post ); $this->show_metabox_nonce_field(); $this->show_settings_metabox( $this ); } } /** * Output Metabox nonce field. */ public function show_metabox_nonce_field() { wp_nonce_field( $this->settings_metabox_key, $this->settings_metabox_key . '[nonce]' ); } /** * Verify Metabox nonce field POST value. */ public function verify_metabox_nonce_field() { if ( ( isset( $_POST[ $this->settings_metabox_key ]['nonce'] ) ) && ( ! empty( $_POST[ $this->settings_metabox_key ]['nonce'] ) ) && ( wp_verify_nonce( esc_attr( $_POST[ $this->settings_metabox_key ]['nonce'] ), $this->settings_metabox_key ) ) ) { return true; } } /** * Save Settings Metabox * * @param integer $post_id $Post ID is post being saved. * @param object $saved_post WP_Post object being saved. * @param boolean $update If update true, otherwise false. * @param array $settings_field_updates array of settings fields to update. */ public function save_post_meta_box( $post_id = 0, $saved_post = null, $update = null, $settings_field_updates = null ) { if ( true === $this->verify_metabox_nonce_field() ) { if ( is_null( $settings_field_updates ) ) { $settings_field_updates = $this->get_post_settings_field_updates( $post_id, $saved_post, $update ); } if ( ( ! empty( $settings_field_updates ) ) && ( is_array( $settings_field_updates ) ) ) { foreach ( $settings_field_updates as $_key => $_val ) { learndash_update_setting( $saved_post, $_key, $_val ); } } } } public function get_post_settings_field_updates( $post_id = 0, $saved_post = null, $update = null ) { $settings_field_updates = array(); if ( ( $saved_post ) && ( is_a( $saved_post, 'WP_Post' ) ) && ( $saved_post->post_type === $this->settings_screen_id ) ) { if ( ( true === $this->verify_metabox_nonce_field() ) && ( isset( $_POST[ $this->settings_metabox_key ] ) ) ) { $post_values = $_POST[ $this->settings_metabox_key ]; $this->init( $saved_post ); $settings_fields_map = $this->get_save_settings_fields_map_form_post_values( $post_values ); if ( ! empty( $settings_fields_map ) ) { // This valiadate_args array will be passed to the validation function for context. $validate_args = array( 'settings_page_id' => $this->settings_screen_id, 'setting_option_key' => $this->settings_metabox_key, 'post_fields' => $settings_field_updates, 'field' => null, ); foreach ( $settings_fields_map as $_internal => $_legacy ) { $settings_field = $this->get_settings_field_by_key( $_internal ); if ( $settings_field ) { if ( isset( $post_values[ $_internal ] ) ) { $post_value = $post_values[ $_internal ]; } else { $post_value = ''; } $validate_args['field'] = $settings_field['args']; if ( ( isset( $settings_field['args']['value_callback'] ) ) && ( ! empty( $settings_field['args']['value_callback'] ) ) && ( is_callable( $settings_field['args']['value_callback'] ) ) ) { $post_value = call_user_func( $settings_field['args']['value_callback'], $post_value, $_internal, $validate_args, $post_values ); } else { $post_value = esc_attr( $post_value ); } if ( ( isset( $settings_field['args']['validate_callback'] ) ) && ( ! empty( $settings_field['args']['validate_callback'] ) ) && ( is_callable( $settings_field['args']['validate_callback'] ) ) ) { $post_value = call_user_func( $settings_field['args']['validate_callback'], $post_value, $_internal, $validate_args ); } else { $post_value = esc_attr( $post_value ); } $settings_field_updates[ $_legacy ] = $post_value; } } } } } $settings_field_updates = apply_filters( 'learndash_metabox_save_fields', $settings_field_updates, $this->settings_metabox_key, $this->settings_screen_id ); $settings_field_updates = apply_filters( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, $settings_field_updates, $this->settings_metabox_key, $this->settings_screen_id ); return $settings_field_updates; } /** * Show the meta box settings * * @param string $section Section to be shown. */ public function show_settings_metabox( $metabox = null ) { if ( ( $metabox ) && ( is_object( $metabox ) ) && ( isset( self::$_instances[ get_class( $metabox ) ] ) ) ) { // If this section defined its own display callback logic. if ( ( isset( $metabox->settings_fields_callback ) ) && ( ! empty( $metabox->settings_fields_callback ) ) && ( is_callable( $metabox->settings_fields_callback ) ) ) { call_user_func( $metabox->settings_fields_callback, $this->settings_metabox_key ); } else { do_action( 'learndash_metabox_description_before', $metabox->settings_metabox_key ); $this->show_settings_section_description(); do_action( 'learndash_metabox_description_after', $metabox->settings_metabox_key ); if ( learndash_get_post_type_slug( 'quiz' ) === $this->settings_screen_id ) { echo '
    '; } do_action( 'learndash_metabox_options_div_before', $metabox->settings_metabox_key ); echo '
    '; do_action( 'learndash_metabox_options_div_inside_top', $metabox->settings_metabox_key ); $this->show_settings_metabox_fields( $metabox ); do_action( 'learndash_metabox_options_div_inside_bottom', $metabox->settings_metabox_key ); echo '
    '; do_action( 'learndash_metabox_options_div_after', $metabox->settings_metabox_key ); if ( learndash_get_post_type_slug( 'quiz' ) === $this->settings_screen_id ) { echo '
    '; } } } } /** * Show Settings Section Fields. * * @param string $page Page shown. * @param string $section Section shown. */ protected function show_settings_metabox_fields( $metabox = null ) { if ( $metabox ) { LearnDash_Settings_Fields::show_section_fields( $metabox->setting_option_fields ); } } /** * Filter the legacy settings fields when display to remove items * handled by this metabox, * * @since 3.0 * @param array $settings_fields Array of settings fields. * @param string $location Screen/Post Type location. * @param array $settings_values Array of current field values. */ public function display_settings_filter( $settings_fields = array(), $location = '', $settings_values = array() ) { if ( ( $location === $this->settings_screen_id ) && ( ! empty( $settings_fields ) ) ) { $this->settings_fields_legacy = array(); $this->settings_values_legacy = array(); foreach ( $settings_fields as $setting_field_key => $setting_field ) { $settings_field_key_name = str_replace( $this->settings_screen_id . '_', '', $setting_field_key ); $settings_key = array_search( $settings_field_key_name, $this->settings_fields_map ); if ( false !== $settings_key ) { $this->settings_fields_legacy[ $settings_field_key_name ] = $setting_field; unset( $settings_fields[ $setting_field_key ] ); } } foreach ( $settings_values as $setting_value_key => $setting_value ) { $settings_value_key_name = str_replace( $this->settings_screen_id . '_', '', $setting_value_key ); $settings_key = array_search( $settings_value_key_name, $this->settings_fields_map ); if ( false !== $settings_key ) { $this->settings_values_legacy[ $settings_value_key_name ] = $setting_value; } } } return $settings_fields; } public function get_settings_field_by_key( $field_key = '' ) { if ( ! empty( $field_key ) ) { if ( ! empty( $this->setting_option_fields ) ) { if ( isset( $this->setting_option_fields[ $field_key ] ) ) { return $this->setting_option_fields[ $field_key ]; } } if ( ! empty( $this->settings_sub_option_fields ) ) { foreach ( $this->settings_sub_option_fields as $sub_option_key => $sub_option_fields ) { if ( isset( $sub_option_fields[ $field_key ] ) ) { return $sub_option_fields[ $field_key ]; } } } } } public function init_quiz_edit( $post ) { static $pro_quiz_edit = array(); $quiz_mapper = new WpProQuiz_Model_QuizMapper(); $prerequisite_mapper = new WpProQuiz_Model_PrerequisiteMapper(); $form_mapper = new WpProQuiz_Model_FormMapper(); $pro_quiz_id = absint( learndash_get_setting( $post->ID, 'quiz_pro' ) ); if ( ! isset( $pro_quiz_edit[ $pro_quiz_id ] ) ) { if ( ! empty( $pro_quiz_id ) ) { $pro_quiz_edit[ $pro_quiz_id ] = array( 'quiz' => $quiz_mapper->fetch( $pro_quiz_id ), 'prerequisiteQuizList' => $prerequisite_mapper->fetchQuizIds( $pro_quiz_id ), 'forms' => $form_mapper->fetch( $pro_quiz_id ), ); $pro_quiz_edit[ $pro_quiz_id ]['quiz']->setPostId( absint( $post->ID ) ); } else { $pro_quiz_edit[ $pro_quiz_id ] = array( 'quiz' => $quiz_mapper->fetch( 0 ), 'prerequisiteQuizList' => $prerequisite_mapper->fetchQuizIds( 0 ), 'forms' => $form_mapper->fetch( 0 ), ); } if ( ( isset( $_GET['templateLoadId'] ) ) && ( ! empty( $_GET['templateLoadId'] ) ) ) { $template_id = absint( $_GET['templateLoadId'] ); if ( ! empty( $template_id ) ) { $template_mapper = new WpProQuiz_Model_TemplateMapper(); $template = $template_mapper->fetchById( $template_id ); $data = $template->getData(); if ( null !== $data ) { if ( ( isset( $data['quiz'] ) ) && ( is_a( $data['quiz'], 'WpProQuiz_Model_Quiz' ) ) ) { $data['quiz']->setId( $pro_quiz_edit[ $pro_quiz_id ]['quiz']->getId() ); $data['quiz']->setPostId( $post->ID ); $data['quiz']->setName( $pro_quiz_edit[ $pro_quiz_id ]['quiz']->getName() ); $data['quiz']->setText( 'AAZZAAZZ' ); } else { $data['quiz'] = $quiz_mapper->fetch( 0 ); } if ( ! isset( $data['forms'] ) ) { $data['forms'] = array(); } if ( ! isset( $data['prerequisiteQuizList'] ) ) { $data['prerequisiteQuizList'] = array(); } if ( isset( $data['_' . learndash_get_post_type_slug( 'quiz' ) ] ) ) { $quiz_postmeta = $data['_' . learndash_get_post_type_slug( 'quiz' ) ]; foreach( $this->settings_fields_map as $_key => $_val ) { if ( isset( $data['_' . learndash_get_post_type_slug( 'quiz' ) ][ $_key ] ) ) { $this->setting_option_values[ $_key ] = $data['_' . learndash_get_post_type_slug( 'quiz' ) ][ $_key ]; } } } else { $quiz_postmeta = array(); } $pro_quiz_edit[ $pro_quiz_id ] = array( 'quiz' => $data['quiz'], 'prerequisiteQuizList' => $data['prerequisiteQuizList'], 'forms' => $data['forms'], 'quiz_postmeta' => $quiz_postmeta, ); } } } } return $pro_quiz_edit[ $pro_quiz_id ]; } public function check_legacy_metabox_fields( $legacy_fields = array() ) { if ( ! empty( $legacy_fields ) ) { foreach ( $legacy_fields as $field_key => $field_value ) { //if ( isset( $this->settings_fields_map[ $field_key ] ) ) { if ( in_array( $field_key, $this->settings_fields_map ) ) { unset( $legacy_fields[ $field_key ] ); } } } return $legacy_fields; } // End of functions. } } PK^\TMsettings-loader.phpnuW+Asettings_screen_id = 'sfwd-quiz'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-quiz-admin-data-handling-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Administrative and Data Handling Settings', 'learndash' ); $this->settings_section_description = esc_html__( 'Controls data handling options, notifications and templates.', 'learndash' ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'associated_settings_enabled' => 'associated_settings_enabled', 'toplistDataShowIn_enabled' => 'toplistDataShowIn_enabled', 'statisticsIpLock_enabled' => 'statisticsIpLock_enabled', 'associated_settings' => 'quiz_pro', 'formActivated' => 'formActivated', 'formShowPosition' => 'formShowPosition', 'toplistDataAddPermissions' => 'toplistDataAddPermissions', 'toplistDataAddMultiple' => 'toplistDataAddMultiple', 'toplistDataAddBlock' => 'toplistDataAddBlock', 'toplistDataAddAutomatic' => 'toplistDataAddAutomatic', 'toplistDataShowLimit' => 'toplistDataShowLimit', 'toplistDataSort' => 'toplistDataSort', 'toplistActivated' => 'toplistActivated', 'toplistDataShowIn' => 'toplistDataShowIn', 'toplistDataCaptcha' => 'toplistDataCaptcha', 'statisticsOn' => 'statisticsOn', 'viewProfileStatistics' => 'viewProfileStatistics', 'statisticsIpLock' => 'statisticsIpLock', 'email_enabled' => 'email_enabled', 'email_enabled_admin' => 'email_enabled_admin', 'emailNotification' => 'emailNotification', 'userEmailNotification' => 'userEmailNotification', 'timeLimitCookie_enabled' => 'timeLimitCookie_enabled', 'timeLimitCookie' => 'timeLimitCookie', 'templates_enabled' => 'templates_enabled', //'templateLoadId' => 'templateLoadId', //'templateSaveList' => 'templateSaveList', //'templateName' => 'templateName', ); parent::__construct(); } /** * Used to save the settings fields back to the global $_POST object so * the WPProQuiz normal form processing can take place. * * @since 3.0 * @param object $pro_quiz_edit WpProQuiz_Controller_Quiz instance (not used). * @param array $settings_values Array of settings fields. */ public function save_fields_to_post( $pro_quiz_edit, $settings_values = array() ) { $_POST['formActivated'] = $settings_values['formActivated']; $_POST['formShowPosition'] = $settings_values['formShowPosition']; $_POST['toplistActivated'] = $settings_values['toplistActivated']; $_POST['toplistDataAddPermissions'] = $settings_values['toplistDataAddPermissions']; $_POST['toplistDataAddMultiple'] = $settings_values['toplistDataAddMultiple']; $_POST['toplistDataAddBlock'] = $settings_values['toplistDataAddBlock']; $_POST['toplistDataAddAutomatic'] = $settings_values['toplistDataAddAutomatic']; $_POST['toplistDataShowLimit'] = $settings_values['toplistDataShowLimit']; $_POST['toplistDataSort'] = $settings_values['toplistDataSort']; $_POST['toplistDataShowIn'] = $settings_values['toplistDataShowIn']; $_POST['toplistDataCaptcha'] = $settings_values['toplistDataCaptcha']; $_POST['statisticsOn'] = $settings_values['statisticsOn']; $_POST['viewProfileStatistics'] = $settings_values['viewProfileStatistics']; $_POST['statisticsIpLock'] = $settings_values['statisticsIpLock']; $_POST['emailNotification'] = $settings_values['emailNotification']; $_POST['userEmailNotification'] = $settings_values['userEmailNotification']; $_POST['timeLimitCookie'] = $settings_values['timeLimitCookie']; // $_POST['templateLoadId'] = $settings_values['templateLoadId']; // $_POST['templateSaveList'] = $settings_values['templateSaveList']; // $_POST['templateName'] = $settings_values['templateName']; } /** * Initialize the metabox settings values. */ public function load_settings_values() { global $pagenow; parent::load_settings_values(); $this->quiz_edit = $this->init_quiz_edit( $this->_post ); if ( true === $this->settings_values_loaded ) { if ( $this->quiz_edit['quiz'] ) { $this->setting_option_values['formActivated'] = $this->quiz_edit['quiz']->isFormActivated(); if ( true === $this->setting_option_values['formActivated'] ) { $this->setting_option_values['formActivated'] = 'on'; } else { $this->setting_option_values['formActivated'] = ''; } //$form_mapper = new WpProQuiz_Model_FormMapper(); //$this->setting_option_values['custom_fields_forms'] = $form_mapper->fetch( $this->quiz_edit['quiz']->getId() ); if ( $this->quiz_edit['forms'] ) { $this->setting_option_values['custom_fields_forms'] = $this->quiz_edit['forms']; } else { $this->setting_option_values['custom_fields_forms'] = array(); } if ( empty( $this->setting_option_values['custom_fields_forms'] ) ) { $this->setting_option_values['formActivated'] = ''; } else { $this->setting_option_values['formActivated'] = 'on'; } $this->setting_option_values['formShowPosition'] = $this->quiz_edit['quiz']->getFormShowPosition(); if ( WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START === $this->setting_option_values['formShowPosition'] ) { $this->setting_option_values['formShowPosition'] = WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START; } else { $this->setting_option_values['formShowPosition'] = WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_END; } $this->setting_option_values['toplistActivated'] = $this->quiz_edit['quiz']->isToplistActivated(); if ( true === $this->setting_option_values['toplistActivated'] ) { $this->setting_option_values['toplistActivated'] = 'on'; } else { $this->setting_option_values['toplistActivated'] = ''; } $this->setting_option_values['toplistDataAddPermissions'] = $this->quiz_edit['quiz']->getToplistDataAddPermissions(); $this->setting_option_values['toplistDataAddMultiple'] = $this->quiz_edit['quiz']->isToplistDataAddMultiple(); if ( true === $this->setting_option_values['toplistDataAddMultiple'] ) { $this->setting_option_values['toplistDataAddMultiple'] = 'on'; } $this->setting_option_values['toplistDataAddBlock'] = absint( $this->quiz_edit['quiz']->getToplistDataAddBlock() ); $this->setting_option_values['toplistDataAddAutomatic'] = $this->quiz_edit['quiz']->isToplistDataAddAutomatic(); if ( true === $this->setting_option_values['toplistDataAddAutomatic'] ) { $this->setting_option_values['toplistDataAddAutomatic'] = 'on'; } else { $this->setting_option_values['toplistDataAddAutomatic'] = ''; } $this->setting_option_values['toplistDataShowLimit'] = $this->quiz_edit['quiz']->getToplistDataShowLimit(); $this->setting_option_values['toplistDataSort'] = $this->quiz_edit['quiz']->getToplistDataSort(); $this->setting_option_values['toplistDataShowIn'] = $this->quiz_edit['quiz']->getToplistDataShowIn(); if ( absint( $this->setting_option_values['toplistDataShowIn'] ) > 0 ) { $this->setting_option_values['toplistDataShowIn_enabled'] = 'on'; } else { $this->setting_option_values['toplistDataShowIn_enabled'] = ''; } if ( class_exists( 'ReallySimpleCaptcha' ) ) { $this->setting_option_values['toplistDataCaptcha'] = $this->quiz_edit['quiz']->isToplistDataCaptcha(); if ( true === $this->setting_option_values['toplistDataCaptcha'] ) { $this->setting_option_values['toplistDataCaptcha'] = 'on'; } else { $this->setting_option_values['toplistDataCaptcha'] = ''; } } else { $this->setting_option_values['toplistDataCaptcha'] = ''; } if ( 'on' !== $this->setting_option_values['toplistActivated'] ) { $this->setting_option_values['toplistDataAddPermissions'] = ''; $this->setting_option_values['toplistDataAddMultiple'] = ''; $this->setting_option_values['toplistDataAddBlock'] = 0; $this->setting_option_values['toplistDataAddAutomatic'] = ''; $this->setting_option_values['toplistDataShowLimit'] = ''; $this->setting_option_values['toplistDataSort'] = ''; $this->setting_option_values['toplistDataShowIn'] = ''; $this->setting_option_values['toplistDataShowIn_enabled'] = ''; $this->setting_option_values['toplistDataCaptcha'] = ''; } $this->setting_option_values['statisticsOn'] = $this->quiz_edit['quiz']->isStatisticsOn(); if ( true === $this->setting_option_values['statisticsOn'] ) { $this->setting_option_values['statisticsOn'] = 'on'; } else { $this->setting_option_values['statisticsOn'] = ''; } if ( isset( $this->quiz_edit['quiz_postmeta']['viewProfileStatistics'] ) ) { $this->setting_option_values['viewProfileStatistics'] = $this->quiz_edit['quiz_postmeta']['viewProfileStatistics']; } else { if ( 'post-new.php' === $pagenow ) { $this->setting_option_values['viewProfileStatistics'] = true; } else { $this->setting_option_values['viewProfileStatistics'] = $this->quiz_edit['quiz']->getViewProfileStatistics(); } } if ( true === $this->setting_option_values['viewProfileStatistics'] ) { $this->setting_option_values['viewProfileStatistics'] = 'on'; } else { $this->setting_option_values['viewProfileStatistics'] = ''; } $this->setting_option_values['statisticsIpLock'] = $this->quiz_edit['quiz']->getStatisticsIpLock(); if ( ! empty( $this->setting_option_values['statisticsIpLock'] ) ) { $this->setting_option_values['statisticsIpLock'] = round( $this->setting_option_values['statisticsIpLock'] / 60 ); $this->setting_option_values['statisticsIpLock_enabled'] = 'on'; } else { $this->setting_option_values['statisticsIpLock_enabled'] = ''; } $this->setting_option_values['emailNotification'] = $this->quiz_edit['quiz']->getEmailNotification(); if ( ( $this->setting_option_values['emailNotification'] == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL ) || ( $this->setting_option_values['emailNotification'] == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER ) ) { $this->setting_option_values['email_enabled_admin'] = 'on'; } else { $this->setting_option_values['email_enabled_admin'] = ''; } $this->setting_option_values['userEmailNotification'] = $this->quiz_edit['quiz']->isUserEmailNotification(); if ( true === $this->setting_option_values['userEmailNotification'] ) { $this->setting_option_values['userEmailNotification'] = 'on'; } else { $this->setting_option_values['userEmailNotification'] = ''; } if ( ( 'on' !== $this->setting_option_values['userEmailNotification'] ) && ( 'on' !== $this->setting_option_values['email_enabled_admin'] ) ) { $this->setting_option_values['email_enabled'] = ''; } else { $this->setting_option_values['email_enabled'] = 'on'; } if ( isset( $this->quiz_edit['quiz_postmeta']['timeLimitCookie'] ) ) { $this->setting_option_values['timeLimitCookie'] = $this->quiz_edit['quiz_postmeta']['timeLimitCookie']; } else { $this->setting_option_values['timeLimitCookie'] = $this->quiz_edit['quiz']->getTimeLimitCookie(); } if ( ! empty( $this->setting_option_values['timeLimitCookie'] ) ) { $this->setting_option_values['timeLimitCookie_enabled'] = 'on'; } else { $this->setting_option_values['timeLimitCookie_enabled'] = ''; } $this->setting_option_values['associated_settings'] = learndash_get_setting( get_the_ID(), 'quiz_pro' ); if ( ! isset( $this->setting_option_values['advanced_settings'] ) ) { $this->setting_option_values['advanced_settings'] = ''; } if ( 'on' === $this->setting_option_values['timeLimitCookie_enabled'] ) { $this->setting_option_values['advanced_settings'] = 'on'; } } } $this->setting_option_values['templateLoadId'] = ''; if ( ( isset( $_GET['templateLoadId'] ) ) && ( ! empty( $_GET['templateLoadId'] ) ) ) { $this->setting_option_values['templateLoadId'] = absint( $_GET['templateLoadId'] ); } if ( ! empty( $this->setting_option_values['templateLoadId'] ) ) { $this->setting_option_values['templates_enabled'] = 'on'; } else { $this->setting_option_values['templates_enabled'] = ''; } foreach ( $this->settings_fields_map as $_internal => $_external ) { if ( ! isset( $this->setting_option_values[ $_internal ] ) ) { $this->setting_option_values[ $_internal ] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $pro_quiz_options = LD_QuizPro::get_quiz_list(); $pro_quiz_options_default = array( '-1' => esc_html__( 'Select a ProQuiz association', 'learndash' ), 'new' => esc_html__( 'New ProQuiz association', 'learndash' ), ); $pro_quiz_options = $pro_quiz_options_default + $pro_quiz_options; $this->setting_option_fields = array( 'toplistDataAddBlock' => array( 'name' => 'toplistDataAddBlock', 'label' => esc_html__( 'Re-apply after', 'learndash' ), 'label_full' => true, 'input_full' => true, 'type' => 'number', 'value' => $this->setting_option_values['toplistDataAddBlock'], 'input_label' => esc_html__( 'minutes', 'learndash' ), 'default' => '1', 'attrs' => array( 'step' => 1, 'min' => 0, ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['leaderboard_add_multiple_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'toplistDataShowIn' => array( 'name' => 'toplistDataShowIn', 'label_none' => true, 'type' => 'radio', 'value' => $this->setting_option_values['toplistDataShowIn'], 'default' => '1', 'options' => array( '1' => esc_html__( 'Below the result text', 'learndash' ), '2' => esc_html__( 'In a button', 'learndash' ), ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['leaderboard_result_display_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'statisticsIpLock' => array( 'name' => 'statisticsIpLock', 'label_full' => true, 'label' => esc_html__( 'IP-lock time limit', 'learndash' ), 'label_description' => esc_html__( 'Protect the statistics from spam. Results will only be saved every X minutes.', 'learndash' ), 'input_full' => true, 'type' => 'number', 'class' => '-small', 'value' => $this->setting_option_values['statisticsIpLock'], 'input_label' => esc_html__( 'minutes', 'learndash' ), 'default' => '0', 'attrs' => array( 'step' => 1, 'min' => 0, ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['quiz_statistics_ip_lock_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'emailNotification' => array( 'name' => 'emailNotification', 'label' => esc_html__( 'Email trigger', 'learndash' ), 'label_full' => true, 'label_description' => sprintf( // translators: placeholder: quiz. esc_html_x( 'The admin will receive an email notification when the following users have taken the %s.', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'type' => 'select', 'value' => $this->setting_option_values['emailNotification'], 'input_full' => true, 'default' => WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER, 'options' => array( WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL => esc_html__( 'All users', 'learndash' ), WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER => esc_html__( 'Registered users only', 'learndash' ), ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['emailNotification_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'timeLimitCookie' => array( 'name' => 'timeLimitCookie', 'label_full' => true, 'label' => esc_html__( 'Cookie time limit', 'learndash' ), 'label_description' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Save the user’s answers into a browser cookie until the %s is submitted', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'input_full' => true, 'type' => 'number', 'class' => '-small', 'value' => $this->setting_option_values['timeLimitCookie'], 'input_label' => esc_html__( 'seconds', 'learndash' ), 'default' => '', 'attrs' => array( 'step' => 1, 'min' => 0, ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['timeLimitCookie_enabled_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'associated_settings' => array( 'name' => 'associated_settings', 'type' => 'select', 'label_full' => true, 'label' => esc_html__( 'Associated Quiz Database Table', 'learndash' ), 'label_description' => wp_kses_post( 'This will change the database association.
    We do not recommend editing this unless for a specific purpose.', 'learndash' ), 'input_full' => true, 'value' => $this->setting_option_values['associated_settings'], 'parent_setting' => 'associated_settings_enabled', 'default' => '', 'options' => $pro_quiz_options, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['associated_settings_enabled_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'formActivated' => array( 'name' => 'formActivated', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Custom Fields', 'learndash' ), 'value' => $this->setting_option_values['formActivated'], 'default' => '', 'help_text' => sprintf( // translators: placeholder: quiz, Quiz esc_html_x( 'Enable this option to gather data from your users before or after the %1$s. All data is stored in the %2$s Statistics.', 'placeholder: quiz, Quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label( 'quiz' ) ), 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['formActivated'] ) ? 'open' : 'closed', ), 'custom_fields_forms' => array( 'name' => 'custom_fields_forms', 'type' => 'quiz-custom-fields', 'label_none' => true, 'input_full' => true, 'value' => $this->setting_option_values['custom_fields_forms'], 'parent_setting' => 'formActivated', ), 'formShowPosition' => array( 'name' => 'formShowPosition', 'type' => 'radio', 'label' => esc_html__( 'Display Position', 'learndash' ), 'value' => $this->setting_option_values['formShowPosition'], 'parent_setting' => 'formActivated', 'default' => WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START, 'options' => array( WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START => sprintf( // translators: placeholder: quiz. esc_html_x( 'On the %s startpage', 'placeholder: quiz.', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_END => sprintf( // translators: placeholder: quiz, quiz. esc_html_x( 'At the end of the %1$s (before the %2$s result)', 'placeholder: quiz, quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'quiz' ) ), ), ), 'toplistActivated' => array( 'name' => 'toplistActivated', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Leaderboard', 'learndash' ), 'value' => $this->setting_option_values['toplistActivated'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['toplistActivated'] ) ? 'open' : 'closed', ), 'toplistDataAddPermissions' => array( 'name' => 'toplistDataAddPermissions', 'type' => 'select', 'label' => esc_html__( 'Who can apply?', 'learndash' ), 'value' => $this->setting_option_values['toplistDataAddPermissions'], 'options' => array( '1' => esc_html__( 'All user', 'learndash' ), '2' => esc_html__( 'Registered users only', 'learndash' ), '3' => esc_html__( 'Anonymous users only', 'learndash' ), ), 'parent_setting' => 'toplistActivated', ), 'toplistDataAddMultiple' => array( 'name' => 'toplistDataAddMultiple', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Multiple Applications per user', 'learndash' ), 'value' => $this->setting_option_values['toplistDataAddMultiple'], 'parent_setting' => 'toplistActivated', 'default' => '', 'options' => array( '' => '', 'on' => esc_html__( 'Users can apply more than once to the leaderboard', 'learndash' ), ), 'inline_fields' => array( 'leaderboard_add_multiple_min' => $this->settings_sub_option_fields['leaderboard_add_multiple_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['toplistDataAddMultiple'] ) ? 'open' : 'closed', ), 'toplistDataAddAutomatic' => array( 'name' => 'toplistDataAddAutomatic', 'type' => 'checkbox', 'label' => esc_html__( 'Automatic user entry', 'learndash' ), 'value' => $this->setting_option_values['toplistDataAddAutomatic'], 'parent_setting' => 'toplistActivated', 'default' => '', 'options' => array( 'on' => '', ), ), 'toplistDataShowLimit' => array( 'name' => 'toplistDataShowLimit', 'label' => esc_html__( 'Number of displayed entries', 'learndash' ), 'type' => 'number', 'class' => '-small', 'parent_setting' => 'toplistActivated', 'value' => $this->setting_option_values['toplistDataShowLimit'], 'default' => '10', 'attrs' => array( 'step' => 1, 'min' => 0, ), ), 'toplistDataSort' => array( 'name' => 'toplistDataSort', 'type' => 'select', 'label' => esc_html__( 'Sort list by?', 'learndash' ), 'value' => $this->setting_option_values['toplistDataSort'], 'parent_setting' => 'toplistActivated', 'default' => '1', 'options' => array( '1' => esc_html__( 'Best user', 'learndash' ), '2' => esc_html__( 'Newest entry', 'learndash' ), '3' => esc_html__( 'Oldest entry', 'learndash' ), ), ), 'toplistDataShowIn_enabled' => array( 'name' => 'toplistDataShowIn_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Display on %s results page', 'placeholder: Quiz.', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['toplistDataShowIn_enabled'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'toplistActivated', 'inline_fields' => array( 'leaderboard_result_display_fields' => $this->settings_sub_option_fields['leaderboard_result_display_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['toplistDataShowIn_enabled'] ) ? 'open' : 'closed', ), 'toplistDataCaptcha' => array( 'name' => 'toplistDataCaptcha', 'type' => 'checkbox', 'label' => esc_html__( 'Really Simple CAPTCHA', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: links to Real Simple CAPTCHA. esc_html_x( 'This option requires additional plugin: %s', 'placeholder: links to Real Simple CAPTCHA', 'learndash' ), '
    Really Simple CAPTCHA' ), 'value' => $this->setting_option_values['toplistDataCaptcha'], 'parent_setting' => 'toplistActivated', 'default' => '', 'options' => array( 'on' => '', ), ), 'statisticsOn' => array( 'name' => 'statisticsOn', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Statistics', 'placeholder: Quiz.', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['statisticsOn'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['statisticsOn'] ) ? 'open' : 'closed', ), 'viewProfileStatistics' => array( 'name' => 'viewProfileStatistics', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Front-end Profile Display', 'learndash' ), 'value' => $this->setting_option_values['viewProfileStatistics'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'statisticsOn', ), 'statisticsIpLock_enabled' => array( 'name' => 'statisticsIpLock_enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Statistics IP-lock', 'learndash' ), 'value' => $this->setting_option_values['statisticsIpLock_enabled'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'statisticsOn', 'inline_fields' => array( 'quiz_statistics_ip_lock_fields' => $this->settings_sub_option_fields['quiz_statistics_ip_lock_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['statisticsIpLock_enabled'] ) ? 'open' : 'closed', ), 'email_enabled' => array( 'name' => 'email_enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Email Notifications', 'learndash' ), 'value' => $this->setting_option_values['email_enabled'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['email_enabled'] ) ? 'open' : 'closed', ), 'email_enabled_admin' => array( 'name' => 'email_enabled_admin', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Admin', 'learndash' ), 'value' => $this->setting_option_values['email_enabled_admin'], 'default' => '', 'options' => array( 'on' => '', ), 'inline_fields' => array( 'emailNotification_fields' => $this->settings_sub_option_fields['emailNotification_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['email_enabled_admin'] ) ? 'open' : 'closed', 'parent_setting' => 'email_enabled', ), 'userEmailNotification' => array( 'name' => 'userEmailNotification', 'type' => 'checkbox-switch', 'label' => esc_html__( 'User', 'learndash' ), 'value' => $this->setting_option_values['userEmailNotification'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'email_enabled', ), 'templates_enabled' => array( 'name' => 'templates_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz esc_html_x( '%s Templates', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['templates_enabled'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['templates_enabled'] ) ? 'open' : 'closed', ), 'templateLoadId' => array( 'name' => 'templateLoadId', 'type' => 'quiz-templates-load', 'label' => esc_html__( 'Use Template', 'learndash' ), 'value' => $this->setting_option_values['templateLoadId'], 'default' => '', 'template_type' => WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, 'parent_setting' => 'templates_enabled', ), 'templateSaveList' => array( 'name' => 'templateSaveList', 'type' => 'quiz-templates-save', 'label' => esc_html__( 'Save as Template', 'learndash' ), //'value' => $this->setting_option_values['templates_load'], //'default' => '', 'template_type' => WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, 'parent_setting' => 'templates_enabled', ), 'advanced_settings' => array( 'name' => 'advanced_settings', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Advanced Settings', 'learndash' ), 'value' => $this->setting_option_values['advanced_settings'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['advanced_settings'] ) ? 'open' : 'closed', ), 'timeLimitCookie_enabled' => array( 'name' => 'timeLimitCookie_enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Browser Cookie Answer Protection', 'learndash' ), 'value' => $this->setting_option_values['timeLimitCookie_enabled'], 'help_text' => sprintf( // translators: placeholder: quizzes esc_html_x( 'Browser cookies have limited memory. This may not work with large %s.', 'placeholder: quizzes', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ) ), 'default' => '', 'options' => array( 'on' => '', ), 'inline_fields' => array( 'timeLimitCookie_enabled_fields' => $this->settings_sub_option_fields['timeLimitCookie_enabled_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['timeLimitCookie_enabled'] ) ? 'open' : 'closed', 'parent_setting' => 'advanced_settings', ), 'associated_settings_enabled' => array( 'name' => 'associated_settings_enabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Associated Settings', 'learndash' ), 'value' => '', 'default' => '', 'options' => array( 'on' => '', ), 'inline_fields' => array( 'associated_settings_enabled_fields' => $this->settings_sub_option_fields['associated_settings_enabled_fields'], ), 'inner_section_state' => 'closed', 'parent_setting' => 'advanced_settings', ), ); // If the Real Simple CAPTCHA is not installed thenclear and disable the checkbox. if ( ! class_exists( 'ReallySimpleCaptcha' ) ) { if ( isset( $this->setting_option_fields['toplistDataCaptcha'] ) ) { $this->setting_option_fields['toplistDataCaptcha']['value'] = ''; $this->setting_option_fields['toplistDataCaptcha']['attrs'] = array( 'disabled' => 'disabled', ); } } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( isset( $settings_values['formActivated'] ) ) && ( 'on' === $settings_values['formActivated'] ) ) { $settings_values['formActivated'] = true; } else { $settings_values['formActivated'] = false; } if ( ( isset( $settings_values['toplistActivated'] ) ) && ( 'on' === $settings_values['toplistActivated'] ) ) { $settings_values['toplistActivated'] = true; } else { $settings_values['toplistActivated'] = false; } if ( ( isset( $settings_values['toplistDataAddMultiple'] ) ) && ( 'on' === $settings_values['toplistDataAddMultiple'] ) ) { $settings_values['toplistDataAddMultiple'] = true; } else { $settings_values['toplistDataAddMultiple'] = false; } if ( ( isset( $settings_values['toplistDataAddAutomatic'] ) ) && ( 'on' === $settings_values['toplistDataAddAutomatic'] ) ) { $settings_values['toplistDataAddAutomatic'] = true; } else { $settings_values['toplistDataAddAutomatic'] = false; } if ( ( isset( $settings_values['toplistDataShowIn_enabled'] ) ) && ( 'on' === $settings_values['toplistDataShowIn_enabled'] ) ) { if ( isset( $settings_values['toplistDataShowIn'] ) ) { $settings_values['toplistDataShowIn'] = absint( $settings_values['toplistDataShowIn'] ); if ( empty( $settings_values['toplistDataShowIn'] ) ) { $settings_values['toplistDataShowIn'] = 0; } } else { $settings_values['toplistDataShowIn'] = 0; } } else { $settings_values['toplistDataShowIn'] = 0; } if ( ( isset( $settings_values['toplistDataCaptcha'] ) ) && ( 'on' === $settings_values['toplistDataCaptcha'] ) ) { $settings_values['toplistDataCaptcha'] = true; } else { $settings_values['toplistDataCaptcha'] = false; } if ( true !== $settings_values['toplistActivated'] ) { $settings_values['toplistDataAddMultiple'] = false; $settings_values['toplistDataAddAutomatic'] = false; $settings_values['toplistDataShowIn'] = 0; $settings_values['toplistDataCaptcha'] = false; } if ( ( isset( $settings_values['statisticsOn'] ) ) && ( 'on' === $settings_values['statisticsOn'] ) ) { $settings_values['statisticsOn'] = true; } else { $settings_values['statisticsOn'] = false; } if ( ( isset( $settings_values['viewProfileStatistics'] ) ) && ( 'on' === $settings_values['viewProfileStatistics'] ) ) { $settings_values['viewProfileStatistics'] = true; } else { $settings_values['viewProfileStatistics'] = false; } if ( ( isset( $settings_values['statisticsIpLock_enabled'] ) ) && ( 'on' === $settings_values['statisticsIpLock_enabled'] ) ) { if ( isset( $settings_values['statisticsIpLock'] ) ) { $settings_values['statisticsIpLock'] = absint( $settings_values['statisticsIpLock'] ) * 60; if ( empty( $settings_values['statisticsIpLock'] ) ) { $settings_values['statisticsIpLock'] = 0; } } else { $settings_values['statisticsIpLock'] = 0; } } else { $this->setting_option_values['statisticsIpLock'] = 0; } // Main Email notification switch. if ( ( isset( $settings_values['email_enabled'] ) ) && ( 'on' === $settings_values['email_enabled'] ) ) { if ( ( isset( $settings_values['email_enabled_admin'] ) ) && ( 'on' === $settings_values['email_enabled_admin'] ) ) { if ( ( isset( $settings_values['emailNotification'] ) ) && ( ( $settings_values['emailNotification'] == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL ) || ( $settings_values['emailNotification'] == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER ) ) ) { $settings_values['emailNotification'] = $settings_values['emailNotification']; } else { $settings_values['emailNotification'] = WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_NONE; } } else { $settings_values['emailNotification'] = WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_NONE; } if ( ( isset( $settings_values['userEmailNotification'] ) ) && ( 'on' === $settings_values['userEmailNotification'] ) ) { $settings_values['userEmailNotification'] = true; } else { $settings_values['userEmailNotification'] = false; } } else { $settings_values['emailNotification'] = WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_NONE; $settings_values['userEmailNotification'] = false; } if ( ( isset( $settings_values['templates_enabled'] ) ) && ( 'on' === $settings_values['templates_enabled'] ) ) { if ( '-1' === $_POST['templateSaveList'] ) { $_POST['templateSaveList'] = ''; } if ( "0" === $_POST['templateSaveList'] ) { if ( empty( $_POST['templateName'] ) ) { $_POST['templateSaveList'] = ''; } } else if ( '' !== $_POST['templateSaveList'] ) { $_POST['templateName'] = ''; } } else { $_POST['templateSaveList'] = ''; $_POST['templateName'] = ''; } if ( ( isset( $settings_values['timeLimitCookie_enabled'] ) ) && ( 'on' === $settings_values['timeLimitCookie_enabled'] ) ) { if ( ( isset( $settings_values['timeLimitCookie'] ) ) && ( ! empty( $settings_values['timeLimitCookie'] ) ) ) { $timeLimit_cookie = absint( $settings_values['timeLimitCookie'] ); if ( ! empty( $timeLimit_cookie ) ) { $settings_values['timeLimitCookie'] = $timeLimit_cookie; } else { $settings_values['timeLimitCookie'] = ''; } } } else { $settings_values['timeLimitCookie'] = ''; } if ( '-1' === $settings_values['quiz_pro'] ) { $settings_values['quiz_pro'] = ''; } /** * We set the value from the settings if empty to prevent the ProQuiz logic from * assigning a new pro_quiz ID. */ if ( empty( $settings_values['quiz_pro'] ) ) { $settings_values['quiz_pro'] = learndash_get_setting( get_the_ID(), 'quiz_pro' ); } if ( 'new' === $settings_values['quiz_pro'] ) { $settings_values['quiz_pro'] = ''; } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'quiz' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings'] = LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\Yƃ+YYKsettings-metaboxes/class-ld-settings-metabox-course-navigation-settings.phpnuW+Asettings_screen_id = 'sfwd-courses'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-course-navigation-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: course. esc_html_x( '%s Navigation Settings', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ); $this->settings_section_description = esc_html__( 'Controls how users interact with the content and their navigational experience', 'learndash' ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'course_disable_lesson_progression' => 'course_disable_lesson_progression', ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['course_disable_lesson_progression'] ) ) { $this->setting_option_values['course_disable_lesson_progression'] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $field_name_wrap = false; $this->setting_option_fields = array( 'course_disable_lesson_progression' => array( 'name' => 'course_disable_lesson_progression', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Progression', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'radio', 'options' => array( '' => array( 'label' => esc_html__( 'Linear', 'learndash' ), 'description' => sprintf( // translators: placeholder: Course. esc_html_x( 'Requires the user to progress through the %s in the designated step sequence', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'on' => array( 'label' => esc_html__( 'Free form', 'learndash' ), 'description' => sprintf( // translators: placeholder: Course. esc_html_x( 'Allows the user to move freely through the %s without following the designated step sequence', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), ), 'value' => $this->setting_option_values['course_disable_lesson_progression'], 'default' => '', ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ! isset( $settings_values['course_disable_lesson_progression'] ) ) { $settings_values['course_disable_lesson_progression'] = ''; } $settings_values = apply_filters( 'learndash_settings_save_values', $settings_values, $this->settings_metabox_key ); } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'course' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Course_Navigation_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Course_Navigation_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Course_Navigation_Settings'] = LearnDash_Settings_Metabox_Course_Navigation_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\g?Fsettings-metaboxes/class-ld-settings-metabox-topic-display-content.phpnuW+Asettings_screen_id = 'sfwd-topic'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-topic-display-content-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Display and Content Options', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: topic. esc_html_x( 'Controls the look and feel of the %s and optional content settings', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( // New fields 'topic_materials_enabled' => 'topic_materials_enabled', 'topic_materials' => 'topic_materials', 'lesson_video_enabled' => 'lesson_video_enabled', 'lesson_video_url' => 'lesson_video_url', 'lesson_video_shown' => 'lesson_video_shown', 'lesson_video_auto_start' => 'lesson_video_auto_start', 'lesson_video_show_controls' => 'lesson_video_show_controls', 'lesson_video_auto_complete' => 'lesson_video_auto_complete', 'lesson_video_auto_complete_delay' => 'lesson_video_auto_complete_delay', 'lesson_video_hide_complete_button' => 'lesson_video_hide_complete_button', 'lesson_video_show_complete_button' => 'lesson_video_show_complete_button', 'lesson_assignment_upload' => 'lesson_assignment_upload', 'assignment_upload_limit_extensions' => 'assignment_upload_limit_extensions', 'assignment_upload_limit_size' => 'assignment_upload_limit_size', 'lesson_assignment_points_enabled' => 'lesson_assignment_points_enabled', 'lesson_assignment_points_amount' => 'lesson_assignment_points_amount', 'assignment_upload_limit_count' => 'assignment_upload_limit_count', 'lesson_assignment_deletion_enabled' => 'lesson_assignment_deletion_enabled', 'auto_approve_assignment' => 'auto_approve_assignment', 'forced_lesson_time_enabled' => 'forced_lesson_time_enabled', 'forced_lesson_time' => 'forced_lesson_time', //'forced_lesson_time_cookie_key' => 'forced_lesson_time_cookie_key', ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { global $sfwd_lms; $post_settings_fields = $sfwd_lms->get_post_args_section( $this->settings_screen_id, 'fields' ); parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['topic_materials'] ) ) { $this->setting_option_values['topic_materials'] = ''; } if ( ! empty( $this->setting_option_values['topic_materials'] ) ) { $this->setting_option_values['topic_materials_enabled'] = 'on'; } else { $this->setting_option_values['topic_materials_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_enabled'] ) ) { $this->setting_option_values['lesson_video_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_url'] ) ) { $this->setting_option_values['lesson_video_url'] = ''; } if ( ( ! isset( $this->setting_option_values['lesson_video_shown'] ) ) || ( empty( $this->setting_option_values['lesson_video_shown'] ) ) ) { $this->setting_option_values['lesson_video_shown'] = 'BEFORE'; } if ( ! isset( $this->setting_option_values['lesson_video_auto_start'] ) ) { $this->setting_option_values['lesson_video_auto_start'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_show_controls'] ) ) { $this->setting_option_values['lesson_video_show_controls'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_auto_complete'] ) ) { $this->setting_option_values['lesson_video_auto_complete'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_auto_complete_delay'] ) ) { $this->setting_option_values['lesson_video_auto_complete_delay'] = '0'; } if ( ! isset( $this->setting_option_values['lesson_video_hide_complete_button'] ) ) { $this->setting_option_values['lesson_video_hide_complete_button'] = ''; } if ( 'on' === $this->setting_option_values['lesson_video_hide_complete_button'] ) { $this->setting_option_values['lesson_video_show_complete_button'] = ''; } else { $this->setting_option_values['lesson_video_show_complete_button'] = 'on'; } if ( ! isset( $this->setting_option_values['lesson_assignment_upload'] ) ) { $this->setting_option_values['lesson_assignment_upload'] = ''; } if ( ! isset( $this->setting_option_values['assignment_upload_limit_extensions'] ) ) { $this->setting_option_values['assignment_upload_limit_extensions'] = ''; } if ( ! isset( $this->setting_option_values['assignment_upload_limit_size'] ) ) { $this->setting_option_values['assignment_upload_limit_size'] = ''; } if ( ! isset( $this->setting_option_values['lesson_assignment_points_enabled'] ) ) { $this->setting_option_values['lesson_assignment_points_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_assignment_points_amount'] ) ) { $this->setting_option_values['lesson_assignment_points_amount'] = ''; } if ( ! isset( $this->setting_option_values['assignment_upload_limit_count'] ) ) { $this->setting_option_values['assignment_upload_limit_count'] = ''; } $this->setting_option_values['assignment_upload_limit_count'] = absint( $this->setting_option_values['assignment_upload_limit_count'] ); if ( empty( $this->setting_option_values['assignment_upload_limit_count'] ) ) { $this->setting_option_values['assignment_upload_limit_count'] = 1; } if ( ! isset( $this->setting_option_values['lesson_assignment_deletion_enabled'] ) ) { $this->setting_option_values['lesson_assignment_deletion_enabled'] = ''; } if ( ! isset( $this->setting_option_values['auto_approve_assignment'] ) ) { $this->setting_option_values['auto_approve_assignment'] = 'on'; } if ( ! isset( $this->setting_option_values['forced_lesson_time'] ) ) { $this->setting_option_values['forced_lesson_time'] = ''; } if ( ! isset( $this->setting_option_values['forced_lesson_time_enabled'] ) ) { $this->setting_option_values['forced_lesson_time_enabled'] = ''; } if ( ( isset( $this->setting_option_values['forced_lesson_time'] ) ) && ( ! empty( $this->setting_option_values['forced_lesson_time'] ) ) ) { $this->setting_option_values['forced_lesson_time_enabled'] = 'on'; } else { $this->setting_option_values['forced_lesson_time_enabled'] = ''; } } if ( 'on' === $this->setting_option_values['lesson_video_enabled'] ) { $this->setting_option_values['lesson_assignment_upload'] = ''; $this->setting_option_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $this->setting_option_values['lesson_assignment_upload'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $this->setting_option_values['forced_lesson_time_enabled'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['lesson_assignment_upload'] = ''; } if ( 'on' !== $this->setting_option_values['lesson_video_enabled'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['lesson_video_url'] = ''; $this->setting_option_values['lesson_video_shown'] = ''; $this->setting_option_values['lesson_video_auto_start'] = ''; $this->setting_option_values['lesson_video_show_controls'] = ''; $this->setting_option_values['lesson_video_auto_complete'] = ''; $this->setting_option_values['lesson_video_auto_complete_delay'] = '0'; $this->setting_option_values['lesson_video_show_complete_button'] = ''; } elseif ( 'on' !== $this->setting_option_values['lesson_assignment_upload'] ) { $this->setting_option_values['lesson_assignment_upload'] = ''; $this->setting_option_values['assignment_upload_limit_extensions'] = ''; $this->setting_option_values['assignment_upload_limit_size'] = ''; $this->setting_option_values['lesson_assignment_points_enabled'] = ''; $this->setting_option_values['lesson_assignment_points_amount'] = ''; $this->setting_option_values['assignment_upload_limit_count'] = ''; $this->setting_option_values['lesson_assignment_deletion_enabled'] = ''; $this->setting_option_values['auto_approve_assignment'] = 'on'; } elseif ( 'on' !== $this->setting_option_values['forced_lesson_time_enabled'] ) { $this->setting_option_values['forced_lesson_time_enabled'] = ''; $this->setting_option_values['forced_lesson_time'] = ''; //$this->setting_option_values['forced_lesson_time_cookie_key'] = ''; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $this->setting_option_fields = array( 'lesson_video_auto_complete' => array( 'name' => 'lesson_video_auto_complete', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s auto-completion', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), 'default' => '', 'value' => $this->setting_option_values['lesson_video_auto_complete'], 'options' => array( '' => '', 'on' => '', ), 'help_text' => sprintf( // translators: placeholder: topic. esc_html_x( ' Automatically mark the %s as completed once the user has watched the full video.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), ), 'lesson_video_auto_complete_delay' => array( 'name' => 'lesson_video_auto_complete_delay', 'label' => esc_html__( 'Completion delay', 'learndash' ), 'type' => 'number', 'class' => '-small', 'default' => 0, 'value' => $this->setting_option_values['lesson_video_auto_complete_delay'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'input_label' => esc_html__( 'seconds', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: topic. esc_html_x( 'Specify a delay between video completion and %s completion.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'default' => 0, ), 'lesson_video_show_complete_button' => array( 'name' => 'lesson_video_show_complete_button', 'label' => esc_html__( 'Mark Complete Button', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => sprintf( // translators: placeholder: lesson. esc_html_x( 'Display the Mark Complete button on a %s even if not yet clickable.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => $this->setting_option_values['lesson_video_show_complete_button'], 'default' => '', 'options' => array( 'on' => '', ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['video_display_timing_after_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'assignment_upload_limit_count' => array( 'name' => 'assignment_upload_limit_count', 'label' => esc_html__( 'Limit number of uploaded files', 'learndash' ), 'type' => 'number', 'value' => $this->setting_option_values['assignment_upload_limit_count'], 'default' => '1', 'class' => 'small-text', 'input_label' => esc_html__( 'file(s) maximum', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 1, ), 'help_text' => esc_html__( 'Specify the maximum number of files a user can upload for this assignment.', 'learndash' ), ), 'lesson_assignment_deletion_enabled' => array( 'name' => 'lesson_assignment_deletion_enabled', 'label' => esc_html__( 'Allow file deletion', 'learndash' ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['lesson_assignment_deletion_enabled'], 'default' => '', 'help_text' => esc_html__( 'Allow the user to delete their own uploaded files. This is only possible up until the assignment has been approved.', 'learndash' ), 'options' => array( 'on' => '', ), 'default' => 0, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['lesson_assignment_grading_manual_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'topic_materials_enabled' => array( 'name' => 'topic_materials_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Materials', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), 'help_text' => sprintf( // translators: placeholder: topic, topic. esc_html_x( 'List and display support materials for the %1$s. This is visible to any user having access to the %2$s.', 'placeholder: topic, topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ), learndash_get_custom_label_lower( 'topic' ) ), 'value' => $this->setting_option_values['topic_materials_enabled'], 'default' => '', 'options' => array( 'on' => sprintf( // translators: placeholder: topic. esc_html_x( 'Any content added below is displayed on the %s page', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), '' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['topic_materials_enabled'] ) ? 'open' : 'closed', ), 'topic_materials' => array( 'name' => 'topic_materials', 'type' => 'wpeditor', 'parent_setting' => 'topic_materials_enabled', 'value' => $this->setting_option_values['topic_materials'], 'default' => '', 'placeholder' => esc_html__( 'Add a list of needed documents or URLs. This field supports HTML.', 'learndash' ), 'editor_args' => array( 'textarea_name' => $this->settings_metabox_key . '[topic_materials]', 'textarea_rows' => 3, ), ), 'lesson_video_enabled' => array( 'name' => 'lesson_video_enabled', 'label' => esc_html__( 'Video Progression', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => sprintf( // translators: placeholder: Course. esc_html_x( 'Require users to watch the full video as part of the %s progression. Use shortcode [ld_video] to move within the post content.', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['lesson_video_enabled'], 'default' => '', 'options' => array( '' => '', 'on' => array( 'label' => sprintf( // translators: placeholder: Course. esc_html_x( 'The below video is tied to %s progression', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'description' => '', 'tooltip' => sprintf( // translators: placeholder: Topic. esc_html_x( 'Cannot be enabled while %s timer or Assignments are enabled', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_video_enabled'] ) ? 'open' : 'closed', ), 'lesson_video_url' => array( 'name' => 'lesson_video_url', 'label' => esc_html__( 'Video URL', 'learndash' ), 'type' => 'textarea', 'class' => 'full-text', 'value' => $this->setting_option_values['lesson_video_url'], 'default' => '', 'placeholder' => esc_html__( 'Input URL, iFrame, or shortcode here.', 'learndash' ), 'attrs' => array( 'rows' => '1', 'cols' => '57', ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_video_shown' => array( 'name' => 'lesson_video_shown', 'label' => esc_html__( 'Display Timing', 'learndash' ), 'type' => 'radio', 'value' => $this->setting_option_values['lesson_video_shown'], 'default' => 'AFTER', 'parent_setting' => 'lesson_video_enabled', 'options' => array( 'BEFORE' => array( 'label' => esc_html__( 'Before completed sub-steps', 'learndash' ), 'description' => sprintf( // translators: placeholder: topic. esc_html_x( 'The video will be shown and must be fully watched before the user can access the %s’s associated steps.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), ), 'AFTER' => array( 'label' => esc_html__( 'After completing sub-steps', 'learndash' ), 'description' => sprintf( // translators: placeholder: topic, topic. esc_html_x( 'The video will be visible after the user has completed the %1$s’s associated steps. The full video must be watched in order to complete the %2$s.', 'placeholder: topic, topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ), learndash_get_custom_label_lower( 'topic' ) ), 'inline_fields' => array( 'lesson_video_display_timing_after' => $this->settings_sub_option_fields['video_display_timing_after_fields'], ), 'inner_section_state' => ( 'AFTER' === $this->setting_option_values['lesson_video_shown'] ) ? 'open' : 'closed', ), ), ), 'lesson_video_auto_start' => array( 'name' => 'lesson_video_auto_start', 'label' => esc_html__( 'Autostart', 'learndash' ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['lesson_video_auto_start'], 'default' => '', 'options' => array( 'on' => esc_html__( 'The video now starts automatically on page load', 'learndash' ), '' => '', ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_video_show_controls' => array( 'name' => 'lesson_video_show_controls', 'label' => esc_html__( 'Video Controls Display', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => esc_html__( 'Only available for YouTube and local videos.', 'learndash' ), 'value' => $this->setting_option_values['lesson_video_show_controls'], 'default' => '', 'options' => array( '' => '', 'on' => esc_html__( 'Users can pause, move backward and forward within the video', 'learndash' ), ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_assignment_upload' => array( 'name' => 'lesson_assignment_upload', 'label' => esc_html__( 'Assignment Uploads', 'learndash' ), 'type' => 'checkbox-switch', 'default' => '', 'value' => $this->setting_option_values['lesson_assignment_upload'], 'options' => array( 'on' => array( 'label' => '', 'description' => '', 'tooltip' => sprintf( // translators: placeholder: topic. esc_html_x( 'Cannot be enabled while %s timer or Video progression are enabled', 'placeholder: toic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_assignment_upload'] ) ? 'open' : 'closed', ), 'assignment_upload_limit_extensions' => array( 'name' => 'assignment_upload_limit_extensions', 'label' => esc_html__( 'File Extensions', 'learndash' ), 'type' => 'text', 'placeholder' => esc_html__( 'pdf, xls, zip', 'learndash' ), 'help_text' => esc_html__( 'Specify the type of files users can upload. Leave blank for any.', 'learndash' ), 'class' => '-small', 'default' => '', 'value' => $this->setting_option_values['assignment_upload_limit_extensions'], 'parent_setting' => 'lesson_assignment_upload', ), 'assignment_upload_limit_size' => array( 'name' => 'assignment_upload_limit_size', 'label' => esc_html__( 'File Size Limit', 'learndash' ), 'type' => 'text', 'class' => '-small', 'placeholder' => sprintf( // translators: placeholder: PHP file upload size. esc_html_x( '%s', 'placeholder: PHP file upload size', 'learndash' ), ini_get( 'upload_max_filesize' ) ), 'help_text' => sprintf( // translators: placeholder: PHP file upload size. esc_html_x( 'Default maximum file size supported is: %s', 'placeholder: PHP file upload size', 'learndash' ), ini_get( 'upload_max_filesize' ) ), 'default' => '', 'value' => $this->setting_option_values['assignment_upload_limit_size'], 'parent_setting' => 'lesson_assignment_upload', ), 'lesson_assignment_points_enabled' => array( 'name' => 'lesson_assignment_points_enabled', 'label' => esc_html__( 'Points', 'learndash' ), 'type' => 'checkbox-switch', 'default' => 0, 'value' => $this->setting_option_values['lesson_assignment_points_enabled'], 'options' => array( 'on' => esc_html__( 'Award points for submitting assignments', 'learndash' ), '' => '', ), 'parent_setting' => 'lesson_assignment_upload', 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_assignment_points_enabled'] ) ? 'open' : 'closed', ), 'lesson_assignment_points_amount' => array( 'name' => 'lesson_assignment_points_amount', 'type' => 'number', 'class' => '-small', 'attrs' => array( 'step' => 1, 'min' => 0, ), 'default' => 0, 'value' => $this->setting_option_values['lesson_assignment_points_amount'], 'input_label' => esc_html__( 'available point(s)', 'learndash' ), 'parent_setting' => 'lesson_assignment_points_enabled', ), 'auto_approve_assignment' => array( 'name' => 'auto_approve_assignment', 'label' => esc_html__( 'Grading Type', 'learndash' ), 'type' => 'radio', 'value' => $this->setting_option_values['auto_approve_assignment'], 'parent_setting' => 'lesson_assignment_upload', 'options' => array( 'on' => array( 'label' => esc_html__( 'Auto-approve', 'learndash' ), 'description' => esc_html__( 'No grading or approval needed. The assignment will be automatically approved and full points will be awarded.', 'learndash' ), ), '' => array( 'label' => esc_html__( 'Manually grade', 'learndash' ), 'description' => sprintf( // translators: placeholder: topic. esc_html_x( 'Admin or group leader approval and grading required. The %s cannot be completed until the assignment is approved.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'inline_fields' => array( 'lesson_assignment_grading_manual' => $this->settings_sub_option_fields['lesson_assignment_grading_manual_fields'], ), 'inner_section_state' => ( '' === $this->setting_option_values['auto_approve_assignment'] ) ? 'open' : 'closed', ), ), ), 'forced_lesson_time_enabled' => array( 'name' => 'forced_lesson_time_enabled', 'label' => sprintf( // translators: placeholder: Topic. esc_html_x( '%s Timer', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ), 'default' => '', 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['forced_lesson_time_enabled'], 'help_text' => sprintf( // translators: placeholder: topic. esc_html_x( 'The %s cannot be marked as completed until the set time has elapsed.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label_lower( 'topic' ) ), 'options' => array( 'on' => array( 'label' => '', 'description' => '', 'tooltip' => esc_html__( 'Cannot be enabled while Video progression or Assignments are enabled', 'learndash' ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['forced_lesson_time_enabled'] ) ? 'open' : 'closed', ), 'forced_lesson_time' => array( 'name' => 'forced_lesson_time', 'type' => 'timer-entry', 'class' => 'small-text', 'default' => '', 'value' => $this->setting_option_values['forced_lesson_time'], 'parent_setting' => 'forced_lesson_time_enabled', ), ); if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { unset( $this->setting_option_fields['course'] ); unset( $this->setting_option_fields['lesson'] ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( 'on' !== $settings_values['topic_materials_enabled'] ) || ( empty( $settings_values['topic_materials'] ) ) ) { $settings_values['topic_materials_enabled'] = ''; $settings_values['topic_materials'] = ''; } // If video progression is enables but the video URL is empty then turn off video progression. if ( ( 'on' !== $settings_values['lesson_video_enabled'] ) || ( empty( $settings_values['lesson_video_url'] ) ) ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_video_url'] = ''; } if ( ( 'on' !== $settings_values['forced_lesson_time_enabled'] ) || ( empty( $settings_values['forced_lesson_time'] ) ) ) { $settings_values['forced_lesson_time_enabled'] = ''; $settings_values['forced_lesson_time'] = ''; //$settings_values['forced_lesson_time_cookie_key'] = ''; } if ( ( 'on' !== $settings_values['lesson_assignment_points_enabled'] ) || ( empty( $settings_values['lesson_assignment_points_amount'] ) ) ) { $settings_values['lesson_assignment_points_amount'] = ''; $settings_values['lesson_assignment_points_enabled'] = ''; } if ( 'on' === $settings_values['lesson_video_enabled'] ) { $settings_values['lesson_assignment_upload'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $settings_values['lesson_assignment_upload'] ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $settings_values['forced_lesson_time_enabled'] ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_assignment_upload'] = ''; } else { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_assignment_upload'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } if ( 'on' !== $settings_values['lesson_video_enabled'] ) { $settings_values['lesson_video_url'] = ''; $settings_values['lesson_video_shown'] = ''; $settings_values['lesson_video_auto_start'] = ''; $settings_values['lesson_video_show_controls'] = ''; $settings_values['lesson_video_auto_complete'] = ''; $settings_values['lesson_video_auto_complete_delay'] = ''; $settings_values['lesson_video_show_complete_button'] = ''; $settings_values['lesson_video_hide_complete_button'] = ''; } if ( 'on' !== $settings_values['lesson_assignment_upload'] ) { $settings_values['assignment_upload_limit_extensions'] = ''; $settings_values['assignment_upload_limit_size'] = ''; $settings_values['lesson_assignment_points_enabled'] = ''; $settings_values['lesson_assignment_points_amount'] = ''; $settings_values['assignment_upload_limit_count'] = ''; $settings_values['lesson_assignment_deletion_enabled'] = ''; $settings_values['auto_approve_assignment'] = ''; } if ( 'on' !== $settings_values['forced_lesson_time_enabled'] ) { $settings_values['forced_lesson_time_enabled'] = ''; $settings_values['forced_lesson_time'] = ''; //$settings_values['forced_lesson_time_cookie_key'] = ''; } if ( 'on' === $settings_values['lesson_video_enabled'] ) { if ( ( 'on' === $settings_values['lesson_video_show_complete_button'] ) ) { $settings_values['lesson_video_hide_complete_button'] = ''; } else { $settings_values['lesson_video_hide_complete_button'] = 'on'; } } if ( 'on' === $settings_values['lesson_assignment_upload'] ) { if ( ! empty( $settings_values['assignment_upload_limit_extensions'] ) ) { $settings_values['assignment_upload_limit_extensions'] = learndash_validate_extensions( $settings_values['assignment_upload_limit_extensions'] ); } if ( ! empty( $settings_values['assignment_upload_limit_size'] ) ) { $limit_file_size = learndash_return_bytes_from_shorthand( $settings_values['assignment_upload_limit_size'] ); $wp_limit_file_size = wp_max_upload_size(); if ( $limit_file_size > $wp_limit_file_size ) { $settings_values['assignment_upload_limit_size'] = ''; } } } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'topic' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Topic_Display_Content'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Topic_Display_Content' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Topic_Display_Content'] = LearnDash_Settings_Metabox_Topic_Display_Content::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\|6|6Esettings-metaboxes/class-ld-settings-metabox-quiz-access-settings.phpnuW+Asettings_screen_id = 'sfwd-quiz'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-quiz-access-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Access Settings', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ); $this->settings_section_description = sprintf( // translators: placeholder: quiz. esc_html_x( 'Controls the requirements for accessing the %s', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'course' => 'course', 'lesson' => 'lesson', 'startOnlyRegisteredUser' => 'startOnlyRegisteredUser', 'prerequisite' => 'prerequisite', 'prerequisiteList' => 'prerequisiteList', ); parent::__construct(); } /** * Used to save the settings fields back to the global $_POST object so * the WPProQuiz normal form processing can take place. * * @since 3.0 * @param object $pro_quiz_edit WpProQuiz_Controller_Quiz instance (not used). * @param array $settings_values Array of settings fields. */ public function save_fields_to_post( $pro_quiz_edit, $settings_values = array() ) { $_POST['prerequisite'] = $settings_values['prerequisite']; $_POST['prerequisiteList'] = $settings_values['prerequisiteList']; $_POST['startOnlyRegisteredUser'] = $settings_values['startOnlyRegisteredUser']; } /** * Hook into filter before the metabox is registered in WP. * * @since 3.0 * @param boolean $show_metabox True or False to show metabox. * @param string $settings_metabox_key metabox key. * @return boolean $show_metabox */ /* public function check_show_metabox( $show_metabox, $settings_metabox_key = '' ) { if ( $settings_metabox_key === $this->settings_metabox_key ) { // IF Course shared Steps is enabled we don't show this metabox. if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { $show_metabox = false; } } return $show_metabox; } */ /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['course'] ) ) { $this->setting_option_values['course'] = ''; } if ( ! isset( $this->setting_option_values['lesson'] ) ) { $this->setting_option_values['lesson'] = ''; } $this->quiz_edit = $this->init_quiz_edit( $this->_post ); if ( $this->quiz_edit['quiz'] ) { $this->setting_option_values['startOnlyRegisteredUser'] = $this->quiz_edit['quiz']->isStartOnlyRegisteredUser(); if ( true === $this->setting_option_values['startOnlyRegisteredUser'] ) { $this->setting_option_values['startOnlyRegisteredUser'] = 'on'; } else { $this->setting_option_values['startOnlyRegisteredUser'] = ''; } } if ( $this->quiz_edit['prerequisiteQuizList'] ) { $this->setting_option_values['prerequisiteList'] = $this->quiz_edit['prerequisiteQuizList']; } else { $this->setting_option_values['prerequisiteList'] = array(); } } foreach ( $this->settings_fields_map as $_internal => $_external ) { if ( ! isset( $this->setting_option_values[ $_internal ] ) ) { $this->setting_option_values[ $_internal ] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $select_course_options = $sfwd_lms->select_a_course(); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_course_options_default = array( '-1' => sprintf( // translators: placeholder: course. esc_html_x( 'Search or select a %s…', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } else { $select_course_options_default = array( '' => sprintf( // translators: placeholder: course. esc_html_x( 'Select %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } $select_course_options = $select_course_options_default + $select_course_options; if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_lesson_options_default = array( '-1' => sprintf( // translators: placeholder: Lesson, Topic. esc_html_x( 'Search or select a %1$s or %2$s…', 'placeholder: Lesson, Topic', 'learndash' ), learndash_get_custom_label( 'lesson' ), learndash_get_custom_label( 'topic' ) ), ); } else { $select_lesson_options_default = array( '' => sprintf( // translators: placeholder: Lesson, Topic. esc_html_x( 'Select a %1$s or %2$s', 'placeholder: Lesson, Topic', 'learndash' ), learndash_get_custom_label( 'lesson' ), learndash_get_custom_label( 'topic' ) ), ); } $select_lesson_options = array(); if ( ( isset( $this->setting_option_values['course'] ) ) && ( ! empty( $this->setting_option_values['course'] ) ) ) { $select_lesson_options = $sfwd_lms->select_a_lesson_or_topic( absint( $this->setting_option_values['course'] ) ); if ( ( is_array( $select_lesson_options ) ) && ( ! empty( $select_lesson_options ) ) ) { if ( isset( $select_lesson_options[0] ) ) { unset( $select_lesson_options[0] ); } $select_lesson_options = $select_lesson_options_default + $select_lesson_options; } else { $select_lesson_options = $select_lesson_options_default; } } else { $select_lesson_options = $select_lesson_options_default; } if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_quiz_prerequisite_options_default = array( '-1' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'No previous %s required', 'placeholder: Quiz.', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ); } else { $select_quiz_prerequisite_options_default = array( '' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'No previous %s required', 'placeholder: Quiz.', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ); } $quiz_mapper = new WpProQuiz_Model_QuizMapper(); $prerequisite_quizzes = $quiz_mapper->fetchAllAsArray( array( 'id', 'name' ), array() ); $select_quiz_prerequisite_options = array(); if ( ! empty( $prerequisite_quizzes ) ) { foreach ( $prerequisite_quizzes as $quiz_set ) { if ( absint( $quiz_set['id'] ) !== absint( $this->quiz_edit['quiz']->getId() ) ) { $select_quiz_prerequisite_options[ $quiz_set['id'] ] = $quiz_set['name']; } } } if ( ( is_array( $select_quiz_prerequisite_options ) ) && ( ! empty( $select_quiz_prerequisite_options ) ) ) { $select_quiz_prerequisite_options = $select_quiz_prerequisite_options_default + $select_quiz_prerequisite_options; } else { $select_quiz_prerequisite_options = $select_quiz_prerequisite_options_default; } $this->setting_option_fields = array( 'course' => array( 'name' => 'course', 'label' => sprintf( // translators: Associated Course Label. esc_html_x( 'Associated %s', 'Associated Course Label', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'select', 'default' => '', 'value' => $this->setting_option_values['course'], 'options' => $select_course_options, 'attrs' => array( 'data-ld_selector_nonce' => wp_create_nonce( 'sfwd-courses' ), 'data-ld_selector_default' => '1', ), ), 'lesson' => array( 'name' => 'lesson', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Associated %s', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'type' => 'select', 'default' => '', 'value' => $this->setting_option_values['lesson'], 'options' => $select_lesson_options, 'attrs' => array( 'data-ld_selector_nonce' => wp_create_nonce( 'sfwd-lessons' ), 'data-ld_selector_default' => '1', ), ), 'prerequisiteList' => array( 'name' => 'prerequisiteList', 'type' => 'multiselect', //'multiple' => 'true', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Prerequisites', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholderss: quizzes, quiz. esc_html_x( 'Select one or more %1$s that must be completed prior to taking this %2$s.', 'placeholderss: Quizzes Quiz', 'learndash' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'quiz' ) ), 'placeholder' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'No previous %s required', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'default' => '', 'value' => $this->setting_option_values['prerequisiteList'], 'options' => $select_quiz_prerequisite_options, ), 'startOnlyRegisteredUser' => array( 'name' => 'startOnlyRegisteredUser', 'type' => 'checkbox', 'label' => esc_html__( 'Allowed Users', 'learndash' ), 'value' => $this->setting_option_values['startOnlyRegisteredUser'], 'help_text' => sprintf( // translators: placeholders: quizzes, courses, quiz. esc_html_x( 'This option is especially useful if administering %1$s via shortcodes on non-course pages, or if your %2$s are open but you wish only authenticated users to take the %3$s.', 'placeholders: quizzes, courses, quiz.', 'learndash' ), learndash_get_custom_label( 'quizzes' ), learndash_get_custom_label( 'course' ), learndash_get_custom_label( 'quiz' ) ), 'default' => '', 'options' => array( 'on' => sprintf( //translators: placeholder: quiz. esc_html_x( 'Only registered users can take this quiz', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ), ), ); if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { unset( $this->setting_option_fields['course'] ); unset( $this->setting_option_fields['lesson'] ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( ! isset( $settings_values['course'] ) ) || ( '-1' === $settings_values['course'] ) ) { $settings_values['course'] = ''; } if ( ( ! isset( $settings_values['lesson'] ) ) || ( '-1' === $settings_values['lesson'] ) ) { $settings_values['lesson'] = ''; } if ( ( isset( $settings_values['startOnlyRegisteredUser'] ) ) && ( 'on' === $settings_values['startOnlyRegisteredUser'] ) ) { $settings_values['startOnlyRegisteredUser'] = true; } else { $settings_values['startOnlyRegisteredUser'] = false; } if ( ! isset( $settings_values['prerequisiteList'] ) ) { $settings_values['prerequisiteList'] = ''; } if ( '-1' === $settings_values['prerequisiteList'] ) { $settings_values['prerequisiteList'] = ''; } if ( ! empty( $settings_values['prerequisiteList'] ) ) { $settings_values['prerequisite'] = true; } else { $settings_values['prerequisite'] = ''; } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'quiz' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Quiz_Access_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Quiz_Access_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Quiz_Access_Settings'] = LearnDash_Settings_Metabox_Quiz_Access_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\uFzMzMGsettings-metaboxes/class-ld-settings-metabox-course-display-content.phpnuW+Asettings_screen_id = 'sfwd-courses'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-course-display-content-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Display and Content Options', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: course. esc_html_x( 'Controls the look and feel of the %s and optional content settings', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( // New fields 'course_materials_enabled' => 'course_materials_enabled', //'course_topics_per_page' => 'course_topics_per_page', 'course_lesson_order_enabled' => 'course_lesson_order_enabled', // Legacy fields 'course_materials' => 'course_materials', 'certificate' => 'certificate', 'course_disable_content_table' => 'course_disable_content_table', 'course_lesson_per_page' => 'course_lesson_per_page', 'course_lesson_per_page_custom' => 'course_lesson_per_page_custom', 'course_topic_per_page_custom' => 'course_topic_per_page_custom', 'course_lesson_orderby' => 'course_lesson_orderby', 'course_lesson_order' => 'course_lesson_order', ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { global $sfwd_lms; parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['course_materials_enabled'] ) ) { $this->setting_option_values['course_materials_enabled'] = ''; if ( ( isset( $this->setting_option_values['course_materials'] ) ) && ( ! empty( $this->setting_option_values['course_materials'] ) ) ) { $this->setting_option_values['course_materials_enabled'] = 'on'; } } if ( ! isset( $this->setting_option_values['course_materials'] ) ) { $this->setting_option_values['course_materials'] = ''; } if ( ! isset( $this->setting_option_values['certificate'] ) ) { $this->setting_option_values['certificate'] = ''; } if ( ! isset( $this->setting_option_values['course_disable_content_table'] ) ) { $this->setting_option_values['course_disable_content_table'] = ''; } if ( ! isset( $this->setting_option_values['course_lesson_per_page'] ) ) { $this->setting_option_values['course_lesson_per_page'] = ''; } if ( 'CUSTOM' === $this->setting_option_values['course_lesson_per_page'] ) { $this->setting_option_values['course_lesson_per_page_custom'] = absint( $this->setting_option_values['course_lesson_per_page_custom'] ); $this->setting_option_values['course_topic_per_page_custom'] = absint( $this->setting_option_values['course_topic_per_page_custom'] ); } else { $this->setting_option_values['course_lesson_per_page_custom'] = LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Management_Display', 'course_pagination_lessons' ); $this->setting_option_values['course_topic_per_page_custom'] = LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Management_Display', 'course_pagination_topics' ); } if ( ! isset( $this->setting_option_values['course_lesson_orderby'] ) ) { $this->setting_option_values['course_lesson_orderby'] = learndash_get_setting( get_the_ID(), 'course_lesson_orderby' ); } if ( ! isset( $this->setting_option_values['course_lesson_order'] ) ) { $this->setting_option_values['course_lesson_order'] = learndash_get_setting( get_the_ID(), 'course_lesson_order' ); } if ( ! isset( $this->setting_option_values['course_lesson_order_enabled'] ) ) { $this->setting_option_values['course_lesson_order_enabled'] = ''; } if ( ( isset( $this->setting_option_values['course_lesson_orderby'] ) ) && ( ! empty( $this->setting_option_values['course_lesson_orderby'] ) ) || ( isset( $this->setting_option_values['course_lesson_order'] ) ) && ( ! empty( $this->setting_option_values['course_lesson_order'] ) ) ) { $this->setting_option_values['course_lesson_order_enabled'] = 'on'; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $course_lessons_options_labels = array( //'orderby' => LearnDash_Settings_Section_Lessons_Display_Order::get_setting_select_option_label( 'orderby' ), 'orderby' => LearnDash_Settings_Section::get_section_setting_select_option_label( 'LearnDash_Settings_Section_Lessons_Display_Order', 'orderby' ), //'order' => LearnDash_Settings_Section_Lessons_Display_Order::get_setting_select_option_label( 'order' ), 'order' => LearnDash_Settings_Section::get_section_setting_select_option_label( 'LearnDash_Settings_Section_Lessons_Display_Order', 'order' ), ); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_cert_options_default = array( '-1' => esc_html__( 'Search or select a certificate…', 'learndash' ), ); } else { $select_cert_options_default = array( '' => esc_html__( 'Select Certificate', 'learndash' ), ); } $select_cert_options = $sfwd_lms->select_a_certificate(); if ( ( is_array( $select_cert_options ) ) && ( ! empty( $select_cert_options ) ) ) { $select_cert_options = $select_cert_options_default + $select_cert_options; } else { $select_cert_options = $select_cert_options_default; } $this->setting_option_fields = array( 'course_materials_enabled' => array( 'name' => 'course_materials_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Materials', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'List and display support materials for the %s. This is visible to all users (including non-enrollees) by default.', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['course_materials_enabled'], 'default' => '', 'options' => array( 'on' => sprintf( // translators: placeholder: Course. esc_html_x( 'Any content added below is displayed on the main %s page', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), '' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['course_materials_enabled'] ) ? 'open' : 'closed', ), 'course_materials' => array( 'name' => 'course_materials', 'type' => 'wpeditor', 'parent_setting' => 'course_materials_enabled', 'value' => $this->setting_option_values['course_materials'], 'default' => '', 'placeholder' => esc_html__( 'Add a list of needed documents or URLs. This field supports HTML.', 'learndash' ), 'editor_args' => array( 'textarea_name' => $this->settings_metabox_key . '[course_materials]', 'textarea_rows' => 3, ), ), 'certificate' => array( 'name' => 'certificate', 'type' => 'select', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Certificate', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'default' => '', 'value' => $this->setting_option_values['certificate'], 'options' => $select_cert_options, ), 'course_disable_content_table' => array( 'name' => 'course_disable_content_table', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Content', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'radio', 'default' => '', 'help_text' => sprintf( // translators: placeholder: Course. esc_html_x( 'Choose whether to display the %s content table to ALL users or only enrollees', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'options' => array( '' => esc_html__( 'Always visible', 'learndash' ), 'on' => esc_html__( 'Only visible to enrollees', 'learndash' ), ), 'value' => $this->setting_option_values['course_disable_content_table'], ), 'course_lesson_per_page' => array( 'name' => 'course_lesson_per_page', 'label' => esc_html__( 'Custom Pagination', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => sprintf( // translators: placeholders: course, course. esc_html_x( 'Customize the pagination options for this %1$s content table and %2$s navigation widget.', 'placeholders: course, course', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ) ), 'options' => array( '' => esc_html__( 'Currently showing default pagination', 'learndash' ), 'CUSTOM' => '', ), 'value' => $this->setting_option_values['course_lesson_per_page'], 'child_section_state' => ( 'CUSTOM' === $this->setting_option_values['course_lesson_per_page'] ) ? 'open' : 'closed', ), 'course_lesson_per_page_custom' => array( 'name' => 'course_lesson_per_page_custom', 'type' => 'number', 'class' => 'small-text', 'label' => sprintf( // translators: placeholder: Lessons per page. esc_html_x( '%s', 'placeholder: Lessons per page', 'learndash' ), learndash_get_custom_label( 'lessons' ) ), 'input_label' => esc_html__( 'per page', 'learndash' ), 'value' => $this->setting_option_values['course_lesson_per_page_custom'], 'default' => '', 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'course_lesson_per_page', ), 'course_topic_per_page_custom' => array( 'name' => 'course_topic_per_page_custom', 'type' => 'number', 'class' => 'small-text', 'label' => sprintf( // translators: placeholder: Topics per page. esc_html_x( '%s', 'placeholder: Topics per page', 'learndash' ), learndash_get_custom_label( 'topics' ) ), 'input_label' => esc_html__( 'per page', 'learndash' ), 'default' => '', 'value' => $this->setting_option_values['course_topic_per_page_custom'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'parent_setting' => 'course_lesson_per_page', ), 'course_lesson_order_enabled' => array( 'name' => 'course_lesson_order_enabled', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Custom %s Order', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'type' => 'checkbox-switch', 'help_text' => sprintf( // translators: placeholders: lessons, topics. esc_html_x( 'Customize the display order of %1$s and %2$s.', 'placeholders: lessons, topics', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ), learndash_get_custom_label_lower( 'topics' ) ), 'options' => array( '' => sprintf( // translators: placeholder: lesson order by, lesson order direction labels. esc_html_x( 'Using default sorting by %1$s in %2$s order', 'placeholder: lesson order by, lesson order direction labels', 'learndash' ), '' . //LearnDash_Settings_Section_Lessons_Display_Order::get_setting_select_option_label( 'orderby' ) LearnDash_Settings_Section::get_section_setting_select_option_label( 'LearnDash_Settings_Section_Lessons_Display_Order', 'orderby' ) . '', '' . //LearnDash_Settings_Section_Lessons_Display_Order::get_setting_select_option_label( 'order' ) LearnDash_Settings_Section::get_section_setting_select_option_label( 'LearnDash_Settings_Section_Lessons_Display_Order', 'order' ) . '' ), 'on' => '', ), 'value' => $this->setting_option_values['course_lesson_order_enabled'], 'child_section_state' => ( 'on' === $this->setting_option_values['course_lesson_order_enabled'] ) ? 'open' : 'closed', ), 'course_lesson_orderby' => array( 'name' => 'course_lesson_orderby', 'label' => esc_html__( 'Sort By', 'learndash' ), 'type' => 'select', 'options' => array( '' => esc_html__( 'Use Default', 'learndash' ) . ' ( ' . $course_lessons_options_labels['orderby'] . ' )', 'title' => esc_html__( 'Title', 'learndash' ), 'date' => esc_html__( 'Date', 'learndash' ), 'menu_order' => esc_html__( 'Menu Order', 'learndash' ), ), 'default' => '', 'value' => $this->setting_option_values['course_lesson_orderby'], 'parent_setting' => 'course_lesson_order_enabled', ), 'course_lesson_order' => array( 'name' => 'course_lesson_order', 'label' => esc_html__( 'Order Direction', 'learndash' ), 'type' => 'select', 'options' => array( '' => esc_html__( 'Use Default', 'learndash' ) . ' ( ' . $course_lessons_options_labels['order'] . ' )', 'ASC' => esc_html__( 'Ascending', 'learndash' ), 'DESC' => esc_html__( 'Descending', 'learndash' ), ), 'default' => '', 'value' => $this->setting_option_values['course_lesson_order'], 'parent_setting' => 'course_lesson_order_enabled', ), ); if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) === 'yes' ) { unset( $this->setting_option_fields['course_lesson_order_enabled'] ); unset( $this->setting_option_fields['course_lesson_orderby'] ); unset( $this->setting_option_fields['course_lesson_order'] ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { /** * Check the Course Materials set course_materials_enabled/course_materials. If 'course_materials_enabled' setting is * 'on' then make sure 'course_materials' is not empty. */ if ( ! isset( $settings_values['course_materials_enabled'] ) ) { $settings_values['course_materials_enabled'] = ''; } if ( ! isset( $settings_values['course_materials'] ) ) { $settings_values['course_materials'] = ''; } if ( 'on' !== $settings_values['course_materials_enabled'] ) { $settings_values['course_materials'] = ''; } if ( ( 'on' === $settings_values['course_materials_enabled'] ) && ( empty( $settings_values['course_materials'] ) ) ) { $settings_values['course_materials_enabled'] = ''; } /** * Check the Lessons Per Page set course_lesson_per_page/course_lesson_per_page_custom. If 'course_lesson_per_page' setting is * 'CUSTOM' then make sure 'course_lesson_per_page_custom' is not empty. */ if ( ! isset( $settings_values['course_lesson_per_page'] ) ) { $settings_values['course_lesson_per_page'] = ''; } if ( ! isset( $settings_values['course_lesson_per_page_custom'] ) ) { $settings_values['course_lesson_per_page_custom'] = ''; } if ( ! isset( $settings_values['course_topic_per_page_custom'] ) ) { $settings_values['course_topic_per_page_custom'] = ''; } //if ( 'CUSTOM' === $settings_values['course_lesson_per_page'] ) { // if ( ( empty( $settings_values['course_lesson_per_page_custom'] ) ) && ( empty( $settings_values['course_topic_per_page_custom'] ) ) ) { // $settings_values['course_lesson_per_page'] = ''; // } //} if ( empty( $settings_values['course_lesson_per_page'] ) ) { $settings_values['course_lesson_per_page_custom'] = ''; $settings_values['course_topic_per_page_custom'] = ''; } /** * Check Certificate choice. */ if ( ! isset( $settings_values['certificate'] ) ) { $settings_values['certificate'] = ''; } if ( '-1' === $settings_values['certificate'] ) { $settings_values['certificate'] = ''; } if ( ! isset( $settings_values['course_lesson_order_enabled'] ) ) { $settings_values['course_lesson_order_enabled'] = ''; } if ( ! isset( $settings_values['course_lesson_orderby'] ) ) { $settings_values['course_lesson_orderby'] = ''; } if ( ! isset( $settings_values['course_lesson_order'] ) ) { $settings_values['course_lesson_order'] = ''; } if ( 'on' === $settings_values['course_lesson_order_enabled'] ) { if ( ( empty( $settings_values['course_lesson_orderby'] ) ) || ( empty( $settings_values['course_lesson_order'] ) ) ) { $settings_values['course_lesson_order_enabled'] = ''; } } if ( empty( $settings_values['course_lesson_order_enabled'] ) ) { $settings_values['course_lesson_orderby'] = ''; $settings_values['course_lesson_order'] = ''; } apply_filters( 'learndash_settings_save_values', $settings_values, $this->settings_metabox_key ); } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'course' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Course_Display_Content'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Course_Display_Content' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Course_Display_Content'] = LearnDash_Settings_Metabox_Course_Display_Content::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\Q1,,Gsettings-metaboxes/class-ld-settings-metabox-lesson-access-settings.phpnuW+Asettings_screen_id = 'sfwd-lessons'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-lesson-access-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Access Settings', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ); $this->settings_section_description = sprintf( // translators: placeholder: lessons. esc_html_x( 'Controls the timing and way %s can be accessed.', 'placeholder: lessons', 'learndash' ), learndash_get_custom_label_lower( 'lessons' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'lesson_schedule' => 'lesson_schedule', 'course' => 'course', 'sample_lesson' => 'sample_lesson', 'visible_after' => 'visible_after', 'visible_after_specific_date' => 'visible_after_specific_date', ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['lesson_materials_enabled'] ) ) { $this->setting_option_values['lesson_materials_enabled'] = ''; if ( ( isset( $this->setting_option_values['lesson_materials'] ) ) && ( ! empty( $this->setting_option_values['lesson_materials'] ) ) ) { $this->setting_option_values['lesson_materials_enabled'] = 'on'; } } if ( ! isset( $this->setting_option_values['course'] ) ) { $this->setting_option_values['course'] = ''; } if ( ! isset( $this->setting_option_values['sample_lesson'] ) ) { $this->setting_option_values['sample_lesson'] = ''; } if ( ! isset( $this->setting_option_values['visible_after'] ) ) { $this->setting_option_values['visible_after'] = ''; } if ( ! isset( $this->setting_option_values['visible_after_specific_date'] ) ) { $this->setting_option_values['visible_after_specific_date'] = ''; } if ( ! empty( $this->setting_option_values['visible_after'] ) ) { $this->setting_option_values['lesson_schedule'] = 'visible_after'; } else if ( ! empty( $this->setting_option_values['visible_after_specific_date'] ) ) { $this->setting_option_values['lesson_schedule'] = 'visible_after_specific_date'; } else { $this->setting_option_values['lesson_schedule'] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $billing_cycle_html = $sfwd_lms->learndash_course_price_billing_cycle_html(); $select_course_options = $sfwd_lms->select_a_course(); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_course_options_default = array( '-1' => sprintf( // translators: placeholder: course. esc_html_x( 'Search or select a %s…', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } else { $select_course_options_default = array( '' => sprintf( // translators: placeholder: course. esc_html_x( 'Select %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } $select_course_options = $select_course_options_default + $select_course_options; $this->setting_option_fields = array( 'visible_after' => array( 'name' => 'visible_after', 'type' => 'number', 'value' => $this->setting_option_values['visible_after'], 'class' => 'small-text', 'label_none' => true, 'input_full' => true, 'input_label' => esc_html__( 'day(s)', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 0, ), 'default' => 0, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['lesson_schedule_visible_after_days_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'visible_after_specific_date' => array( 'name' => 'visible_after_specific_date', 'value' => $this->setting_option_values['visible_after_specific_date'], 'label_none' => true, 'input_full' => true, 'type' => 'date-entry', 'class' => 'learndash-datepicker-field', ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['visible_after_specific_date_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'course' => array( 'name' => 'course', 'label' => sprintf( // Translators: placeholder: Course. esc_html_x( 'Associated %s', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'select', 'default' => '', 'value' => $this->setting_option_values['course'], 'lazy_load' => true, 'default' => '', 'options' => $select_course_options, ), 'sample_lesson' => array( 'name' => 'sample_lesson', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Sample %s', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['sample_lesson'], 'options' => array( 'on' => sprintf( // Translators: placeholder: lesson, course. esc_html_x( 'This %1$s is accessible to all visitors regardless of %2$s enrollment', 'placeholder: lesson, course', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'course' ) ), '' => '', ), ), 'lesson_schedule' => array( 'name' => 'lesson_schedule', 'label' => sprintf( // Translators: placeholder: Lesson. esc_html_x( '%s Release Schedule', 'placeholder: Lessons', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'type' => 'radio', 'value' => $this->setting_option_values['lesson_schedule'], 'options' => array( '' => array( 'label' => esc_html__( 'Immediately', 'learndash' ), 'description' => sprintf( // translators: placeholder: lesson, course. esc_html_x( 'The %1$s is made available on %2$s enrollment.', 'placeholder: lesson, course', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'course' ) ), ), 'visible_after' => array( 'label' => esc_html__( 'Enrollment-based', 'learndash' ), 'description' => sprintf( // translators: placeholder: lesson, course. esc_html_x( 'The %1$s will be available X days after %2$s enrollment.', 'placeholder: lesson, course.', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'course' ) ), 'inline_fields' => array( 'lesson_schedule_visible_after_days' => $this->settings_sub_option_fields['lesson_schedule_visible_after_days_fields'], ), 'inner_section_state' => ( 'visible_after' === $this->setting_option_values['lesson_schedule'] ) ? 'open' : 'closed', ), 'visible_after_specific_date' => array( 'label' => esc_html__( 'Specific date', 'learndash' ), 'description' => sprintf( // translators: placeholders: lesson. esc_html_x( 'The %s will be available on a specific date.', 'placeholders: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'inline_fields' => array( 'visible_after_specific_date' => $this->settings_sub_option_fields['visible_after_specific_date_fields'], ), 'inner_section_state' => ( 'visible_after_specific_date' === $this->setting_option_values['lesson_schedule'] ) ? 'open' : 'closed', ), ), ), ); if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { unset( $this->setting_option_fields['course'] ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { /** * Check the Course Materials set course_points_enabled/course_points/course_points_access. If 'course_points_enabled' setting is * 'on' then make sure 'course_points' and 'course_points_access' are not empty. */ if ( isset( $settings_values['lesson_schedule'] ) ) { switch ( $settings_values['lesson_schedule'] ) { case 'visible_after': $settings_values['visible_after_specific_date'] = ''; break; case 'visible_after_specific_date': $settings_values['visible_after'] = ''; break; case '': default: $settings_values['visible_after'] = ''; $settings_values['visible_after_specific_date'] = ''; break; } } if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { unset( $settings_values['course'] ); } elseif ( ( ! isset( $settings_values['course'] ) ) || ( '-1' === $settings_values['course'] ) ) { $settings_values['course'] = ''; } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'lesson' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Lesson_Access_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Lesson_Access_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Lesson_Access_Settings'] = LearnDash_Settings_Metabox_Lesson_Access_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\=settings-metaboxes/class-ld-settings-metabox-course-users.phpnuW+Asettings_screen_id = 'sfwd-courses'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-course-users-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Course. esc_html_x( '%s Users', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ); /* $this->settings_section_description = sprintf( // translators: placeholder: course. esc_html_x( 'Controls how users will gain access to the %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); */ parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { parent::load_settings_fields(); } protected function show_settings_metabox_fields( $metabox = null ) { if ( ( is_object( $metabox ) ) && ( is_a( $metabox, 'LearnDash_Settings_Metabox' ) ) && ( $metabox->settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( isset( $metabox->post ) ) && ( is_a( $metabox->post, 'WP_Post ' ) ) ) { $course_id = $metabox->post->ID; } else { $course_id = get_the_ID(); } if ( ( ! empty( $course_id ) ) && ( get_post_type( $course_id ) === learndash_get_post_type_slug( 'course' ) ) ) { $course_price_type = learndash_get_setting( $course_id, 'course_price_type' ); if ( 'open' !== $course_price_type ) { $selected_user_ids = array(); $metabox_description = ''; $course_access_users = learndash_get_course_users_access_from_meta( $course_id ); if ( ! empty( $course_access_users )) { $course_access_users = learndash_convert_course_access_list( $course_access_users, true ); } else { $course_access_users = array(); } $course_users_binary_args = array( 'html_title' => '', 'course_id' => $course_id, 'search_posts_per_page' => 100, 'selected_ids' => $course_access_users ); // Use nonce for verification. wp_nonce_field( 'learndash_course_users_nonce_' . $course_id, 'learndash_course_users_nonce' ); if ( ! empty( $metabox_description ) ) { $metabox_description .= ' '; } $metabox_description .= sprintf( // translators: placeholder: Course. esc_html_x( 'Users enrolled via Groups using this %s are excluded from the listings below and should be manage via the Group admin screen.', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?>
    show(); ?>

    settings_screen_id = 'sfwd-courses'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-course-access-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Course. esc_html_x( '%s Access Settings', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ); $this->settings_section_description = sprintf( // translators: placeholder: course. esc_html_x( 'Controls how users will gain access to the %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); add_filter( 'learndash_admin_settings_data', array( $this, 'learndash_admin_settings_data' ), 30, 1 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( // New fields 'course_access_list_enabled' => 'course_access_list_enabled', // Legacy fields 'course_price_type' => 'course_price_type', 'course_price_type_paynow_price' => 'course_price', 'course_price_type_subscribe_price' => 'course_price', 'course_price_type_subscribe_billing_cycle' => 'course_price_billing_cycle', 'course_price_type_closed_custom_button_label' => 'custom_button_label', 'course_price_type_closed_custom_button_url' => 'custom_button_url', 'course_price_type_closed_price' => 'course_price', 'course_prerequisite_enabled' => 'course_prerequisite_enabled', 'course_prerequisite' => 'course_prerequisite', 'course_prerequisite_compare' => 'course_prerequisite_compare', 'course_points_enabled' => 'course_points_enabled', 'course_points' => 'course_points', 'course_points_access' => 'course_points_access', 'expire_access' => 'expire_access', 'expire_access_days' => 'expire_access_days', 'expire_access_delete_progress' => 'expire_access_delete_progress', 'course_disable_lesson_progression' => 'course_disable_lesson_progression', 'course_access_list' => 'course_access_list', ); parent::__construct(); } /** * Add script data to array. * * @since 3.0 * @param array $script_data Script data array to be sent out to browser. * @return array $script_data */ public function learndash_admin_settings_data( $script_data = array() ) { $script_data['valid_recurring_paypal_day_range'] = esc_html__( 'Valid range is 1 to 90 when the Billing Cycle is set to days.', 'learndash' ); $script_data['valid_recurring_paypal_week_range'] = esc_html__( 'Valid range is 1 to 52 when the Billing Cycle is set to weeks.', 'learndash' ); $script_data['valid_recurring_paypal_month_range'] = esc_html__( 'Valid range is 1 to 24 when the Billing Cycle is set to months.', 'learndash' ); $script_data['valid_recurring_paypal_year_range'] = esc_html__( 'Valid range is 1 to 5 when the Billing Cycle is set to years.', 'learndash' ); return $script_data; } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['course_points_enabled'] ) ) { $this->setting_option_values['course_points_enabled'] = ''; } if ( ! isset( $this->setting_option_values['expire_access'] ) ) { $this->setting_option_values['expire_access'] = ''; } if ( ! isset( $this->setting_option_values['expire_access_delete_progress'] ) ) { $this->setting_option_values['expire_access_delete_progress'] = ''; } if ( ! isset( $this->setting_option_values['course_access_list_enabled'] ) ) { $this->setting_option_values['course_access_list_enabled'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type_paynow_price'] ) ) { $this->setting_option_values['course_price_type_paynow_price'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type_subscribe_price'] ) ) { $this->setting_option_values['course_price_type_subscribe_price'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type_closed_price'] ) ) { $this->setting_option_values['course_price_type_closed_price'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type_closed_custom_button_url'] ) ) { $this->setting_option_values['course_price_type_closed_custom_button_url'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type'] ) ) { $this->setting_option_values['course_price_type'] = 'open'; } if ( ! isset( $this->setting_option_values['course_prerequisite_enabled'] ) ) { $this->setting_option_values['course_prerequisite_enabled'] = ''; } if ( ! isset( $this->setting_option_values['course_prerequisite'] ) ) { $this->setting_option_values['course_prerequisite'] = ''; } if ( ! isset( $this->setting_option_values['course_prerequisite_compare'] ) ) { $this->setting_option_values['course_prerequisite_compare'] = 'ANY'; } if ( ! isset( $this->setting_option_values['course_points_access'] ) ) { $this->setting_option_values['course_points_access'] = ''; } if ( ! isset( $this->setting_option_values['course_points'] ) ) { $this->setting_option_values['course_points'] = ''; } if ( ! isset( $this->setting_option_values['expire_access_days'] ) ) { $this->setting_option_values['expire_access_days'] = ''; } if ( ! isset( $this->setting_option_values['course_access_list'] ) ) { $this->setting_option_values['course_access_list'] = ''; } if ( ! isset( $this->setting_option_values['course_price_type_closed_custom_button_label'] ) ) { $this->setting_option_values['course_price_type_closed_custom_button_label'] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $this->settings_sub_option_fields = array(); $select_course_options = $sfwd_lms->select_a_course(); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_course_options_default = sprintf( // translators: placeholder: course. esc_html_x( 'Search or select a %s…', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ); } else { $select_course_options_default = array( '' => sprintf( // translators: placeholder: course. esc_html_x( 'Select %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); if ( ( is_array( $select_course_options ) ) && ( ! empty( $select_course_options ) ) ) { $select_course_options = $select_course_options_default + $select_course_options; } else { $select_course_options = $select_course_options_default; } $select_course_options_default = ''; } $this->setting_option_fields = array( 'course_price_type_paynow_price' => array( 'name' => 'course_price_type_paynow_price', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Price', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'text', 'class' => '-medium', 'value' => $this->setting_option_values['course_price_type_paynow_price'], 'default' => '', ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['course_price_type_paynow_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'course_price_type_subscribe_price' => array( 'name' => 'course_price_type_subscribe_price', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Price', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'text', 'class' => '-medium', 'value' => $this->setting_option_values['course_price_type_subscribe_price'], 'default' => '', ), 'course_price_type_subscribe_billing_cycle' => array( 'name' => 'course_price_type_subscribe_billing_cycle', 'label' => esc_html__( 'Billing Cycle', 'learndash' ), 'type' => 'custom', 'html' => $sfwd_lms->learndash_course_price_billing_cycle_html(), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['course_price_type_subscribe_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( /* 'course_price_type_closed_custom_button_label' => array( 'name' => 'course_price_type_closed_custom_button_label', 'label' => esc_html__( 'Label (optional)', 'learndash' ), 'type' => 'text', 'placeholder' => learndash_get_custom_label( 'button_take_this_course' ), 'value' => $this->setting_option_values['course_price_type_closed_custom_button_label'], 'help_text' => esc_html__( 'Label displayed in the Course Grid listing. Requires Course Grid add-on.', 'learndash'), 'default' => '', ), */ 'course_price_type_closed_price' => array( 'name' => 'course_price_type_closed_price', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Price', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'text', 'class' => '-medium', 'value' => $this->setting_option_values['course_price_type_closed_price'], 'default' => '', ), 'course_price_type_closed_custom_button_url' => array( 'name' => 'course_price_type_closed_custom_button_url', 'label' => esc_html__( 'Button URL', 'learndash' ), 'type' => 'url', 'class' => 'full-text', 'value' => $this->setting_option_values['course_price_type_closed_custom_button_url'], 'help_text' => sprintf( // translators: placeholder: "Take this Course" button label esc_html_x( 'Redirect the "%s" button to a specific URL.', 'placeholder: "Take this Course" button label', 'learndash' ), learndash_get_custom_label( 'button_take_this_course' ) ), 'default' => '', ), ); /* if ( ! defined( 'LEARNDASH_COURSE_GRID_VERSION' ) ) { unset( $this->setting_option_fields['course_price_type_closed_custom_button_label'] ); } */ parent::load_settings_fields(); $this->settings_sub_option_fields['course_price_type_closed_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'course_price_type' => array( 'name' => 'course_price_type', 'label' => esc_html__( 'Access Mode', 'learndash' ), 'type' => 'radio', 'value' => $this->setting_option_values['course_price_type'], 'default' => 'open', 'options' => array( 'open' => array( 'label' => esc_html__( 'Open', 'learndash' ), 'description' => sprintf( // translators: placeholder: course. esc_html_x( 'The %s is not protected. Any user can access its content without the need to be logged-in or enrolled.', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'free' => array( 'label' => esc_html__( 'Free', 'learndash' ), 'description' => sprintf( // translators: placeholder: course. esc_html_x( 'The %s is protected. Registration and enrollment are required in order to access the content.', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'paynow' => array( 'label' => esc_html__( 'Buy now', 'learndash' ), 'description' => sprintf( // translators: placeholder: course, course. esc_html_x( 'The %1$s is protected via the LearnDash built-in PayPal and/or Stripe. Users need to purchase the %2$s (one-time fee) in order to gain access.', 'placeholder: course, course', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ) ), 'inline_fields' => array( 'course_price_type_paynow' => $this->settings_sub_option_fields['course_price_type_paynow_fields'], ), 'inner_section_state' => ( 'paynow' === $this->setting_option_values['course_price_type'] ) ? 'open' : 'closed', ), 'subscribe' => array( 'label' => esc_html__( 'Recurring', 'learndash' ), 'description' => sprintf( // translators: placeholder: course, course. esc_html_x( 'The %1$s is protected via the LearnDash built-in PayPal and/or Stripe. Users need to purchase the %2$s (recurring fee) in order to gain access.', 'placeholder: course, course', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ) ), 'inline_fields' => array( 'course_price_type_subscribe' => $this->settings_sub_option_fields['course_price_type_subscribe_fields'], ), 'inner_section_state' => ( 'subscribe' === $this->setting_option_values['course_price_type'] ) ? 'open' : 'closed', ), 'closed' => array( 'label' => esc_html__( 'Closed', 'learndash' ), 'description' => sprintf( // translators: placeholder: course. esc_html_x( 'The %s can only be accessed through admin enrollment (manual), group enrollment, or integration (shopping cart or membership) enrollment. No enrollment button will be displayed, unless a URL is set (optional).', 'placeholder: course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'inline_fields' => array( 'course_price_type_closed' => $this->settings_sub_option_fields['course_price_type_closed_fields'], ), 'inner_section_state' => ( 'closed' === $this->setting_option_values['course_price_type'] ) ? 'open' : 'closed', ), ), ), 'course_prerequisite_enabled' => array( 'name' => 'course_prerequisite_enabled', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Prerequisites', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['course_prerequisite_enabled'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['course_prerequisite_enabled'] ) ? 'open' : 'closed', ), 'course_prerequisite_compare' => array( 'name' => 'course_prerequisite_compare', 'label' => esc_html__( 'Compare Mode', 'learndash' ), 'type' => 'radio', 'default' => 'ANY', 'value' => $this->setting_option_values['course_prerequisite_compare'], 'options' => array( 'ANY' => array( 'label' => esc_html__( 'Any Selected', 'learndash' ), 'description' => sprintf( // translators: placeholder: courses, course. esc_html_x( 'The user must complete any one of the selected %1$s in order to access this %2$s', 'placeholder: course, course', 'learndash' ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'course' ) ), ), 'ALL' => array( 'label' => esc_html__( 'All Selected', 'learndash' ), 'description' => sprintf( // translators: placeholder: course, course. esc_html_x( 'The user must complete all selected %1$s in order to access this %2$s', 'placeholder: course, course', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'course' ) ), ), ), 'parent_setting' => 'course_prerequisite_enabled', ), 'course_prerequisite' => array( 'name' => 'course_prerequisite', 'type' => 'multiselect', 'multiple' => 'true', 'default' => '', 'value' => $this->setting_option_values['course_prerequisite'], 'placeholder' => $select_course_options_default, 'value_type' => 'intval', 'label' => sprintf( // translators: placeholder: Courses. esc_html_x( '%s to Complete', 'placeholder: courses', 'learndash' ), learndash_get_custom_label( 'courses' ) ), 'parent_setting' => 'course_prerequisite_enabled', 'options' => $select_course_options, ), 'course_points_enabled' => array( 'name' => 'course_points_enabled', 'label' => sprintf( // translators: placeholder: Course esc_html_x( '%s Points', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['course_points_enabled'], 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['course_points_enabled'] ) ? 'open' : 'closed', ), 'course_points_access' => array( 'name' => 'course_points_access', 'label' => esc_html__( 'Required for Access', 'learndash' ), 'type' => 'number', 'value' => $this->setting_option_values['course_points_access'], 'default' => 0, 'class' => 'small-text', 'input_label' => esc_html__( 'point(s)', 'learndash' ), 'input_error' => esc_html__( 'Value should be zero or greater with up to 2 decimal places.', 'learndash' ), 'parent_setting' => 'course_points_enabled', 'attrs' => array( 'step' => 'any', 'min' => '0.00', //'max' => '10.00', 'can_decimal' => 2, 'can_empty' => true, ), 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Number of points required in order to gain access to this %s.', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'course_points' => array( 'name' => 'course_points', 'label' => esc_html__( 'Awarded on Completion', 'learndash' ), 'type' => 'number', 'step' => 'any', 'min' => '0', 'value' => $this->setting_option_values['course_points'], 'default' => '', 'class' => 'small-text', 'input_label' => esc_html__( 'point(s)', 'learndash' ), 'parent_setting' => 'course_points_enabled', 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Number of points awarded for completing this %s.', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'input_error' => esc_html__( 'Value should be zero or greater with up to 2 decimal places.', 'learndash' ), 'attrs' => array( 'step' => 'any', 'min' => '0.00', //'max' => '10.00', 'can_decimal' => 2, 'can_empty' => true, ), ), 'expire_access' => array( 'name' => 'expire_access', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Access Expiration', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'checkbox-switch', 'options' => array( 'on' => '', ), 'value' => $this->setting_option_values['expire_access'], 'child_section_state' => ( 'on' === $this->setting_option_values['expire_access'] ) ? 'open' : 'closed', ), 'expire_access_days' => array( 'name' => 'expire_access_days', 'label' => esc_html__( 'Access Period', 'learndash' ), 'type' => 'number', 'class' => 'small-text', 'min' => '0', 'value' => $this->setting_option_values['expire_access_days'], 'input_label' => esc_html__( 'days', 'learndash' ), 'parent_setting' => 'expire_access', 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Set the number of days a user will have access to the %s from enrollment date.', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'expire_access_delete_progress' => array( 'name' => 'expire_access_delete_progress', 'label' => esc_html__( 'Data Deletion', 'learndash' ), 'type' => 'checkbox-switch', 'options' => array( 'on' => sprintf( // translators: placeholder: course. esc_html_x( 'All user %s data will be deleted upon access expiration', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), '' => '', ), 'value' => $this->setting_option_values['expire_access_delete_progress'], 'parent_setting' => 'expire_access', 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Delete the user\'s %1$s and %2$s data when the %3$s access expires.', 'placeholder: course, quiz, course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'course' ) ), ), 'course_access_list_enabled' => array( 'name' => 'course_access_list_enabled', 'label' => sprintf( // translators: placeholder: Course esc_html_x( 'Alter %s Access List', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'checkbox-switch', 'options' => array( 'on' => sprintf( // translators: placeholder: Course esc_html_x( 'You can change the LD-%s enrollees by user ID (Proceed with caution)', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), '' => '', ), 'value' => $this->setting_option_values['course_access_list_enabled'], 'default' => '', 'child_section_state' => ( 'on' === $this->setting_option_values['course_access_list_enabled'] ) ? 'open' : 'closed', 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Displays a list of %s enrollees by user ID. Note that not all enrollees may be reflected. We do not recommend editing this field.', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ), 'course_access_list' => array( 'name' => 'course_access_list', 'type' => 'textarea', 'value' => $this->setting_option_values['course_access_list'], 'default' => '', 'parent_setting' => 'course_access_list_enabled', 'placeholder' => sprintf( // translators: placeholder: course. esc_html_x( 'Add a comma-list of user IDs to grant access to this %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'attrs' => array( 'rows' => '2', 'cols' => '57', ), ), ); /* if ( isset( $_GET['course_access_list_meta'] ) ) { $this->setting_option_fields['course_access_list_enabled']['value'] = 'on'; $this->setting_option_fields['course_access_list_enabled']['child_section_state'] = 'open'; $course_access_list_meta_array = learndash_get_course_users_access_from_meta( get_the_ID() ); if ( ! empty( $course_access_list_meta_array ) ) { $course_access_list_meta_array = learndash_convert_course_access_list( $course_access_list_meta_array, true ); } else { $course_access_list_meta_array = array(); } $course_access_list_array = learndash_convert_course_access_list( $this->setting_option_values['course_access_list'], true ); error_log('course_access_list_meta_array
    '. print_r($course_access_list_meta_array, true) .'
    '); error_log('course_access_list_array
    '. print_r($course_access_list_array, true) .'
    '); $course_access_list_diff_array = array_diff( $course_access_list_meta_array, $course_access_list_array ); if ( ! empty( $course_access_list_diff_array ) ) { $course_access_list_diff_str = learndash_convert_course_access_list( $course_access_list_diff_array ); } else { $course_access_list_diff_str = ''; } $this->setting_option_fields['course_access_list_meta'] = array( 'name' => 'course_access_list_meta', 'label' => esc_html__( 'Show Missing Users', 'learndash' ), 'type' => 'textarea', 'value' => $course_access_list_diff_str, 'default' => '', 'parent_setting' => 'course_access_list_enabled', 'attrs' => array( 'rows' => '2', 'cols' => '57', ), ); } else { $this->setting_option_fields['course_access_list_meta'] = array( 'name' => 'course_access_list_meta', 'label' => esc_html__( 'Show Missing Users', 'learndash' ), 'type' => 'html', 'value' => '' . esc_html( 'click to show missing users', 'learndash' ) .'', 'parent_setting' => 'course_access_list_enabled', ); } */ if ( false === learndash_use_legacy_course_access_list() ) { unset( $this->setting_option_fields['course_access_list_enabled'] ); unset( $this->setting_option_fields['course_access_list'] ); } $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } protected function get_save_settings_fields_map_form_post_values( $post_values = array() ) { $settings_fields_map = $this->settings_fields_map; if ( ( isset( $post_values['course_price_type'] ) ) && ( ! empty( $post_values['course_price_type'] ) ) ) { if ( 'paynow' === $post_values['course_price_type'] ) { unset( $settings_fields_map['course_price_type_subscribe_price'] ); unset( $settings_fields_map['course_price_type_subscribe_billing_cycle'] ); unset( $settings_fields_map['course_price_type_closed_price'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_label'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_url'] ); } elseif ( 'subscribe' === $post_values['course_price_type'] ) { unset( $settings_fields_map['course_price_type_paynow_price'] ); unset( $settings_fields_map['course_price_type_closed_price'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_label'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_url'] ); } elseif ( 'closed' === $post_values['course_price_type'] ) { unset( $settings_fields_map['course_price_type_subscribe_price'] ); unset( $settings_fields_map['course_price_type_subscribe_billing_cycle'] ); unset( $settings_fields_map['course_price_type_paynow_price'] ); } else { unset( $settings_fields_map['course_price_type_paynow_price'] ); unset( $settings_fields_map['course_price_type_subscribe_price'] ); unset( $settings_fields_map['course_price_type_subscribe_billing_cycle'] ); unset( $settings_fields_map['course_price_type_closed_price'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_label'] ); unset( $settings_fields_map['course_price_type_closed_custom_button_url'] ); } } return $settings_fields_map; } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ! isset( $settings_values['course_price_type'] ) ) { $settings_values['course_price_type'] = ''; } if ( 'paynow' === $settings_values['course_price_type'] ) { $settings_values['custom_button_url'] = ''; $settings_values['course_price_billing_p3'] = ''; $settings_values['course_price_billing_t3'] = ''; } elseif ( 'subscribe' === $settings_values['course_price_type'] ) { $settings_values['custom_button_url'] = ''; } elseif ( 'closed' === $settings_values['course_price_type'] ) { $settings_values['course_price_billing_p3'] = ''; $settings_values['course_price_billing_t3'] = ''; } else { $settings_values['course_price'] = ''; $settings_values['custom_button_url'] = ''; $settings_values['course_price_billing_p3'] = ''; $settings_values['course_price_billing_t3'] = ''; } /** * Check the Course Materials set course_points_enabled/course_points/course_points_access. If 'course_points_enabled' setting is * 'on' then make sure 'course_points' and 'course_points_access' are not empty. */ if ( ( isset( $settings_values['course_points_enabled'] ) ) && ( 'on' === $settings_values['course_points_enabled'] ) ) { if ( ( isset( $settings_values['course_points'] ) ) && ( empty( $settings_values['course_points'] ) ) && ( isset( $settings_values['course_points_access'] ) ) && ( empty( $settings_values['course_points_access'] ) ) ) { $settings_values['course_points_enabled'] = ''; } } /** * Check the Lessons Per Page set course_prerequisite_enabled/course_prerequisite. If 'course_prerequisite_enabled' setting is * 'on' then make sure 'course_prerequisite' is not empty. */ if ( ( isset( $settings_values['course_prerequisite_enabled'] ) ) && ( 'on' === $settings_values['course_prerequisite_enabled'] ) ) { if ( ( isset( $settings_values['course_prerequisite'] ) ) && ( is_array( $settings_values['course_prerequisite'] ) ) && ( ! empty( $settings_values['course_prerequisite'] ) ) ) { $settings_values['course_prerequisite'] = array_diff( $settings_values['course_prerequisite'], array( 0 ) ); if ( empty( $settings_values['course_prerequisite'] ) ) { $settings_values['course_prerequisite_enabled'] = ''; } } else { $settings_values['course_prerequisite_enabled'] = ''; } } /** * Check the Lessons Per Page set expire_access/expire_access_days. If 'expire_access' setting is * 'on' then make sure 'expire_access_days' is not empty. */ if ( ( isset( $settings_values['expire_access'] ) ) && ( 'on' === $settings_values['expire_access'] ) ) { if ( ( isset( $settings_values['expire_access_days'] ) ) && ( empty( $settings_values['expire_access_days'] ) ) ) { $settings_values['expire_access'] = ''; } } /** * Check the Lessons Per Page set expire_access/expire_access_days. If 'expire_access' setting is * 'on' then make sure 'expire_access_days' is not empty. */ if ( ( isset( $settings_values['course_access_list_enabled'] ) ) && ( 'on' === $settings_values['course_access_list_enabled'] ) ) { if ( ( isset( $settings_values['course_access_list'] ) ) && ( empty( $settings_values['course_access_list'] ) ) ) { $settings_values['course_access_list_enabled'] = ''; } } $settings_values = apply_filters( 'learndash_settings_save_values', $settings_values, $this->settings_metabox_key ); } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'course' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Course_Access_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Course_Access_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Course_Access_Settings'] = LearnDash_Settings_Metabox_Course_Access_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\חb b Fsettings-metaboxes/class-ld-settings-metabox-topic-access-settings.phpnuW+Asettings_screen_id = 'sfwd-topic'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-topic-access-settings'; // Section label/header. $this->settings_section_label = sprintf( // translators: placeholder: Topic. esc_html_x( '%s Access Settings', 'placeholder: Topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ); $this->settings_section_description = sprintf( // translators: placeholder: topic. esc_html_x( 'Controls how, where, and when the %s can be accessed.', 'placeholder: topic', 'learndash' ), learndash_get_custom_label( 'topic' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); add_filter( 'learndash_show_metabox', array( $this, 'check_show_metabox' ), 50, 2 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'course' => 'course', 'lesson' => 'lesson', ); parent::__construct(); } /** * Hook into filter before the metabox is registered in WP. * * @since 3.0 * @param boolean $show_metabox True or False to show metabox. * @param string $settings_metabox_key metabox key. * @return boolean $show_metabox */ public function check_show_metabox( $show_metabox, $settings_metabox_key = '' ) { if ( $settings_metabox_key === $this->settings_metabox_key ) { // IF Course shared Steps is enabled we don't show this metabox. if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) { $show_metabox = false; } } return $show_metabox; } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['course'] ) ) { $this->setting_option_values['course'] = ''; } if ( ! isset( $this->setting_option_values['lesson'] ) ) { $this->setting_option_values['lesson'] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $select_course_options = $sfwd_lms->select_a_course(); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_course_options_default = array( '-1' => sprintf( // translators: placeholder: course. esc_html_x( 'Search or select a %s…', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } else { $select_course_options_default = array( '' => sprintf( // translators: placeholder: course. esc_html_x( 'Select %s', 'placeholder: course', 'learndash' ), learndash_get_custom_label( 'course' ) ), ); } $select_course_options = $select_course_options_default + $select_course_options; if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_lesson_options_default = array( '-1' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Search or select a %s…', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ); } else { $select_lesson_options_default = array( '' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Select %s', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ); } $select_lesson_options = array(); if ( ( isset( $this->setting_option_values['course'] ) ) && ( ! empty( $this->setting_option_values['course'] ) ) ) { $select_lesson_options = $sfwd_lms->select_a_lesson( absint( $this->setting_option_values['course'] ) ); if ( ( is_array( $select_lesson_options ) ) && ( ! empty( $select_lesson_options ) ) ) { if ( isset( $select_lesson_options[0] ) ) { unset( $select_lesson_options[0] ); } $select_lesson_options = $select_lesson_options_default + $select_lesson_options; } else { $select_lesson_options = $select_lesson_options_default; } } else { $select_lesson_options = $select_lesson_options_default; } $this->setting_option_fields = array( 'course' => array( 'name' => 'course', 'label' => sprintf( // translators: placeholders: course. esc_html_x( 'Associated %s', 'Associated Course Label', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'type' => 'select', 'lazy_load' => true, 'help_text' => sprintf( // translators: placeholders: Topic, Course. esc_html_x( 'Associate this %1$s with a %2$s.', 'placeholder: Topic, Course.', 'learndash' ), learndash_get_custom_label( 'topic' ), learndash_get_custom_label( 'course' ) ), 'default' => '', 'value' => $this->setting_option_values['course'], 'options' => $select_course_options, 'attrs' => array( 'data-ld_selector_nonce' => wp_create_nonce( 'sfwd-courses' ), 'data-ld_selector_default' => '1', ), ), 'lesson' => array( 'name' => 'lesson', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Associated %s', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'type' => 'select', 'lazy_load' => true, 'help_text' => sprintf( // translators: placeholders: Lesson, Course. esc_html_x( 'Associate this %1$s with a %2$s.', 'placeholders: Lesson, Course', 'learndash' ), learndash_get_custom_label( 'lesson' ), learndash_get_custom_label( 'course' ) ), 'default' => '', 'value' => $this->setting_option_values['lesson'], 'options' => $select_lesson_options, 'attrs' => array( 'data-ld_selector_nonce' => wp_create_nonce( 'sfwd-lessons' ), 'data-ld_selector_default' => '1', ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( ! isset( $settings_values['course'] ) ) || ( '-1' === $settings_values['course'] ) ) { $settings_values['course'] = ''; } if ( ( ! isset( $settings_values['lesson'] ) ) || ( '-1' === $settings_values['lesson'] ) ) { $settings_values['lesson'] = ''; } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'topic' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Topic_Access_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Topic_Access_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Topic_Access_Settings'] = LearnDash_Settings_Metabox_Topic_Access_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\p}ddEsettings-metaboxes/class-ld-settings-metabox-quiz-display-content.phpnuW+Asettings_screen_id = 'sfwd-quiz'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-quiz-display-content-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Display and Content Options', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: quiz. esc_html_x( 'Controls how the %s will look and what will be displayed', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'quiz_materials_enabled' => 'quiz_materials_enabled', 'quiz_materials' => 'quiz_materials', 'custom_sorting' => 'custom_sorting', 'autostart' => 'autostart', 'showReviewQuestion' => 'showReviewQuestion', 'quizSummaryHide' => 'quizSummaryHide', 'skipQuestionDisabled' => 'skipQuestionDisabled', 'sortCategories' => 'sortCategories', 'questionRandom' => 'questionRandom', 'showMaxQuestion' => 'showMaxQuestion', 'showMaxQuestionValue' => 'showMaxQuestionValue', 'showPoints' => 'showPoints', 'showCategory' => 'showCategory', 'hideQuestionPositionOverview' => 'hideQuestionPositionOverview', 'hideQuestionNumbering' => 'hideQuestionNumbering', 'numberedAnswer' => 'numberedAnswer', 'answerRandom' => 'answerRandom', 'quizModus' => 'quizModus', 'quizModus_multiple_questionsPerPage' => 'quizModus_multiple_questionsPerPage', 'quizModus_single_back_button' => 'quizModus_single_back_button', 'quizModus_single_feedback' => 'quizModus_single_feedback', 'titleHidden' => 'titleHidden', ); parent::__construct(); } /** * Used to save the settings fields back to the global $_POST object so * the WPProQuiz normal form processing can take place. * * @since 3.0 * @param object $pro_quiz_edit WpProQuiz_Controller_Quiz instance (not used). * @param array $settings_values Array of settings fields. */ public function save_fields_to_post( $pro_quiz_edit, $settings_values = array() ) { $_POST['autostart'] = $settings_values['autostart']; $_POST['showReviewQuestion'] = $settings_values['showReviewQuestion']; $_POST['quizSummaryHide'] = $settings_values['quizSummaryHide']; $_POST['skipQuestionDisabled'] = $settings_values['skipQuestionDisabled']; $_POST['sortCategories'] = $settings_values['sortCategories']; $_POST['questionRandom'] = $settings_values['questionRandom']; $_POST['showMaxQuestion'] = $settings_values['showMaxQuestion']; $_POST['showMaxQuestionValue'] = $settings_values['showMaxQuestionValue']; $_POST['answerRandom'] = $settings_values['answerRandom']; $_POST['showPoints'] = $settings_values['showPoints']; $_POST['showCategory'] = $settings_values['showCategory']; $_POST['hideQuestionPositionOverview'] = $settings_values['hideQuestionPositionOverview']; $_POST['hideQuestionNumbering'] = $settings_values['hideQuestionNumbering']; $_POST['numberedAnswer'] = $settings_values['numberedAnswer']; $_POST['quizModus'] = $settings_values['quizModus']; $_POST['questionsPerPage'] = $settings_values['quizModus_multiple_questionsPerPage']; $_POST['titleHidden'] = $settings_values['titleHidden']; } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $this->quiz_edit = $this->init_quiz_edit( $this->_post ); $this->ld_quiz_questions_object = LDLMS_Factory_Post::quiz_questions( $this->_post->ID ); if ( true === $this->settings_values_loaded ) { $questionMapper = new WpProQuiz_Model_QuestionMapper(); $questions = $questionMapper->fetchAll( $this->quiz_edit['quiz'] ); if ( ( is_array( $questions ) ) && ( ! empty( $questions ) ) ) { $this->questions_count = count( $questions ); } if ( ! isset( $this->setting_option_values['quiz_materials'] ) ) { $this->setting_option_values['quiz_materials'] = ''; } if ( ! empty( $this->setting_option_values['quiz_materials'] ) ) { $this->setting_option_values['quiz_materials_enabled'] = 'on'; } else { $this->setting_option_values['quiz_materials_enabled'] = ''; } if ( $this->quiz_edit['quiz'] ) { $this->setting_option_values['autostart'] = $this->quiz_edit['quiz']->isAutostart(); if ( true === $this->setting_option_values['autostart'] ) { $this->setting_option_values['autostart'] = 'on'; } else { $this->setting_option_values['autostart'] = ''; } $this->setting_option_values['showReviewQuestion'] = $this->quiz_edit['quiz']->isShowReviewQuestion(); if ( true === $this->setting_option_values['showReviewQuestion'] ) { $this->setting_option_values['showReviewQuestion'] = 'on'; } else { $this->setting_option_values['showReviewQuestion'] = ''; } $this->setting_option_values['quizSummaryHide'] = $this->quiz_edit['quiz']->isQuizSummaryHide(); if ( true === $this->setting_option_values['quizSummaryHide'] ) { $this->setting_option_values['quizSummaryHide'] = ''; } else { $this->setting_option_values['quizSummaryHide'] = 'on'; } $this->setting_option_values['skipQuestionDisabled'] = $this->quiz_edit['quiz']->isSkipQuestionDisabled(); if ( true === $this->setting_option_values['skipQuestionDisabled'] ) { $this->setting_option_values['skipQuestionDisabled'] = ''; } else { $this->setting_option_values['skipQuestionDisabled'] = 'on'; } $this->setting_option_values['sortCategories'] = $this->quiz_edit['quiz']->isSortCategories(); if ( true === $this->setting_option_values['sortCategories'] ) { $this->setting_option_values['sortCategories'] = 'on'; } else { $this->setting_option_values['sortCategories'] = ''; } $this->setting_option_values['questionRandom'] = $this->quiz_edit['quiz']->isQuestionRandom(); if ( true === $this->setting_option_values['questionRandom'] ) { $this->setting_option_values['questionRandom'] = 'on'; } else { $this->setting_option_values['questionRandom'] = ''; } $this->setting_option_values['showMaxQuestion'] = $this->quiz_edit['quiz']->isShowMaxQuestion(); if ( true === $this->setting_option_values['showMaxQuestion'] ) { $this->setting_option_values['showMaxQuestion'] = 'on'; } else { $this->setting_option_values['showMaxQuestion'] = ''; } $this->setting_option_values['showMaxQuestionValue'] = $this->quiz_edit['quiz']->getShowMaxQuestionValue(); if ( ! empty( $this->setting_option_values['showMaxQuestionValue'] ) ) { $this->setting_option_values['showMaxQuestionValue'] = absint( $this->setting_option_values['showMaxQuestionValue'] ); } else { $this->setting_option_values['showMaxQuestionValue'] = ''; } if ( absint( $this->setting_option_values['showMaxQuestionValue'] ) > $this->questions_count ) { $this->setting_option_values['showMaxQuestionValue'] = $this->questions_count; } if ( 'on' === $this->setting_option_values['questionRandom'] ) { if ( 'on' !== $this->setting_option_values['showMaxQuestion'] ) { $this->setting_option_values['showMaxQuestionValue'] = 0; } } else { $this->setting_option_values['showMaxQuestion'] = ''; $this->setting_option_values['showMaxQuestionValue'] = 0; } if ( ( 'on' === $this->setting_option_values['sortCategories'] ) || ( 'on' === $this->setting_option_values['questionRandom'] ) ) { $this->setting_option_values['custom_sorting'] = 'on'; } else { $this->setting_option_values['custom_sorting'] = ''; } $this->setting_option_values['showPoints'] = $this->quiz_edit['quiz']->isShowPoints(); if ( true === $this->quiz_edit['quiz']->isShowPoints() ) { $this->setting_option_values['showPoints'] = 'on'; } else { $this->setting_option_values['showPoints'] = ''; } $this->setting_option_values['showCategory'] = $this->quiz_edit['quiz']->isShowCategory(); if ( true === $this->setting_option_values['showCategory'] ) { $this->setting_option_values['showCategory'] = 'on'; } else { $this->setting_option_values['showCategory'] = ''; } $this->setting_option_values['hideQuestionPositionOverview'] = $this->quiz_edit['quiz']->isHideQuestionPositionOverview(); if ( true !== $this->setting_option_values['hideQuestionPositionOverview'] ) { $this->setting_option_values['hideQuestionPositionOverview'] = 'on'; } else { $this->setting_option_values['hideQuestionPositionOverview'] = ''; } $this->setting_option_values['hideQuestionNumbering'] = $this->quiz_edit['quiz']->isHideQuestionNumbering(); if ( true !== $this->setting_option_values['hideQuestionNumbering'] ) { $this->setting_option_values['hideQuestionNumbering'] = 'on'; } else { $this->setting_option_values['hideQuestionNumbering'] = ''; } $this->setting_option_values['numberedAnswer'] = $this->quiz_edit['quiz']->isNumberedAnswer(); if ( true === $this->setting_option_values['numberedAnswer'] ) { $this->setting_option_values['numberedAnswer'] = 'on'; } else { $this->setting_option_values['numberedAnswer'] = ''; } $this->setting_option_values['answerRandom'] = $this->quiz_edit['quiz']->isAnswerRandom(); if ( true === $this->setting_option_values['answerRandom'] ) { $this->setting_option_values['answerRandom'] = 'on'; } else { $this->setting_option_values['answerRandom'] = ''; } $this->setting_option_values['quizModus'] = ''; $this->setting_option_values['quizModus_single_feedback'] = ''; $this->setting_option_values['quizModus_single_back_button'] = ''; $this->setting_option_values['quizModus_multiple_questionsPerPage'] = 0; $this->setting_option_values['quizModus'] = (int) $this->quiz_edit['quiz']->getQuizModus(); if ( 0 === $this->setting_option_values['quizModus'] ) { $this->setting_option_values['quizModus'] = 'single'; $this->setting_option_values['quizModus_single_feedback'] = 'end'; } elseif ( 1 === $this->setting_option_values['quizModus'] ) { $this->setting_option_values['quizModus'] = 'single'; $this->setting_option_values['quizModus_single_feedback'] = 'end'; $this->setting_option_values['quizModus_single_back_button'] = 'on'; } elseif ( 2 === $this->setting_option_values['quizModus'] ) { $this->setting_option_values['quizModus'] = 'single'; $this->setting_option_values['quizModus_single_feedback'] = 'each'; } elseif ( 3 === $this->setting_option_values['quizModus'] ) { $this->setting_option_values['quizModus'] = 'multiple'; $this->setting_option_values['quizModus_multiple_questionsPerPage'] = (int) $this->quiz_edit['quiz']->getQuestionsPerPage(); } $this->setting_option_values['titleHidden'] = $this->quiz_edit['quiz']->isTitleHidden(); if ( true !== $this->setting_option_values['titleHidden'] ) { $this->setting_option_values['titleHidden'] = 'on'; } else { $this->setting_option_values['titleHidden'] = ''; } } if ( ( 'on' === $this->setting_option_values['showPoints'] ) || ( 'on' === $this->setting_option_values['showCategory'] ) || ( 'on' === $this->setting_option_values['hideQuestionPositionOverview'] ) || ( 'on' === $this->setting_option_values['hideQuestionNumbering'] ) || ( 'on' === $this->setting_option_values['numberedAnswer'] ) ) { $this->setting_option_values['custom_question_elements'] = 'on'; } else { $this->setting_option_values['custom_question_elements'] = ''; } } foreach ( $this->settings_fields_map as $_internal => $_external ) { if ( ! isset( $this->setting_option_values[ $_internal ] ) ) { $this->setting_option_values[ $_internal ] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; //apply_filters( $this->settings_screen_id . '_display_settings', $this->settings_fields_legacy, $this->settings_screen_id, $this->settings_values_legacy ); $this->setting_option_fields = array( 'quizModus_single_back_button' => array( 'name' => 'quizModus_single_back_button', 'label_none' => true, 'input_full' => true, 'type' => 'checkbox', 'value' => $this->setting_option_values['quizModus_single_back_button'], 'default' => '', 'options' => array( 'on' => esc_html__( 'Display Back button', 'learndash' ), ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['quizModus_single_back_button_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'quizModus_single_feedback' => array( 'name' => 'quizModus_single_feedback', 'label_none' => true, 'input_full' => true, 'type' => 'radio', 'value' => $this->setting_option_values['quizModus_single_feedback'], 'default' => 'end', 'options' => array( 'end' => array( 'label' => esc_html__( 'Display results at the end only', 'learndash' ), 'inline_fields' => array( 'quizModus_single' => $this->settings_sub_option_fields['quizModus_single_back_button_fields'], ), 'inner_section_state' => ( 'end' === $this->setting_option_values['quizModus_single_feedback'] ) ? 'open' : 'closed', ), 'each' => array( 'label' => esc_html__( 'Display results after each submitted answer', 'learndash' ), ), ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['quizModus_single_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'quizModus_multiple_questionsPerPage' => array( 'name' => 'quizModus_multiple_questionsPerPage', 'type' => 'number', 'class' => 'small-text', 'label_none' => true, 'input_full' => true, 'input_label' => sprintf( // translators: placeholder: questions. esc_html_x( '%s per page (0 = all)', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), 'attrs' => array( 'step' => 1, 'min' => 0, ), 'value' => $this->setting_option_values['quizModus_multiple_questionsPerPage'], 'default' => 0, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['quizModus_multiple_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'showMaxQuestionValue' => array( 'name' => 'showMaxQuestionValue', 'type' => 'number', 'class' => 'small-text', 'label_none' => true, 'input_full' => true, 'input_label' => sprintf( // translators: placeholder: questions. esc_html_x( 'out of %1$d %2$s.', 'placeholder: count of questions, questions label.', 'learndash' ), $this->questions_count, learndash_get_custom_label_lower( 'questions' ) ), 'attrs' => array( 'step' => 1, 'min' => 0, 'max' => $this->questions_count, ), 'value' => $this->setting_option_values['showMaxQuestionValue'], 'default' => 0, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['showMaxQuestionValue_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'quiz_materials_enabled' => array( 'name' => 'quiz_materials_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Materials', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'help_text' => sprintf( // translators: placeholder: quiz, quiz. esc_html_x( 'List and display support materials for the %1$s. This is visible to any user having access to the %2$s.', 'placeholder: quiz, quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => $this->setting_option_values['quiz_materials_enabled'], 'default' => '', 'options' => array( 'on' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Any content added below is displayed on the %s page', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), '' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['quiz_materials_enabled'] ) ? 'open' : 'closed', ), 'quiz_materials' => array( 'name' => 'quiz_materials', 'type' => 'wpeditor', 'parent_setting' => 'quiz_materials_enabled', 'value' => $this->setting_option_values['quiz_materials'], 'default' => '', 'placeholder' => esc_html__( 'Add a list of needed documents or URLs. This field supports HTML.', 'learndash' ), 'editor_args' => array( 'textarea_name' => $this->settings_metabox_key . '[quiz_materials]', 'textarea_rows' => 3, ), ), 'autostart' => array( 'name' => 'autostart', 'type' => 'checkbox', 'label' => esc_html__( 'Autostart', 'learndash' ), 'value' => $this->setting_option_values['autostart'], 'default' => '', 'options' => array( 'on' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Start automatically, without the "Start %s" button', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ), ), 'quizModus' => array( 'name' => 'quizModus', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Display', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'type' => 'select', 'default' => 'single', 'value' => $this->setting_option_values['quizModus'], 'options' => array( 'single' => array( 'label' => sprintf( // translators: placeholder: question. esc_html_x( 'One %s at a time', 'placeholder: question', 'learndash' ), learndash_get_custom_label_lower( 'question' ) ), 'inline_fields' => array( 'quizModus_single' => $this->settings_sub_option_fields['quizModus_single_fields'], ), 'inner_section_state' => ( 'single' === $this->setting_option_values['quizModus'] ) ? 'open' : 'closed', ), 'multiple' => array( 'label' => sprintf( // translators: placeholder: questions. esc_html_x( 'All %s at once (or paginated)', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), 'inline_fields' => array( 'quizModus_multiple' => $this->settings_sub_option_fields['quizModus_multiple_fields'], ), 'inner_section_state' => ( 'multiple' === $this->setting_option_values['quizModus'] ) ? 'open' : 'closed', ), ), ), 'showReviewQuestion' => array( 'name' => 'showReviewQuestion', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Overview Table', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['showReviewQuestion'], 'default' => '', 'options' => array( '' => '', 'on' => sprintf( // translators: placeholder: Quiz, Questions. esc_html_x( 'An overview table will be shown for all %s.', 'placeholder: Questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['showReviewQuestion'] ) ? 'open' : 'closed', ), 'quizSummaryHide' => array( 'name' => 'quizSummaryHide', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Summary', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['quizSummaryHide'], 'default' => '', 'options' => array( '' => '', 'on' => esc_html__( 'Display a summary table before submission', 'learndash' ), ), 'parent_setting' => 'showReviewQuestion', ), 'skipQuestionDisabled' => array( 'name' => 'skipQuestionDisabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( 'Skip %s', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['skipQuestionDisabled'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'showReviewQuestion', ), 'custom_sorting' => array( 'name' => 'custom_sorting', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( 'Custom %s Ordering', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['custom_sorting'], 'default' => '', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['custom_sorting'] ) ? 'open' : 'closed', ), 'sortCategories' => array( 'name' => 'sortCategories', 'type' => 'checkbox', 'label' => esc_html__( 'Sort by Category', 'learndash' ), 'value' => $this->setting_option_values['sortCategories'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_sorting', ), 'questionRandom' => array( 'name' => 'questionRandom', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Randomize Order', 'learndash' ), 'value' => $this->setting_option_values['questionRandom'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_sorting', 'child_section_state' => ( 'on' === $this->setting_option_values['questionRandom'] ) ? 'open' : 'closed', ), 'showMaxQuestion' => array( 'name' => 'showMaxQuestion', 'label' => '', 'type' => 'radio', 'value' => $this->setting_option_values['showMaxQuestion'], 'default' => '', 'options' => array( '' => array( 'label' => sprintf( // translators: placeholder: questions. esc_html_x( 'Display all %s', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), ), 'on' => array( 'label' => sprintf( // translators: placeholder: questions. esc_html_x( 'Display subset of %s', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), 'inline_fields' => array( 'showMaxQuestionValue_fields' => $this->settings_sub_option_fields['showMaxQuestionValue_fields'], ), 'inner_section_state' => ( 'on' === $this->setting_option_values['showMaxQuestion'] ) ? 'open' : 'closed', ), ), 'parent_setting' => 'questionRandom', ), 'custom_question_elements' => array( 'name' => 'custom_question_elements', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( 'Additional %s Options', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['custom_question_elements'], 'default' => '', 'options' => array( '' => '', 'on' => sprintf( // translators: placeholder: Question. esc_html_x( 'Any enabled elements below will be displayed in each %s', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['custom_question_elements'] ) ? 'open' : 'closed', ), 'showPoints' => array( 'name' => 'showPoints', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Point Value', 'learndash' ), 'value' => $this->setting_option_values['showPoints'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'showCategory' => array( 'name' => 'showCategory', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Category', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['showCategory'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'hideQuestionPositionOverview' => array( 'name' => 'hideQuestionPositionOverview', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Position', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['hideQuestionPositionOverview'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'hideQuestionNumbering' => array( 'name' => 'hideQuestionNumbering', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Numbering', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['hideQuestionNumbering'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'numberedAnswer' => array( 'name' => 'numberedAnswer', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Number Answers', 'learndash' ), 'value' => $this->setting_option_values['numberedAnswer'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'answerRandom' => array( 'name' => 'answerRandom', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Randomize Answers', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: question. esc_html_x( 'Answer display will be randomized within any given %s.', 'placeholder: question.', 'learndash' ), learndash_get_custom_label_lower( 'question' ) ), 'value' => $this->setting_option_values['answerRandom'], 'default' => '', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_question_elements', ), 'titleHidden' => array( 'name' => 'titleHidden', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( '%s Title', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'value' => $this->setting_option_values['titleHidden'], 'default' => '', 'help_text' => sprintf( // translators: placeholder: quiz, Quiz, Quizzes. esc_html_x( 'A second %1$s title will be displayed on the %2$s Post. This option is recommended if displaying %3$s via Shortcode.', 'placeholder: quiz, Quiz, Quizzes.', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ), learndash_get_custom_label( 'quiz' ), learndash_get_custom_label( 'quizzes' ) ), 'options' => array( '' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Only the %s Post title is shown', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'on' => sprintf( // translators: placeholder: Quiz, Quiz, quiz. esc_html_x( 'The %1$s Title is displayed in addition to the %2$s Post title. Recommended for %3$s shortcode usage.', 'placeholder: Quiz, Quiz, quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ), learndash_get_custom_label( 'quiz' ), learndash_get_custom_label_lower( 'quiz' ) ), ), ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( 'on' !== $settings_values['quiz_materials_enabled'] ) || ( empty( $settings_values['quiz_materials'] ) ) ) { $settings_values['quiz_materials_enabled'] = ''; $settings_values['quiz_materials'] = ''; } if ( ( isset( $settings_values['autostart'] ) ) && ( 'on' === $settings_values['autostart'] ) ) { $settings_values['autostart'] = true; } else { $settings_values['autostart'] = false; } if ( ( isset( $settings_values['showReviewQuestion'] ) ) && ( 'on' === $settings_values['showReviewQuestion'] ) ) { $settings_values['showReviewQuestion'] = true; } else { $settings_values['showReviewQuestion'] = false; } if ( ( isset( $settings_values['quizSummaryHide'] ) ) && ( 'on' === $settings_values['quizSummaryHide'] ) ) { $settings_values['quizSummaryHide'] = false; } else { $settings_values['quizSummaryHide'] = true; } if ( ( isset( $settings_values['skipQuestionDisabled'] ) ) && ( 'on' === $settings_values['skipQuestionDisabled'] ) ) { $settings_values['skipQuestionDisabled'] = false; } else { $settings_values['skipQuestionDisabled'] = true; } if ( ( isset( $settings_values['sortCategories'] ) ) && ( 'on' === $settings_values['sortCategories'] ) ) { $settings_values['sortCategories'] = true; } else { $settings_values['sortCategories'] = false; } if ( ( isset( $settings_values['questionRandom'] ) ) && ( 'on' === $settings_values['questionRandom'] ) ) { $settings_values['questionRandom'] = true; } else { $settings_values['questionRandom'] = false; } if ( ( isset( $settings_values['answerRandom'] ) ) && ( 'on' === $settings_values['answerRandom'] ) ) { $settings_values['answerRandom'] = true; } else { $settings_values['answerRandom'] = false; } if ( ( isset( $settings_values['showMaxQuestion'] ) ) && ( 'on' === $settings_values['showMaxQuestion'] ) ) { $settings_values['showMaxQuestion'] = true; } else { $settings_values['showMaxQuestion'] = false; } if ( ( isset( $settings_values['showMaxQuestionValue'] ) ) && ( ! empty( $settings_values['showMaxQuestionValue'] ) ) ) { $settings_values['showMaxQuestionValue'] = absint( $settings_values['showMaxQuestionValue'] ); if ( empty( $settings_values['showMaxQuestionValue'] ) ) { $settings_values['showMaxQuestionValue'] = ''; } } else { $settings_values['showMaxQuestion'] = ''; } //if ( ( isset( $settings_values['answerRandom'] ) ) && ( 'on' === $settings_values['answerRandom'] ) ) { // $settings_values['answerRandom'] = true; //} else { // $settings_values['answerRandom'] = false; //} if ( ( isset( $settings_values['showPoints'] ) ) && ( 'on' === $settings_values['showPoints'] ) ) { $settings_values['showPoints'] = true; } else { $settings_values['showPoints'] = false; } if ( ( isset( $settings_values['showCategory'] ) ) && ( 'on' === $settings_values['showCategory'] ) ) { $settings_values['showCategory'] = true; } else { $settings_values['showCategory'] = false; } if ( ( isset( $settings_values['hideQuestionPositionOverview'] ) ) && ( 'on' === $settings_values['hideQuestionPositionOverview'] ) ) { $settings_values['hideQuestionPositionOverview'] = false; } else { $settings_values['hideQuestionPositionOverview'] = true; } if ( ( isset( $settings_values['hideQuestionNumbering'] ) ) && ( 'on' === $settings_values['hideQuestionNumbering'] ) ) { $settings_values['hideQuestionNumbering'] = false; } else { $settings_values['hideQuestionNumbering'] = true; } if ( ( isset( $settings_values['numberedAnswer'] ) ) && ( 'on' === $settings_values['numberedAnswer'] ) ) { $settings_values['numberedAnswer'] = true; } else { $settings_values['numberedAnswer'] = false; } if ( ( isset( $settings_values['titleHidden'] ) ) && ( 'on' === $settings_values['titleHidden'] ) ) { $settings_values['titleHidden'] = false; } else { $settings_values['titleHidden'] = true; } if ( ( isset( $settings_values['quizModus'] ) ) && ( ! empty( $settings_values['quizModus'] ) ) ) { if ( 'single' === $settings_values['quizModus'] ) { $settings_values['quizModus_multiple_questionsPerPage'] = 0; $settings_values['quizModus'] = 0; if ( 'on' === $settings_values['quizModus_single_back_button'] ) { $settings_values['quizModus'] = 1; } if ( 'each' === $settings_values['quizModus_single_feedback'] ) { $settings_values['quizModus'] = 2; } } elseif ( 'multiple' === $settings_values['quizModus'] ) { $settings_values['quizModus'] = 3; if ( isset( $settings_values['quizModus_multiple_questionsPerPage'] ) ) { $settings_values['quizModus_multiple_questionsPerPage'] = absint( $settings_values['quizModus_multiple_questionsPerPage'] ); } } } if ( ( isset( $settings_values['custom_sorting'] ) ) && ( 'on' === $settings_values['custom_sorting'] ) ) { if ( ( isset( $settings_values['questionRandom'] ) ) && ( true === $settings_values['questionRandom'] ) ) { if ( ( isset( $settings_values['showMaxQuestion'] ) ) && ( true === $settings_values['showMaxQuestion'] ) ) { if ( ( isset( $settings_values['showMaxQuestionValue'] ) ) && ( ! empty( $settings_values['showMaxQuestionValue'] ) ) ) { $settings_values['showMaxQuestionValue'] = absint( $settings_values['showMaxQuestionValue'] ); } else { $settings_values['showMaxQuestion'] = ''; $settings_values['showMaxQuestionValue'] = 0; } } else { $settings_values['showMaxQuestion'] = ''; } } else { $settings_values['questionRandom'] = ''; } } else { $settings_values['custom_sorting'] = ''; $settings_values['questionRandom'] = ''; $settings_values['showMaxQuestion'] = ''; $settings_values['showMaxQuestionValue'] = ''; } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'quiz' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Quiz_Display_Content'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Quiz_Display_Content' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Quiz_Display_Content'] = LearnDash_Settings_Metabox_Quiz_Display_Content::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\ __Usettings-metaboxes/class-ld-settings-metabox-quiz-results-display-content-options.phpnuW+Asettings_screen_id = 'sfwd-quiz'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-quiz-results-options'; // Section label/header. $this->settings_section_label = esc_html__( 'Results Page Display', 'learndash' ); $this->settings_section_description = esc_html__( 'Controls how the results page will look', 'learndash' ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'resultGradeEnabled' => 'resultGradeEnabled', 'resultText' => 'resultText', 'resultTextGrade' => 'resultTextGrade', 'btnRestartQuizHidden' => 'btnRestartQuizHidden', 'showAverageResult' => 'showAverageResult', 'showCategoryScore' => 'showCategoryScore', 'hideResultPoints' => 'hideResultPoints', 'hideResultCorrectQuestion' => 'hideResultCorrectQuestion', 'hideResultQuizTime' => 'hideResultQuizTime', 'hideAnswerMessageBox' => 'hideAnswerMessageBox', 'disabledAnswerMark' => 'disabledAnswerMark', 'btnViewQuestionHidden' => 'btnViewQuestionHidden', 'custom_answer_feedback' => 'custom_answer_feedback', ); parent::__construct(); } public function save_fields_to_post( $pro_quiz_edit, $settings_values = array() ) { $_POST['resultGradeEnabled'] = $settings_values['resultGradeEnabled']; $_POST['btnRestartQuizHidden'] = $settings_values['btnRestartQuizHidden']; $_POST['showAverageResult'] = $settings_values['showAverageResult']; $_POST['showCategoryScore'] = $settings_values['showCategoryScore']; $_POST['hideResultPoints'] = $settings_values['hideResultPoints']; $_POST['hideResultCorrectQuestion'] = $settings_values['hideResultCorrectQuestion']; $_POST['hideResultQuizTime'] = $settings_values['hideResultQuizTime']; $_POST['hideAnswerMessageBox'] = $settings_values['hideAnswerMessageBox']; $_POST['disabledAnswerMark'] = $settings_values['disabledAnswerMark']; $_POST['btnViewQuestionHidden'] = $settings_values['btnViewQuestionHidden']; } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $this->quiz_edit = $this->init_quiz_edit( $this->_post ); if ( true === $this->settings_values_loaded ) { if ( $this->quiz_edit['quiz'] ) { $this->setting_option_values['resultGradeEnabled'] = $this->quiz_edit['quiz']->isResultGradeEnabled(); if ( true === $this->setting_option_values['resultGradeEnabled'] ) { $this->setting_option_values['resultGradeEnabled'] = true; } else { $this->setting_option_values['resultGradeEnabled'] = ''; } // Always enabled. //$this->setting_option_values['resultGradeEnabled'] = true; $this->setting_option_values['btnRestartQuizHidden'] = $this->quiz_edit['quiz']->isBtnRestartQuizHidden(); if ( true !== $this->setting_option_values['btnRestartQuizHidden'] ) { $this->setting_option_values['btnRestartQuizHidden'] = 'on'; } else { $this->setting_option_values['btnRestartQuizHidden'] = ''; } $this->setting_option_values['showAverageResult'] = $this->quiz_edit['quiz']->isShowAverageResult(); if ( true === $this->setting_option_values['showAverageResult'] ) { $this->setting_option_values['showAverageResult'] = 'on'; } else { $this->setting_option_values['showAverageResult'] = ''; } $this->setting_option_values['showCategoryScore'] = $this->quiz_edit['quiz']->isShowCategoryScore(); if ( true === $this->setting_option_values['showCategoryScore'] ) { $this->setting_option_values['showCategoryScore'] = 'on'; } else { $this->setting_option_values['showCategoryScore'] = ''; } $this->setting_option_values['hideResultPoints'] = $this->quiz_edit['quiz']->isHideResultPoints(); if ( true !== $this->setting_option_values['hideResultPoints'] ) { $this->setting_option_values['hideResultPoints'] = 'on'; } else { $this->setting_option_values['hideResultPoints'] = ''; } $this->setting_option_values['hideResultCorrectQuestion'] = $this->quiz_edit['quiz']->isHideResultCorrectQuestion(); if ( true !== $this->setting_option_values['hideResultCorrectQuestion'] ) { $this->setting_option_values['hideResultCorrectQuestion'] = 'on'; } else { $this->setting_option_values['hideResultCorrectQuestion'] = ''; } $this->setting_option_values['hideResultQuizTime'] = $this->quiz_edit['quiz']->isHideResultQuizTime(); if ( true !== $this->setting_option_values['hideResultQuizTime'] ) { $this->setting_option_values['hideResultQuizTime'] = 'on'; } else { $this->setting_option_values['hideResultQuizTime'] = ''; } if ( ( 'on' === $this->setting_option_values['showAverageResult'] ) || ( 'on' === $this->setting_option_values['showCategoryScore'] ) || ( 'on' === $this->setting_option_values['hideResultPoints'] ) || ( 'on' === $this->setting_option_values['hideResultCorrectQuestion'] ) || ( 'on' === $this->setting_option_values['hideResultQuizTime'] ) ) { $this->setting_option_values['custom_result_data_display'] = 'on'; } else { $this->setting_option_values['custom_result_data_display'] = ''; } $this->setting_option_values['hideAnswerMessageBox'] = $this->quiz_edit['quiz']->isHideAnswerMessageBox(); if ( true !== $this->setting_option_values['hideAnswerMessageBox'] ) { $this->setting_option_values['hideAnswerMessageBox'] = 'on'; } else { $this->setting_option_values['hideAnswerMessageBox'] = ''; } $this->setting_option_values['disabledAnswerMark'] = $this->quiz_edit['quiz']->isDisabledAnswerMark(); if ( true !== $this->setting_option_values['disabledAnswerMark'] ) { $this->setting_option_values['disabledAnswerMark'] = 'on'; } else { $this->setting_option_values['disabledAnswerMark'] = ''; } $this->setting_option_values['btnViewQuestionHidden'] = $this->quiz_edit['quiz']->isBtnViewQuestionHidden(); if ( true !== $this->setting_option_values['btnViewQuestionHidden'] ) { $this->setting_option_values['btnViewQuestionHidden'] = 'on'; } else { $this->setting_option_values['btnViewQuestionHidden'] = ''; } if ( ( 'on' === $this->setting_option_values['hideAnswerMessageBox'] ) || ( 'on' === $this->setting_option_values['disabledAnswerMark'] ) || ( 'on' === $this->setting_option_values['btnViewQuestionHidden'] ) ) { $this->setting_option_values['custom_answer_feedback'] = 'on'; } else { $this->setting_option_values['custom_answer_feedback'] = ''; } $this->setting_option_values['resultTextGrade'] = array(); $this->setting_option_values['resultText'] = $this->quiz_edit['quiz']->getResultText(); if ( ( '' === $this->setting_option_values['resultText'] ) || ( isset ( $this->setting_option_values['resultText']['text'][0] ) ) && ( ! empty( $this->setting_option_values['resultText']['text'][0] ) ) ) { $this->setting_option_values['resultGradeEnabled'] = 'on'; if ( is_array( $this->setting_option_values['resultText'] ) ) { $this->setting_option_values['resultTextGrade'] = $this->setting_option_values['resultText']; } else { $this->setting_option_values['resultTextGrade']['text'][0] = $this->setting_option_values['resultText']; $this->setting_option_values['resultTextGrade']['prozent'][0] = '0'; $this->setting_option_values['resultTextGrade']['activ'][0] = '1'; } } else { $this->setting_option_values['resultGradeEnabled'] = ''; } } } foreach ( $this->settings_fields_map as $_internal => $_external ) { if ( ! isset( $this->setting_option_values[ $_internal ] ) ) { $this->setting_option_values[ $_internal ] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; $this->setting_option_fields = array( 'resultGradeEnabled' => array( 'name' => 'resultGradeEnabled', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Result Message(s)', 'learndash' ), 'value' => $this->setting_option_values['resultGradeEnabled'], 'default' => '', 'help_text' => esc_html__( "When enabled, the first message will be diplayed to ALL users. To customize the message based on earned score, add new Graduation Levels and set the 'From' field to the desired grade.", 'learndash' ), 'options' => array( '' => '', 'on' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'The message below is displayed on the %s results page.', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'Quiz' ) ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['resultGradeEnabled'] ) ? 'open' : 'closed', ), 'resultText' => array( 'name' => 'resultText', 'type' => 'custom', 'label_none' => true, 'input_full' => true, 'parent_setting' => 'resultGradeEnabled', 'html' => $this->get_custom_result_messages(), ), 'btnRestartQuizHidden' => array( 'name' => 'btnRestartQuizHidden', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Restart %s button', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'Quiz' ) ), 'value' => $this->setting_option_values['btnRestartQuizHidden'], 'default' => 'on', 'options' => array( 'on' => '', ), ), 'custom_result_data_display' => array( 'name' => 'custom_result_data_display', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Custom Results Display', 'learndash' ), 'value' => $this->setting_option_values['custom_result_data_display'], 'default' => 'on', 'options' => array( '' => '', 'on' => esc_html__( 'Enable the items you wish to display on the Result Page', 'learndash' ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['custom_result_data_display'] ) ? 'open' : 'closed', ), 'showAverageResult' => array( 'name' => 'showAverageResult', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Average Score', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: quiz. esc_html_x( 'Display the average score of all users who took the %s', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), 'value' => $this->setting_option_values['showAverageResult'], 'default' => 'on', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_result_data_display', ), 'showCategoryScore' => array( 'name' => 'showCategoryScore', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Category Score', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: Question. esc_html_x( 'Display the score achieved for each %s Category', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'value' => $this->setting_option_values['showCategoryScore'], 'default' => 'on', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_result_data_display', ), 'hideResultPoints' => array( 'name' => 'hideResultPoints', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Overall Score', 'learndash' ), 'parent_setting' => 'custom_result_data_display', 'value' => $this->setting_option_values['hideResultPoints'], 'default' => 'on', 'options' => array( 'on' => '', '' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'The achieved %s score is NOT be displayed on the Results page', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), ), ), 'hideResultCorrectQuestion' => array( 'name' => 'hideResultCorrectQuestion', 'type' => 'checkbox-switch', 'label' => esc_html__( 'No. of Correct Answers', 'learndash' ), 'parent_setting' => 'custom_result_data_display', 'value' => $this->setting_option_values['hideResultCorrectQuestion'], 'default' => 'on', 'options' => array( 'on' => '', '' => sprintf( // translators: placeholder: Questions. esc_html_x( 'The number of correctly answered %s is NOT displayed on the Results page.', 'placeholder: Questions', 'learndash' ), learndash_get_custom_label( 'questions' ) ), ), ), 'hideResultQuizTime' => array( 'name' => 'hideResultQuizTime', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Time Spent', 'learndash' ), 'parent_setting' => 'custom_result_data_display', 'value' => $this->setting_option_values['hideResultQuizTime'], 'default' => 'on', 'options' => array( 'on' => '', ), ), 'custom_answer_feedback' => array( 'name' => 'custom_answer_feedback', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Custom Answer Feedback', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: questions. esc_html_x( 'Select which data users should be able to view when reviewing their submitted %s.', 'placeholder: questions', 'learndash' ), learndash_get_custom_label_lower( 'questions' ) ), 'value' => $this->setting_option_values['custom_answer_feedback'], 'default' => 'on', 'options' => array( 'on' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['custom_answer_feedback'] ) ? 'open' : 'closed', ), 'hideAnswerMessageBox' => array( 'name' => 'hideAnswerMessageBox', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Correct / Incorrect Messages', 'learndash' ), 'value' => $this->setting_option_values['hideAnswerMessageBox'], 'default' => 'on', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_answer_feedback', ), 'disabledAnswerMark' => array( 'name' => 'disabledAnswerMark', 'type' => 'checkbox-switch', 'label' => esc_html__( 'Correct / Incorrect Answer Marks', 'learndash' ), 'value' => $this->setting_option_values['disabledAnswerMark'], 'default' => 'on', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_answer_feedback', ), 'btnViewQuestionHidden' => array( 'name' => 'btnViewQuestionHidden', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Questions. esc_html_x( 'View %s Button', 'placeholder: Questions', 'learndash' ), learndash_get_custom_label( 'questions' ) ), 'value' => $this->setting_option_values['btnViewQuestionHidden'], 'default' => 'on', 'options' => array( 'on' => '', ), 'parent_setting' => 'custom_answer_feedback', ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( isset( $settings_values['resultGradeEnabled'] ) ) && ( 'on' === $settings_values['resultGradeEnabled'] ) ) { $settings_values['resultGradeEnabled'] = true; } else { $settings_values['resultGradeEnabled'] = false; } //if ( isset( $_POST['resultTextGrade'] ) ) { // if ( ( isset( $_POST['resultTextGrade']['text'][0] ) ) && ( ! empty( $_POST['resultTextGrade']['text'][0] ) ) ) { // $settings_values['btnRestartQuizHidden'] = true; // } //} if ( ( ! isset( $settings_values['btnRestartQuizHidden'] ) ) || ( 'on' === $settings_values['btnRestartQuizHidden'] ) ) { $settings_values['btnRestartQuizHidden'] = false; } else { $settings_values['btnRestartQuizHidden'] = true; } if ( ! isset( $settings_values['showAverageResult'] ) ) { $settings_values['showAverageResult'] = ''; } if ( ! isset( $settings_values['showCategoryScore'] ) ) { $settings_values['showCategoryScore'] = ''; } if ( ( ! isset( $settings_values['hideResultPoints'] ) ) || ( 'on' === $settings_values['hideResultPoints'] ) ) { $settings_values['hideResultPoints'] = false; } else { $settings_values['hideResultPoints'] = true; } if ( ( ! isset( $settings_values['hideResultCorrectQuestion'] ) ) || ( 'on' === $settings_values['hideResultCorrectQuestion'] ) ) { $settings_values['hideResultCorrectQuestion'] = false; } else { $settings_values['hideResultCorrectQuestion'] = true; } if ( ( ! isset( $settings_values['hideResultQuizTime'] ) ) || ( 'on' === $settings_values['hideResultQuizTime'] ) ) { $settings_values['hideResultQuizTime'] = false; } else { $settings_values['hideResultQuizTime'] = true; } if ( ( ! isset( $settings_values['hideAnswerMessageBox'] ) ) || ( 'on' === $settings_values['hideAnswerMessageBox'] ) ) { $settings_values['hideAnswerMessageBox'] = false; } else { $settings_values['hideAnswerMessageBox'] = true; } if ( ( ! isset( $settings_values['disabledAnswerMark'] ) ) || ( 'on' === $settings_values['disabledAnswerMark'] ) ) { $settings_values['disabledAnswerMark'] = false; } else { $settings_values['disabledAnswerMark'] = true; } if ( ( ! isset( $settings_values['btnViewQuestionHidden'] ) ) || ( 'on' === $settings_values['btnViewQuestionHidden'] ) ) { $settings_values['btnViewQuestionHidden'] = false; } else { $settings_values['btnViewQuestionHidden'] = true; } if ( ! isset( $settings_values['custom_answer_feedback'] ) ) { $settings_values['custom_answer_feedback'] = ''; } if ( '' === $settings_values['custom_answer_feedback'] ) { $settings_values['hideAnswerMessageBox'] = true; $settings_values['disabledAnswerMark'] = true; $settings_values['btnViewQuestionHidden'] = true; } if ( ! isset( $settings_values['custom_result_data_display'] ) ) { $settings_values['custom_result_data_display'] = ''; } } return $settings_values; } public function get_custom_result_messages() { $result_text = $this->setting_option_values['resultText']; $html = ''; $level = ob_get_level(); ob_start(); ?>
    • ' ); ?>
      3, 'textarea_name' => 'resultTextGrade[text][]', ) ); ?>
    settings_screen_id = 'sfwd-lessons'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-lesson-display-content-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Display and Content Options', 'learndash' ); // Used to show the section description above the fields. Can be empty. $this->settings_section_description = sprintf( // translators: placeholder: lesson. esc_html_x( 'Controls the look and feel of the %s and optional content settings', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( // New fields 'lesson_materials_enabled' => 'lesson_materials_enabled', 'lesson_materials' => 'lesson_materials', 'lesson_video_enabled' => 'lesson_video_enabled', 'lesson_video_url' => 'lesson_video_url', 'lesson_video_shown' => 'lesson_video_shown', 'lesson_video_auto_start' => 'lesson_video_auto_start', 'lesson_video_show_controls' => 'lesson_video_show_controls', 'lesson_video_auto_complete' => 'lesson_video_auto_complete', 'lesson_video_auto_complete_delay' => 'lesson_video_auto_complete_delay', 'lesson_video_hide_complete_button' => 'lesson_video_hide_complete_button', 'lesson_video_show_complete_button' => 'lesson_video_show_complete_button', 'lesson_assignment_upload' => 'lesson_assignment_upload', 'assignment_upload_limit_extensions' => 'assignment_upload_limit_extensions', 'assignment_upload_limit_size' => 'assignment_upload_limit_size', 'lesson_assignment_points_enabled' => 'lesson_assignment_points_enabled', 'lesson_assignment_points_amount' => 'lesson_assignment_points_amount', 'assignment_upload_limit_count' => 'assignment_upload_limit_count', 'lesson_assignment_deletion_enabled' => 'lesson_assignment_deletion_enabled', 'auto_approve_assignment' => 'auto_approve_assignment', 'forced_lesson_time_enabled' => 'forced_lesson_time_enabled', 'forced_lesson_time' => 'forced_lesson_time', //'forced_lesson_time_cookie_key' => 'forced_lesson_time_cookie_key', ); parent::__construct(); } /** * Initialize the metabox settings values. */ public function load_settings_values() { global $sfwd_lms; $post_settings_fields = $sfwd_lms->get_post_args_section( $this->settings_screen_id, 'fields' ); parent::load_settings_values(); if ( true === $this->settings_values_loaded ) { if ( ! isset( $this->setting_option_values['lesson_materials'] ) ) { $this->setting_option_values['lesson_materials'] = ''; } if ( ! empty( $this->setting_option_values['lesson_materials'] ) ) { $this->setting_option_values['lesson_materials_enabled'] = 'on'; } else { $this->setting_option_values['lesson_materials_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_enabled'] ) ) { $this->setting_option_values['lesson_video_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_url'] ) ) { $this->setting_option_values['lesson_video_url'] = ''; } if ( ( ! isset( $this->setting_option_values['lesson_video_shown'] ) ) || ( empty( $this->setting_option_values['lesson_video_shown'] ) ) ) { $this->setting_option_values['lesson_video_shown'] = 'BEFORE'; } if ( ! isset( $this->setting_option_values['lesson_video_auto_start'] ) ) { $this->setting_option_values['lesson_video_auto_start'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_show_controls'] ) ) { $this->setting_option_values['lesson_video_show_controls'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_auto_complete'] ) ) { $this->setting_option_values['lesson_video_auto_complete'] = ''; } if ( ! isset( $this->setting_option_values['lesson_video_auto_complete_delay'] ) ) { $this->setting_option_values['lesson_video_auto_complete_delay'] = '0'; } if ( ! isset( $this->setting_option_values['lesson_video_hide_complete_button'] ) ) { $this->setting_option_values['lesson_video_hide_complete_button'] = ''; } if ( 'on' === $this->setting_option_values['lesson_video_hide_complete_button'] ) { $this->setting_option_values['lesson_video_show_complete_button'] = ''; } else { $this->setting_option_values['lesson_video_show_complete_button'] = 'on'; } if ( ! isset( $this->setting_option_values['lesson_assignment_upload'] ) ) { $this->setting_option_values['lesson_assignment_upload'] = ''; } if ( ! isset( $this->setting_option_values['assignment_upload_limit_extensions'] ) ) { $this->setting_option_values['assignment_upload_limit_extensions'] = ''; } if ( ! empty( $this->setting_option_values['assignment_upload_limit_extensions'] ) ) { if ( is_array( $this->setting_option_values['assignment_upload_limit_extensions'] ) ) { if ( count( $this->setting_option_values['assignment_upload_limit_extensions'] ) > 1 ) { $this->setting_option_values['assignment_upload_limit_extensions'] = implode( ',', $this->setting_option_values['assignment_upload_limit_extensions'] ); } else { $this->setting_option_values['assignment_upload_limit_extensions'] = $this->setting_option_values['assignment_upload_limit_extensions'][0]; } } } if ( ! isset( $this->setting_option_values['assignment_upload_limit_size'] ) ) { $this->setting_option_values['assignment_upload_limit_size'] = ''; } if ( ! isset( $this->setting_option_values['lesson_assignment_points_enabled'] ) ) { $this->setting_option_values['lesson_assignment_points_enabled'] = ''; } if ( ! isset( $this->setting_option_values['lesson_assignment_points_amount'] ) ) { $this->setting_option_values['lesson_assignment_points_amount'] = ''; } if ( ! isset( $this->setting_option_values['assignment_upload_limit_count'] ) ) { $this->setting_option_values['assignment_upload_limit_count'] = ''; } $this->setting_option_values['assignment_upload_limit_count'] = absint( $this->setting_option_values['assignment_upload_limit_count'] ); if ( empty( $this->setting_option_values['assignment_upload_limit_count'] ) ) { $this->setting_option_values['assignment_upload_limit_count'] = 1; } if ( ! isset( $this->setting_option_values['lesson_assignment_deletion_enabled'] ) ) { $this->setting_option_values['lesson_assignment_deletion_enabled'] = ''; } if ( ! isset( $this->setting_option_values['auto_approve_assignment'] ) ) { $this->setting_option_values['auto_approve_assignment'] = 'on'; } if ( ! isset( $this->setting_option_values['forced_lesson_time'] ) ) { $this->setting_option_values['forced_lesson_time'] = ''; } if ( ! isset( $this->setting_option_values['forced_lesson_time_enabled'] ) ) { $this->setting_option_values['forced_lesson_time_enabled'] = ''; } if ( ( isset( $this->setting_option_values['forced_lesson_time'] ) ) && ( ! empty( $this->setting_option_values['forced_lesson_time'] ) ) ) { $this->setting_option_values['forced_lesson_time_enabled'] = 'on'; } else { $this->setting_option_values['forced_lesson_time_enabled'] = ''; } } if ( 'on' === $this->setting_option_values['lesson_video_enabled'] ) { $this->setting_option_values['lesson_assignment_upload'] = ''; $this->setting_option_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $this->setting_option_values['lesson_assignment_upload'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $this->setting_option_values['forced_lesson_time_enabled'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['lesson_assignment_upload'] = ''; } if ( 'on' !== $this->setting_option_values['lesson_video_enabled'] ) { $this->setting_option_values['lesson_video_enabled'] = ''; $this->setting_option_values['lesson_video_url'] = ''; $this->setting_option_values['lesson_video_shown'] = ''; $this->setting_option_values['lesson_video_auto_start'] = ''; $this->setting_option_values['lesson_video_show_controls'] = ''; $this->setting_option_values['lesson_video_auto_complete'] = ''; $this->setting_option_values['lesson_video_auto_complete_delay'] = '0'; $this->setting_option_values['lesson_video_show_complete_button'] = ''; } elseif ( 'on' !== $this->setting_option_values['lesson_assignment_upload'] ) { $this->setting_option_values['lesson_assignment_upload'] = ''; $this->setting_option_values['assignment_upload_limit_extensions'] = ''; $this->setting_option_values['assignment_upload_limit_size'] = ''; $this->setting_option_values['lesson_assignment_points_enabled'] = ''; $this->setting_option_values['lesson_assignment_points_amount'] = ''; $this->setting_option_values['assignment_upload_limit_count'] = ''; $this->setting_option_values['lesson_assignment_deletion_enabled'] = ''; $this->setting_option_values['auto_approve_assignment'] = 'on'; } elseif ( 'on' !== $this->setting_option_values['forced_lesson_time_enabled'] ) { $this->setting_option_values['forced_lesson_time_enabled'] = ''; $this->setting_option_values['forced_lesson_time'] = ''; //$this->setting_option_values['forced_lesson_time_cookie_key'] = ''; } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { $this->setting_option_fields = array( 'lesson_video_auto_complete' => array( 'name' => 'lesson_video_auto_complete', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s auto-completion', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'default' => '', 'value' => $this->setting_option_values['lesson_video_auto_complete'], 'options' => array( '' => '', 'on' => '', ), 'help_text' => sprintf( // translators: placeholder: lesson. esc_html_x( ' Automatically mark the %s as completed once the user has watched the full video.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), ), 'lesson_video_auto_complete_delay' => array( 'name' => 'lesson_video_auto_complete_delay', 'label' => esc_html__( 'Completion delay', 'learndash' ), 'type' => 'number', 'class' => '-small', 'default' => 0, 'value' => $this->setting_option_values['lesson_video_auto_complete_delay'], 'attrs' => array( 'step' => 1, 'min' => 0, ), 'input_label' => esc_html__( 'seconds', 'learndash' ), 'help_text' => sprintf( // translators: placeholder: lesson. esc_html_x( 'Specify a delay between video completion and %s completion.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'default' => 0, ), 'lesson_video_show_complete_button' => array( 'name' => 'lesson_video_show_complete_button', 'label' => esc_html__( 'Mark Complete Button', 'learndash' ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['lesson_video_show_complete_button'], 'help_text' => sprintf( // translators: placeholder: lesson. esc_html_x( 'Display the Mark Complete button on a %s even if not yet clickable.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'default' => '', 'options' => array( 'on' => '', ), ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['video_display_timing_after_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'assignment_upload_limit_count' => array( 'name' => 'assignment_upload_limit_count', 'label' => esc_html__( 'Limit number of uploaded files', 'learndash' ), 'type' => 'number', 'value' => $this->setting_option_values['assignment_upload_limit_count'], 'default' => '1', 'class' => 'small-text', 'input_label' => esc_html__( 'file(s) maximum', 'learndash' ), 'attrs' => array( 'step' => 1, 'min' => 1, ), 'help_text' => esc_html__( 'Specify the maximum number of files a user can upload for this assignment.', 'learndash' ), ), 'lesson_assignment_deletion_enabled' => array( 'name' => 'lesson_assignment_deletion_enabled', 'label' => esc_html__( 'Allow file deletion', 'learndash' ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['lesson_assignment_deletion_enabled'], 'default' => '', 'help_text' => esc_html__( 'Allow the user to delete their own uploaded files. This is only possible up until the assignment has been approved.', 'learndash' ), 'options' => array( 'on' => '', ), 'default' => 0, ), ); parent::load_settings_fields(); $this->settings_sub_option_fields['lesson_assignment_grading_manual_fields'] = $this->setting_option_fields; $this->setting_option_fields = array( 'lesson_materials_enabled' => array( 'name' => 'lesson_materials_enabled', 'type' => 'checkbox-switch', 'label' => sprintf( // translators: placeholder: Lesson. esc_html_x( '%s Materials', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'help_text' => sprintf( // translators: placeholder: lesson, lesson. esc_html_x( 'List and display support materials for the %1$s. This is visible to any user having access to the %2$s.', 'placeholder: lesson, lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'lesson' ) ), 'value' => $this->setting_option_values['lesson_materials_enabled'], 'default' => '', 'options' => array( 'on' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Any content added below is displayed on the %s page', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), '' => '', ), 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_materials_enabled'] ) ? 'open' : 'closed', ), 'lesson_materials' => array( 'name' => 'lesson_materials', 'type' => 'wpeditor', 'parent_setting' => 'lesson_materials_enabled', 'value' => $this->setting_option_values['lesson_materials'], 'default' => '', 'placeholder' => esc_html__( 'Add a list of needed documents or URLs. This field supports HTML.', 'learndash' ), 'editor_args' => array( 'textarea_name' => $this->settings_metabox_key . '[lesson_materials]', 'textarea_rows' => 3, ), ), 'lesson_video_enabled' => array( 'name' => 'lesson_video_enabled', 'label' => esc_html__( 'Video Progression', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => sprintf( // translators: placeholder: Course. esc_html_x( 'Require users to watch the full video as part of the %s progression. Use shortcode [ld_video] to move within the post content.', 'placeholder: Course', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), 'value' => $this->setting_option_values['lesson_video_enabled'], 'default' => '', 'options' => array( '' => '', 'on' => array( 'description' => '', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( 'The below video is tied to %s progression', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), 'tooltip' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Cannot be enabled while %s timer or Assignments are enabled', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_video_enabled'] ) ? 'open' : 'closed', ), 'lesson_video_url' => array( 'name' => 'lesson_video_url', 'label' => esc_html__( 'Video URL', 'learndash' ), 'type' => 'textarea', 'class' => 'full-text', 'value' => $this->setting_option_values['lesson_video_url'], 'default' => '', 'placeholder' => esc_html__( 'Input URL, iFrame, or shortcode here.', 'learndash' ), 'attrs' => array( 'rows' => '1', 'cols' => '57', ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_video_shown' => array( 'name' => 'lesson_video_shown', 'label' => esc_html__( 'Display Timing', 'learndash' ), 'type' => 'radio', 'value' => $this->setting_option_values['lesson_video_shown'], 'default' => 'BEFORE', 'parent_setting' => 'lesson_video_enabled', 'options' => array( 'BEFORE' => array( 'label' => esc_html__( 'Before completed sub-steps', 'learndash' ), 'description' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'The video will be shown and must be fully watched before the user can access the %s’s associated steps.', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), ), 'AFTER' => array( 'label' => esc_html__( 'After completing sub-steps', 'learndash' ), 'description' => sprintf( // translators: placeholder: Lesson, Lesson. esc_html_x( 'The video will be visible after the user has completed the %1$s’s associated steps. The full video must be watched in order to complete the %2$s.', 'placeholder: Lesson, Lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ), learndash_get_custom_label_lower( 'lesson' ) ), 'inline_fields' => array( 'lesson_video_display_timing_after' => $this->settings_sub_option_fields['video_display_timing_after_fields'], ), 'inner_section_state' => ( 'AFTER' === $this->setting_option_values['lesson_video_shown'] ) ? 'open' : 'closed', ), ), ), 'lesson_video_auto_start' => array( 'name' => 'lesson_video_auto_start', 'label' => esc_html__( 'Autostart', 'learndash' ), 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['lesson_video_auto_start'], 'help_text' => esc_html__( 'Video may not autostart for mobile users. Check with the video provider for details.', 'learndash' ), 'default' => '', 'options' => array( 'on' => esc_html__( 'The video now starts automatically on page load', 'learndash' ), '' => '', ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_video_show_controls' => array( 'name' => 'lesson_video_show_controls', 'label' => esc_html__( 'Video Controls Display', 'learndash' ), 'type' => 'checkbox-switch', 'help_text' => esc_html__( 'Only available for YouTube and local videos. Vimeo supported if autostart is enabled.', 'learndash' ), 'value' => $this->setting_option_values['lesson_video_show_controls'], 'default' => '', 'options' => array( '' => '', 'on' => esc_html__( 'Users can pause, move backward and forward within the video', 'learndash' ), ), 'parent_setting' => 'lesson_video_enabled', ), 'lesson_assignment_upload' => array( 'name' => 'lesson_assignment_upload', 'label' => esc_html__( 'Assignment Uploads', 'learndash' ), 'type' => 'checkbox-switch', 'default' => '', 'value' => $this->setting_option_values['lesson_assignment_upload'], 'options' => array( 'on' => array( 'label' => '', 'description' => '', 'tooltip' => sprintf( // translators: placeholder: Lesson. esc_html_x( 'Cannot be enabled while %s timer or Video progression are enabled', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_assignment_upload'] ) ? 'open' : 'closed', ), 'assignment_upload_limit_extensions' => array( 'name' => 'assignment_upload_limit_extensions', 'label' => esc_html__( 'File Extensions', 'learndash' ), 'type' => 'text', 'placeholder' => esc_html__( 'pdf, xls, zip', 'learndash' ), 'help_text' => esc_html__( 'Specify the type of files users can upload. Leave blank for any.', 'learndash' ), 'class' => '-small', 'default' => '', 'value' => $this->setting_option_values['assignment_upload_limit_extensions'], 'parent_setting' => 'lesson_assignment_upload', ), 'assignment_upload_limit_size' => array( 'name' => 'assignment_upload_limit_size', 'label' => esc_html__( 'File Size Limit', 'learndash' ), 'type' => 'text', 'class' => '-small', 'placeholder' => sprintf( // translators: placeholder: PHP file upload size. esc_html_x( '%s', 'placeholder: PHP file upload size', 'learndash' ), ini_get( 'upload_max_filesize' ) ), 'help_text' => esc_html__( 'Default maximum file size supported is controlled by your host.', 'learndash' ), 'default' => '', 'value' => $this->setting_option_values['assignment_upload_limit_size'], 'parent_setting' => 'lesson_assignment_upload', ), 'lesson_assignment_points_enabled' => array( 'name' => 'lesson_assignment_points_enabled', 'label' => esc_html__( 'Points', 'learndash' ), 'type' => 'checkbox-switch', 'default' => 0, 'value' => $this->setting_option_values['lesson_assignment_points_enabled'], 'options' => array( 'on' => esc_html__( 'Award points for submitting assignments', 'learndash' ), '' => '', ), 'parent_setting' => 'lesson_assignment_upload', 'child_section_state' => ( 'on' === $this->setting_option_values['lesson_assignment_points_enabled'] ) ? 'open' : 'closed', ), 'lesson_assignment_points_amount' => array( 'name' => 'lesson_assignment_points_amount', 'type' => 'number', 'class' => '-small', 'attrs' => array( 'step' => 1, 'min' => 0, ), 'default' => 0, 'value' => $this->setting_option_values['lesson_assignment_points_amount'], 'input_label' => esc_html__( 'available point(s)', 'learndash' ), 'parent_setting' => 'lesson_assignment_points_enabled', ), 'auto_approve_assignment' => array( 'name' => 'auto_approve_assignment', 'label' => esc_html__( 'Grading Type', 'learndash' ), 'type' => 'radio', 'value' => $this->setting_option_values['auto_approve_assignment'], 'options' => array( 'on' => array( 'label' => esc_html__( 'Auto-approve', 'learndash' ), 'description' => esc_html__( 'No grading or approval needed. The assignment will be automatically approved and full points will be awarded.', 'learndash' ), ), '' => array( 'label' => esc_html__( 'Manually grade', 'learndash' ), 'description' => sprintf( // translators: placeholder: lesson. esc_html_x( 'Admin or group leader approval and grading required. The %s cannot be completed until the assignment is approved.', 'placeholder: lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'inline_fields' => array( 'lesson_assignment_grading_manual' => $this->settings_sub_option_fields['lesson_assignment_grading_manual_fields'], ), 'inner_section_state' => ( '' === $this->setting_option_values['auto_approve_assignment'] ) ? 'open' : 'closed', ), ), 'parent_setting' => 'lesson_assignment_upload', ), 'forced_lesson_time_enabled' => array( 'name' => 'forced_lesson_time_enabled', 'label' => sprintf( // translators: Forced Lesson Timer Label. esc_html_x( 'Forced %s Timer', 'Forced Lesson Timer Label', 'learndash' ), learndash_get_custom_label( 'lesson' ) ), 'default' => '', 'type' => 'checkbox-switch', 'value' => $this->setting_option_values['forced_lesson_time_enabled'], 'help_text' => sprintf( // translators: placeholder: topic. esc_html_x( 'The %s cannot be marked as completed until the set time has elapsed.', 'placeholder: Lesson', 'learndash' ), learndash_get_custom_label_lower( 'lesson' ) ), 'options' => array( 'on' => array( 'label' => '', 'description' => '', 'tooltip' => esc_html__( 'Cannot be enabled while Video progression or Assignments are enabled', 'learndash' ), ), ), 'child_section_state' => ( 'on' === $this->setting_option_values['forced_lesson_time_enabled'] ) ? 'open' : 'closed', ), 'forced_lesson_time' => array( 'name' => 'forced_lesson_time', 'type' => 'timer-entry', 'default' => '', 'class' => 'small-text', 'value' => $this->setting_option_values['forced_lesson_time'], 'parent_setting' => 'forced_lesson_time_enabled', ), /* 'forced_lesson_time_cookie_key' => array( 'name' => 'forced_lesson_time_cookie_key', 'type' => 'text', 'label' => esc_html__( 'Timer cookie key', 'learndash' ), 'help_text' => esc_html__( 'Default is blank. Changing this key will reset all in-process students timers.', 'learndash'), 'class' => '-medium', 'default' => '', 'value' => $this->setting_option_values['forced_lesson_time_cookie_key'], 'parent_setting' => 'forced_lesson_time_enabled', ), */ ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ( 'on' !== $settings_values['lesson_materials_enabled'] ) || ( empty( $settings_values['lesson_materials'] ) ) ) { $settings_values['lesson_materials_enabled'] = ''; $settings_values['lesson_materials'] = ''; } // If video progression is enables but the video URL is empty then turn off video progression. if ( ( 'on' !== $settings_values['lesson_video_enabled'] ) || ( empty( $settings_values['lesson_video_url'] ) ) ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_video_url'] = ''; } if ( ( 'on' !== $settings_values['forced_lesson_time_enabled'] ) || ( empty( $settings_values['forced_lesson_time'] ) ) ) { $settings_values['forced_lesson_time_enabled'] = ''; $settings_values['forced_lesson_time'] = ''; //$settings_values['forced_lesson_time_cookie_key'] = ''; } if ( ( 'on' !== $settings_values['lesson_assignment_points_enabled'] ) || ( empty( $settings_values['lesson_assignment_points_amount'] ) ) ) { $settings_values['lesson_assignment_points_amount'] = ''; $settings_values['lesson_assignment_points_enabled'] = ''; } if ( 'on' === $settings_values['lesson_video_enabled'] ) { $settings_values['lesson_assignment_upload'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $settings_values['lesson_assignment_upload'] ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } elseif ( 'on' === $settings_values['forced_lesson_time_enabled'] ) { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_assignment_upload'] = ''; } else { $settings_values['lesson_video_enabled'] = ''; $settings_values['lesson_assignment_upload'] = ''; $settings_values['forced_lesson_time_enabled'] = ''; } if ( 'on' !== $settings_values['lesson_video_enabled'] ) { $settings_values['lesson_video_url'] = ''; $settings_values['lesson_video_shown'] = ''; $settings_values['lesson_video_auto_start'] = ''; $settings_values['lesson_video_show_controls'] = ''; $settings_values['lesson_video_auto_complete'] = ''; $settings_values['lesson_video_auto_complete_delay'] = ''; $settings_values['lesson_video_show_complete_button'] = ''; $settings_values['lesson_video_hide_complete_button'] = ''; } if ( 'on' !== $settings_values['lesson_assignment_upload'] ) { $settings_values['assignment_upload_limit_extensions'] = ''; $settings_values['assignment_upload_limit_size'] = ''; $settings_values['lesson_assignment_points_enabled'] = ''; $settings_values['lesson_assignment_points_amount'] = ''; $settings_values['assignment_upload_limit_count'] = ''; $settings_values['lesson_assignment_deletion_enabled'] = ''; $settings_values['auto_approve_assignment'] = ''; } if ( 'on' !== $settings_values['forced_lesson_time_enabled'] ) { $settings_values['forced_lesson_time_enabled'] = ''; $settings_values['forced_lesson_time'] = ''; //$settings_values['forced_lesson_time_cookie_key'] = ''; } if ( 'on' === $settings_values['lesson_video_enabled'] ) { if ( ( 'on' === $settings_values['lesson_video_show_complete_button'] ) ) { $settings_values['lesson_video_hide_complete_button'] = ''; } else { $settings_values['lesson_video_hide_complete_button'] = 'on'; } } if ( 'on' === $settings_values['lesson_assignment_upload'] ) { if ( ! empty( $settings_values['assignment_upload_limit_extensions'] ) ) { $settings_values['assignment_upload_limit_extensions'] = learndash_validate_extensions( $settings_values['assignment_upload_limit_extensions'] ); } if ( ! empty( $settings_values['assignment_upload_limit_size'] ) ) { $limit_file_size = learndash_return_bytes_from_shorthand( $settings_values['assignment_upload_limit_size'] ); $wp_limit_file_size = wp_max_upload_size(); if ( $limit_file_size > $wp_limit_file_size ) { $settings_values['assignment_upload_limit_size'] = ''; } } } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'lesson' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Lesson_Display_Content'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Lesson_Display_Content' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Lesson_Display_Content'] = LearnDash_Settings_Metabox_Lesson_Display_Content::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\d4M4MGsettings-metaboxes/class-ld-settings-metabox-quiz-progress-settings.phpnuW+Asettings_screen_id = 'sfwd-quiz'; // Used within the Settings API to uniquely identify this section. $this->settings_metabox_key = 'learndash-quiz-progress-settings'; // Section label/header. $this->settings_section_label = esc_html__( 'Progression and Restriction Settings', 'learndash' ); $this->settings_section_description = sprintf( // translators: placeholder: quiz. esc_html_x( 'Controls the requirement for accessing and completing the %s', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ); add_filter( 'learndash_metabox_save_fields_' . $this->settings_metabox_key, array( $this, 'filter_saved_fields' ), 30, 3 ); // Map internal settings field ID to legacy field ID. $this->settings_fields_map = array( 'retry_restrictions' => 'retry_restrictions', 'repeats' => 'repeats', 'quizRunOnce' => 'quizRunOnce', 'quizRunOnceType' => 'quizRunOnceType', 'quizRunOnceCookie' => 'quizRunOnceCookie', 'passingpercentage' => 'passingpercentage', 'certificate' => 'certificate', 'threshold' => 'threshold', 'quiz_time_limit_enabled' => 'quiz_time_limit_enabled', 'timeLimit' => 'timeLimit', 'forcingQuestionSolve' => 'forcingQuestionSolve', ); parent::__construct(); } /** * Used to save the settings fields back to the global $_POST object so * the WPProQuiz normal form processing can take place. * * @since 3.0 * @param object $pro_quiz_edit WpProQuiz_Controller_Quiz instance (not used). * @param array $settings_values Array of settings fields. */ public function save_fields_to_post( $pro_quiz_edit, $settings_values = array() ) { $_POST['quizRunOnce'] = $settings_values['quizRunOnce']; $_POST['quizRunOnceType'] = $settings_values['quizRunOnceType']; $_POST['quizRunOnceCookie'] = $settings_values['quizRunOnceCookie']; $_POST['forcingQuestionSolve'] = $settings_values['forcingQuestionSolve']; $_POST['timeLimit'] = $settings_values['timeLimit']; } /** * Initialize the metabox settings values. */ public function load_settings_values() { parent::load_settings_values(); $this->quiz_edit = $this->init_quiz_edit( $this->_post ); if ( true === $this->settings_values_loaded ) { if ( ( isset( $this->setting_option_values['passingpercentage'] ) ) && ( '' !== $this->setting_option_values['passingpercentage'] ) ) { $this->setting_option_values['passingpercentage'] = floatval( $this->setting_option_values['passingpercentage'] ); } else { $this->setting_option_values['passingpercentage'] = '80'; } if ( ( isset( $this->setting_option_values['threshold'] ) ) && ( '' !== $this->setting_option_values['threshold'] ) ) { $this->setting_option_values['threshold'] = floatval( $this->setting_option_values['threshold'] ) * 100; } else { $this->setting_option_values['threshold'] = '80'; } if ( $this->quiz_edit['quiz'] ) { $this->setting_option_values['timeLimit'] = $this->quiz_edit['quiz']->getTimeLimit(); $this->setting_option_values['forcingQuestionSolve'] = $this->quiz_edit['quiz']->isForcingQuestionSolve(); if ( true === $this->setting_option_values['forcingQuestionSolve'] ) { $this->setting_option_values['forcingQuestionSolve'] = 'on'; } $this->setting_option_values['quizRunOnceType'] = ''; $this->setting_option_values['quizRunOnceCookie'] = ''; if ( ( isset( $this->setting_option_values['repeats'] ) ) && ( '' !== $this->setting_option_values['repeats'] ) ) { $this->setting_option_values['quizRunOnceType'] = $this->quiz_edit['quiz']->getQuizRunOnceType(); $this->setting_option_values['quizRunOnceCookie'] = $this->quiz_edit['quiz']->isQuizRunOnceCookie(); } else { $this->setting_option_values['repeats'] = ''; if ( $this->quiz_edit['quiz']->isQuizRunOnce() ) { $this->setting_option_values['repeats'] = '0'; $this->setting_option_values['quizRunOnceType'] = $this->quiz_edit['quiz']->getQuizRunOnceType(); $this->setting_option_values['quizRunOnceCookie'] = $this->quiz_edit['quiz']->isQuizRunOnceCookie(); } } if ( true === $this->setting_option_values['quizRunOnceCookie'] ) { $this->setting_option_values['quizRunOnceCookie'] = 'on'; } if ( ( isset( $this->setting_option_values['repeats'] ) ) && ( '' !== $this->setting_option_values['repeats'] ) ) { $this->setting_option_values['retry_restrictions'] = 'on'; } else { $this->setting_option_values['retry_restrictions'] = ''; $this->setting_option_values['repeats'] = '0'; $this->setting_option_values['quizRunOnce'] = false; $this->setting_option_values['quizRunOnceType'] = ''; $this->setting_option_values['quizRunOnceCookie'] = ''; } if ( ! isset( $this->setting_option_values['quiz_time_limit_enabled'] ) ) { $this->setting_option_values['quiz_time_limit_enabled'] = ''; if ( ( isset( $this->setting_option_values['timeLimit'] ) ) && ( ! empty( $this->setting_option_values['timeLimit'] ) ) ) { $this->setting_option_values['quiz_time_limit_enabled'] = 'on'; } } } } foreach ( $this->settings_fields_map as $_internal => $_external ) { if ( ! isset( $this->setting_option_values[ $_internal ] ) ) { $this->setting_option_values[ $_internal ] = ''; } } } /** * Initialize the metabox settings fields. */ public function load_settings_fields() { global $sfwd_lms; if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_cert_options_default = array( '-1' => esc_html__( 'Search or select a certificate…', 'learndash' ), ); } else { $select_cert_options_default = array( '' => esc_html__( 'Select Certificate', 'learndash' ), ); } $select_cert_options = $sfwd_lms->select_a_certificate(); if ( ( is_array( $select_cert_options ) ) && ( ! empty( $select_cert_options ) ) ) { $select_cert_options = $select_cert_options_default + $select_cert_options; } else { $select_cert_options = $select_cert_options_default; } /* if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $select_quiz_options_default = array( '' => sprintf( // translators: placeholder: quiz. esc_html_x( 'Search or select a %s…', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), ); } else { $select_quiz_options_default = array( '' => sprintf( // translators: placeholder: quiz. esc_html_x( 'Select a %s…', 'placeholder: quiz', 'learndash' ), learndash_get_custom_label_lower( 'quiz' ) ), ); } $select_quiz_options = $sfwd_lms->select_a_quiz(); if ( ( is_array( $select_quiz_options ) ) && ( ! empty( $select_quiz_options ) ) ) { $select_quiz_options = $select_quiz_options_default + $select_quiz_options; } else { $select_quiz_options = $select_quiz_options_default; } */ /* $this->setting_option_fields = array( 'quizRunOnceType' => array( 'name' => 'quizRunOnceType', 'label_none' => true, 'type' => 'select', 'default' => '1', 'value' => $this->setting_option_values['quizRunOnceType'], 'input_label' => esc_html__( 'users', 'learndash' ), 'options' => array( '1' => esc_html__( 'All users', 'learndash' ), '2' => esc_html__( 'Registered users only', 'learndash' ), '3' => esc_html__( 'Anonymous user only', 'learndash' ), ), ), 'quizRunOnceCookie' => array( 'name' => 'quizRunOnceCookie', 'label_none' => true, 'type' => 'checkbox-switch', 'options' => array( 'on' => esc_html__( 'Use a cookie to restrict ALL users, including anonymous visitors', 'learndash' ), ), 'value' => $this->setting_option_values['quizRunOnceCookie'], 'default' => '', ), 'quiz_reset_cookies' => array( 'name' => 'quiz_reset_cookies', 'type' => 'custom', 'html' => '

    ', 'label_none' => true, 'input_full' => true, ) ); parent::load_settings_fields(); $this->settings_sub_option_fields['retry_restrictions_options_once_fields'] = $this->setting_option_fields; */ $this->setting_option_fields = array( 'passingpercentage' => array( 'name' => 'passingpercentage', 'label' => esc_html__( 'Passing Score', 'learndash' ), 'type' => 'number', 'value' => $this->setting_option_values['passingpercentage'], 'default' => '80', 'placeholder' => 'e.g. 80', 'class' => '-small', 'input_label' => '%', 'attrs' => array( 'min' => '0', 'max' => '100', //'step' => '0.01', ), ), 'certificate' => array( 'name' => 'certificate', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( ' %s Certificate', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'type' => 'select', 'value' => $this->setting_option_values['certificate'], 'options' => $select_cert_options, 'child_section_state' => ( ( ! empty( $this->setting_option_values['certificate'] ) ) && ( '-1' !== $this->setting_option_values['certificate'] ) ) ? 'open' : 'closed', ), 'threshold' => array( 'name' => 'threshold', 'label' => esc_html__( 'Certificate Awarded for', 'learndash' ), 'type' => 'number', 'default' => '80', 'placeholder' => 'e.g. 80', 'class' => '-small', 'help_text' => esc_html__( 'Set the score needed to receive a certificate. This can be different from the "Passing Score".', 'learndash' ), 'input_label' => esc_html__( '% score', 'learndash' ), 'attrs' => array( 'min' => '0', 'max' => '100', //'step' => '0.01', ), 'value' => $this->setting_option_values['threshold'], 'class' => '-small', 'parent_setting' => 'certificate', ), 'retry_restrictions' => array( 'name' => 'retry_restrictions', 'label' => sprintf( // translators: placeholder: Quiz. esc_html_x( 'Restrict %s Retakes', 'placeholder: Quiz', 'learndash' ), learndash_get_custom_label( 'quiz' ) ), 'type' => 'checkbox-switch', 'options' => array( 'on' => '', ), 'value' => $this->setting_option_values['retry_restrictions'], 'default' => '', 'child_section_state' => ( 'on' === $this->setting_option_values['retry_restrictions'] ) ? 'open' : 'closed', ), 'repeats' => array( 'name' => 'repeats', 'label' => esc_html__( 'Number of Retries Allowed', 'learndash' ), 'help_text' => esc_html__( 'You must input a whole number value or leave blank to default to 0.', 'learndash' ), 'type' => 'number', 'class' => '-small', 'default' => '', 'value' => $this->setting_option_values['repeats'], //'value_allow_blank' => true, //'value_abs' => true, 'attrs' => array( 'step' => 1, 'min' => 0, 'can_empty' => true, 'can_decimal' => false ), 'parent_setting' => 'retry_restrictions', ), 'quizRunOnceType' => array( 'name' => 'quizRunOnceType', 'label' => esc_html__( 'Retries Applicable to', 'learndash' ), 'type' => 'select', 'default' => '1', 'value' => $this->setting_option_values['quizRunOnceType'], 'options' => array( '1' => esc_html__( 'All users', 'learndash' ), '2' => esc_html__( 'Registered users only', 'learndash' ), '3' => esc_html__( 'Anonymous user only', 'learndash' ), ), 'parent_setting' => 'retry_restrictions', ), 'quizRunOnceCookie' => array( 'name' => 'quizRunOnceCookie', 'label' => '', 'type' => 'checkbox', 'options' => array( 'on' => esc_html__( 'Use a cookie to restrict ALL users, including anonymous visitors', 'learndash' ), ), 'value' => $this->setting_option_values['quizRunOnceCookie'], 'default' => '', 'parent_setting' => 'retry_restrictions', ), 'quiz_reset_cookies' => array( 'name' => 'quiz_reset_cookies', 'type' => 'custom', 'html' => '

    ', 'label' => '', 'parent_setting' => 'retry_restrictions', ), 'forcingQuestionSolve' => array( 'name' => 'forcingQuestionSolve', 'label' => sprintf( // translators: placeholder: Question. esc_html_x( '%s Completion', 'placeholder: Question', 'learndash' ), learndash_get_custom_label( 'question' ) ), 'type' => 'checkbox', 'options' => array( 'on' => sprintf( // translators: placeholder: Questions. esc_html_x( 'All %s required to complete', 'placeholder: Questions', 'learndash' ), learndash_get_custom_label( 'questions' ) ), ), 'value' => $this->setting_option_values['forcingQuestionSolve'], 'default' => 'on', ), 'quiz_time_limit_enabled' => array( 'name' => 'quiz_time_limit_enabled', 'label' => esc_html__( 'Time Limit', 'learndash' ), 'type' => 'checkbox-switch', 'options' => array( 'on' => '', ), 'value' => $this->setting_option_values['quiz_time_limit_enabled'], 'default' => '', 'child_section_state' => ( 'on' === $this->setting_option_values['quiz_time_limit_enabled'] ) ? 'open' : 'closed', ), 'timeLimit' => array( 'name' => 'timeLimit', 'label' => esc_html__( 'Automatically Submit After', 'learndash' ), 'type' => 'timer-entry', 'class' => 'small-text', 'placeholder' => esc_html__( 'e.g. 0', 'learndash' ), 'default' => '', 'value' => $this->setting_option_values['timeLimit'], 'parent_setting' => 'quiz_time_limit_enabled', ), ); $this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_metabox_key ); parent::load_settings_fields(); } /** * Filter settings values for metabox before save to database. * * @param array $settings_values Array of settings values. * @param string $settings_metabox_key Metabox key. * @param string $settings_screen_id Screen ID. * @return array $settings_values. */ public function filter_saved_fields( $settings_values = array(), $settings_metabox_key = '', $settings_screen_id = '' ) { if ( ( $settings_screen_id === $this->settings_screen_id ) && ( $settings_metabox_key === $this->settings_metabox_key ) ) { if ( ! isset( $settings_values['certificate'] ) ) { $settings_values['certificate'] = ''; } if ( ! isset( $settings_values['threshold'] ) ) { $settings_values['threshold'] = ''; } if ( '-1' === $settings_values['certificate'] ) { $settings_values['certificate'] = ''; } if ( ! empty( $settings_values['certificate'] ) ) { $settings_values['threshold'] = floatval( $settings_values['threshold'] ) / 100; } else { $settings_values['threshold'] = ''; $settings_values['certificate'] = ''; } // Clear out the time limit is the time limit enabled is not set. if ( ! isset( $settings_values['quiz_time_limit_enabled'] ) ) { $settings_values['quiz_time_limit_enabled'] = ''; } if ( ! isset( $settings_values['timeLimit'] ) ) { $settings_values['timeLimit'] = ''; } if ( 'on' === $settings_values['quiz_time_limit_enabled'] ) { if ( empty( $settings_values['timeLimit'] ) ) { $settings_values['quiz_time_limit_enabled'] = ''; } } if ( ! empty( $settings_values['timeLimit'] ) ) { if ( 'on' !== $settings_values['quiz_time_limit_enabled'] ) { $settings_values['timeLimit'] = 0; } } if ( 'on' === $settings_values['forcingQuestionSolve'] ) { $settings_values['forcingQuestionSolve'] = true; } else { $settings_values['forcingQuestionSolve'] = false; } if ( ! isset( $settings_values['retry_restrictions'] ) ) { $settings_values['retry_restrictions'] = ''; } if ( ! isset( $settings_values['repeats'] ) ) { $settings_values['repeats'] = ''; } if ( ( 'on' !== $settings_values['retry_restrictions'] ) || ( '' === $settings_values['repeats'] ) ) { $settings_values['repeats'] = ''; $settings_values['retry_restrictions'] = ''; $settings_values['quizRunOnce'] = false; $settings_values['quizRunOnceType'] = ''; $settings_values['quizRunOnceCookie'] = ''; } else { $settings_values['quizRunOnce'] = true; if ( ( isset( $settings_values['quizRunOnceCookie'] ) ) && ( 'on' === $settings_values['quizRunOnceCookie'] ) ) { $settings_values['quizRunOnceCookie'] = true; } } } return $settings_values; } // End of functions. } add_filter( 'learndash_post_settings_metaboxes_init_' . learndash_get_post_type_slug( 'quiz' ), function( $metaboxes = array() ) { if ( ( ! isset( $metaboxes['LearnDash_Settings_Metabox_Quiz_Progress_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Quiz_Progress_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Quiz_Progress_Settings'] = LearnDash_Settings_Metabox_Quiz_Progress_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } PK^\V0settings-fields/class-ld-settings-fields-url.phpnuW+Afield_type = 'url'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html .= $this->get_field_attribute_input_label( $field_args ); $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { return esc_url( $val ); } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_URL::add_field_instance( 'url' ); } ); PK^\#T9settings-fields/class-ld-settings-fields-media-upload.phpnuW+Afield_type = 'media-upload'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['desc'] ) ) && ( ! empty( $field_args['desc'] ) ) ) { $html .= $field_args['desc']; } $html .= '
    '; $html .= $this->get_field_legend( $field_args ); $html .= '
    get_field_attribute_id( $field_args, false ) . '_wrapper" '; $html .= '>'; $default_img_url = LEARNDASH_LMS_PLUGIN_URL . 'assets/images/nologo.jpg'; $image_id = 0; $image_url = $default_img_url; if ( isset( $field_args['value'] ) ) { $image_id = absint( $field_args['value'] ); } if ( ! empty( $image_id ) ) { $image_url = wp_get_attachment_url( $image_id ); if ( empty( $image_url ) ) { $image_id = 0; $image_url = $default_img_url; } } $html .= '
    '; $html .= ''; $html .= '
    '; $html .= ''; $html .= ''; $html .= 'get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( ( isset( $image_id ) ) && ( ! empty( $image_id ) ) ) { $html .= ' value="' . $image_id . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html .= '
    '; $html .= '
    '; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( isset( $args['field']['options'][ $val ] ) ) { return $val; } elseif ( isset( $args['field']['default'] ) ) { return $args['field']['default']; } else { return ''; } } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Media_Upload::add_field_instance( 'media-upload' ); } ); PK^\ҹ3settings-fields/class-ld-settings-fields-select.phpnuW+Afield_type = 'select'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { $html .= ''; $html .= ''; $html .= ''; $html .= $this->get_field_attribute_input_label( $field_args ); $html .= $html_sub_fields; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key = '', $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = call_user_func( $args['field']['value_type'], $val ); } else { $val = ''; } return $val; } return false; } // end of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Select::add_field_instance( 'select' ); } ); PK^\m@settings-fields/class-ld-settings-fields-quiz-templates-load.phpnuW+Afield_type = 'quiz-templates-load'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['value'] ) ) && ( ! empty( $field_args['value'] ) ) ) { $template_loaded_id = absint( $field_args['value'] ) ; } else { $template_loaded_id = 0; } $select_template_options = array(); $template_type = ''; if ( isset( $field_args['template_type'] ) ) { $template_type = $field_args['template_type']; } else { global $post_type; if ( learndash_get_post_type_slug( 'quiz' ) === $post_type ) { $template_type = WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ; } elseif ( learndash_get_post_type_slug( 'question' ) === $post_type ) { $template_type = WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION; } } if ( ( isset( $template_type ) ) && ( '' !== $template_type ) ) { $template_mapper = new WpProQuiz_Model_TemplateMapper(); $templates = $template_mapper->fetchAll( $template_type, false ); if ( ! empty( $templates ) ) { foreach ( $templates as $template ) { $select_template_options[ absint( $template->getTemplateId() ) ] = esc_html( $template->getName() ); } } } /* */ $html .= ''; // $html .= 'get_field_attribute_type( $field_args ); //$html .= $this->get_field_attribute_name( $field_args ); $html .= ' name="templateLoadId" '; $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === LEARNDASH_SELECT2_LIB ) ) { if ( ! isset( $field_args['attrs']['data-ld-select2'] ) ) { $html .= ' data-ld-select2="1" '; } } $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); $html .= $this->get_field_sub_trigger( $field_args ); $html .= $this->get_field_inner_trigger( $field_args ); $html .= ' >'; if ( ( isset( $_GET['post'] ) ) && ( ! empty( $_GET['post'] ) ) && ( isset( $_GET['templateLoadId'] ) ) && ( ! empty( $_GET['templateLoadId'] ) ) ) { $template_url = remove_query_arg( 'templateLoadId' ); $template_url = add_query_arg( 'currentTab', learndash_get_post_type_slug( 'quiz' ) .'-settings', $template_url ); $html .= ''; } else { if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $html .= ''; } else { $html .= ''; } } if ( ! empty( $select_template_options ) ) { foreach ( $select_template_options as $template_id => $template_name ) { if ( $template_id > 0 ) { $template_url = add_query_arg( 'templateLoadId', $template_id ); } else { $template_url = $template_id; } $selected = ''; if ( absint( $template_loaded_id) === absint( $template_id ) ) { $selected = ' selected="selected" '; } $html .= ''; } } $html .= ''; $html .= '
    '; $html .= '

    '; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = wp_check_invalid_utf8( $val ); if ( ! empty( $val ) ) { $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); } } return $val; } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Quiz_Templates_Load::add_field_instance( 'quiz-templates-load' ); } ); PK^\X22@settings-fields/class-ld-settings-fields-quiz-templates-save.phpnuW+Afield_type = 'quiz-templates-save'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $select_template_options = array(); $template_type = ''; if ( isset( $field_args['template_type'] ) ) { $template_type = $field_args['template_type']; } else { global $post_type; if ( learndash_get_post_type_slug( 'quiz' ) === $post_type ) { $template_type = WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ; } elseif ( learndash_get_post_type_slug( 'question' ) === $post_type ) { $template_type = WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION; } } if ( ( isset( $template_type ) ) && ( '' !== $template_type ) ) { $template_mapper = new WpProQuiz_Model_TemplateMapper(); $templates = $template_mapper->fetchAll( $template_type, false ); if ( ! empty( $templates ) ) { foreach ( $templates as $template ) { $select_template_options[ absint( $template->getTemplateId() ) ] = esc_html( $template->getName() ); } } } $html .= ''; //$html .= 'get_field_attribute_type( $field_args ); //$html .= $this->get_field_attribute_name( $field_args ); $html .= ' name="templateSaveList" '; $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === LEARNDASH_SELECT2_LIB ) ) { if ( ! isset( $field_args['attrs']['data-ld-select2'] ) ) { $html .= ' data-ld-select2="1" '; } } $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); $html .= $this->get_field_sub_trigger( $field_args ); $html .= $this->get_field_inner_trigger( $field_args ); $html .= ' >'; if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $html .= ' '; $html .= ' '; if ( ! empty( $select_template_options ) ) { foreach ( $select_template_options as $template_id => $template_name ) { $html .= ''; } } $html .= ''; $html .= '
    '; $html .= ''; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = wp_check_invalid_utf8( $val ); if ( ! empty( $val ) ) { $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); } } return $val; } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Quiz_Templates_Save::add_field_instance( 'quiz-templates-save' ); } ); PK^\~3r5settings-fields/class-ld-settings-fields-checkbox.phpnuW+Afield_type = 'checkbox'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { if ( ( isset( $field_args['desc'] ) ) && ( ! empty( $field_args['desc'] ) ) ) { $html .= $field_args['desc']; } if ( ! isset( $field_args['class'] ) ) { $field_args['class'] = ''; } $field_args['class'] .= ' ld-checkbox-input'; $html .= '
    '; $html .= $this->get_field_legend( $field_args ); $checkbox_multiple = ''; if ( count( $field_args['options'] ) > 1 ) { $checkbox_multiple = '[]'; } foreach ( $field_args['options'] as $option_key => $option_label ) { $html .= '

    '; $html .= 'get_field_attribute_type( $field_args ); $html .= ' id="' . $this->get_field_attribute_id( $field_args, false ) . '-' . $option_key . '"'; $html .= ' name="' . $this->get_field_attribute_name( $field_args, false ) . $checkbox_multiple . '"'; $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); $html .= ' value="' . $option_key . '" '; if ( ( is_array( $field_args['value'] ) ) && ( in_array( $option_key, $field_args['value'] ) ) ) { $html .= ' ' . checked( $option_key, $option_key, false ) . ' '; } else if ( is_string( $field_args['value'] ) ) { $html .= ' ' . checked( $option_key, $field_args['value'], false ) . ' '; } $html .= ' />'; $html .= '

    '; } elseif ( ( is_array( $option_label ) ) && ( ! empty( $option_label ) ) ) { if ( ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '' . $option_label['label'] . ''; } $html .= '

    '; if ( ( isset( $option_label['description'] ) ) && ( ! empty( $option_label['description'] ) ) ) { $html .= '

    ' . $option_label['description'] . '

    '; } } else { $html .= '

    '; } } //$html .= $this->get_field_attribute_input_label( $field_args ); $html .= '
    '; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $this->field_type === $args['field']['type'] ) ) { if ( is_array( $val ) ) { foreach ( $val as $val_idx => $val_val ) { if ( ! isset( $args['field']['options'][ $val_val ] ) ) { unset( $val[ $val_val ] ); } } return $val; } else if ( is_string( $val ) ) { if ( ( '' === $val ) || ( isset( $args['field']['options'][ $val ] ) ) ) { return $val; } elseif ( isset( $args['field']['default'] ) ) { return $args['field']['default']; } else { return ''; } } } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Checkbox::add_field_instance( 'checkbox' ); } ); PK^\h czz<settings-fields/class-ld-settings-fields-checkbox-switch.phpnuW+Afield_type = 'checkbox-switch'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { if ( ( isset( $field_args['desc'] ) ) && ( ! empty( $field_args['desc'] ) ) ) { $html .= $field_args['desc']; } if ( ! isset( $field_args['class'] ) ) { $field_args['class'] = ''; } $field_args['class'] .= ' ld-switch__input'; $html .= '
    '; $html .= $this->get_field_legend( $field_args ); $sel_option_key = $field_args['value']; $sel_option_label = ''; if ( count( $field_args['options'] ) > 1 ) { if ( isset( $field_args['options'][ $sel_option_key ] ) ) { $sel_option_label = $field_args['options'][ $sel_option_key ]; } } else { foreach ( $field_args['options'] as $option_key => $option_label ) { if ( is_string( $option_label ) ) { $sel_option_label = $option_label; } elseif ( ( is_array( $option_label ) ) && ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $sel_option_label = $option_label['label']; } } } $html .= ' '; $html .= $html_sub_fields; $html .= '
    '; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( ! empty( $val ) ) && ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( isset( $args['field']['options'][ $val ] ) ) { return $val; } elseif ( isset( $args['field']['default'] ) ) { return $args['field']['default']; } else { return ''; } } return $val; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Checkbox_Switch::add_field_instance( 'checkbox-switch' ); } ); PK^\ ~ 7settings-fields/class-ld-settings-fields-date-entry.phpnuW+Afield_type = 'date-entry'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { global $wp_locale; $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $date_value = ''; if ( isset( $field_args['value'] ) ) { if ( ! empty( $field_args['value'] ) ) { if ( ! is_numeric( $field_args['value'] ) ) { $date_value = learndash_get_timestamp_from_date_string( $value ); } else { // If we have a timestamp we assume it is GMT. So we need to convert it to local. $value_ymd = get_date_from_gmt( date( 'Y-m-d H:i:s', $field_args['value'] ), 'Y-m-d H:i:s' ); $date_value = strtotime( $value_ymd ); } } } if ( ! empty( $date_value ) ) { $value_jj = gmdate( 'd', $date_value ); $value_mm = gmdate( 'm', $date_value ); $value_aa = gmdate( 'Y', $date_value ); $value_hh = gmdate( 'H', $date_value ); $value_mn = gmdate( 'i', $date_value ); } else { $value_jj = ''; $value_mm = ''; $value_aa = ''; $value_hh = ''; $value_mn = ''; } $field_name = $this->get_field_attribute_name( $field_args, false ); $field_class = $this->get_field_attribute_class( $field_args, false ); $field_id = $this->get_field_attribute_id( $field_args, false ); $month_field = '' . esc_html__( 'Month', 'learndash' ) . ''; $day_field = '' . esc_html__( 'Day', 'learndash' ) . ''; $year_field = '' . esc_html__( 'Year', 'learndash' ) . ''; $hour_field = '' . esc_html__( 'Hour', 'learndash' ) . ''; $minute_field = '' . esc_html__( 'Minute', 'learndash' ) . ''; $html .= '
    ' . sprintf( // Translators: placeholders Month, Day, Year, Hour, Minute esc_html__( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month_field, $day_field, $year_field, $hour_field, $minute_field ) . '
    '; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { return sanitize_text_field( $val ); } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function value_section_field( $val = '', $key = '', $args = array(), $post_args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( isset( $val['aa'] ) ) { $val['aa'] = intval( $val['aa'] ); } else { $val['aa'] = 0; } if ( isset( $val['mm'] ) ) { $val['mm'] = intval( $val['mm'] ); } else { $val['mm'] = 0; } if ( isset( $val['jj'] ) ) { $val['jj'] = intval( $val['jj'] ); } else { $val['jj'] = 0; } if ( isset( $val['hh'] ) ) { $val['hh'] = intval( $val['hh'] ); } else { $val['hh'] = 0; } if ( isset( $val['mn'] ) ) { $val['mn'] = intval( $val['mn'] ); } else { $val['mn'] = 0; } if ( ( ! empty( $val['aa'] ) ) && ( ! empty( $val['mm'] ) ) && ( ! empty( $val['jj'] ) ) ) { $date_string = sprintf( '%04d-%02d-%02d %02d:%02d:00', intval( $val['aa'] ), intval( $val['mm'] ), intval( $val['jj'] ), intval( $val['hh'] ), intval( $val['mn'] ) ); $date_string_gmt = get_gmt_from_date( $date_string, 'Y-m-d H:i:s' ); $val = strtotime( $date_string_gmt ); } else { $val = 0; } return $val; } return false; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Date_Entry::add_field_instance( 'date-entry' ); } ); PK^\vee*settings-fields/settings-fields-loader.phpnuW+Afield_type = 'number'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html .= $this->get_field_attribute_input_label( $field_args ); $html .= $this->get_field_error_message( $field_args ); $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key = '', $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { // If empty check our settings. if ( ( '' === $val ) && ( isset( $args['field']['attrs']['can_empty'] ) ) && ( true === $args['field']['attrs']['can_empty'] ) ) { return $val; } if ( ! isset( $args['field']['attrs']['can_decimal'] ) ) { $args['field']['attrs']['can_decimal'] = 0; } if ( $args['field']['attrs']['can_decimal'] > 0 ) { $val = floatval( $val ); //$val = number_format ( $val, absint( $args['field']['attrs']['can_decimal'] ) ); } else { $val = intval( $val ); } if ( ( isset( $args['field']['attrs']['min'] ) ) && ( ! empty( $args['field']['attrs']['min'] ) ) && ( $val < $args['field']['attrs']['min'] ) ) { return false; } elseif ( ( isset( $args['field']['attrs']['max'] ) ) && ( ! empty( $args['field']['attrs']['max'] ) ) && ( $val > $args['field']['attrs']['max'] ) ) { return false; } return $val; } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Number::add_field_instance( 'number' ); } ); PK^\j%R+ + ?settings-fields/class-ld-settings-fields-quiz-custom-fields.phpnuW+Afield_type = 'quiz-custom-fields'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $forms = $field_args['value']; $index = 0; if ( ! is_array( $forms ) ) { $forms = array(); } if ( ! count( $forms ) ) { $forms = array( new WpProQuiz_Model_Form(), new WpProQuiz_Model_Form() ); } else { array_unshift( $forms, new WpProQuiz_Model_Form() ); } $html .= '
    '; $html .= ''; foreach ( $forms as $form ) { $html .= 'getFormId(); if ( empty( $form_id ) ) { $form_id = ''; } $html .= ' '; $html .= ' '; $html .= ' '; } $html .= '
    ' . esc_html__( 'Move', 'learndash' ) . ' ' . esc_html__( 'ID', 'learndash' ) . ' ' . esc_html__( 'Field name', 'learndash' ) . ' ' . esc_html__( 'Type', 'learndash' ) . ' ' . esc_html__( 'Required?', 'learndash' ) . '
    ' . esc_attr( $form_id ) . ''; $html .= ' '; $html .= ' '; $html .= '' . esc_html__( 'Edit list', 'learndash' ) . ''; $html .= '
    isRequired(), 1, false ) . '>
    '; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = wp_check_invalid_utf8( $val ); if ( ! empty( $val ) ) { $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); } } return $val; } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Quiz_Custom_Fields::add_field_instance( 'quiz-custom-fields' ); } ); PK^\KGVpp3settings-fields/class-ld-settings-fields-hidden.phpnuW+Afield_type = 'hidden'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Hidden::add_field_instance( 'hidden' ); } ); PK^\֤  8settings-fields/class-ld-settings-fields-timer-entry.phpnuW+Afield_type = 'timer-entry'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { global $wp_locale; $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['value'] ) ) && ( ! empty( $field_args['value'] ) ) ) { $field_args['value'] = learndash_convert_lesson_time_time( $field_args['value'] ); $value_hh = gmdate( 'H', $field_args['value'] ); $value_mn = gmdate( 'i', $field_args['value'] ); $value_ss = gmdate( 's', $field_args['value'] ); } else { $value_hh = ''; $value_mn = ''; $value_ss = ''; } $field_name = $this->get_field_attribute_name( $field_args, false ); $field_class = $this->get_field_attribute_class( $field_args, false ); $field_id = $this->get_field_attribute_id( $field_args, false ); $hour_field = '' . esc_html__( 'Hour', 'learndash' ) . ''; $minute_field = '' . esc_html__( 'Minute', 'learndash' ) . ''; $second_field = '' . esc_html__( 'Seconds', 'learndash' ) . ''; $html .= '
    ' . sprintf( // translators: placeholders: Hour, Minute, Second. esc_html__( '%1$s:%2$s:%3$s' ), $hour_field, $minute_field, $second_field ) . '
    '; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { return sanitize_text_field( $val ); } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function value_section_field( $val = '', $key = '', $args = array(), $post_args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( isset( $val['hh'] ) ) { $val['hh'] = absint( $val['hh'] ); } else { $val['hh'] = 0; } if ( isset( $val['mn'] ) ) { $val['mn'] = absint( $val['mn'] ); } else { $val['mn'] = 0; } if ( isset( $val['ss'] ) ) { $val['ss'] = absint( $val['ss'] ); } else { $val['ss'] = 0; } $val_seconds = $val['ss'] + ( $val['mn'] * 60 ) + ( $val['hh'] * 60 * 60 ); return $val_seconds; } return false; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Timer_Entry::add_field_instance( 'timer-entry' ); } ); PK^\ 9settings-fields/class-ld-settings-fields-input-select.phpnuW+Afield_type = 'input-select'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { $html .= ''; $html .= ''; $html .= ''; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Input_Select::add_field_instance( 'select' ); } ); PK^\#^8settings-fields/class-ld-settings-fields-multiselect.phpnuW+Afield_type = 'multiselect'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { // Force multiple. $field_args['multiple'] = true; $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { $html .= ''; $html .= ''; $html .= ''; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key = '', $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ( is_array( $val ) ) && ( ! empty( $val ) ) ) { $val = array_map( $args['field']['value_type'], $val ); } elseif ( ! empty( $val ) ) { $val = call_user_func( $args['field']['value_type'], $val ); } else { $val = ''; } return $val; } return false; } // end of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Multiselect::add_field_instance( 'multiselect' ); } ); PK^\} } 5settings-fields/class-ld-settings-fields-textarea.phpnuW+Afield_type = 'textarea'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= ''; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = wp_check_invalid_utf8( $val ); if ( ! empty( $val ) ) { $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); } } return $val; } return false; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Textarea::add_field_instance( 'textarea' ); } ); PK^\EcE1settings-fields/class-ld-settings-fields-text.phpnuW+Afield_type = 'text'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html .= $this->get_field_attribute_input_label( $field_args ); $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { return sanitize_text_field( $val ); } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Text::add_field_instance( 'text' ); } ); PK^\Ltt3settings-fields/class-ld-settings-fields-custom.phpnuW+Afield_type = 'custom'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( isset( $field_args['html'] ) ) { $html .= $field_args['html']; } echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ! empty( $val ) ) { return sanitize_textarea_field( $val ); } return $val; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Custom::add_field_instance( 'custom' ); } ); PK^\;jj1settings-fields/class-ld-settings-fields-html.phpnuW+Afield_type = 'html'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $field_type = apply_filters( 'learndash_settings_field_element_html', 'div' ); $html .= '<' . $field_type . ' '; $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= '>'; if ( isset( $field_args['value'] ) ) { $html .= wptexturize( do_shortcode( $field_args['value'] ) ); } $html .= ''; echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key = '', $args = array() ) { if ( ( ! empty( $val ) ) && ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { return sanitize_textarea_field( $val ); } return $val; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Html::add_field_instance( 'html' ); } ); PK^\r:! ! 5settings-fields/class-ld-settings-fields-wpeditor.phpnuW+Afield_type = 'wpeditor'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); if ( isset( $field_args['editor_args'] ) ) { $wpeditor_args = $field_args['editor_args']; } else { $wpeditor_args = array(); } if ( ( isset( $field_args['attrs'] ) ) && ( ! empty( $field_args['attrs'] ) ) ) { $wpeditor_args = array_merge( $wpeditor_args, $field_args['attrs'] ); } $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); wp_editor( $this->get_field_attribute_value( $field_args, false ), $this->get_field_attribute_id( $field_args, false ), $wpeditor_args ); $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Default validation function. Should be overriden in Field subclass. * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return mixed $val validated value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = wp_check_invalid_utf8( $val ); if ( ! empty( $val ) ) { $val = sanitize_post_field( 'post_content', $val, 0, 'db' ); } } return $val; } return false; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_WPEditor::add_field_instance( 'wpeditor' ); } ); PK^\JE2settings-fields/class-ld-settings-fields-email.phpnuW+Afield_type = 'email'; parent::__construct(); } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( ! empty( $val ) ) { $val = sanitize_email( $val ); } else { $val = ''; } return $val; } return false; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Text::add_field_instance( 'email' ); } ); PK^\s2settings-fields/class-ld-settings-fields-radio.phpnuW+Afield_type = 'radio'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { if ( ( isset( $field_args['desc'] ) ) && ( ! empty( $field_args['desc'] ) ) ) { $html .= $field_args['desc']; } if ( ! isset( $field_args['class'] ) ) { $field_args['class'] = ''; } $field_args['class'] .= ' ld-radio-input'; $html .= '
    '; $html .= $this->get_field_legend( $field_args ); foreach ( $field_args['options'] as $option_key => $option_label ) { $html .= '

    '; $html .= 'get_field_attribute_type( $field_args ); //$html .= $this->get_field_attribute_id( $field_args ); $html .= ' id="' . $this->get_field_attribute_id( $field_args, false ) . '-' . $option_key . '"'; $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); $html .= ' value="' . $option_key . '" '; $html .= ' ' . checked( $option_key, $field_args['value'], false ) . ' '; $html_sub_fields = ''; if ( ( is_array( $option_label ) ) && ( ! empty( $option_label ) ) ) { if ( ( isset( $option_label['inline_fields'] ) ) && ( ! empty( $option_label['inline_fields'] ) ) ) { foreach ( $option_label['inline_fields'] as $sub_field_key => $sub_fields ) { $html .= ' data-settings-inner-trigger="ld-settings-inner-' . $sub_field_key . '" '; if ( ( isset( $option_label['inner_section_state'] ) ) && ( 'open' === $option_label['inner_section_state'] ) ) { $inner_section_state = 'open'; } else { $inner_section_state = 'closed'; } $html_sub_fields .= '

    '; $level = ob_get_level(); ob_start(); foreach ( $sub_fields as $sub_field ) { self::show_section_field_row( $sub_field ); } $html_sub_fields .= learndash_ob_get_clean( $level ); $html_sub_fields .= '
    '; } } } $html .= ' />'; $html .= '

    '; } elseif ( ( is_array( $option_label ) ) && ( ! empty( $option_label ) ) ) { if ( ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '' . $option_label['label'] . ''; } $html .= '

    '; if ( ( isset( $option_label['description'] ) ) && ( ! empty( $option_label['description'] ) ) ) { $html .= '

    ' . $option_label['description'] . '

    '; } } $html .= $html_sub_fields; } $html .= '
    '; } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.4 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key = '', $args = array() ) { if ( ( isset( $args['field']['type'] ) ) && ( $args['field']['type'] === $this->field_type ) ) { if ( isset( $args['field']['options'][ $val ] ) ) { return $val; } } return false; } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Radio::add_field_instance( 'radio' ); } ); PK^\ ?settings-fields/class-ld-settings-fields-select-edit-delete.phpnuW+Afield_type = 'select-edit-delete'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); if ( ( isset( $field_args['options'] ) ) && ( ! empty( $field_args['options'] ) ) ) { $field_id_base = $this->get_field_attribute_id( $field_args, false ); $field_class_base = $this->get_field_attribute_class( $field_args, false ); $html .= ''; $ajax_data = array( 'action' => $field_args['setting_option_key'], 'field_key' => $field_args['setting_option_key'], 'field_nonce' => wp_create_nonce( $field_args['setting_option_key'] ), ); $html .= ''; $html .= '
    '; if ( ( isset( $field_args['buttons'] ) ) && ( ! empty( $field_args['buttons'] ) ) ) { $html .= '
    '; foreach ( $field_args['buttons'] as $button_key => $button_label ) { $html .= ''; } // Add spinner field to be shown during the AJAX processing. $html .= ''; $html .= '
    '; // end of setting-field-sub. // Add an update message holder. This will be filled in with the updated message after the AJAX processing. $html .= ''; } } $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Select_Edit_Delete::add_field_instance( 'select-edit-delete' ); } ); PK^\حˌ8settings-fields/class-ld-settings-fields-colorpicker.phpnuW+Afield_type = 'colorpicker'; parent::__construct(); } /** * Function to crete the settiings field. * * @since 2.4 * * @param array $field_args An array of field arguments used to process the ouput. * @return void */ public function create_section_field( $field_args = array() ) { $field_args = apply_filters( 'learndash_settings_field', $field_args ); $html = apply_filters( 'learndash_settings_field_html_before', '', $field_args ); $html .= 'get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= $this->get_field_attribute_id( $field_args ); $html .= $this->get_field_attribute_class( $field_args ); $html .= $this->get_field_attribute_placeholder( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= $this->get_field_attribute_required( $field_args ); if ( isset( $field_args['value'] ) ) { $html .= ' value="' . $field_args['value'] . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html = apply_filters( 'learndash_settings_field_html_after', $html, $field_args ); echo $html; } /** * Validate field * * @since 2.6.0 * * @param mixed $val Value to validate. * @param string $key Key of value being validated. * @param array $args Array of field args. * * @return integer value. */ public function validate_section_field( $val, $key, $args = array() ) { return sanitize_text_field( $val ); } // End of functions. } } add_action( 'learndash_settings_sections_fields_init', function() { LearnDash_Settings_Fields_Colorpicker::add_field_instance( 'colorpicker' ); } ); PK^\G44class-ld-shortcodes-tinymce.phpnuW+Alearndash_admin_shortcodes_assets ) ) { $this->learndash_admin_shortcodes_assets['popup_title'] = esc_html( 'LearnDash Shortcodes', 'learndash' ); $this->learndash_admin_shortcodes_assets['popup_type'] = apply_filters( 'learndash_shortcodes_popup_type', LEARNDASH_ADMIN_POPUP_STYLE ); $this->learndash_admin_shortcodes_assets['typenow'] = $typenow; $this->learndash_admin_shortcodes_assets['pagenow'] = $pagenow; $this->learndash_admin_shortcodes_assets['nonce'] = wp_create_nonce( 'learndash_admin_shortcodes_assets_nonce_' . get_current_user_id() . '_' . $pagenow ); } } public function wp_enqueue_editor ( $editor_args = array() ) { $this->shortcodes_assets_init(); if ( 'thickbox' === $this->learndash_admin_shortcodes_assets['popup_type'] ) { wp_enqueue_style( 'thickbox' ); wp_enqueue_script( 'thickbox' ); } else if ( 'jQuery-dialog' === $this->learndash_admin_shortcodes_assets['popup_type'] ) { wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though... wp_enqueue_style( 'wp-jquery-ui-dialog' ); } if ( ( isset( $editor_args['tinymce'] ) ) && ( true === $editor_args['tinymce'] ) ) { $this->add_button(); } if ( ( isset( $editor_args['quicktags'] ) ) && ( true === $editor_args['quicktags'] ) ) { add_action( 'admin_print_footer_scripts', array( $this, 'qt_button_script' ) ); } } public function qt_button_script() { ?> json_encode( $data ) ); wp_localize_script( 'sfwd-module-script', 'sfwd_data', $data ); wp_enqueue_style( 'learndash_admin_shortcodes_style', LEARNDASH_LMS_PLUGIN_URL . 'assets/css/learndash-admin-shortcodes' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); wp_style_add_data( 'learndash_admin_shortcodes_style', 'rtl', 'replace' ); $learndash_assets_loaded['styles']['learndash_shortcodes_admin_style'] = __FUNCTION__; $this->shortcodes_assets_init(); wp_enqueue_script( 'learndash_admin_shortcodes_script', LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-shortcodes' . leardash_min_asset() . '.js', array( 'jquery' ), LEARNDASH_SCRIPT_VERSION_TOKEN, true ); $learndash_assets_loaded['styles']['learndash_admin_shortcodes_script'] = __FUNCTION__; wp_localize_script( 'learndash_admin_shortcodes_script', 'learndash_admin_shortcodes_assets', $this->learndash_admin_shortcodes_assets ); if ( 'jQuery-dialog' === $this->learndash_admin_shortcodes_assets['popup_type'] ) { // Hold until after LD 3.0 release. learndash_admin_settings_page_assets(); } } public function learndash_generate_shortcodes_content() { if ( ( ! isset( $_POST['atts'] ) ) || ( empty( $_POST['atts'] ) ) ) { die(); } $fields_args = array( //'post_type' => '', //'post_id' => 0, 'typenow' => '', 'pagenow' => '', 'nonce' => '', ); $fields_args = shortcode_atts( $fields_args, $_POST['atts'] ); if ( ( empty( $fields_args['nonce'] ) ) || ( empty( $fields_args['pagenow'] ) ) ) { die(); } if ( ( empty( $fields_args['post_type'] ) ) && ( ! empty( $fields_args['typenow'] ) ) ) { $fields_args['post_type'] = $fields_args['typenow']; } if ( ! wp_verify_nonce( $fields_args['nonce'], 'learndash_admin_shortcodes_assets_nonce_' . get_current_user_id() . '_' . $fields_args['pagenow'] ) ) { die(); } //if ( ( ! empty( $fields_args['post_type'] ) ) && ( in_array( $fields_args['post_type'], apply_filters( 'learndash_shortcodes_tinymce_post_types', $this->post_types, $fields_args['post_type'] ) ) ) ) { $shortcode_sections = array(); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/class-ld-shortcodes-sections.php'; if ( 'sfwd-certificates' !== $fields_args['typenow'] ) { require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/learndash_login.php'; $shortcode_sections['learndash_login'] = new LearnDash_Shortcodes_Section_learndash_login( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_profile.php'; $shortcode_sections['ld_profile'] = new LearnDash_Shortcodes_Section_ld_profile( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_course_list.php'; $shortcode_sections['ld_course_list'] = new LearnDash_Shortcodes_Section_ld_course_list( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_lesson_list.php'; $shortcode_sections['ld_lesson_list'] = new LearnDash_Shortcodes_Section_ld_lesson_list( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_topic_list.php'; $shortcode_sections['ld_topic_list'] = new LearnDash_Shortcodes_Section_ld_topic_list( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_quiz_list.php'; $shortcode_sections['ld_quiz_list'] = new LearnDash_Shortcodes_Section_ld_quiz_list( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/learndash_course_progress.php'; $shortcode_sections['learndash_course_progress'] = new LearnDash_Shortcodes_Section_learndash_course_progress( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/visitor.php'; $shortcode_sections['visitor'] = new LearnDash_Shortcodes_Section_visitor( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/student.php'; $shortcode_sections['student'] = new LearnDash_Shortcodes_Section_student( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/course_complete.php'; $shortcode_sections['course_complete'] = new LearnDash_Shortcodes_Section_course_complete( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/course_inprogress.php'; $shortcode_sections['course_inprogress'] = new LearnDash_Shortcodes_Section_course_inprogress( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/course_notstarted.php'; $shortcode_sections['course_notstarted'] = new LearnDash_Shortcodes_Section_course_notstarted( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_course_resume.php'; $shortcode_sections['ld_course_resume'] = new LearnDash_Shortcodes_Section_ld_course_resume( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_course_info.php'; $shortcode_sections['ld_course_info'] = new LearnDash_Shortcodes_Section_ld_course_info( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_user_course_points.php'; $shortcode_sections['ld_user_course_points'] = new LearnDash_Shortcodes_Section_ld_user_course_points( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/user_groups.php'; $shortcode_sections['user_groups'] = new LearnDash_Shortcodes_Section_user_groups( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_group.php'; $shortcode_sections['ld_group'] = new LearnDash_Shortcodes_Section_ld_group( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/learndash_payment_buttons.php'; $shortcode_sections['learndash_payment_buttons'] = new LearnDash_Shortcodes_Section_learndash_payment_buttons( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/course_content.php'; $shortcode_sections['course_content'] = new LearnDash_Shortcodes_Section_course_content( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_course_expire_status.php'; $shortcode_sections['ld_course_expire_status'] = new LearnDash_Shortcodes_Section_ld_course_expire_status( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_certificate.php'; $shortcode_sections['ld_certificate'] = new LearnDash_Shortcodes_Section_ld_certificate( $fields_args ); require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_quiz_complete.php'; $shortcode_sections['ld_quiz_complete'] = new LearnDash_Shortcodes_Section_ld_quiz_complete( $fields_args ); if ( ( 'sfwd-lessons' === $fields_args['typenow'] ) || ( 'sfwd-topic' === $fields_args['typenow'] ) ) { require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/ld_video.php'; $shortcode_sections['ld_video'] = new LearnDash_Shortcodes_Section_ld_video( $fields_args ); } } require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/courseinfo.php'; $shortcode_sections['courseinfo'] = new LearnDash_Shortcodes_Section_courseinfo( $fields_args ); if ( 'sfwd-certificates' === $fields_args['typenow'] ) { require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/quizinfo.php'; $shortcode_sections['quizinfo'] = new LearnDash_Shortcodes_Section_quizinfo( $fields_args ); } require_once LEARNDASH_LMS_PLUGIN_DIR . '/includes/settings/shortcodes-sections/usermeta.php'; $shortcode_sections['usermeta'] = new LearnDash_Shortcodes_Section_usermeta( $fields_args ); $shortcode_sections = apply_filters( 'learndash_shortcodes_content_args', $shortcode_sections ); ?>
    setting_option_key, array( $this, 'section_pre_update_option' ), 30, 3 ); add_action( 'update_option_' . $this->setting_option_key, array( $this, 'section_update_option' ), 30, 3 ); $this->metabox_key = $this->setting_option_key . '_' . $this->settings_section_key; if ( empty( $this->settings_screen_id ) ) { $this->settings_screen_id = 'admin_page_' . $this->settings_page_id; } if ( ! empty( $this->settings_deprecated ) ) { foreach ( $this->settings_deprecated as $old_class => $old_settings ) { if ( ! isset( self::$_settings_deprecated[ $old_class ] ) ) { if ( ! isset( $old_settings['class'] ) ) { $old_settings['class'] = get_called_class(); } self::$_settings_deprecated[ $old_class ] = $old_settings; } } } } /** * Get the instance of our class based on the section_key * * @since 2.4.0 * * @param string $section_key Unique section key used to identify instance. */ final public static function get_section_instance( $section_key = '' ) { if ( ! empty( $section_key ) ) { if ( isset( self::$_instances[ $section_key ] ) ) { return self::$_instances[ $section_key ]; } } } /** * Add instance to static tracking array * * @since 2.4.0 */ final public static function add_section_instance() { $section = get_called_class(); if ( ! isset( self::$_instances[ $section ] ) ) { self::$_instances[ $section ] = new $section(); } } /** * Initialize self */ public function init() { if ( ! $this->settings_values_loaded ) { $this->load_settings_values(); } if ( ! $this->settings_fields_loaded ) { $this->load_settings_fields(); } } /** * Load the section settings values. */ public function load_settings_values() { $this->settings_values_loaded = true; $this->setting_option_values = get_option( $this->setting_option_key ); } /** * Load the section settings fields. */ public function load_settings_fields() { $this->settings_fields_loaded = true; foreach ( $this->setting_option_fields as &$setting_option_field ) { if ( ! isset( $setting_option_field['type'] ) ) { continue; //error_log('setting_option_field[type]['. $setting_option_field['type'] .']'); //error_log('setting_option_field
    '. print_r($setting_option_field, true) .'
    '); } $field_instance = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] ); if ( ( $field_instance ) && ( 'LearnDash_Settings_Fields' === get_parent_class( $field_instance ) ) ) { $setting_option_field['setting_option_key'] = $this->setting_option_key; if ( ! isset( $setting_option_field['id'] ) ) { $setting_option_field['id'] = $setting_option_field['setting_option_key'] . '_' . $setting_option_field['name']; } if ( ! isset( $setting_option_field['label_for'] ) ) { $setting_option_field['label_for'] = $setting_option_field['id']; } if ( ! isset( $setting_option_field['name_wrap'] ) ) { $setting_option_field['name_wrap'] = true; } if ( ! isset( $setting_option_field['input_show'] ) ) { $setting_option_field['input_show'] = true; } if ( ! isset( $setting_option_field['display_callback'] ) ) { $display_ref = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] )->get_creation_function_ref(); if ( $display_ref ) { $setting_option_field['display_callback'] = $display_ref; } } if ( ( ! isset( $setting_option_field['value_type'] ) ) || ( empty( $setting_option_field['value_type'] ) ) ) { $setting_option_field['value_type'] = 'sanitize_text_field'; } if ( ! is_callable( $setting_option_field['value_type'] ) ) { $setting_option_field['value_type'] = 'sanitize_text_field'; } if ( ! isset( $setting_option_field['validate_callback'] ) ) { $validate_ref = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] )->get_validation_function_ref(); if ( $validate_ref ) { $setting_option_field['validate_callback'] = $validate_ref; } } if ( ! isset( $setting_option_field['value_callback'] ) ) { $value_ref = LearnDash_Settings_Fields::get_field_instance( $setting_option_field['type'] )->get_value_function_ref(); if ( $value_ref ) { $setting_option_field['value_callback'] = $value_ref; } } } } } /** * Save Section Settings values */ public function save_settings_values() { $this->settings_values_loaded = false; update_option( $this->setting_option_key, $this->setting_option_values ); } /** * Initialize the Settings page. * * @param string $settings_page_id ID of page being initialized. */ public function settings_page_init( $settings_page_id = '' ) { // Ensure settings_page_id is not empty and that it matches the page_id we want to display this section on. if ( ( ! empty( $settings_page_id ) ) && ( $settings_page_id === $this->settings_page_id ) && ( ! empty( $this->setting_option_fields ) ) ) { add_settings_section( $this->settings_section_key, $this->settings_section_label, array( $this, 'show_settings_section_description' ), $this->settings_page_id ); foreach ( $this->setting_option_fields as $setting_option_field ) { if ( ! isset( $setting_option_field['name'] ) ) { continue; } add_settings_field( $setting_option_field['name'], $setting_option_field['label'], $setting_option_field['display_callback'], $this->settings_page_id, $this->settings_section_key, $setting_option_field ); } register_setting( $this->settings_page_id, $this->setting_option_key, array( $this, 'settings_section_fields_validate' ) ); } } /** * Show Settings Section Description */ public function show_settings_section_description() { if ( ! empty( $this->settings_section_description ) ) { echo '
    ' . wpautop( $this->settings_section_description ) . '
    '; } } /** * Output Settings Section nonce field. */ public function show_settings_section_nonce_field() { wp_nonce_field( $this->setting_option_key, $this->setting_option_key . '_nonce' ); } /** * Intercept the WP options save logic and check that we have a valid nonce. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_pre_update_option( $value, $old_value, $section_key = '' ) { if ( ( empty( $section_key ) ) || ( $section_key !== $this->setting_option_key ) ) { return $old_value; } if ( ! $this->verify_metabox_nonce_field() ) { $old_value; } return $value; } /** * Called AFTER section settings are update. * * @since 3.0 * @param array $value Array of section fields values. * @param array $old_value Array of old values. * @param string $section_key Section option key should match $this->setting_option_key. */ public function section_update_option( $old_value = '', $value = '', $section_key = '' ) { if ( ( ! empty( $section_key ) ) && ( $section_key === $this->setting_option_key ) ) { // When a section values change we update our internal set and also trigger reload fresh. if ( ! defined( 'LEARNDASH_SETTINGS_UPDATING' ) ) { define( 'LEARNDASH_SETTINGS_UPDATING', true ); } $this->setting_option_values = $value; $this->settings_values_loaded = false; $this->settings_fields_loaded = false; return true; } } /** * Verify Settings Section nonce field POST value. */ public function verify_metabox_nonce_field() { if ( ( isset( $_POST[ $this->setting_option_key . '_nonce' ] ) ) && ( ! empty( $_POST[ $this->setting_option_key . '_nonce' ] ) ) && ( wp_verify_nonce( esc_attr( $_POST[ $this->setting_option_key . '_nonce' ] ), $this->setting_option_key ) ) ) { return true; } } /** * Show Settings Section reset link */ public function show_settings_section_reset_confirm_link() { if ( ! empty( $this->reset_confirm_message ) ) { $reset_url = add_query_arg( array( 'action' => 'ld_reset_settings', 'ld_wpnonce' => wp_create_nonce( get_current_user_id() . '-' . $this->setting_option_key ), ) ); ?>

    settings_screen_id ) { if ( apply_filters( 'learndash_show_metabox', true, $this->metabox_key, $this->settings_screen_id ) ) { if ( ! isset( $learndash_metaboxes[ $this->settings_screen_id ] ) ) { $learndash_metaboxes[ $this->settings_screen_id ] = array(); } $learndash_metaboxes[ $this->settings_screen_id ][ $this->metabox_key ] = $this->metabox_key; add_meta_box( $this->metabox_key, $this->settings_section_label, array( $this, 'show_meta_box' ), $this->settings_screen_id, $this->metabox_context, $this->metabox_priority ); } } } /** * Show Settings Section meta box. */ public function show_meta_box() { global $wp_settings_sections; $this->show_settings_section_nonce_field(); if ( isset( $wp_settings_sections[ $this->settings_page_id ][ $this->settings_section_key ] ) ) { $this->show_settings_section( $wp_settings_sections[ $this->settings_page_id ][ $this->settings_section_key ] ); } else { $this->show_settings_section(); } } /** * Show the meta box settings * * @param string $section Section to be shown. */ public function show_settings_section( $section = null ) { /** * The 'callback' attribute is set if/when the section description is * to be displayed. See the WP add_settings_section() argument #3. */ if ( ( ! is_null( $section ) ) && ( isset( $section['callback'] ) ) && ( ! empty( $section['callback'] ) ) && ( is_callable( $section['callback'] ) ) ) { call_user_func( $section['callback'] ); } // If this section defined its own display callback logic. if ( ( isset( $this->settings_fields_callback ) ) && ( ! empty( $this->settings_fields_callback ) ) && ( is_callable( $this->settings_fields_callback ) ) ) { call_user_func( $this->settings_fields_callback, $this->settings_page_id, $this->settings_section_key ); } else { /** * Note here we are calling a custom version of the WP function * do_settings_fields because we want to control the label and help icons */ do_action( 'learndash_section_before', $this->settings_section_key, $this->settings_screen_id ); echo '
    '; do_action( 'learndash_section_fields_before', $this->settings_section_key, $this->settings_screen_id ); $this->show_settings_section_fields( $this->settings_page_id, $this->settings_section_key ); do_action( 'learndash_section_fields_after', $this->settings_section_key, $this->settings_screen_id ); do_action( 'learndash_section_reset_before', $this->settings_section_key, $this->settings_screen_id ); $this->show_settings_section_reset_confirm_link(); do_action( 'learndash_section_reset_after', $this->settings_section_key, $this->settings_screen_id ); echo '
    '; do_action( 'learndash_section_after', $this->settings_section_key, $this->settings_screen_id ); } } /** * Show Settings Section Fields. * * @param string $page Page shown. * @param string $section Section shown. */ public function show_settings_section_fields( $page, $section ) { global $wp_settings_fields; if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) { return; } LearnDash_Settings_Fields::show_section_fields( $wp_settings_fields[ $page ][ $section ] ); } /** * This validation function is set via the call to 'register_setting' * and will be called for each section. * * @param array $post_fields Array of section fields. */ public function settings_section_fields_validate( $post_fields = array() ) { $setting_option_values = array(); // This valiadate_args array will be passed to the validation function for context. $validate_args = array( 'settings_page_id' => $this->settings_page_id, 'setting_option_key' => $this->setting_option_key, 'post_fields' => $post_fields, 'field' => null, ); if ( ! empty( $post_fields ) ) { foreach ( $post_fields as $key => $val ) { if ( isset( $this->setting_option_fields[ $key ] ) ) { if ( ( isset( $this->setting_option_fields[ $key ]['validate_callback'] ) ) && ( ! empty( $this->setting_option_fields[ $key ]['validate_callback'] ) ) && ( is_callable( $this->setting_option_fields[ $key ]['validate_callback'] ) ) ) { $validate_args['field'] = $this->setting_option_fields[ $key ]; $setting_option_values[ $key ] = call_user_func( $this->setting_option_fields[ $key ]['validate_callback'], $val, $key, $validate_args ); } } } } return $setting_option_values; } /** * Static function to get section setting. * * @param string $field_key Section field key. * @param mixed $default_return Default value if field not found. */ public static function get_setting( $field_key = '', $default_return = '' ) { return self::get_section_setting( get_called_class(), $field_key, $default_return ); } /** * Static function to get all section settings. */ public static function get_settings_all() { return self::get_section_settings_all( get_called_class() ); } /** * Static function to get section to get option label. * * @param string $field_key Section field key. * @param string $option_key Section option key. */ public static function get_setting_select_option_label( $field_key = '', $option_key = '' ) { return self::get_section_setting_select_option_label( get_called_class(), $field_key, $option_key ); } /** * Static function to get a Section Setting value. * * @param string $section Settings Section. * @param string $field_key Settings Section field key. * @param mixed $default_return Default value if field not found. */ public static function get_section_setting( $section = '', $field_key = '', $default_return = '' ) { if ( empty( $section ) ) { $section = get_called_class(); } $field_key = self::check_deprecated_field_key( $field_key, $section ); $section = self::check_deprecated_class( $section ); if ( isset( self::$_instances[ $section ] ) ) { self::$_instances[ $section ]->init(); if ( isset( self::$_instances[ $section ]->setting_option_fields[ $field_key ] ) ) { $default_return = self::$_instances[ $section ]->setting_option_fields[ $field_key ]['value']; } } return $default_return; } /** * Static function to set a Section Setting value. * * @param string $section Settings Section. * @param string $field_key Settings Section field key. * @param mixed $new_value new value for field. */ public static function set_section_setting( $section = '', $field_key = '', $new_value = '' ) { if ( ( ! empty( $section ) ) && ( ! empty( $field_key ) ) ) { $field_key = self::check_deprecated_field_key( $field_key, $section ); $section = self::check_deprecated_class( $section ); if ( isset( self::$_instances[ $section ] ) ) { self::$_instances[ $section ]->init(); if ( isset( self::$_instances[ $section ]->setting_option_fields[ $field_key ] ) ) { self::$_instances[ $section ]->setting_option_fields[ $field_key ]['value'] = $new_value; self::$_instances[ $section ]->save_settings_values(); } } } } /** * Static function to get all Section fields. * * @param string $section Settings Section. * @param string $field Settings Section field key. */ public static function get_section_settings_all( $section_org = '', $field = 'value' ) { if ( empty( $section_org ) ) { $section_org = get_called_class(); } $section = self::check_deprecated_class( $section_org ); if ( empty( $section ) ) { $section = $section_org; } if ( isset( self::$_instances[ $section ] ) ) { self::$_instances[ $section ]->init(); $fields_values = wp_list_pluck( self::$_instances[ $section ]->setting_option_fields, $field ); // If we are dealing with deprecated values we provide the old key/value sets as well so easy the logic on the caller. if ( $section_org !== $section ) { if ( ( isset( self::$_settings_deprecated[ $section_org ]['fields'] ) ) && ( ! empty( self::$_settings_deprecated[ $section_org ]['fields'] ) ) ) { foreach ( self::$_settings_deprecated[ $section_org ]['fields'] as $old_field => $new_field ) { if ( ( ! isset( $fields_values[ $old_field ] ) ) && ( isset( self::$_instances[ $section ]->setting_option_values[ $new_field ][ $field ] ) ) ) { $fields_values[ $old_field ] = self::$_instances[ $section ]->setting_option_fields[ $new_field ][ $field ]; } elseif ( ( 'value' === $field ) && ( isset( self::$_instances[ $section ]->setting_option_values[ $new_field ] ) ) ) { $fields_values[ $old_field ] = self::$_instances[ $section ]->setting_option_values[ $new_field ]; } } } } return $fields_values; } } /** * From a section settings you can access the label used on a select by the option key. * * @param string $section Settings Section. * @param string $field_key Settings Section field key. * @param string $option_key Option key. */ public static function get_section_setting_select_option_label( $section = '', $field_key = '', $option_key = '' ) { if ( empty( $section ) ) { $section = get_called_class(); } if ( ! empty( $field_key ) ) { $field_key = self::check_deprecated_field_key( $field_key, $section ); $section = self::check_deprecated_class( $section ); if ( isset( self::$_instances[ $section ] ) ) { self::$_instances[ $section ]->init(); // If the option_key was not passed we default to the current selected value. if ( empty( $option_key ) ) { $option_key = self::$_instances[ $section ]->get_setting( $field_key ); } // Now we get the option fields by the field_key and then derive the option label from the option_key. if ( ( isset( self::$_instances[ $section ]->setting_option_fields[ $field_key ] ) ) && ( 'select' === self::$_instances[ $section ]->setting_option_fields[ $field_key ]['type'] ) && ( self::$_instances[ $section ]->setting_option_fields[ $field_key ]['options'] ) && ( isset( self::$_instances[ $section ]->setting_option_fields[ $field_key ]['options'][ $option_key ] ) ) ) { return self::$_instances[ $section ]->setting_option_fields[ $field_key ]['options'][ $option_key ]; } } } } /** * Transition settings from old class into current one. * * @since 3.0 */ public function transition_deprecated_settings() { if ( ! empty( $this->settings_deprecated ) ) { foreach ( $this->settings_deprecated as $old_class => $old_class_settings ) { if ( ( isset( $old_class_settings['option_key'] ) ) && ( ! empty( $old_class_settings['option_key'] ) ) ) { $old_settings_values = get_option( $old_class_settings['option_key'] ); if ( ( isset( $old_class_settings['fields'] ) ) && ( ! empty( $old_class_settings['fields'] ) ) ) { foreach ( $old_class_settings['fields'] as $old_setting_key => $new_setting_key ) { if ( isset( $old_settings_values[ $old_setting_key ] ) ) { $this->setting_option_values[ $new_setting_key ] = $old_settings_values[ $old_setting_key ]; } } } } } } } /** * Transition old Settiings Class to new one. * * @since 3.0 * @param string $section Old section class. * @return string New section Class. */ public static function check_deprecated_class( $section = '' ) { if ( ! empty( $section ) ) { if ( isset( self::$_settings_deprecated[ $section ] ) ) { $section = self::$_settings_deprecated[ $section ]['class']; } } return $section; } /** * Transition old Settiings Class field(s) to new one(s). * * @since 3.0 * @param string $field_key Old section field key. * @param string $section Old section class. * @return string new field key. */ public static function check_deprecated_field_key( $field_key = '', $old_section = '' ) { if ( ( ! empty( $old_section ) ) && ( isset( self::$_settings_deprecated[ $old_section ] ) ) ) { if ( isset( self::$_settings_deprecated[ $old_section ]['fields'] ) ) { $section_fields = self::$_settings_deprecated[ $old_section ]['fields']; if ( ! empty( $section_fields ) ) { if ( isset( $section_fields[ $field_key ] ) ) { $field_key = $section_fields[ $field_key ]; } } } } return $field_key; } } } if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Theme_Settings_Section' ) ) ) { /** * Class to create the settings section. */ abstract class LearnDash_Theme_Settings_Section extends LearnDash_Settings_Section { /** * Match Theme Key. * This should match the theme_key set within the LearnDash_Theme_Register instance. * * @var string $settings_theme_key Settings Theme ID. */ protected $settings_theme_key = ''; /** * Protected constructor for class */ protected function __construct() { parent::__construct(); if ( ! empty( $this->settings_theme_key ) ) { LearnDash_Theme_Register::register_theme_settings_section( $this->settings_theme_key, $this->settings_section_key, $this ); } add_filter( 'learndash_show_metabox', array( $this, 'learndash_show_metabox' ), 1, 3 ); } final public function learndash_show_metabox( $show_metabox = true, $metabox_key = '', $settings_screen_id = '' ) { if ( $metabox_key === $this->metabox_key ) { $show_metabox = false; } return $show_metabox; } } } PK!\O%&*$*$settings-url.phpnuW+APK!\Cppj$settings-module.phpnuW+APK!\1-- =languages.phpnuW+APK!\/\table-languages.phpnuW+APK!\Vezview-about.phpnuW+APK!\{~settings-media.phpnuW+APK!\#00,view-languages.phpnuW+APK!\view-tab-lang.phpnuW+APK!\kύksettings-tools.phpnuW+APK!\ɫ:view-tab-strings.phpnuW+APK!\Vo o settings-cpt.phpnuW+APK!\4))ȳtable-string.phpnuW+APK!\fx`` "settings.phpnuW+APK!\Ҝ::{=table-settings.phpnuW+APK!\ Osettings-browser.phpnuW+APK!\W9)9) Zflags.phpnuW+APK!\YOOxsettings-licenses.phpnuW+APK!\SS view-tab-settings.phpnuW+APKg"\validations.phpnuW+APKg"\RGI bcontrols.phpnuW+APKg"\rs"s"settings-page.phpnuW+APKg"\ɹ(( Ztools.phpnuW+APK4\OMM  manager.phpnuW+APK4\cH H base/css-manager.phpnuW+APK4\]](base/model.phpnuW+APK4\#' ' /+base/manager.phpnuW+APK4\r ttKbase/css-model.phpnuW+APK4\w| LMgeneral/model.phpnuW+APK4\$``Lngeneral/manager.phpnuW+APK4\jcS|jjpage/model.phpnuW+APK4\p>!!page/manager.phpnuW+APK4\a ``editor-preferences/model.phpnuW+APK4\SԲDeditor-preferences/manager.phpnuW+APK^\|MXBXBDclass-ld-settings-pages.phpnuW+APK^\>+66 class-ld-shortcodes-sections.phpnuW+APK^\s7msettings-pages/class-ld-settings-page-data-upgrades.phpnuW+APK^\Aź9!settings-pages/class-ld-settings-page-quizzes-options.phpnuW+APK^\ir3||@(settings-pages/class-ld-settings-page-quizzes-builder-single.phpnuW+APK^\Fh  7Gsettings-pages/class-ld-settings-page-custom-labels.phpnuW+APK^\mm8Usettings-pages/class-ld-settings-page-topics-options.phpnuW+APK^\مi0*settings-pages/class-ld-settings-page-paypal.phpnuW+APK^\Hi@ssettings-pages/class-ld-settings-page-courses-builder-single.phpnuW+APK^\nR1settings-pages/class-ld-settings-page-general.phpnuW+APK^\) 556settings-pages/class-ld-settings-page-translations.phpnuW+APK^\S;7settings-pages/class-ld-settings-page-questions-options.phpnuW+APK^\ orr(<settings-pages/settings-pages-loader.phpnuW+APK^\0&>9Asettings-pages/class-ld-settings-page-courses-options.phpnuW+APK^\1\1Esettings-pages/class-ld-settings-page-license.phpnuW+APK^\(Zzz=$Jsettings-pages/class-ld-settings-page-assignments-options.phpnuW+APK^\i$1 Nsettings-pages/class-ld-settings-page-support.phpnuW+APK^\)o2Kgsettings-pages/class-ld-settings-page-overview.phpnuW+APK^\CMM7Msettings-pages/class-ld-settings-page-import-export.phpnuW+APK^\Hvv9]settings-pages/class-ld-settings-page-lessons-options.phpnuW+APK^\>53@_asettings-pages/class-ld-settings-page-certificate-shortcodes.phpnuW+APK^\]){shortcodes-sections/course_notstarted.phpnuW+APK^\D,,'shortcodes-sections/course_complete.phpnuW+APK^\fJ J &shortcodes-sections/course_content.phpnuW+APK^\89"6shortcodes-sections/ld_profile.phpnuW+APK^\L ##&\shortcodes-sections/ld_course_info.phpnuW+APK^\D  shortcodes-sections/visitor.phpnuW+APK^\ 1shortcodes-sections/learndash_course_progress.phpnuW+APK^\uj1hshortcodes-sections/learndash_payment_buttons.phpnuW+APK^\7KK#shortcodes-sections/user_groups.phpnuW+APK^\Szz(g shortcodes-sections/ld_quiz_complete.phpnuW+APK^\'܎55&9shortcodes-sections/ld_course_list.phpnuW+APK^\bs.**&bSshortcodes-sections/ld_certificate.phpnuW+APK^\3+z/cshortcodes-sections/ld_course_expire_status.phpnuW+APK^\6[= = 'tshortcodes-sections/ld_group.phpnuW+APK^\ Q0Q0&shortcodes-sections/ld_lesson_list.phpnuW+APK^\BV'[shortcodes-sections/learndash_login.phpnuW+APK^\ N (shortcodes-sections/ld_course_resume.phpnuW+APK^\}qQ6 5 5$shortcodes-sections/ld_quiz_list.phpnuW+APK^\,,  shortcodes-sections/ld_video.phpnuW+APK^\ )cshortcodes-sections/course_inprogress.phpnuW+APK^\y9_- shortcodes-sections/ld_user_course_points.phpnuW+APK^\ &shortcodes-sections/usermeta.phpnuW+APK^\&(a .shortcodes-sections/quizinfo.phpnuW+APK^\s s Hshortcodes-sections/student.phpnuW+APK^\+}--"Vshortcodes-sections/courseinfo.phpnuW+APK^\=(22%shortcodes-sections/ld_topic_list.phpnuW+APK^\H_Z!!;settings-sections/class-ld-settings-section-courses-cpt.phpnuW+APK^\kff@.settings-sections/class-ld-settings-section-general-rest-api.phpnuW+APK^\1pAsettings-sections/class-ld-settings-section-support-learndash.phpnuW+APK^\0b㹋 Hwsettings-sections/class-ld-settings-section-support-copy-system-info.phpnuW+APK^\AϾ> settings-sections/class-ld-settings-section-courses-themes.phpnuW+APK^\rZBLsettings-sections/class-ld-settings-section-general-admin-user.phpnuW+APK^\1tLLJsettings-sections/class-ld-settings-section-courses-management-display.phpnuW+APK^\ŽLsettings-sections/class-ld-settings-section-questions-management-display.phpnuW+APK^\cHBB. settings-sections/settings-sections-loader.phpnuW+APK^\$(uuB_) settings-sections/class-ld-settings-section-courses-taxonomies.phpnuW+APK^\K}y y DF> settings-sections/class-ld-settings-section-translations-refresh.phpnuW+APK^\¨''E3H settings-sections/class-ld-settings-section-permalinks-taxonomies.phpnuW+APK^\{| +]+]JPp settings-sections/class-ld-settings-section-quizzes-management-display.phpnuW+APK^\hBt!!G settings-sections/class-ld-settings-section-support-database-tables.phpnuW+APK^\_--A settings-sections/class-ld-settings-section-support-templates.phpnuW+APK^\R$A  settings-sections/class-ld-settings-section-support-wordpress.phpnuW+APK^\@JJI}/ settings-sections/class-ld-settings-section-support-wordpress-plugins.phpnuW+APK^\^577F@B settings-sections/class-ld-settings-section-quizzes-email-settings.phpnuW+APK^\8P'  By settings-sections/class-ld-settings-section-support-data-reset.phpnuW+APK^\:g ( (>4 settings-sections/class-ld-settings-section-support-server.phpnuW+APK^\ZF settings-sections/class-ld-settings-section-translations-learndash.phpnuW+APK^\Nw.H settings-sections/class-ld-settings-section-support-wordpress-themes.phpnuW+APK^\>? settings-sections/class-ld-settings-section-assignments-cpt.phpnuW+APK^\IWsLLB settings-sections/class-ld-settings-section-lessons-taxonomies.phpnuW+APK^\੆cc= settings-sections/class-ld-settings-section-data-upgrades.phpnuW+APK^\NCPT T @ settings-sections/class-ld-settings-section-side-quick-links.phpnuW+APK^\UX占!!;F settings-sections/class-ld-settings-section-quizzes-cpt.phpnuW+APK^\K @Q& settings-sections/class-ld-settings-section-general-per-page.phpnuW+APK^\/**D{G settings-sections/class-ld-settings-section-questions-taxonomies.phpnuW+APK^\QjB r settings-sections/class-ld-settings-section-quizzes-taxonomies.phpnuW+APK^\QZ Z = settings-sections/class-ld-settings-section-questions-cpt.phpnuW+APK^\,;!!:͑ settings-sections/class-ld-settings-section-topics-cpt.phpnuW+APK^\1d = settings-sections/class-ld-settings-section-custom-labels.phpnuW+APK^\dJ settings-sections/class-ld-settings-section-general-login-registration.phpnuW+APK^\"1==A1 settings-sections/class-ld-settings-section-topics-taxonomies.phpnuW+APK^\w7''6 settings-sections/class-ld-settings-section-paypal.phpnuW+APK^\g,,:" settings-sections/class-ld-settings-section-permalinks.phpnuW+APK^\.g:U!!;N settings-sections/class-ld-settings-section-lessons-cpt.phpnuW+APK^\8b;p settings-sections/class-ld-settings-section-side-submit.phpnuW+APK^\Hڙ__ y class-ld-settings-fields.phpnuW+APK^\`O?QYQY class-ld-settings-metaboxes.phpnuW+APK^\TM2 settings-loader.phpnuW+APK^\RR_5 settings-metaboxes/class-ld-settings-metabox-quiz-admin-data-handling-settings.phpnuW+APK^\Yƃ+YYK settings-metaboxes/class-ld-settings-metabox-course-navigation-settings.phpnuW+APK^\g?Fa settings-metaboxes/class-ld-settings-metabox-topic-display-content.phpnuW+APK^\|6|6Eklsettings-metaboxes/class-ld-settings-metabox-quiz-access-settings.phpnuW+APK^\uFzMzMG\settings-metaboxes/class-ld-settings-metabox-course-display-content.phpnuW+APK^\Q1,,GMsettings-metaboxes/class-ld-settings-metabox-lesson-access-settings.phpnuW+APK^\=settings-metaboxes/class-ld-settings-metabox-course-users.phpnuW+APK^\(G 5settings-metaboxes/class-ld-settings-metabox-course-access-settings.phpnuW+APK^\חb b Fsettings-metaboxes/class-ld-settings-metabox-topic-access-settings.phpnuW+APK^\p}ddE`settings-metaboxes/class-ld-settings-metabox-quiz-display-content.phpnuW+APK^\ __U9ssettings-metaboxes/class-ld-settings-metabox-quiz-results-display-content-options.phpnuW+APK^\/qGsettings-metaboxes/class-ld-settings-metabox-lesson-display-content.phpnuW+APK^\d4M4MGXsettings-metaboxes/class-ld-settings-metabox-quiz-progress-settings.phpnuW+APK^\V0~settings-fields/class-ld-settings-fields-url.phpnuW+APK^\#T9settings-fields/class-ld-settings-fields-media-upload.phpnuW+APK^\ҹ3̾settings-fields/class-ld-settings-fields-select.phpnuW+APK^\m@settings-fields/class-ld-settings-fields-quiz-templates-load.phpnuW+APK^\X22@settings-fields/class-ld-settings-fields-quiz-templates-save.phpnuW+APK^\~3r5settings-fields/class-ld-settings-fields-checkbox.phpnuW+APK^\h czz<settings-fields/class-ld-settings-fields-checkbox-switch.phpnuW+APK^\ ~ 7,settings-fields/class-ld-settings-fields-date-entry.phpnuW+APK^\vee*Fsettings-fields/settings-fields-loader.phpnuW+APK^\! 3jMsettings-fields/class-ld-settings-fields-number.phpnuW+APK^\j%R+ + ?Zsettings-fields/class-ld-settings-fields-quiz-custom-fields.phpnuW+APK^\KGVpp37{settings-fields/class-ld-settings-fields-hidden.phpnuW+APK^\֤  8 settings-fields/class-ld-settings-fields-timer-entry.phpnuW+APK^\ 9{settings-fields/class-ld-settings-fields-input-select.phpnuW+APK^\#^8fsettings-fields/class-ld-settings-fields-multiselect.phpnuW+APK^\} } 5Ysettings-fields/class-ld-settings-fields-textarea.phpnuW+APK^\EcE1;settings-fields/class-ld-settings-fields-text.phpnuW+APK^\Ltt3\settings-fields/class-ld-settings-fields-custom.phpnuW+APK^\;jj13settings-fields/class-ld-settings-fields-html.phpnuW+APK^\r:! ! 5settings-fields/class-ld-settings-fields-wpeditor.phpnuW+APK^\JE2settings-fields/class-ld-settings-fields-email.phpnuW+APK^\s2settings-fields/class-ld-settings-fields-radio.phpnuW+APK^\ ?settings-fields/class-ld-settings-fields-select-edit-delete.phpnuW+APK^\حˌ8 settings-fields/class-ld-settings-fields-colorpicker.phpnuW+APK^\G44class-ld-shortcodes-tinymce.phpnuW+APK^\ii>class-ld-settings-sections.phpnuW+APKF$