File manager - Edit - /home/theblueo/tv/fb4e3b/settings.tar
Back
base/model.php 0000666 00000001135 15214141735 0007276 0 ustar 00 <?php namespace Elementor\Core\Settings\Base; use Elementor\Controls_Stack; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings base model. * * Elementor settings base model handler class is responsible for registering * and managing Elementor settings base models. * * @since 1.6.0 * @abstract */ abstract class Model extends Controls_Stack { /** * Get panel page settings. * * Retrieve the page setting for the current panel. * * @since 1.6.0 * @access public * @abstract */ abstract public function get_panel_page_settings(); } base/css-manager.php 0000666 00000004510 15214141735 0010376 0 ustar 00 <?php namespace Elementor\Core\Settings\Base; use Elementor\Core\Files\CSS\Base as CSS_File; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } abstract class CSS_Manager extends Manager { /** * Get CSS file name. * * Retrieve CSS file name for the settings base css manager. * * @since 2.8.0 * @access protected * @abstract * * @return string CSS file name */ abstract protected function get_css_file_name(); /** * Get model for CSS file. * * Retrieve the model for the CSS file. * * @since 2.8.0 * @access protected * @abstract * * @param CSS_File $css_file The requested CSS file. * * @return CSS_Model * */ abstract protected function get_model_for_css_file( CSS_File $css_file ); /** * Get CSS file for update. * * Retrieve the CSS file before updating it. * * @since 2.8.0 * @access protected * @abstract * * @param int $id Post ID. * * @return CSS_File * */ abstract protected function get_css_file_for_update( $id ); /** * Settings base manager constructor. * * Initializing Elementor settings base css manager. * * @since 2.8.0 * @access public */ public function __construct() { parent::__construct(); $name = $this->get_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() ] ); } } base/manager.php 0000666 00000020047 15214141735 0007613 0 ustar 00 <?php namespace Elementor\Core\Settings\Base; use Elementor\Core\Common\Modules\Ajax\Module as Ajax; use Elementor\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings base manager. * * Elementor settings base manager handler class is responsible for registering * and managing Elementor settings base managers. * * @since 1.6.0 * @abstract */ abstract class Manager { /** * Models cache. * * Holds all the models. * * @since 1.6.0 * @access private * * @var Model[] */ private $models_cache = []; /** * Settings base manager constructor. * * Initializing Elementor settings base manager. * * @since 1.6.0 * @access public */ public function __construct() { add_action( 'elementor/editor/init', [ $this, 'on_elementor_editor_init' ] ); add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); } /** * Register ajax actions. * * Add new actions to handle data after an ajax requests returned. * * Fired by `elementor/ajax/register_actions` action. * * @since 2.0.0 * @access public * * @param Ajax $ajax_manager */ public function register_ajax_actions( $ajax_manager ) { $name = $this->get_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.<?php echo $name; ?>.tabs; if ( Object.values( tabs ).length > 1 ) { #> <div class="elementor-panel-navigation"> <# _.each( tabs, function( tabTitle, tabSlug ) { $e.bc.ensureTab( 'panel/<?php echo $name; ?>-settings', tabSlug ); #> <div class="elementor-component-tab elementor-panel-navigation-tab elementor-tab-control-{{ tabSlug }}" data-tab="{{ tabSlug }}"> <a href="#">{{{ tabTitle }}}</a> </div> <# } ); #> </div> <# } #> <div id="elementor-panel-<?php echo $name; ?>-settings-controls"></div> <?php } /** * Create model. * * Create a new model object for any given model ID and store the object in * models cache property for later use. * * @since 1.6.0 * @access private * * @param int $id Model ID. */ private function create_model( $id ) { $class_parts = explode( '\\', get_called_class() ); array_splice( $class_parts, count( $class_parts ) - 1, 1, 'Model' ); $class_name = implode( '\\', $class_parts ); $this->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(); ?> <script type="text/template" id="tmpl-elementor-panel-<?php echo esc_attr( $name ); ?>-settings"> <?php $this->print_editor_template_content( $name ); ?> </script> <?php return ob_get_clean(); } } base/css-model.php 0000666 00000000564 15214141735 0010071 0 ustar 00 <?php namespace Elementor\Core\Settings\Base; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } abstract class CSS_Model extends Model { /** * Get CSS wrapper selector. * * Retrieve the wrapper selector for the current panel. * * @since 1.6.0 * @access public * @abstract */ abstract public function get_css_wrapper_selector(); } editor-preferences/model.php 0000666 00000003540 15214141735 0012153 0 ustar 00 <?php namespace Elementor\Core\Settings\EditorPreferences; use Elementor\Controls_Manager; use Elementor\Core\Settings\Base\Model as BaseModel; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Model extends BaseModel { /** * Get element name. * * Retrieve the element name. * * @return string The name. * @since 2.8.0 * @access public * */ public function get_name() { return 'editor-preferences'; } /** * Get panel page settings. * * Retrieve the page setting for the current panel. * * @since 2.8.0 * @access public */ public function get_panel_page_settings() { return [ 'title' => __( '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(); } } editor-preferences/manager.php 0000666 00000002662 15214141735 0012471 0 ustar 00 <?php namespace Elementor\Core\Settings\EditorPreferences; use Elementor\Core\Settings\Base\Manager as BaseManager; use Elementor\Core\Settings\Base\Model as BaseModel; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Manager extends BaseManager { const META_KEY = 'elementor_preferences'; /** * Get model for config. * * Retrieve the model for settings configuration. * * @since 2.8.0 * @access public * * @return BaseModel The model object. * */ public function get_model_for_config() { return $this->get_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 ); } } manager.php 0000666 00000010515 15214141735 0006700 0 ustar 00 <?php namespace Elementor\Core\Settings; use Elementor\Core\Settings\Base\CSS_Model; use Elementor\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings manager. * * Elementor settings manager handler class is responsible for registering and * managing Elementor settings managers. * * @since 1.6.0 */ class Manager { /** * Settings managers. * * Holds all the registered settings managers. * * @since 1.6.0 * @access private * * @var Base\Manager[] */ private static $settings_managers = []; /** * Builtin settings managers names. * * Holds the names for builtin Elementor settings managers. * * @since 1.6.0 * @access private * * @var array */ private static $builtin_settings_managers_names = [ 'page', 'general', 'editorPreferences' ]; /** * Add settings manager. * * Register a single settings manager to the registered settings managers. * * @since 1.6.0 * @access public * @static * * @param Base\Manager $manager Settings manager. */ public static function add_settings_manager( Base\Manager $manager ) { self::$settings_managers[ $manager->get_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(); } } general/manager.php 0000666 00000010540 15214141735 0010313 0 ustar 00 <?php namespace Elementor\Core\Settings\General; use Elementor\Controls_Manager; use Elementor\Core\Files\CSS\Base; use Elementor\Core\Files\CSS\Global_CSS; use Elementor\Core\Settings\Base\CSS_Manager; use Elementor\Core\Settings\Base\Model as BaseModel; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor general settings manager. * * Elementor general settings manager handler class is responsible for registering * and managing Elementor general settings managers. * * @since 1.6.0 */ class Manager extends CSS_Manager { /** * Lightbox panel tab. */ const PANEL_TAB_LIGHTBOX = 'lightbox'; /** * Meta key for the general settings. */ const META_KEY = '_elementor_general_settings'; /** * General settings manager constructor. * * Initializing Elementor general settings manager. * * @since 1.6.0 * @access public */ public function __construct() { parent::__construct(); $this->add_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' ) ); } } general/model.php 0000666 00000020277 15214141735 0010011 0 ustar 00 <?php namespace Elementor\Core\Settings\General; use Elementor\Controls_Manager; use Elementor\Core\Settings\Base\CSS_Model; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor global settings model. * * Elementor global settings model handler class is responsible for registering * and managing Elementor global settings models. * * @since 1.6.0 */ class Model extends CSS_Model { /** * Get model name. * * Retrieve global settings model name. * * @since 1.6.0 * @access public * * @return string Model name. */ public function get_name() { return 'global-settings'; } /** * Get CSS wrapper selector. * * Retrieve the wrapper selector for the global settings model. * * @since 1.6.0 * @access public * * @return string CSS wrapper selector. */ public function get_css_wrapper_selector() { return ''; } /** * Get panel page settings. * * Retrieve the panel setting for the global settings model. * * @since 1.6.0 * @access public * * @return array { * Panel settings. * * @type string $title The panel title. * @type array $menu The panel menu. * } */ public function get_panel_page_settings() { return [ 'title' => __( '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(); } } } } page/manager.php 0000666 00000020701 15214141735 0007612 0 ustar 00 <?php namespace Elementor\Core\Settings\Page; use Elementor\Core\Files\CSS\Base; use Elementor\Core\Files\CSS\Post; use Elementor\Core\Files\CSS\Post_Preview; use Elementor\Core\Settings\Base\CSS_Manager; use Elementor\Core\Utils\Exceptions; use Elementor\Core\Settings\Base\Model as BaseModel; use Elementor\DB; use Elementor\Plugin; use Elementor\Utils; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor page settings manager. * * Elementor page settings manager handler class is responsible for registering * and managing Elementor page settings managers. * * @since 1.6.0 */ class Manager extends CSS_Manager { /** * Meta key for the page settings. */ const META_KEY = '_elementor_page_settings'; /** * Is CPT supports custom templates. * * Whether the Custom Post Type supports templates. * * @since 1.6.0 * @deprecated 2.0.0 Use `Utils::is_cpt_custom_templates_supported()` method instead. * @access public * @static * * @return bool True is templates are supported, False otherwise. */ public static function is_cpt_custom_templates_supported() { _deprecated_function( __METHOD__, '2.0.0', 'Utils::is_cpt_custom_templates_supported()' ); return Utils::is_cpt_custom_templates_supported(); } /** * Get manager name. * * Retrieve page settings manager name. * * @since 1.6.0 * @access public * * @return string Manager name. */ public function get_name() { return 'page'; } /** * 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() { if ( ! is_singular() && ! Plugin::$instance->editor->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 ) { #> <div class="elementor-panel-navigation"> <# _.each( tabs, function( tabTitle, tabSlug ) { #> <div class="elementor-component-tab elementor-panel-navigation-tab elementor-tab-control-{{ tabSlug }}" data-tab="{{ tabSlug }}"> <a href="#">{{{ tabTitle }}}</a> </div> <# } ); #> </div> <# } #> <div id="elementor-panel-<?php echo $name; ?>-settings-controls"></div> <?php } /** * Save settings to DB. * * Save page settings to the database, as post meta data. * * @since 1.6.0 * @access protected * * @param array $settings Settings. * @param int $id Post ID. */ protected function save_settings_to_db( array $settings, $id ) { // Use update/delete_metadata in order to handle also revisions. if ( ! empty( $settings ) ) { // Use `wp_slash` in order to avoid the unslashing during the `update_post_meta`. update_metadata( 'post', $id, self::META_KEY, wp_slash( $settings ) ); } else { delete_metadata( 'post', $id, self::META_KEY ); } } /** * Get CSS file for update. * * Retrieve the CSS file before updating it. * * This method overrides the parent method to disallow updating CSS files for pages. * * @since 1.6.0 * @access protected * * @param int $id Post ID. * * @return false Disallow The updating CSS files for pages. */ protected function get_css_file_for_update( $id ) { return false; } /** * Get saved settings. * * Retrieve the saved settings from the post meta. * * @since 1.6.0 * @access protected * * @param int $id Post ID. * * @return array Saved settings. */ protected function get_saved_settings( $id ) { $settings = get_post_meta( $id, self::META_KEY, true ); if ( ! $settings ) { $settings = []; } if ( Utils::is_cpt_custom_templates_supported() ) { $saved_template = get_post_meta( $id, '_wp_page_template', true ); if ( $saved_template ) { $settings['template'] = $saved_template; } } return $settings; } /** * Get CSS file name. * * Retrieve CSS file name for the page settings manager. * * @since 1.6.0 * @access protected * * @return string CSS file name. */ protected function get_css_file_name() { return 'post'; } /** * 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 ) { if ( ! $css_file instanceof Post ) { return null; } $post_id = $css_file->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 ); } } page/model.php 0000666 00000007552 15214141735 0007311 0 ustar 00 <?php namespace Elementor\Core\Settings\Page; use Elementor\Core\Settings\Base\CSS_Model; use Elementor\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor page settings model. * * Elementor page settings model handler class is responsible for registering * and managing Elementor page settings models. * * @since 1.6.0 */ class Model extends CSS_Model { /** * WordPress post object. * * Holds an instance of `WP_Post` containing the post object. * * @since 1.6.0 * @access public * * @var \WP_Post */ private $post; /** * @var \WP_Post */ private $post_parent; /** * Model constructor. * * Initializing Elementor page settings model. * * @since 1.6.0 * @access public * * @param array $data Optional. Model data. Default is an empty array. */ public function __construct( array $data = [] ) { $this->post = 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 ); } } } } } validations.php 0000666 00000003177 15214147454 0007615 0 ustar 00 <?php namespace Elementor; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings validations. * * Elementor settings validations handler class is responsible for validating settings * fields. * * @since 1.0.0 */ class Settings_Validations { /** * Validate HTML field. * * Sanitize content for allowed HTML tags and remove backslashes before quotes. * * @since 1.0.0 * @access public * @static * * @param string $input Input field. * * @return string Input field. */ public static function html( $input ) { return stripslashes( wp_filter_post_kses( addslashes( $input ) ) ); } /** * Validate checkbox list. * * Make sure that an empty checkbox list field will return an array. * * @since 1.0.0 * @access public * @static * * @param mixed $input Input field. * * @return mixed Input field. */ public static function checkbox_list( $input ) { if ( empty( $input ) ) { $input = []; } return $input; } /** * Current Time * * Used to return current time * * @since 2.5.0 * @access public * @static * * @param mixed $input Input field. * * @return int */ public static function current_time( $input ) { return time(); } /** * Clear cache. * * Delete post meta containing the post CSS file data. And delete the actual * CSS files from the upload directory. * * @since 1.4.8 * @access public * @static * * @param mixed $input Input field. * * @return mixed Input field. */ public static function clear_cache( $input ) { Plugin::$instance->files_manager->clear_cache(); return $input; } } controls.php 0000666 00000015410 15214147454 0007134 0 ustar 00 <?php namespace Elementor; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings controls. * * Elementor settings controls handler class responsible for creating the final * HTML for various input field types used in Elementor settings pages. * * @since 1.0.0 */ class Settings_Controls { /** * Render settings control. * * Generates the final HTML on the frontend for any given field based on * the field type (text, select, checkbox, raw HTML, etc.). * * @since 1.0.0 * @access public * @static * * @param array $field Optional. Field data. Default is an empty array. */ public static function render( $field = [] ) { if ( empty( $field ) || empty( $field['id'] ) ) { return; } $defaults = [ 'type' => '', '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'] ); ?> <input type="<?php echo esc_attr( $field['type'] ); ?>" id="<?php echo esc_attr( $field['id'] ); ?>" name="<?php echo esc_attr( $field['id'] ); ?>" value="<?php echo esc_attr( get_option( $field['id'], $field['std'] ) ); ?>" <?php echo $attributes; ?>/> <?php if ( ! empty( $field['sub_desc'] ) ) : echo $field['sub_desc']; endif; ?> <?php if ( ! empty( $field['desc'] ) ) : ?> <p class="description"><?php echo $field['desc']; ?></p> <?php endif; } /** * Render checkbox control. * * Generates the final HTML for checkbox controls. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function checkbox( array $field ) { ?> <label> <input type="<?php echo esc_attr( $field['type'] ); ?>" id="<?php echo esc_attr( $field['id'] ); ?>" name="<?php echo esc_attr( $field['id'] ); ?>" value="<?php echo $field['value']; ?>"<?php checked( $field['value'], get_option( $field['id'], $field['std'] ) ); ?> /> <?php if ( ! empty( $field['sub_desc'] ) ) : echo $field['sub_desc']; endif; ?> </label> <?php if ( ! empty( $field['desc'] ) ) : ?> <p class="description"><?php echo $field['desc']; ?></p> <?php endif; } /** * Render checkbox list control. * * Generates the final HTML for checkbox list controls. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function checkbox_list( array $field ) { $old_value = get_option( $field['id'], $field['std'] ); if ( ! is_array( $old_value ) ) { $old_value = []; } foreach ( $field['options'] as $option_key => $option_value ) : ?> <label> <input type="checkbox" name="<?php echo esc_attr( $field['id'] ); ?>[]" value="<?php echo esc_attr( $option_key ); ?>"<?php checked( in_array( $option_key, $old_value ), true ); ?> /> <?php echo $option_value; ?> </label><br /> <?php endforeach; ?> <?php if ( ! empty( $field['desc'] ) ) : ?> <p class="description"><?php echo $field['desc']; ?></p> <?php endif; } /** * Render select control. * * Generates the final HTML for select controls. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function select( array $field ) { $old_value = get_option( $field['id'], $field['std'] ); ?> <select name="<?php echo esc_attr( $field['id'] ); ?>"> <?php if ( ! empty( $field['show_select'] ) ) : ?> <option value="">— <?php echo __( 'Select', 'elementor' ); ?> —</option> <?php endif; ?> <?php foreach ( $field['options'] as $value => $label ) : ?> <option value="<?php echo esc_attr( $value ); ?>"<?php selected( $value, $old_value ); ?>><?php echo $label; ?></option> <?php endforeach; ?> </select> <?php if ( ! empty( $field['desc'] ) ) : ?> <p class="description"><?php echo $field['desc']; ?></p> <?php endif; } /** * Render checkbox list control for CPT. * * Generates the final HTML for checkbox list controls populated with Custom Post Types. * * @since 2.0.0 * @access private * @static * * @param array $field Field data. */ private static function checkbox_list_cpt( array $field ) { $defaults = [ 'exclude' => [], ]; $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; } ?> <div id="<?php echo $field['id']; ?>"> <div><?php echo $field['html']; ?></div> <?php if ( ! empty( $field['sub_desc'] ) ) : echo $field['sub_desc']; endif; ?> <?php if ( ! empty( $field['desc'] ) ) : ?> <p class="description"><?php echo $field['desc']; ?></p> <?php endif; ?> </div> <?php } } settings.php 0000666 00000060035 15214147454 0007134 0 ustar 00 <?php namespace Elementor; use Elementor\Core\Responsive\Responsive; use Elementor\Core\Settings\General\Manager as General_Settings_Manager; use Elementor\Core\Settings\Manager; use Elementor\TemplateLibrary\Source_Local; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor "Settings" page in WordPress Dashboard. * * Elementor settings page handler class responsible for creating and displaying * Elementor "Settings" page in WordPress dashboard. * * @since 1.0.0 */ class Settings extends Settings_Page { /** * Settings page ID for Elementor settings. */ const PAGE_ID = 'elementor'; /** * Go Pro menu priority. */ const MENU_PRIORITY_GO_PRO = 502; /** * Settings page field for update time. */ const UPDATE_TIME_FIELD = '_elementor_settings_update_time'; /** * Settings page general tab slug. */ const TAB_GENERAL = 'general'; /** * Settings page style tab slug. */ const TAB_STYLE = 'style'; /** * Settings page integrations tab slug. */ const TAB_INTEGRATIONS = 'integrations'; /** * Settings page advanced tab slug. */ const TAB_ADVANCED = 'advanced'; /** * Register admin menu. * * Add new Elementor Settings admin menu. * * Fired by `admin_menu` action. * * @since 1.0.0 * @access public */ public function register_admin_menu() { global $menu; $menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // WPCS: override ok. if ( ! current_user_can( 'manage_options' ) ) { return; } add_menu_page( __( 'Elementor', 'elementor' ), __( 'Elementor', 'elementor' ), 'manage_options', self::PAGE_ID, [ $this, 'display_settings_page' ], '', '58.5' ); } /** * Reorder the Elementor menu items in admin. * Based on WC. * * @since 2.4.0 * * @param array $menu_order Menu order. * @return array */ public function menu_order( $menu_order ) { // Initialize our custom order array. $elementor_menu_order = []; // Get the index of our custom separator. $elementor_separator = array_search( 'separator-elementor', $menu_order, true ); // Get index of library menu. $elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true ); // Loop through menu order and do some rearranging. foreach ( $menu_order as $index => $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, '', '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . __( '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'; } ?> <div class="wrap"> <div class="e-getting-started"> <div class="e-getting-started__box postbox"> <div class="e-getting-started__header"> <div class="e-getting-started__title"> <div class="e-logo-wrapper"><i class="eicon-elementor"></i></div> <?php echo __( 'Getting Started', 'elementor' ); ?> </div> <a class="e-getting-started__skip" href="<?php echo esc_url( admin_url() ); ?>"> <i class="eicon-close" aria-hidden="true" title="<?php esc_attr_e( 'Skip', 'elementor' ); ?>"></i> <span class="elementor-screen-only"><?php echo __( 'Skip', 'elementor' ); ?></span> </a> </div> <div class="e-getting-started__content"> <div class="e-getting-started__content--narrow"> <h2><?php echo __( 'Welcome to Elementor', 'elementor' ); ?></h2> <p><?php echo __( 'We recommend you watch this 2 minute getting started video, and then try the editor yourself by dragging and dropping elements to create your first page.', 'elementor' ); ?></p> </div> <div class="e-getting-started__video"> <iframe width="620" height="350" src="https://www.youtube-nocookie.com/embed/nZlgNmbC-Cw?rel=0&controls=1&modestbranding=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="e-getting-started__actions e-getting-started__content--narrow"> <?php if ( ! empty( $create_new_cpt ) ) : ?> <a href="<?php echo esc_url( Utils::get_create_new_post_url( $create_new_cpt ) ); ?>" class="button button-primary button-hero"><?php echo esc_html( $create_new_label ); ?></a> <?php endif; ?> <a href="https://go.elementor.com/getting-started/" target="_blank" class="button button-secondary button-hero"><?php echo __( 'Get the Full Guide', 'elementor' ); ?></a> </div> </div> </div> </div> </div><!-- /.wrap --> <?php } /** * Display settings page. * * Output the content for the custom fonts page. * * @since 2.0.0 * @access public */ public function elementor_custom_fonts() { ?> <div class="wrap"> <div class="elementor-blank_state"> <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; ?>" /> <h2><?php echo __( 'Add Your Custom Fonts', 'elementor' ); ?></h2> <p><?php echo __( 'Custom Fonts allows you to add your self-hosted fonts and use them on your Elementor projects to create a unique brand language.', 'elementor' ); ?></p> <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-custom-fonts&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a> </div> </div><!-- /.wrap --> <?php } /** * Display settings page. * * Output the content for the custom icons page. * * @since 2.8.0 * @access public */ public function elementor_custom_icons() { ?> <div class="wrap"> <div class="elementor-blank_state"> <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; ?>" /> <h2><?php echo __( 'Add Your Custom Icons', 'elementor' ); ?></h2> <p><?php echo __( 'Don\'t rely solely on the FontAwesome icons everyone else is using! Differentiate your website and your style with custom icons you can upload from your favorite icons source.', 'elementor' ); ?></p> <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-custom-icons&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a> </div> </div><!-- /.wrap --> <?php } /** * Display settings page. * * Output the content for the Popups page. * * @since 2.4.0 * @access public */ public function elementor_popups() { ?> <div class="wrap"> <div class="elementor-blank_state"> <i class="eicon-nerd-chuckle"></i> <h2><?php echo __( 'Get Popup Builder', 'elementor' ); ?></h2> <p><?php echo __( 'Popup Builder lets you take advantage of all the amazing features in Elementor, so you can build beautiful & highly converting popups. Go pro and start designing your popups today.', 'elementor' ); ?></p> <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/popup-builder/?utm_source=popup-templates&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a> </div> </div><!-- /.wrap --> <?php } /** * Display settings page. * * Output the content for the Theme Templates page. * * @since 2.4.0 * @access public */ public function elementor_theme_templates() { ?> <div class="wrap"> <div class="elementor-blank_state"> <i class="eicon-nerd-chuckle"></i> <h2><?php echo __( 'Get Theme Builder', 'elementor' ); ?></h2> <p><?php echo __( 'Theme Builder is the industry leading all-in-one solution that lets you customize every part of your WordPress theme visually: Header, Footer, Single, Archive & WooCommerce.', 'elementor' ); ?></p> <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/theme-builder/?utm_source=theme-templates&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a> </div> </div><!-- /.wrap --> <?php } /** * On admin init. * * Preform actions on WordPress admin initialization. * * Fired by `admin_init` action. * * @since 2.0.0 * @access public */ public function on_admin_init() { $this->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( ' <a href="%1$s" target="_blank">%2$s</a>', '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' => '<div class="elementor-css-print-method-description" data-value="external" style="display: none">' . __( 'Use external CSS files for all generated stylesheets. Choose this setting for better performance (recommended).', 'elementor' ) . '</div><div class="elementor-css-print-method-description" data-value="internal" style="display: none">' . __( 'Use internal CSS that is embedded in the head of the page. For troubleshooting server configuration conflicts and managing development environments.', 'elementor' ) . '</div>', ], ], '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' ) . '<br>' . __( 'Elementor will try to sanitize the SVG files, removing potential malicious code and scripts.', 'elementor' ) . '<br>' . __( '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' ] ); } } } } settings-page.php 0000666 00000021163 15214147454 0010045 0 ustar 00 <?php namespace Elementor; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor settings page. * * An abstract class that provides the needed properties and methods to handle * WordPress dashboard settings pages in inheriting classes. * * @since 1.0.0 * @abstract */ abstract class Settings_Page { /** * Settings page ID. */ const PAGE_ID = ''; /** * Tabs. * * Holds the settings page tabs, sections and fields. * * @access private * * @var array */ private $tabs; /** * Create tabs. * * Return the settings page tabs, sections and fields. * * @since 1.5.0 * @access protected * @abstract */ abstract protected function create_tabs(); /** * Get settings page title. * * Retrieve the title for the settings page. * * @since 1.5.0 * @access protected * @abstract */ abstract protected function get_page_title(); /** * Get settings page URL. * * Retrieve the URL of the settings page. * * @since 1.5.0 * @access public * @static * * @return string Settings page URL. */ final public static function get_url() { return admin_url( 'admin.php?page=' . static::PAGE_ID ); } /** * Settings page constructor. * * Initializing Elementor settings page. * * @since 1.5.0 * @access public */ public function __construct() { if ( ! empty( $_POST['option_page'] ) && static::PAGE_ID === $_POST['option_page'] ) { add_action( 'admin_init', [ $this, 'register_settings_fields' ] ); } } /** * Get tabs. * * Retrieve the settings page tabs, sections and fields. * * @since 1.5.0 * @access public * * @return array Settings page tabs, sections and fields. */ final public function get_tabs() { $this->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(); ?> <div class="wrap"> <h1><?php echo $this->get_page_title(); ?></h1> <div id="elementor-settings-tabs-wrapper" class="nav-tab-wrapper"> <?php foreach ( $tabs as $tab_id => $tab ) { if ( empty( $tab['sections'] ) ) { continue; } $active_class = ''; if ( 'general' === $tab_id ) { $active_class = ' nav-tab-active'; } echo "<a id='elementor-settings-tab-{$tab_id}' class='nav-tab{$active_class}' href='#tab-{$tab_id}'>{$tab['label']}</a>"; } ?> </div> <form id="elementor-settings-form" method="post" action="options.php"> <?php settings_fields( static::PAGE_ID ); foreach ( $tabs as $tab_id => $tab ) { if ( empty( $tab['sections'] ) ) { continue; } $active_class = ''; if ( 'general' === $tab_id ) { $active_class = ' elementor-active'; } echo "<div id='tab-{$tab_id}' class='elementor-settings-form-page{$active_class}'>"; foreach ( $tab['sections'] as $section_id => $section ) { $full_section_id = 'elementor_' . $section_id . '_section'; if ( ! empty( $section['label'] ) ) { echo "<h2>{$section['label']}</h2>"; } if ( ! empty( $section['callback'] ) ) { $section['callback'](); } echo '<table class="form-table">'; do_settings_fields( static::PAGE_ID, $full_section_id ); echo '</table>'; } echo '</div>'; } submit_button(); ?> </form> </div><!-- /.wrap --> <?php } /** * Ensure tabs. * * Make sure the settings page has tabs before inserting any new sections or * fields. * * @since 1.5.0 * @access private */ private function ensure_tabs() { if ( null === $this->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 ); } } } tools.php 0000666 00000024355 15214147454 0006441 0 ustar 00 <?php namespace Elementor; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Elementor "Tools" page in WordPress Dashboard. * * Elementor settings page handler class responsible for creating and displaying * Elementor "Tools" page in WordPress dashboard. * * @since 1.0.0 */ class Tools extends Settings_Page { /** * Settings page ID for Elementor tools. */ const PAGE_ID = 'elementor-tools'; /** * Register admin menu. * * Add new Elementor Tools admin menu. * * Fired by `admin_menu` action. * * @since 1.0.0 * @access public */ public function register_admin_menu() { add_submenu_page( Settings::PAGE_ID, __( 'Tools', 'elementor' ), __( 'Tools', 'elementor' ), 'manage_options', self::PAGE_ID, [ $this, 'display_settings_page' ] ); } /** * Clear cache. * * Delete post meta containing the post CSS file data. And delete the actual * CSS files from the upload directory. * * Fired by `wp_ajax_elementor_clear_cache` action. * * @since 1.0.0 * @access public */ public function ajax_elementor_clear_cache() { check_ajax_referer( 'elementor_clear_cache', '_nonce' ); Plugin::$instance->files_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 = '<select class="elementor-rollback-select">'; foreach ( $this->get_rollback_versions() as $version ) { $rollback_html .= "<option value='{$version}'>$version</option>"; } $rollback_html .= '</select>'; return [ 'general' => [ 'label' => __( 'General', 'elementor' ), 'sections' => [ 'tools' => [ 'fields' => [ 'clear_cache' => [ 'label' => __( 'Regenerate CSS', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', 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( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', 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 */ __( '<strong>Important:</strong> It is strongly recommended that you <a target="_blank" href="%s">backup your database</a> before using Replace URL.', 'elementor' ), 'https://codex.wordpress.org/WordPress_Backups' ); $intro_text = '<div>' . $intro_text . '</div>'; echo '<h2>' . esc_html__( 'Replace URL', 'elementor' ) . '</h2>'; echo $intro_text; }, 'fields' => [ 'replace_url' => [ 'label' => __( 'Update Site Address (URL)', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( '<input type="text" name="from" placeholder="http://old-url.com" class="medium-text"><input type="text" name="to" placeholder="http://new-url.com" class="medium-text"><button data-nonce="%s" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', 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 = '<p>' . $intro_text . '</p>'; echo $intro_text; }, 'fields' => [ 'rollback' => [ 'label' => __( 'Rollback Version', 'elementor' ), 'field_args' => [ 'type' => 'raw_html', 'html' => sprintf( $rollback_html . '<a data-placeholder-text="' . __( 'Reinstall', 'elementor' ) . ' v{VERSION}" href="#" data-placeholder-url="%s" class="button elementor-button-spinner elementor-rollback-button">%s</a>', wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ), __( 'Reinstall', 'elementor' ) ), 'desc' => '<span style="color: red;">' . __( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>', ], ], ], ], '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 = '<p>' . $intro_text . '</p>'; $newsletter_opt_in_text = sprintf( __( '<a id="beta-tester-first-to-know" href="%s">Click here</a> 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' => '<span style="color: red;">' . __( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>', ], ], ], ], ], ], ]; } /** * 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' ); } } class-ld-settings-pages.php 0000666 00000041130 15214240575 0011722 0 ustar 00 <?php /** * LearnDash Settings Page Abstract Class. * * @package LearnDash * @subpackage Settings */ if ( ! class_exists( 'LearnDash_Settings_Page' ) ) { /** * Absract for LearnDash Settings Pages. */ abstract class LearnDash_Settings_Page { /** * Variable to hold all settings page instances. * * @var array $_instances */ protected static $_instances = array(); /** * Match the parent menu below LearnDash main menu. This will be the URL as in * edit.php?post_type=sfwd-courses, admin.php?page=learndash-lms-reports, admin.php?page=learndash_lms_settings * * @var string $parent_menu_page_url string. */ protected $parent_menu_page_url = ''; /** * Match the user capability to view this page * * @var string $menu_page_capability */ protected $menu_page_capability = LEARNDASH_ADMIN_CAPABILITY_CHECK; /** * Match the WP Screen ID. DO NOT SET. This is set when from add_submenu_page(). * The value set via WP will be somethiing like 'sfwd-courses_page_courses-options' * for the URL admin.php?page=courses-options because it will reside within the * sfwd-courses submenu. * * @var string $settings_screen_id */ protected $settings_screen_id = ''; /** * Match the URL 'page=' parameter value. For example admin.php?page=learndash-lms-reports * value will be 'learndash-lms-reports' * * @var string $settings_page_id */ protected $settings_page_id = ''; /** * Title for page <h1></h1> 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 <form></form>. * * @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() { ?> <script type="text/javascript"> //<![CDATA[ jQuery(document).ready( function($) { // toggle $('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles( '<?php echo esc_attr( $this->settings_screen_id ); ?>' ); // display spinner $('#fx-smb-form').submit( function() { $('#publishing-action .spinner').css('display','inline'); }); // confirm before reset $('.learndash-settings-page-wrap .submitdelete').on('click', function() { var confirm_message = $(this).data('confirm'); if (typeof confirm_message !== 'undefined') { return confirm( confirm_message ); } }); if ( jQuery( '#side-sortables').length ) { if ( jQuery( '#side-sortables div.postbox').length ) { jQuery( '#side-sortables').removeClass('empty-container'); } } }); //]]> </script> <?php do_action( 'learndash_settings_page_footer_scripts', $this->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 ) ) { ?> <div class="wrap learndash-settings-page-wrap"> <?php settings_errors(); ?> <?php do_action( 'learndash_settings_page_before_title', $this->settings_screen_id, $this->settings_page_id ); ?> <?php echo $this->get_admin_page_title(); ?> <?php do_action( 'learndash_settings_page_after_title', $this->settings_screen_id, $this->settings_page_id ); ?> <?php do_action( 'learndash_settings_page_before_form', $this->settings_screen_id, $this->settings_page_id ); ?> <?php echo $this->get_admin_page_form( true ); ?> <?php do_action( 'learndash_settings_page_inside_form_top', $this->settings_screen_id, $this->settings_page_id ); ?> <?php settings_fields( $this->settings_page_id ); ?> <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> <div id="postbox-container-1" class="postbox-container"> <?php do_meta_boxes( $this->settings_screen_id, 'side', null ); ?> </div> <div id="postbox-container-2" class="postbox-container"> <?php do_action( 'learndash_settings_page_before_metaboxes', $this->settings_screen_id, $this->settings_page_id ); ?> <?php do_meta_boxes( $this->settings_screen_id, 'normal', null ); ?> <?php do_meta_boxes( $this->settings_screen_id, 'advanced', null ); ?> <?php do_action( 'learndash_settings_page_after_metaboxes', $this->settings_screen_id, $this->settings_page_id ); ?> </div> </div> <br class="clear"> </div> <?php do_action( 'learndash_settings_page_inside_form_bottom', $this->settings_screen_id, $this->settings_page_id ); ?> <?php echo $this->get_admin_page_form( false ); ?> <?php do_action( 'learndash_settings_page_after_form', $this->settings_screen_id, $this->settings_page_id ); ?> </div> <?php } else { ?> <div class="wrap learndash-settings-page-wrap"> <?php settings_errors(); ?> <?php echo $this->get_admin_page_title(); ?> <?php echo $this->get_admin_page_form( true ); ?> <?php // This prints out all hidden setting fields. settings_fields( $this->settings_page_id ); do_settings_sections( $this->settings_page_id ); ?> <?php submit_button( esc_html__( 'Save Changes', 'learndash' ) ); ?> <?php echo $this->get_admin_page_form( false ); ?> </div> <?php } } /** * Class utility function to return the settings page title. * * @return string page title. */ public function get_admin_page_title() { /** * Control if page title should be displayed. * * @param array $flag Defines if page title should be displayed. */ if ( true === apply_filters( 'learndash_admin_page_title_should_display', false ) ) { return apply_filters( 'learndash_admin_page_title', '<h1>' . esc_html( get_admin_page_title() ) . '</h1>' ); } else { return '<h1 class="learndash-empty-page-title"></h1>'; } } /** * Class utility function to return the form wrapper. Supports * the beginning <form> an ending </form>. * * @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', '<form id="learndash-settings-page-form" method="post" action="options.php">', $start ); } else { return apply_filters( 'learndash_admin_page_form', '</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'] = '<div id="learndash-settings-fields-notice-errors" class="learndash-settings-fields-notice-errors notice notice-error"><p class="errors-header">' . esc_html__( 'You have errors on the following settings', 'learndash' ) . '</p><ul class="errors-list"></ul></div>'; } $script_data = array( 'json' => json_encode( $script_data ) ); wp_localize_script( 'learndash-admin-settings-page', 'learndash_admin_settings_data', $script_data ); } } class-ld-shortcodes-sections.php 0000666 00000013466 15214240575 0013002 0 ustar 00 <?php /** * LearnDash Admin Shortcods Section Class. * * @package LearnDash * @subpackage Admin */ if ( ! class_exists( 'LearnDash_Shortcodes_Section' ) ) { /** * Class for LearnDash Admin Course Edit. */ class LearnDash_Shortcodes_Section { /** * Shortcodes Section Key. * * @var string $shortcodes_section_key */ protected $shortcodes_section_key = ''; /** * Shortcodes Section Title. * * @var string $shortcodes_section_title */ protected $shortcodes_section_title = ''; /** * Shortcodes Section Type. * * @var integer $shortcodes_section_type */ protected $shortcodes_section_type = 1; /** * Shortcodes Section Description. * * @var string $shortcodes_section_description */ protected $shortcodes_section_description = ''; /** * Shortcodes Section Fields. * * @var array $shortcodes_option_fields */ protected $shortcodes_option_fields = array(); /** * Shortcodes Section Values. * * @var array $shortcodes_option_values */ protected $shortcodes_option_values = array(); /** * This is derived from the $shortcodes_option_fields within the function init_shortcodes_section_fields(); * * @var array $shortcodes_settings_fields */ protected $shortcodes_settings_fields = array(); /** * This is the HTML form field prefix used. * * @var array $shortcodes_option_fields */ protected $setting_field_prefix = ''; /** * Fields Args. * * @var array $fields_args */ protected $fields_args = array(); /** * Public constructor for class. */ public function __construct() { $this->init_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() { ?><form id="learndash_shortcodes_form_<?php echo $this->shortcodes_section_key; ?>" class="learndash_shortcodes_form" shortcode_slug="<?php echo $this->shortcodes_section_key; ?>" shortcode_type="<?php echo $this->shortcodes_section_type; ?>"> <?php $this->show_shortcodes_section_title(); ?> <?php $this->show_shortcodes_section_description(); ?> <div class="sfwd sfwd_options learndash_shortcodes_section" style="clear:left"> <?php } /** * Show Section Footer. */ public function show_shortcodes_section_footer() { ?> </div> <?php $this->show_shortcodes_section_footer_extra(); ?> <p style="clear:left"><input type="submit" class="button-primary" value="<?php esc_html_e( 'Insert Shortcode', 'learndash' ); ?>"></p> </form> <?php } /** * Show Section Footer Extra. */ public function show_shortcodes_section_footer_extra() { // This is a hook called after the section closing </div> 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 ) ) { ?> <h2><?php echo $this->shortcodes_section_title; ?> [<?php echo $this->shortcodes_section_key; ?>]</h2> <?php } } /** * Get Section Description. */ public function get_shortcodes_section_description() { return $this->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 ]; } } } } settings-pages/class-ld-settings-page-data-upgrades.php 0000666 00000003756 15214240575 0017227 0 ustar 00 <?php /** * LearnDash Settings Page Data Upgrades]. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Data_Upgrades' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Data_Upgrades extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-quizzes-options.php 0000666 00000003272 15214240575 0017702 0 ustar 00 <?php /** * LearnDash Settings Page Quizzes Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Quizzes_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Quizzes_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-quizzes-builder-single.php 0000666 00000017174 15214240575 0021122 0 ustar 00 <?php /** * LearnDash Settings Page Quiz Builder Single. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Quiz_Builder_Single' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Quiz_Builder_Single extends LearnDash_Settings_Page { /** * Private variable to contain the update status. * * @var boolean $update_success */ private $update_success = false; /** * Priority for tab * * @var integer $settings_tab_priority */ protected $settings_tab_priority = 8; /** * Public constructor for class */ public function __construct() { $this->parent_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 ) ) { ?> <div id="course-builder-title-box"> <h2 class="course-title"><?php echo $quiz_post->post_title; ?></h2> <p class="course-links"> <strong><?php esc_html_e( 'Permalink:', 'learndash' ); ?></strong> <a href="<?php echo get_permalink( $quiz_id ); ?>"><?php echo get_permalink( $quiz_id ); ?></a><br /> <strong><?php esc_html_e( 'Edit:', 'learndash' ); ?></strong> <a href="<?php echo get_edit_post_link( $quiz_id ); ?>"><?php echo get_edit_post_link( $quiz_id ); ?></a> </p> </div> <?php } } } } /** * 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', '<form id="learndash-settings-page-form" method="post">', $start ); } else { return apply_filters( 'learndash_admin_page_form', '</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 ) { ?> <div class="notice notice-success is-dismissible"> <p><strong><?php esc_html_e( 'Settings saved.', 'learndash' ); ?></strong></p> <button type="button" class="notice-dismiss"> <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'learndash' ); ?></span> </button> </div> <?php } } /** * Add Quiz Builder link to Quizzes row action array. * * @since 2.5.0 * * @param array $row_actions Existing Row actions for quiz. * @param WP_Post $quiz_post Quiz Post object for current row. * * @return array $row_actions */ public function learndash_quiz_row_actions( $row_actions = array(), $quiz_post = null ) { global $typenow, $pagenow; if ( ( 'edit.php' === $pagenow ) && ( learndash_get_post_type_slug( 'quiz' ) === $typenow ) && ( is_a( $quiz_post, 'WP_Post' ) ) ) { if ( ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Quizzes_Builder', 'enabled' ) ) && ( ! isset( $row_actions['ld-quiz-builder'] ) ) ) { if ( apply_filters( 'learndash_show_quiz_builder_row_actions', true, $quiz_post ) === true ) { $quiz_label = sprintf( // translators: placeholder: Quiz. esc_html_x( 'Use %s Builder', 'placeholder: Quiz', 'learndash' ), LearnDash_Custom_Label::get_label( 'quiz' ) ); $row_actions['ld-quiz-builder'] = sprintf( '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 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(); } ); settings-pages/class-ld-settings-page-custom-labels.php 0000666 00000002013 15214240575 0017241 0 ustar 00 <?php /** * LearnDash Settings Page Custom Labels. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Custom_Labels' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Custom_Labels extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-addons.php 0000666 00000046074 15214240575 0015756 0 ustar 00 <?php /** * LearnDash Settings Page Add-ons. * * @since 2.5.4 * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Addons' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Addons extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->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', '<h1>' . $this->settings_page_title . '</h1>' ); } /** * 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 ) { ?> <style> h1.nav-tab-wrapper { display: none; }</style> <?php } } return $tab_set; } /** * Custom display function for page content. * * @since 2.5.5 */ public function show_settings_page() { ?> <div class="wrap learndash-settings-page-wrap"> <?php settings_errors(); ?> <?php do_action( 'learndash_settings_page_before_title', $this->settings_screen_id ); ?> <?php echo $this->get_admin_page_title(); ?> <?php do_action( 'learndash_settings_page_after_title', $this->settings_screen_id ); ?> <?php do_action( 'learndash_settings_page_before_form', $this->settings_screen_id ); ?> <div id="plugin-filter-xxx"> <?php echo $this->get_admin_page_form( true ); ?> <?php do_action( 'learndash_settings_page_inside_form_top', $this->settings_screen_id ); ?> <?php $wp_list_table = new Learndash_Admin_Addons_List_Table(); $wp_list_table->prepare_items(); $wp_list_table->views(); $wp_list_table->display(); ?> <?php do_action( 'learndash_settings_page_inside_form_bottom', $this->settings_screen_id ); ?> <?php echo $this->get_admin_page_form( false ); ?> </div> <?php do_action( 'learndash_settings_page_after_form', $this->settings_screen_id ); ?> </div> <?php /** * The following is needed to trigger the wp-admin/js/updates.js logic in * wp.updates.updatePlugin() where is checks for specific pagenow values * but doesn't leave any option for externals. */ ?> <script type="text/javascript"> //pagenow = 'plugin-install'; </script> <?php } /** * Display plugin information in dialog box form. * * @since 2.5.5 * * @global string $tab */ public function shows_addon_plugin_information() { if ( empty( $_REQUEST['plugin'] ) ) { return; } $addon_updater = new LearnDash_Addon_Updater(); $plugin_readme_information = $addon_updater->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']; ?> <style type="text/css"> #plugin-information-title.with-banner { background-image: url( <?php echo esc_url( $low ); ?> ); } @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { #plugin-information-title.with-banner { background-image: url( <?php echo esc_url( $high ); ?> ); } } </style> <?php } echo '<div id="plugin-information-scrollable">'; echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\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<a name='$san_section' href='$href' $class>$title</a>\n"; } echo "</div>\n"; ?> <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> <div class="fyi"> <ul> <?php if ( ! empty( $api->version ) ) { ?> <li><strong><?php _e( 'Version:', 'learndash' ); ?></strong> <?php echo $api->version; ?></li> <?php } if ( ! empty( $api->author ) ) { ?> <li><strong><?php _e( 'Author:', 'learndash' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> <?php } if ( ! empty( $api->last_updated ) ) { ?> <li><strong><?php _e( 'Last Updated:', 'learndash' ); ?></strong> <?php /* translators: %s: Time since the last update */ printf( __( '%s ago', 'default' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?> </li> <?php } if ( ! empty( $api->requires ) ) { ?> <li> <strong><?php _e( 'Requires WordPress Version:', 'default' ); ?></strong> <?php /* translators: %s: WordPress version */ printf( __( '%s or higher', 'default' ), $api->requires ); ?> </li> <?php } if ( ! empty( $api->tested ) ) { ?> <li><strong><?php _e( 'Compatible up to:', 'default' ); ?></strong> <?php echo $api->tested; ?></li> <?php } if ( isset( $api->active_installs ) ) { ?> <li><strong><?php _e( 'Active Installations:', 'default' ); ?></strong> <?php if ( $api->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 ) . '+'; } ?> </li> <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> <li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/', 'default' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »', 'default' ); ?></a></li> <?php } if ( ! empty( $api->homepage ) ) { ?> <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage »', 'default' ); ?></a></li> <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> <li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »', 'default' ); ?></a></li> <?php } ?> </ul> <?php if ( ! empty( $api->rating ) ) { ?> <h3><?php _e( 'Average Rating', 'default' ); ?></h3> <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings, ) ); ?> <p aria-hidden="true" class="fyi-description"><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings, 'default' ), number_format_i18n( $api->num_ratings ) ); ?></p> <?php } if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { ?> <h3><?php _e( 'Reviews', 'default' ); ?></h3> <p class="fyi-description"><?php _e( 'Read all reviews on WordPress.org or write your own!', 'default' ); ?></p> <?php foreach ( $api->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' ) ); ?> <div class="counter-container"> <span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>" target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf( _n( '%d star', '%d stars', $key, 'default' ), $key ); ?></a></span> <span class="counter-back"> <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span> </span> <span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span> </div> <?php } } if ( ! empty( $api->contributors ) ) { ?> <h3><?php _e( 'Contributors', 'default' ); ?></h3> <ul class="contributors"> <?php foreach ( (array) $api->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 "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' alt='' />{$contrib_username}</li>"; } else { echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' alt='' />{$contrib_username}</a></li>"; } } ?> </ul> <?php if ( ! empty( $api->donate_link ) ) { ?> <a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »', 'default' ); ?></a> <?php } ?> <?php } ?> </div> <div id="section-holder"> <?php $wp_version = get_bloginfo( 'version' ); if ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'default' ) . '</p></div>'; } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'default' ) . '</p></div>'; } 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<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; echo $content; echo "\t</div>\n"; } echo "</div>\n"; echo "</div>\n"; echo "</div>\n"; // #plugin-information-scrollable echo "<div id='$tab-footer'>\n"; if ( empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { if ( isset( $api->plugin_status ) ) { $status = $api->plugin_status; switch ( $status['status'] ) { case 'install': if ( $status['url'] ) { echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now', 'default' ) . '</a>'; } break; case 'update_available': if ( $status['url'] ) { echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now', 'default' ) . '</a>'; } break; case 'newer_installed': /* translators: %s: Plugin version */ echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed', 'default' ), $status['version'] ) . '</a>'; break; case 'latest_installed': echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed', 'default' ) . '</a>'; break; } } } echo "</div>\n"; iframe_footer(); exit; } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Addons::add_page_instance(); } ); settings-pages/class-ld-settings-page-courses-shortcodes.php 0000666 00000057412 15214240575 0020342 0 ustar 00 <?php /** * LearnDash Settings Page Courses Shortcodes. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Courses_Shortcodes' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Courses_Shortcodes extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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() { ?> <div id='course-shortcodes' class='wrap'> <h1> <?php printf( // translators: placeholder: Course Label. esc_html_x( '%s Shortcodes', 'placeholder: Course Label', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> </h1> <div class='sfwd_options_wrapper sfwd_settings_left'> <div class='postbox ' id='sfwd-course_metabox'> <div class='inside' style='margin: 11px 0; padding: 0 12px 12px;'> <?php echo '<b>' . esc_html__( 'Shortcode Options', 'learndash' ) . '</b> <p>' . 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' ) ) . '</p> <p class="ld-shortcode-header">[ld_profile]</p> <p>' . 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' ) ) . '</p> <ul> <li><b>order</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'sets order of %1$s. Default value DESC. Possible values: <b>DESC</b>, <b>ASC</b>. Example: <b>[ld_profile order="ASC"]</b> shows %2$s in ascending order.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>orderby</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'sets what the list of ordered by. Default value ID. Possible values: <b>ID</b>, <b>title</b>. Example: <b>[ld_profile orderby="title" order="ASC"]</b> shows %s in ascending order by title.', 'placeholders: courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> </ul> <p>' . wp_kses_post( __( 'See <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', 'learndash' ) ) . '</p><br/> <p class="ld-shortcode-header">[ld_course_list]</p> <p>' . 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 <code>/%2$s</code> 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' ) ) . '</p> <ul> <li><b>num</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'limits the number of %1$s displayed. Example: <b>[ld_course_list num="10"]</b> shows 10 %2$s.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>order</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'sets order of %1$s. Possible values: <b>DESC</b>, <b>ASC</b>. Example: <b>[ld_course_list order="ASC"]</b> shows %2$s in ascending order.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>orderby</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'sets what the list of ordered by. Example: <b>[ld_course_list order="ASC" orderby="title"]</b> shows %s in ascending order by title.', 'placeholders: courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>mycourses</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'show current user\'s %1$s. Example: <b>[ld_course_list mycourses="true"]</b> 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' ) ) . '</li> <li><b>col</b>: ' . wp_kses_post( __( 'number of columns to show when using course grid addon. Example: <b>[ld_course_list col="2"]</b> shows 2 columns.', 'learndash' ) ) . '</li>'; if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'wp_post_category' ) == 'yes' ) { echo '<li><b>cat</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned category id. Example: <b>[ld_course_list cat="10"]</b> 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' ) ) . '</li> <li><b>category_name</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned category slug. Example: <b>[ld_course_list category_name="math"]</b> shows %2$s having category slug math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li>'; echo '<li><b>categoryselector</b>: ' . wp_kses_post( __( 'shows a course category dropdown. Example: <b>[ld_course_list categoryselector="true"]</b>.', 'learndash' ) ) . '</li>'; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'wp_post_tag' ) == 'yes' ) { echo '<li><b>tag</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses. _x( 'shows %1$s with mentioned tag. Example: <b>[ld_course_list tag="math"]</b> shows %2$s having tag math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>tag_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned tag_id. Example: <b>[ld_course_list tag_id="30"]</b> 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' ) ) . '</li>'; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'ld_course_category' ) == 'yes' ) { echo '<li><b>course_cat</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course category id. Example: <b>[ld_course_list course_cat="10"]</b> 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' ) ) . '</li> <li><b>course_category_name</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course category slug. Example: <b>[ld_course_list course_category_name="math"]</b> shows %2$s having course category slug math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li>'; echo '<li><b>course_categoryselector</b>: ' . wp_kses_post( __( 'shows a category dropdown. Example: <b>[ld_course_list course_categoryselector="true"]</b>.', 'learndash' ) ) . '</li>'; } if ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Taxonomies', 'ld_course_tag' ) == 'yes' ) { echo '<li><b>course_tag</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses _x( 'shows %1$s with mentioned course tag. Example: <b>[ld_course_list course_tag="math"]</b> shows %2$s having course tag math.', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ) . '</li> <li><b>course_tag_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'shows %1$s with mentioned course_tag_id. Example: <b>[ld_course_list course_tag_id="30"]</b> 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' ) ) . '</li>'; } echo '</ul></p> <p>' . wp_kses_post( __( 'See the full list of <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters">Category</a> and <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters">Tag</a> filtering options.', 'learndash' ) ) . '</p><br /> <p class="ld-shortcode-header">[ld_lesson_list]</p> <p>' . 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' ) ) . '</p><br> <p class="ld-shortcode-header">[ld_topic_list]</p> <p>' . 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' ) ) . '</p><br> <p class="ld-shortcode-header">[ld_quiz_list]</p> <p>' . 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' ) ) . '</p><br> <p class="ld-shortcode-header">[learndash_course_progress]</p><p>' . 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' ) ) . '</p><br> <p class="ld-shortcode-header">[visitor]</p> <p>' . 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 <strong>any</strong> page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student does not have access to a specific %s. Example: <b>[visitor course_id="10"]insert any content[/visitor]</b>', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</li> </ul><br> <p class="ld-shortcode-header">[student]</p> <p>' . 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 <strong>any</strong> page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: <b>[student course_id="10"]insert any content[/student]</b>', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</li> </ul><br> <p class="ld-shortcode-header">[course_complete]</p><p>' . 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 <strong>any</strong> page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: <b>[course_complete course_id="10"]insert any content[/course_complete]</b>', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</li> <li><b>user_id</b>: ' . wp_kses_post( __( 'Optional. If not provided will use current logged in user. Example: <b>[course_complete course_id="10" user_id="456"]insert any content[/course_complete]</b>', 'learndash' ) ) . '</li> </ul><br /> <p class="ld-shortcode-header">[course_inprogress]</p> <p>' . 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 <strong>any</strong> page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: <b>[course_inprogress course_id="10"]insert any content[/course_inprogress]</b>', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</li> <li><b>user_id</b>: ' . __( 'Optional. If not provided will use current logged in user. Example: <b>[course_inprogress course_id="10" user_id="456"]insert any content[/course_inprogress]</b>', 'learndash' ) . '</li> </ul><br /> <p class="ld-shortcode-header">[course_notstarted]</p> <p>' . 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 <strong>any</strong> page or widget area. This shortcode can take following parameters:', 'placeholders: course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . sprintf( wp_kses_post( // translators: placeholders: courses, courses. _x( 'Optional. Show content if the student has access to a specific %s. Example: <b>[course_notstarted course_id="10"]insert any content[/course_notstarted]</b>', 'placeholders: courses, courses', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</li> <li><b>user_id</b>: ' . wp_kses_post( __( 'Optional. If not provided will use current logged in user. Example: <b>[course_notstarted course_id="10" user_id="456"]insert any content[/course_notstarted]</b>', 'learndash' ) ) . '</li> </ul><br /> <p class="ld-shortcode-header">[ld_course_info]</p> <p>' . 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: <strong>[ld_course_info user_id="123"]</strong> 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' ) ) . '</p><br /> <p class="ld-shortcode-header">[ld_user_course_points]</p> <p>' . 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: <strong>[ld_user_course_points]</strong></strong>', 'placeholders: course, course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ) ) . '</p><br /> <p class="ld-shortcode-header">[user_groups]</p> <p>' . esc_html__( 'This shortcode displays the list of groups users are assigned to as users or leaders.', 'learndash' ) . '</p><br/ > <p class="ld-shortcode-header">[ld_group]</p><p>' . __( 'This shortcode shows the content if the user is enrolled in a specific group. Example usage: <strong>[ld_group]</strong>Welcome to the Group!<strong>[/ld_group]</strong> This shortcode takes the following parameters:', 'learndash' ) . '</p> <ul> <li><b>group_id</b>: ' . wp_kses_post( __( 'Required. Show content if the student has access to a specific group. Example: <b>[ld_group group_id="16"]insert any content[/ld_group]</b>', 'learndash' ) ) . '</li> </ul><br /> <p id="shortcode_ld_video" class="ld-shortcode-header">[ld_video]</p><p>' . 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' ) ) . '</p><br /> <p class="ld-shortcode-header">[learndash_payment_buttons]</p> <p>' . sprintf( wp_kses_post( // translators: placeholders: course, Courses. _x( 'This shortcode can show the payment buttons on any page. Example: <strong>[learndash_payment_buttons course_id="123"]</strong> 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' ) ) . '</p><br> <p class="ld-shortcode-header">[course_content]</p> <p>' . 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: <strong>[course_content course_id="123"]</strong> 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' ) ) . '</p><br> <p class="ld-shortcode-header">[ld_course_expire_status]</p> <p>' . sprintf( wp_kses_post( // translators: placeholders: course, Course, Course. _x( 'This shortcode displays the user %1$s access expire date. Example: <strong>[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"]</strong>.', 'placeholders: course, Course, Course', 'learndash' ) ), learndash_get_custom_label_lower( 'course' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'course' ) ) . '</p> <ul> <li><b>course_id</b>: ' . 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: <b>[ld_course_expire_status course_id="111"]</b> ', 'plaeholders: course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ) ) . '</li> <li><b>user_id</b>: ' . wp_kses_post( __( 'The ID of the user to check. If not provided the current logged in user ID will be used. Example: <b>[ld_course_expire_status user_id="222"]</b>', 'learndash' ) ) . '</li> <li><b>label_before</b>: ' . 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: <b>[ld_course_expire_status label_before="Your access to this %2$s will expire on:"]</b>', 'placeholders: Course, course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'course' ) ) . '</li> <li><b>label_after</b>: ' . 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: <b>[ld_course_expire_status label_after="Your access to this %2$s expired on:"]</b>', 'placeholders: Course, course', 'learndash' ) ), LearnDash_Custom_Label::get_label( 'course' ), learndash_get_custom_label_lower( 'course' ) ) . '</li> <li><b>format</b>: ' . 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: <b>[ld_course_expire_status format="F j, Y g:i a"]</b>', 'learndash' ) ) . '</li> </ul> '; ?> </div> </div> </div> </div> <?php } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Courses_Shortcodes::add_page_instance(); } ); settings-pages/class-ld-settings-page-topics-options.php 0000666 00000001555 15214240575 0017473 0 ustar 00 <?php /** * LearnDash Settings Page Topics Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Topics_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Topics_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-paypal.php 0000666 00000001751 15214240575 0015765 0 ustar 00 <?php /** * LearnDash Settings Page PayPal. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_PayPal' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_PayPal extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-courses-builder-single.php 0000666 00000015004 15214240575 0021061 0 ustar 00 <?php /** * LearnDash Settings Page Course Builder Single. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Course_Builder_Single' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Course_Builder_Single extends LearnDash_Settings_Page { /** * Private variable to contain the update status. * * @var boolean $update_success */ private $update_success = false; /** * Public constructor for class */ public function __construct() { $this->parent_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', '<form id="learndash-settings-page-form" method="post">', $start ); } else { return apply_filters( 'learndash_admin_page_form', '</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 ) { ?> <div class="notice notice-success is-dismissible"> <p><strong><?php esc_html_e( 'Settings saved.', 'learndash' ); ?></strong></p> <button type="button" class="notice-dismiss"> <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'learndash' ); ?></span> </button> </div> <?php } } /** * Add Course Builder link to Courses row action array. * * @since 2.5.0 * * @param array $row_actions Existing Row actions for course. * @param WP_Post $course_post Course Post object for current row. * * @return array $row_actions */ public function learndash_course_row_actions( $row_actions = array(), $course_post = null ) { global $typenow, $pagenow; if ( ( 'edit.php' === $pagenow ) && ( 'sfwd-courses' === $typenow ) && ( is_a( $course_post, 'WP_Post' ) ) ) { if ( ( LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'enabled' ) == 'yes' ) && ( ! isset( $row_actions['ld-course-builder'] ) ) ) { if ( apply_filters( 'learndash_show_course_builder_row_actions', true, $course_post ) === true ) { $course_label = sprintf( // translators: placeholder: Course. esc_html_x( 'Use %s Builder', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); $row_actions['ld-course-builder'] = sprintf( '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 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(); } ); settings-pages/class-ld-settings-page-general.php 0000666 00000001667 15214240575 0016122 0 ustar 00 <?php /** * LearnDash Settings Page General. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_General' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_General extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-translations.php 0000666 00000014065 15214240575 0017222 0 ustar 00 <?php /** * LearnDash Settings Page Translations. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Translations' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Translations extends LearnDash_Settings_Page { private $ld_options_key = 'ld-translatation-message'; /** * Public constructor for class */ public function __construct() { $this->parent_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'] ) { ?> <div class="notice notice-success is-dismissible"> <?php echo $reply['message']; ?> <button type="button" class="notice-dismiss"> <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'learndash' ); ?></span> </button> </div> <?php } else { ?> <div class="notice notice-error is-dismissible"> <?php echo $reply['message']; ?> <button type="button" class="notice-dismiss"> <span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'learndash' ); ?></span> </button> </div> <?php } } } } public function handle_translation_actions() { if ( isset( $_GET['action'] ) ) { $action = esc_attr( $_GET['action'] ); } if ( isset( $_GET['project'] ) ) { $project = esc_attr( $_GET['project'] ); } else { $project = ''; } if ( isset( $_GET['locale'] ) ) { $locale = esc_attr( $_GET['locale'] ); } else { $locale = ''; } if ( isset( $_GET['ld-translation-nonce'] ) ) { $nonce = esc_attr( $_GET['ld-translation-nonce'] ); } else { $nonce = ''; } if ( ! empty( $action ) ) { switch ( $action ) { case 'pot_download': if ( ( ! empty( $project ) ) && ( ! empty( $nonce ) ) ) { if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action . '-' . $project ) ) { $reply = LearnDash_Translations::download_pot_file( $project ); } } break; case 'po_download': if ( ( ! empty( $project ) ) && ( ! empty( $locale ) ) && ( ! empty( $nonce ) ) ) { if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action . '-' . $project . '-' . $locale ) ) { $reply = LearnDash_Translations::download_po_file( $project, $locale ); } } break; case 'install': if ( ( ! empty( $project ) ) && ( ! empty( $locale ) ) && ( ! empty( $nonce ) ) ) { if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action . '-' . $project . '-' . $locale ) ) { $reply = LearnDash_Translations::install_translation( $project, $locale ); } } break; case 'update': if ( ( ! empty( $project ) ) && ( ! empty( $locale ) ) && ( ! empty( $nonce ) ) ) { if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action . '-' . $project . '-' . $locale ) ) { $reply = LearnDash_Translations::update_translation( $project, $locale ); } } break; case 'remove': if ( ( ! empty( $project ) ) && ( ! empty( $locale ) ) && ( ! empty( $nonce ) ) ) { if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action . '-' . $project . '-' . $locale ) ) { $reply = LearnDash_Translations::remove_translation( $project, $locale ); } } break; case 'refresh': if ( wp_verify_nonce( $nonce, 'ld-translation-' . $action ) ) { $reply = LearnDash_Translations::refresh_translations(); } break; default: break; } if ( ( isset( $reply ) ) && ( ! empty( $reply ) ) ) { update_option( $this->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(); } ); settings-pages/class-ld-settings-page-questions-options.php 0000666 00000001777 15214240575 0020232 0 ustar 00 <?php /** * LearnDash Settings Page Questions Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Questions_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Questions_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/settings-pages-loader.php 0000666 00000002562 15214240575 0014431 0 ustar 00 <?php /** * LearnDash Settings Pages Loader. * * @package LearnDash * @subpackage Settings */ require_once __DIR__ . '/class-ld-settings-page-overview.php'; require_once __DIR__ . '/class-ld-settings-page-custom-labels.php'; require_once __DIR__ . '/class-ld-settings-page-courses-options.php'; require_once __DIR__ . '/class-ld-settings-page-courses-shortcodes.php'; require_once __DIR__ . '/class-ld-settings-page-lessons-options.php'; require_once __DIR__ . '/class-ld-settings-page-topics-options.php'; require_once __DIR__ . '/class-ld-settings-page-quizzes-options.php'; require_once __DIR__ . '/class-ld-settings-page-questions-options.php'; require_once __DIR__ . '/class-ld-settings-page-certificate-shortcodes.php'; require_once __DIR__ . '/class-ld-settings-page-assignments-options.php'; require_once __DIR__ . '/class-ld-settings-page-general.php'; require_once __DIR__ . '/class-ld-settings-page-paypal.php'; require_once __DIR__ . '/class-ld-settings-page-data-upgrades.php'; require_once __DIR__ . '/class-ld-settings-page-support.php'; // Add-ons Page. if ( ( defined( 'LEARNDASH_ADDONS_UPDATER' ) ) && ( LEARNDASH_ADDONS_UPDATER === true ) ) { require_once __DIR__ . '/class-ld-settings-page-addons.php'; } if ( ( defined( 'LEARNDASH_TRANSLATIONS' ) ) && ( LEARNDASH_TRANSLATIONS === true ) ) { require_once __DIR__ . '/class-ld-settings-page-translations.php'; } settings-pages/class-ld-settings-page-courses-options.php 0000666 00000001663 15214240575 0017655 0 ustar 00 <?php /** * LearnDash Settings Page Courses Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Courses_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Courses_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-license.php 0000666 00000001731 15214240575 0016117 0 ustar 00 <?php /** * LearnDash Settings Page License. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_License' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_License extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-assignments-options.php 0000666 00000001572 15214240575 0020524 0 ustar 00 <?php /** * LearnDash Settings Page Assignments Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Assignments_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Assignments_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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(); } ); settings-pages/class-ld-settings-page-support.php 0000666 00000014337 15214240575 0016217 0 ustar 00 <?php /** * LearnDash Settings Page Support. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Support' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Support extends LearnDash_Settings_Page { /** * Systems Info array. * * @var array $system_info Array of System Info items to check. */ private $system_info = array(); /** * Public constructor for class */ public function __construct() { $this->parent_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( '<br />', '<br>', '<br >' ), "\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'] ) ) ) { ?> <div class="learndash-support-settings-desc"><?php echo wptexturize( $_set['desc'] ); ?></div> <?php } if ( ( isset( $_set['columns'] ) ) && ( ! empty( $_set['columns'] ) ) && ( isset( $_set['settings'] ) ) && ( ! empty( $_set['settings'] ) ) ) { ?> <table cellspacing="0" class="learndash-support-settings"> <thead> <tr> <?php foreach ( $_set['columns'] as $column_key => $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 ); ?> <th scope="col" class="<?php echo $column_class; ?>"> <?php if ( isset( $column_set['html'] ) ) { echo $column_set['html']; } elseif ( isset( $column_set['text'] ) ) { echo $column_set['text']; } ?> </th> <?php } ?> </tr> </thead> <body> <?php foreach ( $_set['settings'] as $setting_key => $setting_set ) { ?> <tr> <?php foreach ( $_set['columns'] as $column_key => $column_set ) { ?> <td scope="col" class="<?php apply_filters( 'learndash_support_column_class', '', $column_key, $_key ); ?>"> <?php if ( isset( $setting_set[ $column_key . '_html' ] ) ) { echo $setting_set[ $column_key . '_html' ]; } elseif ( isset( $setting_set[ $column_key ] ) ) { echo $setting_set[ $column_key ]; } ?> </td> <?php } ?> </tr> <?php } ?> </body> </table> <?php } } } } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Support::add_page_instance(); } ); settings-pages/class-ld-settings-page-overview.php 0000666 00000163037 15214240575 0016353 0 ustar 00 <?php /** * LearnDash Settings Page Orderview. * * @since 3.0.0 * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Overview' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Overview extends LearnDash_Settings_Page { /** * License information * * @var array */ protected $license_info = []; /** * Announcement posts feed * * @var array */ protected $rss_announcements_posts = []; /** * License information * * @var array */ protected $rss_tips_posts = []; /** * License information * * @var array */ protected $rss_sell_posts = []; /** * Public constructor for class */ public function __construct() { $this->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', '<h1>' . $this->settings_page_title . '</h1>' ); } /** * 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 ) { ?> <style> h1.nav-tab-wrapper { display: none; }</style> <?php } } return $tab_set; } /** * Save toggle state of the LearnDash Bootcamp to an option. * * @since 3.0.0 */ public function save_bootcamp_toggle_state() { if ( isset( $_POST['action'], $_POST['nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'learndash-bootcamp-toggle' ) && current_user_can( 'edit_posts' ) && 'save_bootcamp_toggle_state' === $_POST['action'] ) { if ( ! empty( $_POST['state'] ) ) { update_option( 'learndash_bootcamp_toggle_state', sanitize_text_field( $_POST['state'] ) ); } } } /** * Save 'mark complete' state of LearnDash Bootcamp sections to an option. * * @since 3.0.0 */ public function save_bootcamp_mark_complete_state() { if ( isset( $_POST['action'], $_POST['nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'learndash-bootcamp-mark-complete' ) && current_user_can( 'edit_posts' ) && 'save_bootcamp_mark_complete_state' === $_POST['action'] ) { if ( ( ! empty( $_POST['state'] ) ) && ( ! empty( $_POST['id'] ) ) ) { update_option( sanitize_text_field( $_POST['id'] ), sanitize_text_field( $_POST['state'] ) ); } } } /** * Get feeds from learndash.com and the support site. * * @since 3.0.0 */ public function get_feeds() { include_once ABSPATH . WPINC . '/feed.php'; $rss_announcements = fetch_feed( 'https://www.learndash.com/category/learndash/feed' ); if ( ! is_wp_error( $rss_announcements ) ) { $this->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(); ?> <script>window.location.reload()</script> <?php } else { /** * @TODO : All this logic needs to be encapsulated within the ld-qutoupdate.php * code. We should not be exposing settings keys like 'nss_plugin_license_sfwd_lms' * and 'nss_plugin_license_email_sfwd_lms' spread all over the LD code. * There should be an interface function that simply returns the license * details and status. */ // Get values from the database. $license = get_option( 'nss_plugin_license_sfwd_lms' ); $email = get_option( 'nss_plugin_license_email_sfwd_lms' ); // Make sure there are values. if ( empty( $license ) || empty( $email ) ) { ?> <p class="notice notice-error"> <?php echo sprintf( // translators: placeholder: Link to purchase LearnDash. esc_html_x( 'Please enter your email and a valid license or %s a license now.', 'placeholder: link to purchase LearnDash', 'learndash' ), "<a href='http://www.learndash.com/' target='_blank' rel='noreferrer noopener'>" . esc_html__( 'buy', 'learndash' ) . '</a>' ); ?> </p> <?php } // Check the license. if ( ! empty( $license ) && ! empty( $email ) ) { $license_status = is_learndash_license_valid(); if ( ! $license_status ) { // Clear just to be sure. $license_status = false; /** * We don't want to call getRemote_license() on every page * load. So we use the time_to_recheck() logic. */ if ( $updater->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; ?> <div class="wrap learndash-settings-page-wrap learndash-overview-page-wrap"> <div class="ld-bootview"> <h1><?php echo $this->settings_tab_title; ?></h1> <div class="ld-bootcamp" style="display:<?php echo isset( $toggle_state ) ? esc_attr( $this->maybe_display_bootcamp( $toggle_state ) ) : 'block'; ?>;"> <div class="ld-bootcamp__widget"> <div class="ld-bootcamp__widget--header"> <h2><?php echo esc_html_x( 'LearnDash Bootcamp', 'LearnDash Bootcamp Title', 'learndash' ); ?></h2> <button class="ld-bootcamp--toggle" id="ld-bootcamp--hide" type="button" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-toggle' ) ); ?>"><?php esc_html_e( 'Hide LearnDash Bootcamp', 'learndash' ); ?></button> </div> <div class="ld-bootcamp__widget--body"> <div class="ld-bootcamp__accordion" role="tablist"> <div class="ld-bootcamp__accordion--single <?php echo is_learndash_license_valid() ? '-completed' : ''; ?>"> <h3> <span class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true"></span> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-1" role="tab"> <?php echo esc_html_x( 'Enter Your License', 'Bootcamp headline', 'learndash' ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-1" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p><strong><?php esc_html_e( 'Welcome to LearnDash!', 'learndash' ); ?></strong><br/> <?php esc_html_e( 'We know you are excited to get started, but before you do it is very important that you first add your license details below!', 'learndash' ); ?></p> <ul> <li><?php esc_html_e( 'Your active license gives you access to product support and updates that we push out.', 'learndash' ); ?></li> <li><?php esc_html_e( 'Your license details were emailed to you after purchase.', 'learndash' ); ?></li> <li><?php echo sprintf( // translators: placeholder: Link to the license page on the LearnDash website. esc_html_x( 'You can also find them listed %1$s', 'Link to the license page on the LearnDash website', 'learndash' ), "<a href='https://support.learndash.com/account/' target='_blank' rel='noreferrer noopener'>" . esc_html__( 'on your account.', 'learndash' ) . '</a>' ); ?></li> </ul> <?php if ( learndash_is_admin_user() ) : ?> <div class="ld-bootcamp__license"> <form method="post" action=""> <?php if ( ! is_learndash_license_valid() ) : ?> <p class="notice notice-error is-dismissible"> <?php echo sprintf( // translators: placeholder: Link to purchase LearnDash. esc_html_x( 'Please enter your email and a valid license or %s a license now.', 'placeholder: link to purchase LearnDash', 'learndash' ), "<a href='http://www.learndash.com/' target='_blank' rel='noreferrer noopener'>" . esc_html__( 'buy', 'learndash' ) . '</a>' ); ?> </p> <?php else : ?> <p class="notice notice-success is-dismissible"><?php esc_html_e( 'Your license is valid.', 'learndash' ); ?></p> <?php endif; ?> <div class="ld-bootcamp__license--fields"> <label for="ld-bootcamp__email"><?php echo esc_html_x( 'Enter your Email here', 'License email', 'learndash' ); ?></label> <input type="email" value="<?php echo empty( $this->license_info['email'] ) ? '' : esc_html( $this->license_info['email'] ); ?>" id="ld-bootcamp__email" name="nss_plugin_license_email_sfwd_lms" /> </div> <div class="ld-bootcamp__license--fields"> <label for="ld-bootcamp__license-key"><?php echo esc_html_x( 'Enter your license key here', 'License key', 'learndash' ); ?></label> <input type="text" value="<?php echo empty( $this->license_info['license'] ) ? '' : esc_html( $this->license_info['license'] ); ?>" id="ld-bootcamp__license-key" name="nss_plugin_license_sfwd_lms" /> </div> <input type="submit" value="<?php esc_html_e( 'Save license', 'learndash' ); ?>" name="update_nss_plugin_license_sfwd_lms" class="button button-primary" /> <?php wp_nonce_field( 'ld_bootcamp_license_form_nonce', 'ld_bootcamp_license_form_nonce' ); ?> </form> </div> <?php else : ?> <p class="notice notice-error"> <?php esc_html_e( 'You do not have sufficient permissions to change the license information.', 'learndash' ); ?> </p> <?php endif; ?> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_2' ) ? '-completed' : ''; ?>"> <h3> <button class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_2" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-2" role="tab"> <?php esc_html_e( 'LearnDash Overview', 'learndash' ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-2" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php esc_html_e( 'In this video we will briefly explain the layout of LearnDash, our free add-ons, and where you can go to read more details about our features.', 'learndash' ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/yX5tr5gU_KE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Documentation', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/getting-started/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Getting Started [Guide]', 'learndash' ); ?></a></li> <li><a href="https://support.learndash.com/contact-support" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Contact Support', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button role="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_2" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_3' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_3" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-3" role="tab"> <?php echo sprintf( // translators: placeholder: Courses, Course. esc_html_x( 'Creating %1$s with the %2$s Builder', 'placeholder: Courses, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ), LearnDash_Custom_Label::get_label( 'course' ) ) ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-3" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: Course. esc_html_x( 'In this video we will demonstrate how you can create a course using the LearnDash %s Builder.', 'placeholder: Course.', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/cZ61RgRUXnw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/core/courses/course-builder/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Course. esc_html_x( '%s Builder [Article]', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> </a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_3" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_4' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_4" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-4" role="tab"> <?php echo sprintf( // translators: placeholders: Lessons, Topics esc_html_x( 'Adding Content Using %1$s & %2$s', 'placeholders: Lessons, Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Custom_Label::get_label( 'topics' ) ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-4" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholders: Course, Lessons, Topics esc_html_x( 'Now that you have your %1$s created, it is time to start adding content via %2$s and %3$s. In this video we will show how to do this and explain the various settings.', 'placeholders: Course, Lessons, Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'lessons' ), LearnDash_Custom_Label::get_label( 'topics' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/PD1KKzdakHw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/core/lessons/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Lessons. esc_html_x( '%s Documentation', 'placeholder: Lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ); ?> </a></li> <li><a href="https://www.learndash.com/support/docs/core/topics/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Topics. esc_html_x( '%s Documentation', 'placeholder: Topics', 'learndash' ), LearnDash_Custom_Label::get_label( 'topics' ) ); ?> </a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_4" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_5' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_5" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-5" role="tab"> <?php echo sprintf( // translators: placeholder: Quizzes esc_html_x( 'Creating %s', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-5" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: Quizzes, course, quizzes, course, Quiz, Questions esc_html_x( '%1$s are a great way to check if your learners are understanding the %2$s content. You can have one or more %3$s throughout a %4$s, or you can put it at the end. In this video we demonstrate how to create a %5$s and how to add %6$s.', 'placeholder: Quizzes, course, quizzes, course, Quiz, Questions', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), learndash_get_custom_label_lower( 'quizzes' ), learndash_get_custom_label_lower( 'course' ), LearnDash_Custom_Label::get_label( 'quiz' ), LearnDash_Custom_Label::get_label( 'questions' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/eqH-gSum-qA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/sr24gWa1SbE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/core/quizzes/" target="_blank" rel="noopener noreferrer"><?php echo sprintf( // translators: placeholder: Quizzes. esc_html_x( '%s Documentation', 'placeholder: Quizzes.', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/core/certificates/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Certificate Documentation', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_5" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_6' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_6" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-6" role="tab"> <?php esc_html_e( 'Setting-up User Registration', 'learndash' ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-6" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: Courses esc_html_x( 'Once you have finished creating your %s it is time to configure user registration so that people can access them! In this video we explain how to create an attractive login and registration form.', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/4PJKUIUsurs" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/guides/login-registration/learndash/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Login & Registration [Guide]', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_6" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_7' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_7" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-7" role="tab"> <?php echo sprintf( // translators: placeholder: Courses. esc_html_x( 'Selling Your %s', 'placeholder: Courses.', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-7" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translatord: placeholders: Courses, courses. esc_html_x( 'If you are selling your %1$s then you have many options available to you! In the first video we demonstrate how you can quickly start accepting payments with PayPal and Stripe. In the second video we will show you how to sell %2$s using the popular WordPress shopping cart WooCommerce.', 'placeholders: Courses, courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ), learndash_get_custom_label_lower( 'courses' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/gzGt9pd0eOM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/38X3Pst5b64" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/core/courses/course-access/" target="_blank" rel="noopener noreferrer"><?php echo sprintf( // translators: placeholder: Course. esc_html_x( '%s Access Settings [Article]', 'placeholder: Course.', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/core/settings/paypal-settings/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'PayPal Settings [Article]', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/add-ons/stripe/#" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Stripe Integration [Article]', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/add-ons/woocommerce/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'WooCommerce Integration [Article]', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_7" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_8' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_8" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-8" role="tab"> <?php echo sprintf( // translators: placeholder: Course. esc_html_x( 'Creating a %s Listing', 'placeholder: Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-8" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: Course, Courses, Course. esc_html_x( 'Your %1$s is created and you have also configured registration/login and how you will accept payment (in the event that you are selling your %2$s). It is now time to create a %3$s Listing which is easy to do using the Course Grid Add-on.', 'placeholder: Course, Courses, Course', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ), LearnDash_Custom_Label::get_label( 'courses' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/ZJm7l3vUNRU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/add-ons/course-grid/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Course Grid Add-on [Article]', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button role="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_8" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_9' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_9" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-9" role="tab"> <?php esc_html_e( 'Adding a User Profile Page', 'learndash' ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-9" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: courses. esc_html_x( 'The final step is to create a User Profile so that your users can instantly see which %s they have access to, their progress, performance, and earned certificates!', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ); ?> </p> <div class="ld-bootcamp__embed"> <iframe width="560" height="315" data-src="https://www.youtube.com/embed/Vn-Lf638UXU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <p><?php esc_html_e( 'Additional Resources:', 'learndash' ); ?></p> <ul> <li><a href="https://www.learndash.com/support/docs/guides/user-profiles/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'User Profiles [Guide]', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_9" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> <div class="ld-bootcamp__accordion--single <?php echo 'true' === get_option( 'learndash_bootcamp_mark_complete_section_10' ) ? '-completed' : ''; ?>"> <h3> <button type="button" class="ld-bootcamp__mark-complete--toggle-indicator" aria-hidden="true" data-id="learndash_bootcamp_mark_complete_section_10" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"></button> <button class="ld-bootcamp__accordion--toggle" type="button" aria-selected="false" aria-expanded="false" aria-controls="ld-bootcamp__accordion--content-10" role="tab"> <?php esc_html_e( 'Important Resources', 'learndash' ); ?> <span class="ld-bootcamp__accordion--toggle-indicator"></span> </button> </h3> <div id="ld-bootcamp__accordion--content-10" class="ld-bootcamp__accordion--content" aria-hidden="true" role="tabpanel"> <p> <?php echo sprintf( // translators: placeholder: courses esc_html_x( 'Setting up a learning site is no small task – but you are not alone! Below are some resources available to you so that you can get the most out of your LearnDash powered %s!', 'placeholder: courses', 'learndash' ), learndash_get_custom_label_lower( 'courses' ) ); ?> </p> <div class="ld-bootcamp__resources-box"> <div class="ld-bootcamp__resources"> <ul> <li><a href="https://www.facebook.com/groups/1020920397944393" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Community Facebook Group', 'learndash' ); ?></a></li> <li><a href="https://www.youtube.com/channel/UC1e38G3RVbTDHQrGPe1aVHw" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash YouTube Channel', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/getting-started/help/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'How to Get Help [Article]', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-bootcamp__mark_complete"> <button type="button" class="ld-bootcamp__mark-complete--toggle button-primary" data-id="learndash_bootcamp_mark_complete_section_10" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-mark-complete' ) ); ?>"><?php esc_html_e( 'Mark Complete', 'learndash' ); ?></button> </div> </div> </div> </div> </div> </div> </div> </div> <div class="ld-overview"> <div class="ld-overview--columns"> <div class="ld-overview--column ld-overview--widget"> <h2><?php esc_html_e( 'Tips and Tricks', 'learndash' ); ?></h2> <div class="ld-overview--columns -half"> <div class="ld-overview--column"> <h3> <svg width:"22" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <g fill="#000" fill-rule="evenodd"> <path d="M496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16zM464 96H345.94c-21.38 0-32.09 25.85-16.97 40.97l32.4 32.4L288 242.75l-73.37-73.37c-12.5-12.5-32.76-12.5-45.25 0l-68.69 68.69c-6.25 6.25-6.25 16.38 0 22.63l22.62 22.62c6.25 6.25 16.38 6.25 22.63 0L192 237.25l73.37 73.37c12.5 12.5 32.76 12.5 45.25 0l96-96 32.4 32.4c15.12 15.12 40.97 4.41 40.97-16.97V112c.01-8.84-7.15-16-15.99-16z"/> </g> </svg> <span> <?php echo sprintf( // translators: placeholder: Courses. esc_html_x( 'Sell Online %s', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ); ?> </span> </h3> <?php if ( ! $this->rss_sell_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo '<ul>'; foreach ( $this->rss_sell_posts as $sell_post ) { echo '<li><a href="' . esc_url( $sell_post->get_permalink() ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $sell_post->get_title() ) . '</a></li>'; }; echo '</ul>'; } ?> <p class="ld-overview--more"> <a href="https://www.learndash.com/category/sell-online-courses/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> <div class="ld-overview--column"> <h3> <svg width="22" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 516"> <g fill="#000" fill-rule="evenodd"> <path d="M176 80c-52.94 0-96 43.06-96 96 0 8.84 7.16 16 16 16s16-7.16 16-16c0-35.3 28.72-64 64-64 8.84 0 16-7.16 16-16s-7.16-16-16-16zM96.06 459.17c0 3.15.93 6.22 2.68 8.84l24.51 36.84c2.97 4.46 7.97 7.14 13.32 7.14h78.85c5.36 0 10.36-2.68 13.32-7.14l24.51-36.84c1.74-2.62 2.67-5.7 2.68-8.84l.05-43.18H96.02l.04 43.18zM176 0C73.72 0 0 82.97 0 176c0 44.37 16.45 84.85 43.56 115.78 16.64 18.99 42.74 58.8 52.42 92.16v.06h48v-.12c-.01-4.77-.72-9.51-2.15-14.07-5.59-17.81-22.82-64.77-62.17-109.67-20.54-23.43-31.52-53.15-31.61-84.14-.2-73.64 59.67-128 127.95-128 70.58 0 128 57.42 128 128 0 30.97-11.24 60.85-31.65 84.14-39.11 44.61-56.42 91.47-62.1 109.46a47.507 47.507 0 0 0-2.22 14.3v.1h48v-.05c9.68-33.37 35.78-73.18 52.42-92.16C335.55 260.85 352 220.37 352 176 352 78.8 273.2 0 176 0z"/> </g> </svg> <span><?php esc_html_e( 'LearnDash Tips', 'learndash' ); ?></span> </h3> <?php if ( ! $this->rss_tips_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo '<ul>'; foreach ( $this->rss_tips_posts as $tip_post ) { echo '<li><a href="' . esc_url( $tip_post->get_permalink() ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $tip_post->get_title() ) . '</a></li>'; }; echo '</ul>'; } ?> <p class="ld-overview--more"> <a href="https://www.learndash.com/category/learndash-tips/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> </div> </div> <div class="ld-overview--widget"> <h2><?php esc_html_e( 'LearnDash News', 'learndash' ); ?></h2> <h3> <svg width="22" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"> <g fill="#000" fill-rule="evenodd"> <path d="M552 64H112c-20.858 0-38.643 13.377-45.248 32H24c-13.255 0-24 10.745-24 24v272c0 30.928 25.072 56 56 56h496c13.255 0 24-10.745 24-24V88c0-13.255-10.745-24-24-24zM48 392V144h16v248c0 4.411-3.589 8-8 8s-8-3.589-8-8zm480 8H111.422c.374-2.614.578-5.283.578-8V112h416v288zM172 280h136c6.627 0 12-5.373 12-12v-96c0-6.627-5.373-12-12-12H172c-6.627 0-12 5.373-12 12v96c0 6.627 5.373 12 12 12zm28-80h80v40h-80v-40zm-40 140v-24c0-6.627 5.373-12 12-12h136c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12H172c-6.627 0-12-5.373-12-12zm192 0v-24c0-6.627 5.373-12 12-12h104c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12H364c-6.627 0-12-5.373-12-12zm0-144v-24c0-6.627 5.373-12 12-12h104c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12H364c-6.627 0-12-5.373-12-12zm0 72v-24c0-6.627 5.373-12 12-12h104c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12H364c-6.627 0-12-5.373-12-12z"/> </g> </svg> <span><?php esc_html_e( 'Announcements', 'learndash' ); ?></span> </h3> <?php if ( ! $this->rss_announcements_posts ) { esc_html_e( 'Something went wrong connecting to www.learndash.com. Please reload the page.', 'learndash' ); } else { echo '<ul>'; foreach ( $this->rss_announcements_posts as $announcement_post ) { echo '<li><a href="' . esc_url( $announcement_post->get_permalink() ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $announcement_post->get_title() ) . '</a></li>'; }; echo '</ul>'; } ?> <p class="ld-overview--more"> <a href="https://www.learndash.com/category/learndash/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> </div> <div class="ld-overview--columns -support"> <div class="ld-overview--widget -doc"> <h2><?php esc_html_e( 'Documentation', 'learndash' ); ?></h2> <div class="ld-overview--search"> <form id="ld-overview--search-documentation-form"> <label for="ld-overview--search-term" class="screen-reader-text"><?php esc_html_e( 'Search the Documentation website. A new tab will be opened on submission.', 'learndash' ); ?></label> <input type="text" id="ld-overview--search-term" name="search" value="" placeholder="<?php esc_html_e( 'Search documentation', 'learndash' ); ?>" /> <input type="submit" value="<?php esc_html_e( 'Search', 'learndash' ); ?>" class="button button-primary" /> </form> </div> <div class="ld-overview--columns"> <div class="ld-overview--column"> <h4><?php esc_html_e( 'Getting Started', 'learndash' ); ?></h4> <ul> <li><a href="https://www.learndash.com/support/docs/getting-started/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Getting Started Guide', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/core/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Core Docs', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/core/courses/course-builder/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Course. esc_html_x( '%s Builder', 'placeholder: Course.', 'learndash' ), LearnDash_Custom_Label::get_label( 'course' ) ); ?> </a></li> <li><a href="https://www.learndash.com/support/docs/add-ons/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Add-ons', 'learndash' ); ?></a></li> </ul> <p class="ld-overview--more"> <a href="https://www.learndash.com/support/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> <div class="ld-overview--column"> <h4><?php esc_html_e( 'Popular Articles', 'learndash' ); ?></h4> <ul> <li><a href="https://www.learndash.com/support/docs/guides/login-registration/learndash/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Registration & Login', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/guides/focus-mode/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Focus Mode', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/guides/user-profiles/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'User Profiles', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/add-ons/course-grid/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Course Grid Add-on', 'learndash' ); ?></a></li> </ul> <p class="ld-overview--more"> <a href="https://www.learndash.com/support/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> <div class="ld-overview--column"> <h4><?php esc_html_e( 'FAQ', 'learndash' ); ?></h4> <ul> <li><a href="https://www.learndash.com/support/docs/getting-started/themes/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Recommended WordPress Themes', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/account/license/#why_won8217t_my_license_validate" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Invalid License Notice', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/faqs/design/hide-post-meta-data/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Hiding Post Meta Data', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/troubleshooting/404-errors-learndash-pages/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( '404 Error on LearnDash Content', 'learndash' ); ?></a></li> </ul> <p class="ld-overview--more"> <a href="https://www.learndash.com/support/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View more', 'learndash' ); ?></a> </p> </div> </div> <div class="ld-overview--topics"> <h4><?php esc_html_e( 'Popular Support Topics', 'learndash' ); ?></h4> <div class="ld-overview--columns"> <div class="ld-overview--column"> <ul> <li><a href="https://www.learndash.com/support/docs/core/courses/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Courses. esc_html_x( '%s', 'placeholder: Courses', 'learndash' ), LearnDash_Custom_Label::get_label( 'courses' ) ); ?> </a></li> <li><a href="https://www.learndash.com/support/docs/core/lessons/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Lessons. esc_html_x( '%s', 'placeholder: Lessons', 'learndash' ), LearnDash_Custom_Label::get_label( 'lessons' ) ); ?> </a></li> <li><a href="https://www.learndash.com/support/docs/core/quizzes/" target="_blank" rel="noopener noreferrer"> <?php echo sprintf( // translators: placeholder: Quizzes. esc_html_x( '%s', 'placeholder: Quizzes', 'learndash' ), LearnDash_Custom_Label::get_label( 'quizzes' ) ); ?> </a></li> <li><a href="https://www.learndash.com/support/docs/core/certificates/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Certificates', 'learndash' ); ?></a></li> </ul> </div> <div class="ld-overview--column"> <ul> <li><a href="https://www.learndash.com/support/docs/core/shortcodes-blocks/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Shortcodes', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/reporting/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Reporting', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/users-groups/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Users & Groups', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/support/docs/add-ons/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Add-ons', 'learndash' ); ?></a></li> </ul> </div> </div> </div> </div> <div class="ld-overview--widget -support"> <h2><?php esc_html_e( 'Support', 'learndash' ); ?></h2> <p><?php esc_html_e( 'Have some questions or need a helping hand? The LearnDash support team is standing by, ready to assist you!', 'learndash' ); ?></p> <a href="https://support.learndash.com/contact-support/" class="button button-primary" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Contact Support', 'learndash' ); ?></a> <ul> <li><a href="https://www.facebook.com/groups/1020920397944393" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash Facebook Group', 'learndash' ); ?></a></li> <li><a href="https://www.youtube.com/channel/UC1e38G3RVbTDHQrGPe1aVHw?sub_confirmation=1" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'LearnDash YouTube', 'learndash' ); ?></a></li> <li><a href="https://www.learndash.com/changelog" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Changelog', 'learndash' ); ?></a></li> <li><button class="ld-bootcamp--toggle button button-orange" id="ld-bootcamp--show" type="button" data-nonce="<?php echo esc_attr( wp_create_nonce( 'learndash-bootcamp-toggle' ) ); ?>"><?php echo esc_html_x( 'Show LearnDash Bootcamp', 'Toggles visibility of the LearnDash Bootcamp section', 'learndash' ); ?></button></li> </ul> </div> </div> </div> </div> </div> <?php } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Overview::add_page_instance(); } ); settings-pages/class-ld-settings-page-import-export.php 0000666 00000007515 15214240575 0017334 0 ustar 00 <?php /** * LearnDash Settings Page Import/Export. * * @since 2.5.4 * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Import_Export' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Import_Export extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->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', '<h1>' . $this->settings_page_title . '</h1>' ); } /** * 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 ) { ?> <style> h1.nav-tab-wrapper { display: none; }</style> <?php } } return $tab_set; } /** * Custom display function for page content. * * @since 2.5.5 */ public function show_settings_page() { ?> <div class="wrap learndash-settings-page-wrap"> <?php settings_errors(); ?> <?php do_action( 'learndash_settings_page_before_title', $this->settings_screen_id ); ?> <?php echo $this->get_admin_page_title(); ?> <?php do_action( 'learndash_settings_page_after_title', $this->settings_screen_id ); ?> <?php do_action( 'learndash_settings_page_before_form', $this->settings_screen_id ); ?> <?php $this->import_export->show(); ?> <?php do_action( 'learndash_settings_page_after_form', $this->settings_screen_id ); ?> </div> <?php /** * The following is needed to trigger the wp-admin/js/updates.js logic in * wp.updates.updatePlugin() where is checks for specific pagenow values * but doesn't leave any option for externals. */ ?> <script type="text/javascript"> //pagenow = 'plugin-install'; </script> <?php } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Import_Export::add_page_instance(); } ); settings-pages/class-ld-settings-page-lessons-options.php 0000666 00000001566 15214240575 0017662 0 ustar 00 <?php /** * LearnDash Settings Page Lessons Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Lessons_Options' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Lessons_Options extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->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(); } ); settings-pages/class-ld-settings-page-certificate-shortcodes.php 0000666 00000015016 15214240575 0021133 0 ustar 00 <?php /** * LearnDash Settings Page for Certificate Shortcodes. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Page' ) ) && ( ! class_exists( 'LearnDash_Settings_Page_Certificates_Shortcodes' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Settings_Page_Certificates_Shortcodes extends LearnDash_Settings_Page { /** * Public constructor for class */ public function __construct() { $this->parent_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 .= '<li><strong>' . $key . '</strong>'; if ( ! empty( $label ) ) { $courseinfo_show_options .= ' - ' . $label; } $courseinfo_show_options .= '</li>'; } } $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 .= '<li><strong>' . $key . '</strong>'; if ( ! empty( $label ) ) { $quizinfo_show_options .= ' - ' . $label; } $quizinfo_show_options .= '</li>'; } } ?> <div id="certificate-shortcodes" class="wrap"> <h2><?php esc_html_e( 'Certificate Shortcodes', 'learndash' ); ?></h2> <div class='sfwd_options_wrapper sfwd_settings_left'> <div class='postbox ' id='sfwd-certificates_metabox'> <div class="inside" style="margin: 11px 0; padding: 0 12px 12px;"> <?php echo wp_kses_post( __( '<b>Shortcode Options</b><p>You may use shortcodes to customize the display of your certificates. Provided is a built-in shortcode for displaying user information.</p><br /> <p class="ld-shortcode-header">[usermeta]</p> <p>This shortcode takes a parameter named field, which is the name of the user meta data field to be displayed.</p><p>Example: <b>[usermeta field="display_name"]</b> would display the user\'s Display Name.</p><p>See <a href="http://codex.wordpress.org/Function_Reference/get_userdata#Notes">the full list of available fields here</a>.', 'learndash' ) ) . '</p><br /> <p class="ld-shortcode-header">[quizinfo]</p> <p>' . 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' ) ) . '</p> <ul> <li><b>SHOW</b>: ' . sprintf( wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode. Possible values are: <ul class="cert_shortcode_parm_list">' . $quizinfo_show_options . '</ul> <br>Example: <b>[quizinfo show="percentage"]</b> shows the percentage score of the user in the %s.', 'placeholder: quiz', 'learndash' ) ), learndash_get_custom_label_lower( 'quiz' ) ) . '<br><br></li> <li><b>FORMAT</b>: ' . wp_kses_post( __( 'This can be used to change the timestamp format. Default: "F j, Y, g:i a" shows as <i>March 10, 2001, 5:16 pm</i>. <br>Example: <b>[quizinfo show="timestamp" format="Y-m-d H:i:s"]</b> will show as <i>2001-03-10 17:16:18</i>', 'learndash' ) ) . '</li> </ul> <p>' . wp_kses_post( __( 'See <a target="_blank" href="http://php.net/manual/en/function.date.php">the full list of available date formatting strings here.</a>', 'learndash' ) ) . '</p><br /> <p class="ld-shortcode-header">[courseinfo]</p> <p>'. esc_html__( 'This shortcode displays course related information on the certificate. This shortcode can use the following parameters:', 'learndash' ) . '</p> <ul> <li><b>SHOW</b>: ' . sprintf( wp_kses_post( _x( 'This parameter determines the information to be shown by the shortcode. Possible values are: <ul class="cert_shortcode_parm_list">' . $courseinfo_show_options . ' </ul> <i>cumulative</i> is average for all %s of the %s.<br> <i>aggregate</i> is sum for all %s of the %s.<br> <br>Example: <b>[courseinfo show="cumulative_score"]</b> 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' )) . '<br><br></li> <li><b>FORMAT</b>: ' . wp_kses_post( __( 'This can be used to change the date format. Default: "F j, Y, g:i a" shows as <i>March 10, 2001, 5:16 pm</i>. <br>Example: <b>[courseinfo show="completed_on" format="Y-m-d H:i:s"]</b> will show as <i>2001-03-10 17:16:18</i>', 'learndash' ) ) . '</li> </ul> <p>' . wp_kses_post( __( 'See <a target="_blank" href="http://php.net/manual/en/function.date.php">the full list of available date formatting strings here.</a>', 'learndash' ) ) . '</p>'; ?> </div> </div> </div> </div> <?php } } } add_action( 'learndash_settings_pages_init', function() { LearnDash_Settings_Page_Certificates_Shortcodes::add_page_instance(); } ); shortcodes-sections/course_notstarted.php 0000666 00000007335 15214240575 0015047 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_course_notstarted' ) ) ) { class LearnDash_Shortcodes_Section_course_notstarted extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->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 <strong>any</strong> 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(); } } } shortcodes-sections/course_complete.php 0000666 00000010054 15214240575 0014460 0 ustar 00 <?php /** * LearnDash Shortcode Section for Course Complete. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_course_complete' ) ) ) { /** * Class to create the settings page. */ class LearnDash_Shortcodes_Section_course_complete extends LearnDash_Shortcodes_Section { /** * Public constructor for class. * * @param array $fields_args Field Args. */ public function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/course_content.php 0000666 00000006112 15214240575 0014322 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_course_content' ) ) ) { class LearnDash_Shortcodes_Section_course_content extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_profile.php 0000666 00000015324 15214240575 0013414 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_profile' ) ) ) { class LearnDash_Shortcodes_Section_ld_profile extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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(); } } } shortcodes-sections/ld_course_info.php 0000666 00000021777 15214240575 0014300 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_ld_course_info' ) ) ) { class LearnDash_Shortcodes_Section_ld_course_info extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here</a>.', '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(); } } } shortcodes-sections/visitor.php 0000666 00000006007 15214240575 0012772 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_visitor' ) ) ) { class LearnDash_Shortcodes_Section_visitor extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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 <strong>any</strong> 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(); } } } shortcodes-sections/learndash_course_progress.php 0000666 00000005400 15214240575 0016534 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_learndash_course_progress' ) ) ) { class LearnDash_Shortcodes_Section_learndash_course_progress extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/learndash_payment_buttons.php 0000666 00000003000 15214240575 0016535 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_learndash_payment_buttons' ) ) ) { class LearnDash_Shortcodes_Section_learndash_payment_buttons extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/user_groups.php 0000666 00000002513 15214240575 0013646 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_user_groups' ) ) ) { class LearnDash_Shortcodes_Section_user_groups extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_quiz_complete.php 0000666 00000010572 15214240575 0014634 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_quiz_complete' ) ) ) { class LearnDash_Shortcodes_Section_ld_quiz_complete extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_course_list.php 0000666 00000032723 15214240575 0014311 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_ld_course_list' ) ) ) { class LearnDash_Shortcodes_Section_ld_course_list extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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 <code>/%s/</code> 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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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() { ?> <script> jQuery(document).ready(function() { if ( jQuery( 'form#learndash_shortcodes_form_ld_course_list select#ld_course_list_mycourses' ).length) { jQuery( 'form#learndash_shortcodes_form_ld_course_list select#ld_course_list_mycourses').change( function() { var selected = jQuery(this).val(); if ( selected == 'enrolled' ) { jQuery( 'form#learndash_shortcodes_form_ld_course_list #ld_course_list_status_field select option').attr('selected', true); jQuery( 'form#learndash_shortcodes_form_ld_course_list #ld_course_list_status_field').slideDown(); } else { jQuery( 'form#learndash_shortcodes_form_ld_course_list #ld_course_list_status_field').hide(); jQuery( 'form#learndash_shortcodes_form_ld_course_list #ld_course_list_status_field select').val(''); } }); jQuery( 'form#learndash_shortcodes_form_ld_course_list select#ld_course_list_mycourses').change(); } }); </script> <?php } } } shortcodes-sections/ld_certificate.php 0000666 00000010052 15214240575 0014227 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_certificate' ) ) ) { class LearnDash_Shortcodes_Section_ld_certificate extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->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(); } } } shortcodes-sections/ld_course_expire_status.php 0000666 00000007746 15214240575 0016244 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_course_expire_status' ) ) ) { class LearnDash_Shortcodes_Section_ld_course_expire_status extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_group.php 0000666 00000005475 15214240575 0013116 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_group' ) ) ) { class LearnDash_Shortcodes_Section_ld_group extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_lesson_list.php 0000666 00000030121 15214240575 0014302 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_ld_lesson_list' ) ) ) { class LearnDash_Shortcodes_Section_ld_lesson_list extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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 <code>/%s/</code> 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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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(); } } } shortcodes-sections/learndash_login.php 0000666 00000012776 15214240575 0014436 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_learndash_login' ) ) ) { class LearnDash_Shortcodes_Section_learndash_login extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_course_resume.php 0000666 00000006602 15214240575 0014633 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_course_resume' ) ) ) { class LearnDash_Shortcodes_Section_ld_course_resume extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/ld_quiz_list.php 0000666 00000032411 15214240575 0013773 0 ustar 00 <?php /** * LearnDash [ld_quiz_list] Shortcode options. * * @package LearnDash * @subpackage shortcode/ld_quiz_list */ if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_quiz_list' ) ) ) { /** * Class for LearnDash Shortcode Section. */ class LearnDash_Shortcodes_Section_ld_quiz_list extends LearnDash_Shortcodes_Section { /** * Public constructor for class. */ public function __construct( $fields_args = array() ) { $this->fields_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 <code>/%2$s/</code> 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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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(); } } } shortcodes-sections/ld_video.php 0000666 00000003454 15214240575 0013063 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_ld_video' ) ) ) { class LearnDash_Shortcodes_Section_ld_video extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/course_inprogress.php 0000666 00000007331 15214240575 0015047 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_course_inprogress' ) ) ) { class LearnDash_Shortcodes_Section_course_inprogress extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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 <strong>any</strong> 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(); } } } shortcodes-sections/ld_user_course_points.php 0000666 00000002767 15214240575 0015715 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_ld_user_course_points' ) ) ) { class LearnDash_Shortcodes_Section_ld_user_course_points extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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(); } } } shortcodes-sections/usermeta.php 0000666 00000003661 15214240575 0013123 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_usermeta' ) ) ) { class LearnDash_Shortcodes_Section_usermeta extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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 <a href="http://codex.wordpress.org/Function_Reference/get_userdata#Notes">the full list of available fields here. Note for security reasons some fields are not allowed.</a>', '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(); } } } shortcodes-sections/quizinfo.php 0000666 00000014623 15214240575 0013142 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_quizinfo' ) ) ) { class LearnDash_Shortcodes_Section_quizinfo extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->fields_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.<br />cumulative - average for all %s of the %s.<br />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 <i>March 10, 2001, 5:16 pm</i>. See <a target="_blank" href="http://php.net/manual/en/function.date.php">the full list of available date formating strings here.</a>', '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() { ?> <script> jQuery(document).ready(function() { if ( jQuery( 'form#learndash_shortcodes_form_quizinfo select#quizinfo_show' ).length) { jQuery( 'form#learndash_shortcodes_form_quizinfo select#quizinfo_show').change( function() { var selected = jQuery(this).val(); if ( selected == 'timestamp' ) { jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_format_field').slideDown(); } else { jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_format_field').hide(); jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_format_field input').val(''); } if ( selected == 'field' ) { jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_field_id_field').slideDown(); } else { jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_field_id_field').hide(); jQuery( 'form#learndash_shortcodes_form_quizinfo #quizinfo_field_id_field input').val(''); } }); jQuery( 'form#learndash_shortcodes_form_quizinfo select#quizinfo_show').change(); } }); </script> <?php } } } shortcodes-sections/student.php 0000666 00000006563 15214240575 0012770 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_student' ) ) ) { class LearnDash_Shortcodes_Section_student extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->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 <strong>any</strong> 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(); } } } shortcodes-sections/courseinfo.php 0000666 00000026406 15214240575 0013454 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( ! class_exists( 'LearnDash_Shortcodes_Section_courseinfo' ) ) ) { class LearnDash_Shortcodes_Section_courseinfo extends LearnDash_Shortcodes_Section { public function __construct( $fields_args = array() ) { $this->fields_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. <strong>Unless specified otherwise, all points, scores and percentages relate to the %2$s associated with the %3$s.</strong>', '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.<br />cumulative - average for all %1$s of the %2$s.<br />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 <i>March 10, 2001, 5:16 pm</i>. See <a target="_blank" href="http://php.net/manual/en/function.date.php">the full list of available date formating strings here.</a>', '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 <i>XXmin YYsec</i>. ', '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() { ?> <script> jQuery(document).ready(function() { if ( jQuery( 'form#learndash_shortcodes_form_courseinfo select#courseinfo_show' ).length) { jQuery( 'form#learndash_shortcodes_form_courseinfo select#courseinfo_show').change( function() { var selected = jQuery(this).val(); if ( ( selected == 'completed_on' ) || ( selected == 'enrolled_on' ) ) { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_format_field').slideDown(); } else { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_format_field').hide(); jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_format_field input').val(''); } if ( selected == 'user_course_time' ) { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_seconds_format_field').show(); } else { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_seconds_format_field').hide(); jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_seconds_format_field input').val(''); } if ( ( selected == 'course_points' ) || ( selected == 'user_course_points' ) ) { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_decimals_field').slideDown(); } else { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_decimals_field').hide(); jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_decimals_field input').val(''); } if ( ( selected == 'course_title' ) || ( selected == 'course_url' ) || ( selected == 'course_points' ) || ( selected == 'course_price' ) || ( selected == 'course_price_type' ) ) { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_user_id_field').hide(); jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_user_id_field input').val(''); } else { jQuery( 'form#learndash_shortcodes_form_courseinfo #courseinfo_user_id_field').slideDown(); } }); jQuery( 'form#learndash_shortcodes_form_courseinfo select#courseinfo_show').change(); } }); </script> <?php } } } shortcodes-sections/ld_topic_list.php 0000666 00000031274 15214240575 0014127 0 ustar 00 <?php if ( ( class_exists( 'LearnDash_Shortcodes_Section' ) ) && ( !class_exists( 'LearnDash_Shortcodes_Section_ld_topic_list' ) ) ) { class LearnDash_Shortcodes_Section_ld_topic_list extends LearnDash_Shortcodes_Section { function __construct( $fields_args = array() ) { $this->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 <code>/%s/</code> 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 <a target="_blank" href="https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters">the full list of available orderby options here.</a>', '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(); } } } settings-sections/class-ld-settings-section-courses-cpt.php 0000666 00000020713 15214240575 0020225 0 ustar 00 <?php /** * LearnDash Settings Section for Courses Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Courses_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Courses_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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' ), '<a href="' . admin_url( 'options-permalink.php' ) . '">' . esc_html__( 're-save your permalinks', 'learndash' ) . '</a>' ), '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' ), '<code><a target="blank" href="' . $cpt_archive_url . '">' . $cpt_archive_url . '</a></code>' ), ), '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' ), '<code><a target="blank" href="' . $cpt_rss_url . '">' . $cpt_rss_url . '</a></code>' ), ), '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(); } ); settings-sections/class-ld-settings-section-general-rest-api.php 0000666 00000015546 15214240575 0021125 0 ustar 00 <?php /** * LearnDash Settings Section for REST API Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_General_REST_API' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_General_REST_API extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-support-learndash.php 0000666 00000100650 15214240575 0021430 0 ustar 00 <?php /** * LearnDash Settings Section for Support LearnDash Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_LearnDash' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_LearnDash extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Translations MO files array. * * @var array $mo_files Array of translation MO files. */ private $mo_files = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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 = '<span style="color: red">' . $version . '</span> ' . ': ' . $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 ) . ' <a href="' . admin_url( 'plugins.php?plugin_status=upgrade' ) . '">' . esc_html__( 'Please upgrade.', 'learndash' ) . '</a>' . "<br />"; $LEARNDASH_VERSION_value = $version . ': ' . $version_date . ' - (X)' . "\r\n"; } else { $LEARNDASH_VERSION_value_html .= '<span style="color: green">' . $version . '</span>' . ': ' . $version_date . "<br />"; $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; } } else { $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; $LEARNDASH_VERSION_value_html .= $version . ': ' . $version_date . "<br />"; } } else { $LEARNDASH_VERSION_value .= $version . ': ' . $version_date . "\r\n"; $LEARNDASH_VERSION_value_html .= $version . ': ' . $version_date . "<br />"; } } } $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 = '<span style="color: green">' . esc_html__( 'Yes', 'learndash' ) . '</span>'; $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 = '<span style="color: red">' . esc_html__( 'No', 'learndash' ) . '</span>'; $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 = '<span style="color: ' . $color . '">' . $data_settings_courses['version'] . '</span>'; if ( 'red' == $color ) { $data_upgrade_courses_value_html .= ' <a href="' . admin_url( 'admin.php?page=learndash_data_upgrades' ) . '">' . esc_html__( 'Please run the Data Upgrade.', 'learndash' ) . '</a>'; } 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 = '<span style="color: ' . $color . '">' . $data_settings_quizzes['version'] . '</span>'; if ( 'red' == $color ) { $data_upgrade_quizzes_value_html .= ' <a href="' . admin_url( 'admin.php?page=learndash_data_upgrades' ) . '">' . 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 = '<span style="color: ' . $color . '">' . $data_pro_quiz_questions['version'] . '</span>'; if ( 'red' == $color ) { $data_pro_quiz_questions_html .= ' <a href="' . admin_url( 'admin.php?page=learndash_data_upgrades' ) . '">' . 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 = '<span style="color: ' . $color . '">' . $data_course_access_lists['version'] . '</span>'; if ( 'red' == $color ) { $data_course_access_lists_html .= ' <a href="' . admin_url( 'admin.php?page=learndash_data_upgrades' ) . '">' . 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'] = '<span style="color: ' . $color . '">' . $assignment_upload_dir_path_r . '</span>'; $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'] = '<span style="color: ' . $color . '">' . $assignment_upload_dir_path_r . '</span>'; $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'] = '<span style="color: ' . $color . '">' . $assignment_upload_dir_path_r . '</span>'; } $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'] = '<span style="color: ' . $color . '">' . $essay_upload_dir_path_r . '</span>'; $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'] = '<span style="color: ' . $color . '">' . $essay_upload_dir_path_r . '</span>'; $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'] = '<span style="color: ' . $color . '">' . $essay_upload_dir_path_r . '</span>'; } 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 .= ' <em>' . learndash_adjust_date_time_display( filectime( $mo_file ) ) . '</em>'; $ld_translation_files .= '<strong>' . LEARNDASH_LMS_TEXT_DOMAIN . '</strong> - ' . $mo_files_output . '<br />'; } } $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(); } ); settings-sections/class-ld-settings-section-support-copy-system-info.php 0000666 00000006613 15214240575 0022720 0 ustar 00 <?php /** * LearnDash Settings Section for Support Copy System Info Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_System_Info' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_System_Info extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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 ) { ?> <textarea id="ld-system-info-text" style="width: 100%; min-height: 80px; font-family: monospace"><?php foreach( $support_page_instance->get_support_sections() as $_key => $_section ) { $support_page_instance->show_support_section( $_key, 'text' ); } //echo $this->show_system_info( 'text' ); ?></textarea><br /> <p><button id="ld-system-info-copy-button"><?php esc_html_e( 'Copy to Clipboard', 'learndash' ); ?></button><span style="display:none" id="ld-copy-status-success"><?php esc_html_e( 'Copy Success', 'learndash' ); ?></span><span style="display:none" id="ld-copy-status-failed"><?php esc_html_e( 'Copy Failed', 'learndash' ); ?></span></p> <script> var copyBtn = document.querySelector('#ld-system-info-copy-button'); copyBtn.addEventListener('click', function(event) { // Select the email link anchor text var copy_text = document.querySelector('#ld-system-info-text'); var range = document.createRange(); range.selectNode(copy_text); window.getSelection().addRange(range); try { // Now that we've selected the anchor text, execute the copy command var successful = document.execCommand('copy'); if ( successful ) { jQuery( '#ld-copy-status-success').show(); } } catch(err) { console.log('Oops, unable to copy'); } // Remove the selections - NOTE: Should use // removeRange(range) when it is supported window.getSelection().removeAllRanges(); event.preventDefault() }); </script> <?php } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Support_System_Info::add_section_instance(); } ); settings-sections/class-ld-settings-section-courses-themes.php 0000666 00000010676 15214240575 0020733 0 ustar 00 <?php /** * LearnDash Settings Section for Course Themes Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Courses_Themes' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Courses_Themes extends LearnDash_Settings_Section { private $themes_list = array(); /** * Protected constructor for class */ protected function __construct() { // The page ID (different than the screen ID). $this->settings_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 '<div id="learndash_theme_settings_section_' . $theme_instance->get_theme_key() . '" class="ld-theme-settings-section ld-theme-settings-section-' . $theme_instance->get_theme_key() . ' ld-theme-settings-section-state-' . $theme_state . '">'; $this->show_settings_section_fields( $section_instance->settings_page_id, $section_key ); echo '</div>'; } } } } } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Courses_Themes::add_section_instance(); } ); settings-sections/class-ld-settings-section-general-admin-user.php 0000666 00000013307 15214240575 0021436 0 ustar 00 <?php /** * LearnDash Settings Section for Admin Users Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_General_Admin_User' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_General_Admin_User extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-courses-management-display.php 0000666 00000046207 15214240575 0023224 0 ustar 00 <?php /** * LearnDash Settings Section for Course Builder Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Courses_Management_Display' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Courses_Management_Display extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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.<br /><br />Note: Enabling this option will also enable the <a href="%6$s">nested permalinks</a> 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' ), '<u>Date</u>', '<u>Ascending</u>' ), '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(); } ); settings-sections/class-ld-settings-section-questions-management-display.php 0000666 00000014675 15214240575 0023577 0 ustar 00 <?php /** * LearnDash Settings Section Question Mangement and Display. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Questions_Management_Display' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Questions_Management_Display extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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'] = '<span style="color: green" >' . __( 'Template updated.', 'learndash' ) . '</span>'; } } } } } 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'] = '<span style="color: green" >' . __( 'Template deleted.', 'learndash' ) . '</span>'; } } } } } } } 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(); } ); settings-sections/settings-sections-loader.php 0000666 00000011502 15214240575 0015703 0 ustar 00 <?php /** * LearnDash Settings Sections Loader. * * @package LearnDash * @subpackage Settings */ require_once __DIR__ . '/class-ld-settings-section-side-submit.php'; require_once __DIR__ . '/class-ld-settings-section-side-quick-links.php'; // Custom Labels Page. require_once __DIR__ . '/class-ld-settings-section-custom-labels.php'; // Course Options. require_once __DIR__ . '/class-ld-settings-section-courses-management-display.php'; require_once __DIR__ . '/class-ld-settings-section-courses-taxonomies.php'; require_once __DIR__ . '/class-ld-settings-section-courses-cpt.php'; // Lessons Options. //require_once 'class-ld-settings-section-lessons-display-order.php'; require_once __DIR__ . '/class-ld-settings-section-lessons-taxonomies.php'; require_once __DIR__ . '/class-ld-settings-section-lessons-cpt.php'; // Topics Options. require_once __DIR__ . '/class-ld-settings-section-topics-taxonomies.php'; require_once __DIR__ . '/class-ld-settings-section-topics-cpt.php'; // Quizzes Options require_once __DIR__ . '/class-ld-settings-section-quizzes-management-display.php'; require_once __DIR__ . '/class-ld-settings-section-quizzes-email-settings.php'; require_once __DIR__ . '/class-ld-settings-section-quizzes-taxonomies.php'; require_once __DIR__ . '/class-ld-settings-section-quizzes-cpt.php'; //require_once __DIR__ . '/_class-ld-settings-section-quizzes-builder.php'; //require_once __DIR__ . '/class-ld-settings-section-quizzes-admin-email.php'; //require_once __DIR__ . '/_class-ld-settings-section-quizzes-user-email.php'; //require_once __DIR__ . '/class-ld-settings-section-quizzes-time-formats.php'; //require_once __DIR__ . '/class-ld-settings-section-quizzes-template-management.php'; // Question Options. require_once __DIR__ . '/class-ld-settings-section-questions-taxonomies.php'; require_once __DIR__ . '/class-ld-settings-section-questions-management-display.php'; //require_once( __DIR__ . '/class-ld-settings-section-questions-cpt.php' ); //require_once __DIR__ . '/class-ld-settings-section-questions-template-management.php'; //require_once __DIR__ . '/class-ld-settings-section-questions-category-management.php'; // Settings General tab. require_once __DIR__ . '/class-ld-settings-section-courses-themes.php'; require_once __DIR__ . '/class-ld-settings-section-general-per-page.php'; require_once __DIR__ . '/class-ld-settings-section-general-admin-user.php'; //require_once( __DIR__ . '/class-ld-settings-section-general-login-registration.php' ); if ( ( defined( 'LEARNDASH_REST_API_ENABLED' ) ) && ( true === LEARNDASH_REST_API_ENABLED ) ) { require_once __DIR__ . '/class-ld-settings-section-general-rest-api.php'; } // Data Upgrades tab. require_once __DIR__ . '/class-ld-settings-section-data-upgrades.php'; // PayPal tab. require_once __DIR__ . '/class-ld-settings-section-paypal.php'; // Support tab. require_once __DIR__ . '/class-ld-settings-section-support-learndash.php'; require_once __DIR__ . '/class-ld-settings-section-support-server.php'; require_once __DIR__ . '/class-ld-settings-section-support-wordpress.php'; require_once __DIR__ . '/class-ld-settings-section-support-templates.php'; require_once __DIR__ . '/class-ld-settings-section-support-database-tables.php'; require_once __DIR__ . '/class-ld-settings-section-support-wordpress-themes.php'; require_once __DIR__ . '/class-ld-settings-section-support-wordpress-plugins.php'; require_once __DIR__ . '/class-ld-settings-section-support-copy-system-info.php'; require_once __DIR__ . '/class-ld-settings-section-support-data-reset.php'; // Translations tab. if ( ( defined( 'LEARNDASH_TRANSLATIONS' ) ) && ( LEARNDASH_TRANSLATIONS === true ) ) { require_once __DIR__ . '/class-ld-settings-section-translations-refresh.php'; require_once __DIR__ . '/class-ld-settings-section-translations-learndash.php'; } // Import/Export. //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/settings-sections-pages/class-ld-settings-page-import-export.php' ); // Assignments require_once __DIR__ . '/class-ld-settings-section-assignments-cpt.php'; //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-page-license.php' ); //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-license.php' ); //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-license-submit.php' ); //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-taxonomies.php' ); //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-general-one.php' ); //require_once( LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-general-two.php' ); // Shows settings section on the WP Settings > Permalinks page. require_once __DIR__ . '/class-ld-settings-section-permalinks.php'; require_once __DIR__ . '/class-ld-settings-section-permalinks-taxonomies.php'; settings-sections/class-ld-settings-section-courses-taxonomies.php 0000666 00000012165 15214240575 0021627 0 ustar 00 <?php /** * LearnDash Settings Section for Courses Taxonomies Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Courses_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Courses_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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(); } ); settings-sections/class-ld-settings-section-translations-refresh.php 0000666 00000004571 15214240575 0022137 0 ustar 00 <?php /** * LearnDash Settings Section for Translations Refresh Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Translations_Refresh' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Translations_Refresh extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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() { ?> <div id="submitpost" class="submitbox"> <div id="major-publishing-actions"> <div id="publishing-action"> <span class="spinner"></span> <input type="hidden" name="translations" value="refresh" /> <?php $last_update_time = LearnDash_Translations::get_last_update(); ?> <?php if ( ! is_null( $last_update_time ) ) { ?> <p class="learndash-translations-last-update"><span class="label"><?php esc_html_e( 'Updated', 'learndash' ); ?></span>: <span class="value"><?php echo learndash_adjust_date_time_display( $last_update_time, 'M d, Y h:ia' ); ?></span></p> <?php } ?> <a id="learndash-translation-refresh" class="button button-primary learndash-translations-refresh" href="<?php echo LearnDash_Translations::get_action_url( 'refresh' ); ?> "><?php esc_html_e( 'Refresh', 'learndash' ); ?></a> </div> <div class="clear"></div> </div><!-- #major-publishing-actions --> </div><!-- #submitpost --> <?php } /** * This is a requires function. */ public function load_settings_fields() { } } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Translations_Refresh::add_section_instance(); } ); settings-sections/class-ld-settings-section-permalinks-taxonomies.php 0000666 00000023650 15214240575 0022312 0 ustar 00 <?php /** * LearnDash Settings Section for Permalink Taxonomies. These are shown are input fields on the WP Settings > 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(); } ); settings-sections/class-ld-settings-section-quizzes-management-display.php 0000666 00000056453 15214240575 0023257 0 ustar 00 <?php /** * LearnDash Settings Section for Quizzes Management and Display Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Quizzes_Management_Display' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Quizzes_Management_Display extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->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_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 = '<span class="error">' . 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' ), '<strong><a href="' . add_query_arg( 'page', 'learndash_data_upgrades', 'admin.php' ) . '">Upgrade WPProQuiz Question</a></strong>' ) . '</span>'; } $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' ) ), '<code>' . get_option( 'date_format' ) . '</code>', '<code>' . get_option( 'time_format' ) . '</code>' ); $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 => '<span class="date-time-text format-i18n">' . date_i18n( $wp_date_time_format ) . '</span><code>' . $wp_date_format . ' ' . $wp_time_format . '</code> - ' . __( 'WordPress default', 'learndash' ), ); foreach ( $date_time_formats as $format ) { if ( ! isset( $options[ $format ] ) ) { $options[ $format ] = '<span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . $format . '</code>'; } } } $options['custom'] = '<span class="date-time-text format-i18n">' . esc_html__( 'Custom', 'learndash' ) . '</span><input type="text" class="-small" name="statistics_time_format_custom" id="statistics_time_format_custom" value="' . $this->setting_option_values['statistics_time_format'] . '">'; 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'] = '<span class="date-time-text format-i18n">' . esc_html__( 'Custom', 'learndash' ) . '</span><input type="text" class="-small" name="toplist_date_format_custom" id="toplist_time_format_custom" value="' . $this->setting_option_values['toplist_time_format'] . '">'; 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'] = '<span style="color: green" >' . __( 'Template updated.', 'learndash' ) . '</span>'; } } } } } 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'] = '<span style="color: green" >' . __( 'Template deleted.', 'learndash' ) . '</span>'; } } } } } } } 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(); } ); settings-sections/class-ld-settings-section-support-database-tables.php 0000666 00000013041 15214240575 0022500 0 ustar 00 <?php /** * LearnDash Settings Section for Support Database Tables Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_Database_Tables' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_Database_Tables extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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'] = '<p>' . 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' ) . '</p>'; $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'] .= '<p style="color: red">' . esc_html__( 'The DB_USER defined in your wp-config.php does not have CREATE permission.', 'learndash' ) . '</p>'; } } $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'] = '<span style="color: green">' . esc_html__( 'Yes', 'learndash' ) . '</span>' . $rows_str; } else { $this->settings_set['settings'][ $db_table ]['value'] = 'No' . ' - (X)'; $this->settings_set['settings'][ $db_table ]['value_html'] = '<span style="color: red">' . esc_html__( 'No', 'learndash' ) . '</span>'; } } } $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(); } ); settings-sections/class-ld-settings-section-support-templates.php 0000666 00000026416 15214240575 0021474 0 ustar 00 <?php /** * LearnDash Settings Section for Support Templates Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_Templates' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_Templates extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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'] .= '<p><strong>' . esc_html__( 'Current Active LD Theme', 'learndash' ) . '</strong>: ' . LearnDash_Theme_Register::get_active_theme_name() . '</p>'; $template_paths = SFWD_LMS::get_template_paths( 'xxx.php' ); $theme_root = get_theme_root(); $theme_root = str_replace( '\\', '/', $theme_root ); $this->settings_set['desc'] .= '<p>' . esc_html__( 'The following is the search order paths for override templates, relative to site root:', 'learndash' ); $this->settings_set['desc'] .= '<ol>'; 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'] .= '<li>' . str_replace( $ABSPATH_tmp, '/', $theme_root ) . '/' . esc_html__( '<PARENT or CHILD THEME>', 'learndash' ) . $theme_path . '</li>'; } } 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'] .= '<li>' . str_replace( $ABSPATH_tmp, '/', $theme_path ) . '</li>'; } } $this->settings_set['desc'] .= '</ol></p>'; $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'] = '<span style="color: red;">' . str_replace( $ABSPATH_tmp, '', $template_path ) . '</span>'; $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(); } ); settings-sections/class-ld-settings-section-support-wordpress.php 0000666 00000016400 15214240575 0021516 0 ustar 00 <?php /** * LearnDash Settings Section for Support WordPress Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_WordPress' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_WordPress extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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 = '<span style="color: green">' . esc_html__( 'Yes', 'learndash' ) . '</span>'; $value = 'Yes'; } else { $value_html = '<span style="color: red">' . esc_html__( 'No', 'learndash' ) . '</span>'; $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 = '<span style="color: red;">' . $defined_value_html . '</span> - <a target="_blank" href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">' . esc_html__( 'Recommended at least 100M memory.', 'learndash' ) . '</a>'; } else { $defined_value_html = '<span style="color: green;">' . $defined_value_html . '</span>'; } } 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 = '<span style="color: red;">' . $defined_value_html . '</span> - <a target="_blank" href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">' . esc_html__( 'Recommended at least 256M memory.', 'learndash' ) . '</a>'; } else { $defined_value_html = '<span style="color: green;">' . $defined_value_html . '</span>'; } } $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(); } ); settings-sections/class-ld-settings-section-support-wordpress-plugins.php 0000666 00000011112 15214240575 0023170 0 ustar 00 <?php /** * LearnDash Settings Section for Support WordPress Plugins Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_WordPress_Plugins' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_WordPress_Plugins extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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 .= ' <span style="color:red;">' . esc_html__( 'Update available', 'learndash' ) . ': ' . $current_plugins->response[ $plugin_key ]->new_version . '</span>'; } } $plugin_value .= ' Path: ' . $plugin_data['PluginURI']; $plugin_value_html .= '<br />' . 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(); } ); settings-sections/class-ld-settings-section-quizzes-email-settings.php 0000666 00000033400 15214240575 0022410 0 ustar 00 <?php /** * LearnDash Settings Section Quiz Email Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Quizzes_Email' ) ) ) { /** * Class to create the Quiz Email Section. */ class LearnDash_Settings_Quizzes_Email extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->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_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' ), '(<strong>' . get_option( 'admin_email' ) . '</strong>)' ), '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' => '<div> <h4>' . esc_html__( 'Supported variables', 'learndash' ) . ':</h4> <ul> <li><span>$userId</span> - ' . esc_html__( 'User-ID', 'learndash' ) . '</li> <li><span>$username</span> - ' . esc_html__( 'Username', 'learndash' ) . '</li> <li><span>$quizname</span> - ' . esc_html__( 'Quiz-Name', 'learndash' ) . '</li> <li><span>$result</span> - ' . esc_html__( 'Result in percent', 'learndash' ) . '</li> <li><span>$points</span> - ' . esc_html__( 'Reached points', 'learndash' ) . '</li> <li><span>$ip</span> - ' . esc_html__( 'IP-address of the user', 'learndash' ) . '</li> <li><span>$categories</span> - ' . esc_html__( 'Category-Overview', 'learndash' ) . '</li> </ul> </div>', ), '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' ), '(<strong>' . get_option( 'admin_email' ) . '</strong>)' ), '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' => '<div> <h4>' . esc_html__( 'Supported variables', 'learndash' ) . ':</h4> <ul> <li><span>$userId</span> - ' . esc_html__( 'User-ID', 'learndash' ) . '</li> <li><span>$username</span> - ' . esc_html__( 'Username', 'learndash' ) . '</li> <li><span>$quizname</span> - ' . esc_html__( 'Quiz-Name', 'learndash' ) . '</li> <li><span>$result</span> - ' . esc_html__( 'Result in percent', 'learndash' ) . '</li> <li><span>$points</span> - ' . esc_html__( 'Reached points', 'learndash' ) . '</li> <li><span>$ip</span> - ' . esc_html__( 'IP-address of the user', 'learndash' ) . '</li> <li><span>$categories</span> - ' . esc_html__( 'Category-Overview', 'learndash' ) . '</li> </ul> </div>', ), '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 .= '<div class="ld-divider"></div>'; } } 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 .= '<div class="ld-settings-email-header-wrapper">'; $content .= '<div class="ld-settings-email-header">'; $content .= esc_html__( 'ADMIN NOTIFICATIONS', 'learndash' ); $content .= '</div>'; $content .= '<div class="ld-settings-email-description">'; $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 .= '</div>'; $content .= '</div>'; } if ( 'user_mail_from_name' === $field_args['name'] ) { $content .= '<div class="ld-settings-email-header-wrapper">'; $content .= '<div class="ld-settings-email-header">'; $content .= esc_html__( 'USER NOTIFICATIONS', 'learndash' ); $content .= '</div>'; $content .= '<div class="ld-settings-email-description">'; $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 .= '</div>'; $content .= '</div>'; } } return $content; } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Quizzes_Email::add_section_instance(); } ); settings-sections/class-ld-settings-section-support-data-reset.php 0000666 00000011014 15214240575 0021513 0 ustar 00 <?php /** * LearnDash Settings Section for Support Data Reset Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Data_Reset' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Data_Reset extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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() ); ?> <hr style="margin-top: 30px; border-top: 5px solid red;"/> <div class="learndash-support-settings-desc"><p><?php _e( '<span style="color:red;">Warning: This will remove ALL LearnDash data including any custom database tables.</style></span>', 'learndash' ); ?></p></div> <hr style="margin-top: 0px; border-top: 5px solid red;"/> <form id="ld_data_remove_form" method="POST"> <input type="hidden" name="ld_data_remove_nonce" value="<?php echo $remove_nonce; ?>" /> <p> <label for="ld_data_remove_verify"><?php _e( '<strong>Confirm the data deletion</strong>', 'learndash' ); ?></label><br /> <input id="ld_data_remove_verify" name="ld_data_remove_verify" type="text" size="50" style="width: 100%;" value="" data-confirm="<?php esc_html_e( 'Are you sure that you want to remove ALL LearnDash data?', 'learndash' ) ?>" /><br /> <span class="description"> <?php printf( // translators: placeholder: secret generated code. _x( 'Enter <code>%s</code> in the above field and click the submit button', 'placeholder: secret generated code', 'learndash' ), $remove_nonce ); ?> </span></p> <p><input type="submit" value="<?php esc_html_e( 'Submit', 'learndash' ); ?>" /></p> </form> <?php $js_confirm_message = esc_html__( 'Are you sure that you want to remove ALL LearnDash data?', 'learndash' ); ?> <script> </script> <?php } } } // End of functions. } } add_action( 'learndash_settings_sections_init', function() { LearnDash_Settings_Section_Data_Reset::add_section_instance(); } ); settings-sections/class-ld-settings-section-support-server.php 0000666 00000024013 15214240575 0020773 0 ustar 00 <?php /** * LearnDash Settings Section for Support Server Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_Server' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_Server extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * PHP ini settings array. * * @var array $php_ini_settings Array of PHP settings to check. */ private $php_ini_settings = array( 'max_execution_time', 'max_input_time', 'max_input_vars', 'post_max_size', 'max_file_uploads', 'upload_max_filesize' ); /** * PHP extensions array. * * @var array $php_extensions Array of PHP extensions to check. */ private $php_extensions = array( 'mbstring' ); /** * Protected constructor for class */ protected function __construct() { $this->settings_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'] = '<span style="color: ' . $color . '">' . $php_version . '</span>'; if ( -1 == $version_compare ) { $this->settings_set['settings']['phpversion']['value_html'] .= ' - <a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress Minimum Requirements', 'learndash' ) . '</a>'; } 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'] = '<span style="color: ' . $color . '">' . $mysql_version . '</span>'; if ( -1 == $version_compare ) { $this->settings_set['settings']['mysql_version']['value_html'] .= ' - <a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress Minimum Requirements', 'learndash' ) . '</a>'; } } $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'] = '<span style="color: red">' . esc_html__( 'No', 'learndash' ) . '</span>'; } else { $this->settings_set['settings']['curl']['value'] = 'Yes<br />'; $this->settings_set['settings']['curl']['value_html'] = '<span style="color: green">' . esc_html__( 'Yes', 'learndash' ) . '</span><br />'; $version = curl_version(); $this->settings_set['settings']['curl']['value'] .= 'Version: ' . $version['version'] . '<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Version', 'learndash' ) . ': ' . $version['version'] . '<br />'; $this->settings_set['settings']['curl']['value'] .= 'SSL Version: ' . $version['ssl_version'] . '<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'SSL Version', 'learndash' ) . ': ' . $version['ssl_version'] . '<br />'; $this->settings_set['settings']['curl']['value'] .= 'Libz Version: ' . $version['libz_version'] . '<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Libz Version', 'learndash' ) . ': ' . $version['libz_version'] . '<br />'; $this->settings_set['settings']['curl']['value'] .= 'Protocols: ' . join( ', ', $version['protocols'] ) . '<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Protocols', 'learndash' ) . ': ' . join( ', ', $version['protocols'] ) . '<br />'; 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)<br />'; $this->settings_set['settings']['curl']['value_html'] .= '<span style="color: red">' . 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' ) . '</span><br />'; } 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)<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Path to the CA certificates not set.', 'learndash' ) . '</span><br />'; } } else { $this->settings_set['settings']['curl']['value'] .= 'Path to the CA certificates: ' . $ca_certificates_path . '<br />'; $this->settings_set['settings']['curl']['value_html'] .= esc_html__( 'Path to the CA certificates', 'learndash' ) . ': ' . $ca_certificates_path . '</span><br />'; } } } } $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' ) : '<span style="color: red">' . esc_html__( 'No', 'learndash' ) . '</span>', ); } } $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(); } ); settings-sections/class-ld-settings-section-translations-learndash.php 0000666 00000002744 15214240575 0022442 0 ustar 00 <?php /** * LearnDash Settings Section for Translations LearnDash Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Translations_LearnDash' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Translations_LearnDash extends LearnDash_Settings_Section { /** * Must match the Text Domain. * * @var string $project_slug String for project. */ private $project_slug = 'learndash'; /** * Protected constructor for class */ protected function __construct() { $this->settings_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 ); } settings-sections/class-ld-settings-section-support-wordpress-themes.php 0000666 00000011037 15214240575 0023002 0 ustar 00 <?php /** * LearnDash Settings Section for Support WordPress Themes Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Support_WordPress_Themes' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Support_WordPress_Themes extends LearnDash_Settings_Section { /** * Settings set array for this section. * * @var array $settings_set Array of settings used by this section. */ protected $settings_set = array(); /** * Protected constructor for class */ protected function __construct() { $this->settings_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 .= ' <span style="color:red;">' . esc_html__( 'Update available', 'learndash' ) . ': ' . $themes_update->response[ $theme_stylesheet ]['new_version'] . '</span>'; } } $theme_value .= ' Path: ' . $current_theme->get( 'ThemeURI' ); $theme_value_html .= '<br />' . 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(); } ); settings-sections/class-ld-settings-section-assignments-cpt.php 0000666 00000007347 15214240575 0021105 0 ustar 00 <?php /** * LearnDash Settings Section for Assignments Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Assignments_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Assignments_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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(); } ); settings-sections/class-ld-settings-section-lessons-taxonomies.php 0000666 00000012114 15214240575 0021624 0 ustar 00 <?php /** * LearnDash Settings Section for Lessons Taxonomies Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Lessons_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Lessons_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-data-upgrades.php 0000666 00000002543 15214240575 0020500 0 ustar 00 <?php /** * LearnDash Settings Section for Data Upgrades Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Data_Upgrades' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Data_Upgrades extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-side-quick-links.php 0000666 00000006124 15214240575 0021132 0 ustar 00 <?php /** * LearnDash Settings Page Quizzes Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Side_Quick_Links' ) ) ) { /** * Class to create the settings metabox. */ class LearnDash_Settings_Section_Side_Quick_Links extends LearnDash_Settings_Section { /** * Public constructor for class * * @param array $args Array of class args. */ public function __construct( $args = array() ) { if ( ( isset( $args['settings_screen_id'] ) ) && ( ! empty( $args['settings_screen_id'] ) ) ) { $this->settings_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; ?> <div id="ld_quick-links" class="submitbox"> <?php $q_links = array(); if ( ( isset( $wp_meta_boxes[ $this->settings_screen_id ] ) ) && ( ! empty( $wp_meta_boxes[ $this->settings_screen_id ] ) ) ) { foreach ( $wp_meta_boxes[ $this->settings_screen_id ] as $mb_context => $mb_set_priority ) { if ( 'side' !== $mb_context ) { foreach ( $mb_set_priority as $priority => $mb_set ) { if ( ! empty( $mb_set ) ) { foreach ( $mb_set as $mb ) { if ( ( ! empty( $mb['id'] ) ) && ( ! empty( $mb['title'] ) ) ) { $q_links[ $mb['id'] ] = $mb['title']; } } } } } } if ( ! empty( $q_links ) ) { echo '<ul>'; $meta_box_order = get_user_option( 'meta-box-order_' . $this->settings_screen_id ); if ( ( isset( $meta_box_order['normal'] ) ) && ( ! empty( $meta_box_order['normal'] ) ) ) { $meta_box_order_items = explode( ',', $meta_box_order['normal'] ); foreach ( $meta_box_order_items as $meta_box_order_item ) { $meta_box_order_item = trim( $meta_box_order_item ); if ( isset( $q_links[ $meta_box_order_item ] ) ) { echo '<li><a href="#' . $meta_box_order_item . '" >' . $q_links[ $meta_box_order_item ] . '</a></li>'; unset( $q_links[ $meta_box_order_item ] ); } } } if ( ! empty( $q_links ) ) { foreach ( $q_links as $link_id => $link_title ) { echo '<li><a href="#' . $link_id . '" >' . $link_title . '</a></li>'; } } echo '</ul>'; } } ?> </div><!-- #submitpost --> <?php } // This is a requires function. public function load_settings_fields() { } } } settings-sections/class-ld-settings-section-quizzes-cpt.php 0000666 00000020640 15214240575 0020253 0 ustar 00 <?php /** * LearnDash Settings Section for Quiz Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Quizzes_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Quizzes_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->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' ), '<a href="' . admin_url( 'options-permalink.php' ) . '">' . esc_html__( 're-save your permalinks', 'learndash' ) . '</a>' ), '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' ), '<code><a target="blank" href="' . $cpt_archive_url . '">' . $cpt_archive_url . '</a></code>' ), ), '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' ), '<code><a target="blank" href="' . $cpt_rss_url . '">' . $cpt_rss_url . '</a></code>' ), ), '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(); } ); settings-sections/class-ld-settings-section-general-per-page.php 0000666 00000020272 15214240575 0021071 0 ustar 00 <?php /** * LearnDash Settings Section for Per Page Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_General_Per_Page' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_General_Per_Page extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-questions-taxonomies.php 0000666 00000025034 15214240575 0022175 0 ustar 00 <?php /** * LearnDash Settings Section for Question Taxonomies Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Questions_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Questions_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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'] = '<span style="color: green" >' . __( 'Category updated.', 'learndash' ) . '</span>'; } } } } } 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'] = '<span style="color: green" >' . __( 'Category deleted.', 'learndash' ) . '</span>'; } } } } } } } 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(); } ); settings-sections/class-ld-settings-section-quizzes-taxonomies.php 0000666 00000012211 15214240575 0021646 0 ustar 00 <?php /** * LearnDash Settings Section for Quiz Taxonomies Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Quizzes_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Quizzes_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->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_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(); } ); settings-sections/class-ld-settings-section-questions-cpt.php 0000666 00000005132 15214240575 0020572 0 ustar 00 <?php /** * LearnDash Settings Section for Question Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Questions_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Questions_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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( '<p>Control the LearnDash %s Custom Post Type Options.</p>', '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(); } ); settings-sections/class-ld-settings-section-topics-cpt.php 0000666 00000020652 15214240575 0020045 0 ustar 00 <?php /** * LearnDash Settings Section for Topics Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Topics_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Topics_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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' ), '<a href="' . admin_url( 'options-permalink.php' ) . '">' . esc_html__( 're-save your permalinks', 'learndash' ) . '</a>' ), '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' ), '<code><a target="blank" href="' . $cpt_archive_url . '">' . $cpt_archive_url . '</a></code>' ), ), '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' ), '<code><a target="blank" href="' . $cpt_rss_url . '">' . $cpt_rss_url . '</a></code>' ), ), '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(); } ); settings-sections/class-ld-settings-section-custom-labels.php 0000666 00000020241 15214240575 0020524 0 ustar 00 <?php /** * LearnDash Settings Section for Custom Labels Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Custom_Labels' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_Custom_Labels extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-general-login-registration.php 0000666 00000007710 15214240575 0023213 0 ustar 00 <?php /** * LearnDash Settings Section for Login Registration Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_General_Login_Registration' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_General_Login_Registration extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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(); } ); settings-sections/class-ld-settings-section-topics-taxonomies.php 0000666 00000012075 15214240575 0021445 0 ustar 00 <?php /** * LearnDash Settings Section for Topics Taxonomies Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Topics_Taxonomies' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Topics_Taxonomies extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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(); } ); settings-sections/class-ld-settings-section-paypal.php 0000666 00000023674 15214240575 0017255 0 ustar 00 <?php /** * LearnDash Settings Section for PayPal Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_PayPal' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Section_PayPal extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { $this->settings_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' ), '<a href="https://developer.paypal.com/docs/classic/api/currency_codes/" target="_blank">' . __( 'Currency Codes', 'learndash' ) . '</a>' ), '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' ), '<a href="https://developer.paypal.com/docs/classic/api/country_codes/" target="_blank">' . __( 'Country Codes', 'learndash' ) . '</a>' ), '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(); } ); settings-sections/class-ld-settings-section-permalinks.php 0000666 00000026033 15214240575 0020124 0 ustar 00 <?php /** * LearnDash Settings Section for Permalinks section shown on WP Settings > 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.<br />For example instead of the default topic URL <code>%5$s</code> the nested URL would be <code>%6$s</code>. If <a href="%7$s">Course Builder Share Steps</a> 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(); } ); settings-sections/class-ld-settings-section-lessons-cpt.php 0000666 00000020666 15214240575 0020237 0 ustar 00 <?php /** * LearnDash Settings Section for Lessons Custom Post Type Metabox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Lessons_CPT' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Lessons_CPT extends LearnDash_Settings_Section { /** * Protected constructor for class */ protected function __construct() { // What screen ID are we showing on. $this->settings_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' ), '<a href="' . admin_url( 'options-permalink.php' ) . '">' . esc_html__( 're-save your permalinks', 'learndash' ) . '</a>' ), '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' ), '<code><a target="blank" href="' . $cpt_archive_url . '">' . $cpt_archive_url . '</a></code>' ), ), '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' ), '<code><a target="blank" href="' . $cpt_rss_url . '">' . $cpt_rss_url . '</a></code>' ), ), '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(); } ); settings-sections/class-ld-settings-section-side-submit.php 0000666 00000003772 15214240575 0020211 0 ustar 00 <?php /** * LearnDash Settings Page Quizzes Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Side_Submit' ) ) ) { /** * Class to create the settings metabox. */ class LearnDash_Settings_Section_Side_Submit extends LearnDash_Settings_Section { /** * Public constructor for class * * @param array $args Array of class args. */ public function __construct( $args = array() ) { if ( ( isset( $args['settings_screen_id'] ) ) && ( ! empty( $args['settings_screen_id'] ) ) ) { $this->settings_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() { ?> <div id="submitpost" class="submitbox"> <div id="major-publishing-actions"> <div id="publishing-action"> <span class="spinner"></span> <?php submit_button( esc_html__( 'Save', 'learndash' ), 'primary', 'submit', false ); ?> </div> <div class="clear"></div> </div><!-- #major-publishing-actions --> </div><!-- #submitpost --> <?php } // This is a requires function public function load_settings_fields() { } } } class-ld-settings-fields.php 0000666 00000057631 15214240575 0012106 0 ustar 00 <?php /** * LearnDash Settings Fields API. * * @package LearnDash * @subpackage Settings */ if ( ! class_exists( 'LearnDash_Settings_Fields' ) ) { /** * Class to create the settings field. */ abstract class LearnDash_Settings_Fields { /** * Array to hold all field type instances. * * @var array */ protected static $_instances = array(); /** * Define the field type 'text', 'select', etc. This is unique. * * @var string */ protected $field_type = ''; /** * Public constructor for class */ public function __construct() { } /** * Get field instance by key * * @since 2.4 * * @param string $field_key Key to unique field instance. * * @return object instance of field if present. */ final public static function get_field_instance( $field_key = '' ) { if ( ! empty( $field_key ) ) { if ( isset( self::$_instances[ $field_key ] ) ) { return self::$_instances[ $field_key ]; } } } /** * Add field instance by key * * @since 2.4 * * @param string $field_key Key to unique field instance. * * @return object instance of field if present. */ final public static function add_field_instance( $field_key = '' ) { if ( ! empty( $field_key ) ) { if ( ! isset( self::$_instances[ $field_key ] ) ) { $section_class = get_called_class(); self::$_instances[ $field_key ] = new $section_class(); } return self::$_instances[ $field_key ]; } } /** * Utility function so we are not hard coding the create/validate * member functions in various settings files. * * @since 2.4 * * @return reference to validation function. */ final public function get_creation_function_ref() { return array( $this, 'create_section_field' ); } /** * Utility function so we are not hard coding the create/validate * member functions in various settings files. * * @since 2.4 * * @return reference to validation function. */ final public function get_validation_function_ref() { return array( $this, 'validate_section_field' ); } /** * Utility function so we are not hard coding the create/validate * member functions in various settings files. * * @since 3.0 * * @return reference to validation function. */ final public function get_value_function_ref() { return array( $this, 'value_section_field' ); } /** * Show all fields in section. * * @since 2.4 * * @param array $section_fields Array of fields for section. */ public static function show_section_fields( $section_fields = array() ) { if ( ! empty( $section_fields ) ) { $parents_settings = array(); foreach ( $section_fields as $field_id => $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 '<div class="ld-settings-sub ld-settings-sub-level-' . count( $parents_settings ) . ' ld-settings-sub-' . $field['args']['parent_setting'] . ' ld-settings-sub-state-' . $child_setting_state . '" data-parent-field="' . $field['args']['setting_option_key'] . '_' . $field['args']['parent_setting'] . '_field">'; } 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 '</div>'; 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 '</div>'; 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 '</div>'; 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; } ?> <div id="<?php echo $field['args']['id']; ?>_field" class="sfwd_input <?php echo $field_class; ?> <?php echo $field_error_class; ?>"> <?php $output = apply_filters( 'learndash_settings_row_inside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> <?php if ( ( isset( $field['args']['row_description_before'] ) ) && ( ! empty( $field['args']['row_description_before'] ) ) ) { echo '<span class="sfwd_row_description sfwd_row_description_before">' . esc_html( $field['args']['row_description_before'] ) . '</span>'; } ?> <?php if ( ( ! isset( $field['args']['label_none'] ) ) || ( true !== $field['args']['label_none'] ) ) { ?> <?php $output = apply_filters( 'learndash_settings_row_label_outside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; } ?> <span class="sfwd_option_label <?php if ( ( isset( $field['args']['label_full'] ) ) && ( true === $field['args']['label_full'] ) ) { echo ' sfwd_option_label_full'; } ?> "> <?php $output = apply_filters( 'learndash_settings_row_label_inside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> <a class="sfwd_help_text_link" <?php if ( ( isset( $field['args']['help_text'] ) ) && ( ! empty( $field['args']['help_text'] ) ) ) { ?> style="cursor:pointer;" title="<?php esc_html_e( 'Click for Help!', 'learndash' ); ?>" onclick="toggleVisibility('<?php echo $field['args']['id']; ?>_tip');" <?php } ?> > <?php if ( ( isset( $field['args']['help_text'] ) ) && ( ! empty( $field['args']['help_text'] ) ) ) { ?> <img alt="" src="<?php echo LEARNDASH_LMS_PLUGIN_URL; ?>assets/images/question.png" /> <?php } ?> <label for="<?php echo esc_attr( $field['args']['label_for'] ); ?>" class="sfwd_label"> <?php if ( ( isset( $field['args']['label'] ) ) && ( ! empty( $field['args']['label'] ) ) ) { echo $field['args']['label']; } if ( isset( $field['args']['required'] ) ) { ?> <span class="learndash_required_field"><abbr title="<?php esc_html_e( 'Required', 'learndash' ); ?>">*</abbr></span> <?php } ?> </label> </a> <?php if ( ( isset( $field['args']['label_description'] ) ) && ( ! empty( $field['args']['label_description'] ) ) ) { ?> <span class="descripton"><?php echo $field['args']['label_description']; ?></span> <?php } if ( ( isset( $field['args']['help_text'] ) ) && ( ! empty( $field['args']['help_text'] ) ) ) { if ( ( isset( $field['args']['help_show'] ) ) && ( true === $field['args']['help_show'] ) ) { $help_style = ' style="display: block !important;" '; } else { $help_style = ' style="display: none;" '; } ?> <div id="<?php echo $field['args']['id']; ?>_tip" class="sfwd_help_text_div" <?php echo $help_style; ?>> <label class="sfwd_help_text"><?php echo $field['args']['help_text']; ?></label> </div> <?php } ?> <?php $output = apply_filters( 'learndash_settings_row_label_inside_after', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> </span> <?php $output = apply_filters( 'learndash_settings_row_label_outside_after', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> <?php } ?> <?php $output = apply_filters( 'learndash_settings_row_input_outside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> <span class="sfwd_option_input <?php if ( ( isset( $field['args']['input_full'] ) ) && ( true === $field['args']['input_full'] ) ) { echo ' sfwd_option_input_full'; } ?> "> <?php $output = apply_filters( 'learndash_settings_row_input_inside_before', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; } if ( ( ! isset( $field['args']['input_show'] ) ) || ( true === $field['args']['input_show'] ) ) { ?> <div class="sfwd_option_div"> <?php call_user_func( $field['args']['display_callback'], $field['args'] ); ?> </div> <?php } $output = apply_filters( 'learndash_settings_row_input_inside_after', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> </span> <?php $output = apply_filters( 'learndash_settings_row_input_outside_after', '<p class="ld-clear"></p>', $field['args'] ); if ( ! empty( $output ) ) { echo $output; }; ?> <?php if ( ( isset( $field['args']['row_description_after'] ) ) && ( ! empty( $field['args']['row_description_after'] ) ) ) { echo '<span class="sfwd_row_description sfwd_row_description_after">' . esc_html( $field['args']['row_description_after'] ) . '</span>'; } ?> <?php $output = apply_filters( 'learndash_settings_row_inside_after', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; } ?> </div> <?php $output = apply_filters( 'learndash_settings_row_outside_after', '', $field['args'] ); if ( ! empty( $output ) ) { echo $output; } } else { if ( ( isset( $field['callback'] ) ) && ( ! empty( $field['callback'] ) ) && ( is_callable( $field['callback'] ) ) ) { call_user_func( $field['callback'], $field['args'] ); } } if ( ( isset( $field['args']['desc_after'] ) ) && ( ! empty( $field['args']['desc_after'] ) ) ) { echo wptexturize( $field['args']['desc_after'] ); } } /** * Skeleton function to create the field output. * * @since 2.4 * * @param array $field_args main field args array. */ public function create_section_field( $field_args = array() ) { return; } /** * Create the HTML output from the field args 'id' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * @param boolean $wrap Flag to wrap field atrribute in normal output or just return value. * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_id( $field_args = array(), $wrap = true ) { $field_attribute = ''; if ( isset( $field_args['id'] ) ) { if ( true === $wrap ) { $field_attribute .= ' id="' . $field_args['id'] . '" '; } else { $field_attribute .= $field_args['id']; } } return $field_attribute; } /** * Create the HTML output from the field args 'required' 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_required( $field_args = array() ) { $field_attribute = ''; if ( isset( $field_args['required'] ) ) { $field_attribute .= ' required="' . $field_args['required'] . '" '; } return $field_attribute; } /** * Create the HTML output from the field args 'name' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * @param boolean $wrap Flag to wrap field atrribute in normal output or just return value. * * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_name( $field_args = array(), $wrap = true ) { $field_attribute = ''; if ( isset( $field_args['name'] ) ) { $field_multiple = ''; if ( ( isset( $field_args['multiple'] ) ) && ( true == $field_args['multiple'] ) ) { $field_multiple = '[]'; } if ( ! empty( $field_args['setting_option_key'] ) ) { if ( true === $wrap ) { if ( ( isset( $field_args['name_wrap'] ) ) && ( true === $field_args['name_wrap'] ) ) { $field_attribute .= ' name="' . $field_args['setting_option_key'] . '[' . $field_args['name'] . ']' . $field_multiple . '" '; } else { $field_attribute .= ' name="' . $field_args['name'] . $field_multiple . '" '; } } else { if ( ( isset( $field_args['name_wrap'] ) ) && ( true === $field_args['name_wrap'] ) ) { $field_attribute .= $field_args['setting_option_key'] . '[' . $field_args['name'] . ']'; } else { $field_attribute .= $field_args['name']; } } } else { if ( true === $wrap ) { $field_attribute .= ' name="' . $field_args['name'] . $field_multiple . '" '; } else { $field_attribute .= $field_args['name'] . $field_multiple; } } } return $field_attribute; } /** * Create the HTML output from the field args 'placeholder' 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_placeholder( $field_args = array() ) { $field_attribute = ''; if ( ( isset( $field_args['placeholder'] ) ) && ( ! empty( $field_args['placeholder'] ) ) ) { $field_attribute .= ' placeholder="' . esc_html( $field_args['placeholder'] ) . '" '; } return $field_attribute; } /** * Create the HTML output from the field args 'placeholder' attribute. * * @since 2.4 * * @param array $field_args main field args array. should contain element for 'attrs'. * @param boolean $wrap Flag to wrap field atrribute in normal output or just return value. * @return string of HTML representation of the attrs array attributes. */ public function get_field_attribute_value( $field_args = array(), $wrap = true ) { $field_attribute = ''; if ( isset( $field_args['id'] ) ) { if ( true === $wrap ) { $field_attribute .= ' value="' . $field_args['value'] . '" '; } else { $field_attribute .= $field_args['value']; } } return $field_attribute; } /** * Create the HTML output from the field args 'legend' 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_legend( $field_args = array() ) { $field_legend = ''; if ( ( isset( $field_args['label'] ) ) && ( ! empty( $field_args['label'] ) ) ) { $field_legend .= '<legend class="screen-reader-text">'; $field_legend .= '<span>' . $field_args['label'] . '</span>'; $field_legend .= '</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 .= '<div class="learndash-section-field-error" style="display:none;">' . $field_args['input_error'] . '</div>'; } 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 .= '<span class="descripton">' . $field_args['input_description'] . '</span>'; } 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; } } } class-ld-settings-metaboxes.php 0000666 00000054521 15214240575 0012622 0 ustar 00 <?php /** * LearnDash Settings Metabox Abstract Class. * * @package LearnDash * @subpackage Settings */ //require_once LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-fields.php'; if ( ! class_exists( 'LearnDash_Settings_Metabox' ) ) { /** * Absract for LearnDash Settings Sections. */ abstract class LearnDash_Settings_Metabox { /** * Static array of section instances. * * @var array $_instances */ protected static $_instances = array(); /** * Match the WP Screen ID * * @var string $settings_screen_id Settings Screen ID. */ //protected $settings_screen_id = ''; /** * Store for all the fields in this section * * @var array $setting_option_fields Array of section fields. */ protected $setting_option_fields = array(); /** * Store for all the sub fields in this section * * @var array $settings_sub_option_fields Array of section sub fields. */ protected $settings_sub_option_fields = array(); /** * Holds the values for the fields. Read in from the wp_options item. * * @var array $setting_option_values Array of section values. */ protected $setting_option_values = array(); /** * Flag for if settings values have been loaded. * * @var boolean $settings_values_loaded Flag. */ protected $settings_values_loaded = false; /** * Flag for if settings fields have been loaded. * * @var boolean $settings_fields_loaded Flag. */ protected $settings_fields_loaded = false; /** * This is used as the option_name when the settings * are saved to the options table. * * @var string $settings_section_key */ protected $settings_metabox_key = ''; /** * Section label/header * This setting is used to show in the title of the metabox or section. * * @var string $settings_section_label */ protected $settings_section_label = ''; /** * Used to show the section description above the fields. Can be empty. * * @var string $settings_section_description */ protected $settings_section_description = ''; /** * Unique ID used for metabox on page. Will be derived from * settings_option_key + setting_section_key * * @var string $metabox_key */ protected $metabox_key = ''; /** * Controls metabox context on page * See WordPress add_meta_box() function 'context' parameter. * * @var string $metabox_context */ protected $metabox_context = 'normal'; /** * Controls metabox priority on page * See WordPress add_meta_box() function 'priority' parameter. * * @var string $metabox_priority */ protected $metabox_priority = 'default'; /** * Lets the section define it's own display function instead of using the Settings API * * @var mixed $settings_fields_callback */ protected $settings_fields_callback = null; /** * Used on submit metaboxes to display reset confirmation popup message. * * @var string $reset_confirm_message */ protected $reset_confirm_message = ''; /** * Map internal settings field ID to legacy field ID. * * @var array $settings_fields_map */ protected $settings_fields_map = array(); /** * Legacy Settings fields. * * @var array $settings_fields_legacy */ protected $settings_fields_legacy = array(); /** * Legacy Settings values. * * @var array $settings_values_legacy */ protected $settings_values_legacy = array(); protected $_post = null; protected $_metabox = null; /** * Public constructor for class */ public function __construct() { add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); add_filter( $this->settings_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 '<div class="ld-metabox-description">' . wpautop( wp_kses_post( $this->settings_section_description ) ) . '</div>'; } } /** * 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 '<div class="wrap wpProQuiz_quizEdit">'; } do_action( 'learndash_metabox_options_div_before', $metabox->settings_metabox_key ); echo '<div class="sfwd sfwd_options ' . esc_attr( $metabox->settings_metabox_key ) . '">'; 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 '</div>'; do_action( 'learndash_metabox_options_div_after', $metabox->settings_metabox_key ); if ( learndash_get_post_type_slug( 'quiz' ) === $this->settings_screen_id ) { echo '</div>'; } } } } /** * 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. } } settings-loader.php 0000666 00000001213 15214240575 0010367 0 ustar 00 <?php /** * LearnDash Settings Loader. * * @package LearnDash * @subpackage Settings */ if ( ! defined( 'LEARNDASH_SETTINGS_SECTION_TYPE' ) ) { define( 'LEARNDASH_SETTINGS_SECTION_TYPE', 'metabox' ); } require_once __DIR__ . '/class-ld-settings-fields.php'; require_once __DIR__ . '/class-ld-settings-pages.php'; require_once __DIR__ . '/class-ld-settings-sections.php'; require_once __DIR__ . '/class-ld-settings-metaboxes.php'; require_once __DIR__ . '/settings-fields/settings-fields-loader.php'; require_once __DIR__ . '/settings-pages/settings-pages-loader.php'; require_once __DIR__ . '/settings-sections/settings-sections-loader.php'; settings-metaboxes/class-ld-settings-metabox-quiz-admin-data-handling-settings.php 0000666 00000121254 15214240575 0024520 0 ustar 00 <?php /** * LearnDash Settings Metabox for Quiz Admin & Data Handling Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings extends LearnDash_Settings_Metabox { protected $quiz_edit = null; /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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.<br /><strong>We do not recommend editing this</strong> 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' ), '<br /><a href="http://wordpress.org/extend/plugins/really-simple-captcha/" target="_blank">Really Simple CAPTCHA</a>' ), '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 ); } settings-metaboxes/class-ld-settings-metabox-course-navigation-settings.php 0000666 00000011131 15214240575 0023376 0 ustar 00 <?php /** * LearnDash Settings Metabox for Course Navigation Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Course_Navigation_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Course_Navigation_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-topic-display-content.php 0000666 00000100224 15214240575 0022336 0 ustar 00 <?php /** * LearnDash Settings Metabox for Topic Display and Content Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Topic_Display_Content' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Topic_Display_Content extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-quiz-access-settings.php 0000666 00000033174 15214240575 0022203 0 ustar 00 <?php /** * LearnDash Settings Metabox for Quiz Access Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Quiz_Access_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Quiz_Access_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-course-display-content.php 0000666 00000046572 15214240575 0022537 0 ustar 00 <?php /** * LearnDash Settings Metabox for Course Display and Content Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Course_Display_Content' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Course_Display_Content extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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' ), '<em>' . //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' ) . '</em>', '<em>' . //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' ) . '</em>' ), '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 ); } settings-metaboxes/class-ld-settings-metabox-lesson-access-settings.php 0000666 00000026341 15214240575 0022514 0 ustar 00 <?php /** * LearnDash Settings Metabox for Lesson Access Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Lesson_Access_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Lesson_Access_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-course-users.php 0000666 00000013016 15214240575 0020546 0 ustar 00 <?php /** * LearnDash Settings Metabox for Course Access Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Course_Users_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Course_Users_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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' ) ); ?> <div id="learndash_course_users_page_box" class="learndash_course_users_page_box"> <?php if ( ! empty( $metabox_description ) ) { echo wpautop( wp_kses_post( $metabox_description ) ); } $ld_binary_selector_course_users = new Learndash_Binary_Selector_Course_Users( $course_users_binary_args ); $ld_binary_selector_course_users->show(); ?> </div> <?php } else { ?> <p> <?php printf( // translators: placeholder: Course. esc_html_x( 'The %s price type is set to "open". This means ALL are automatically enrolled.', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ); ?> </p> <?php } } } } /** * 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 ( ( isset( $_POST['learndash_course_users_nonce'] ) ) && ( wp_verify_nonce( $_POST['learndash_course_users_nonce'], 'learndash_course_users_nonce_' . $post_id ) ) ) { if ( ( isset( $_POST['learndash_course_users'] ) ) && ( isset( $_POST['learndash_course_users'][ $post_id ] ) ) && ( ! empty( $_POST['learndash_course_users'][ $post_id ] ) ) ) { $course_users = (array) json_decode( stripslashes( $_POST['learndash_course_users'][ $post_id ] ) ); learndash_set_users_for_course( $post_id, $course_users ); } } } // 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_Users_Settings'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Course_Users_Settings' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Course_Users_Settings'] = LearnDash_Settings_Metabox_Course_Users_Settings::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } settings-metaboxes/class-ld-settings-metabox-course-access-settings.php 0000666 00000101761 15214240575 0022511 0 ustar 00 <?php /** * LearnDash Settings Metabox for Course Access Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Course_Access_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Course_Access_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->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<pre>'. print_r($course_access_list_meta_array, true) .'</pre>'); error_log('course_access_list_array<pre>'. print_r($course_access_list_array, true) .'</pre>'); $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' => '<a href="'. add_query_arg( 'course_access_list_meta', '1' ) . '">' . esc_html( 'click to show missing users', 'learndash' ) .'</a>', '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 ); } settings-metaboxes/class-ld-settings-metabox-topic-access-settings.php 0000666 00000020142 15214240575 0022320 0 ustar 00 <?php /** * LearnDash Settings Metabox for Topic Access Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Topic_Access_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Topic_Access_Settings extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-quiz-display-content.php 0000666 00000114144 15214240575 0022216 0 ustar 00 <?php /** * LearnDash Settings Metabox for Quiz Display and Content Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Quiz_Display_Content' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Quiz_Display_Content extends LearnDash_Settings_Metabox { /** * Variable to hold the number of questions. * @var integer $questions_count */ var $questions_count = 0; /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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 ); } settings-metaboxes/class-ld-settings-metabox-quiz-results-display-content-options.php 0000666 00000057750 15214240575 0025417 0 ustar 00 <?php /** * LearnDash Settings Metabox for Quiz Results Page Display & Content Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Quiz_Results_Options' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Quiz_Results_Options extends LearnDash_Settings_Metabox { protected $quiz_edit = null; /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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(); ?> <div id="learndash-quiz-resultList"> <ul id="resultList"> <?php $message_prozent_zero_found = false; for ( $i = 0; $i < LEARNDASH_QUIZ_RESULT_MESSAGE_MAX; $i++ ) { $message_text_value = ''; $message_prozent_value = 0; $message_activ_value = 0; $message_show_style = ''; $message_editor_style = ''; $message_input_disabled = ''; $message_delete_enabled = true; $message_arrow_direction = 'down'; $message_editor_style = 'display:none;'; if ( isset( $result_text['text'][ $i ] ) ) { $message_text_value = $result_text['text'][ $i ]; } if ( isset( $result_text['prozent'][ $i ] ) ) { $message_prozent_value = absint( $result_text['prozent'][ $i ] ); } if ( isset( $result_text['activ'][ $i ] ) ) { $message_activ_value = absint( $result_text['activ'][ $i ] ); } if ( true !== $message_prozent_zero_found ) { $message_input_disabled = ' readonly '; $message_prozent_zero_found = true; } else { $message_input_disabled = ''; } if ( empty( $message_activ_value ) ) { $message_show_style = ' display:none;'; $message_arrow_direction = 'up'; $message_editor_style = ''; $message_prozent_value = '1'; } elseif ( 0 === $i ) { $message_delete_enabled = false; $message_arrow_direction = 'up'; $message_editor_style = ''; } ?> <li style="<?php echo $message_show_style; ?>"> <div class="resultHeader"> <input type="hidden" value="<?php echo $message_activ_value; ?>" name="resultTextGrade[activ][]"> <?php echo sprintf( // translators: placeholder: input form field. esc_html_x( 'From %s %% score, display this message:', 'placeholder: input form field', 'learndash' ), '<input type="number" ' . $message_input_disabled . ' name="resultTextGrade[prozent][]" min="1" max="100" step="1" class="-small small-text" value="' . $message_prozent_value . '">' ); ?> <div class="expand-arrow expand-arrow-<?php echo esc_attr( $message_arrow_direction ); ?>"> <svg width="11" height="8" viewBox="0 0 14 8" xmlns="http://www.w3.org/2000/svg"><path d="M1 1l6 6 6-6" stroke="#0073aa" stroke-width="2" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg> </div> <?php if ( true === $message_delete_enabled ) { ?> <input type="button" value="<?php esc_html_e( 'Delete graduation', 'learndash' ); ?>" class="deleteResult"> <?php } ?> <div style="clear: right;"></div> </div> <div class="resultEditor" style="<?php echo $message_editor_style; ?>"> <?php wp_editor( $message_text_value, 'resultText_' . $i, array( 'textarea_rows' => 3, 'textarea_name' => 'resultTextGrade[text][]', ) ); ?> </div> </li> <?php } ?> </ul> <input type="button" class="addResult" name="addResult" id="addResult" value="<?php esc_html_e( 'Add graduation', 'learndash' ); ?>"> </div> <?php $html .= learndash_ob_get_clean( $level ); return $html; } // 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_Results_Options'] ) ) && ( class_exists( 'LearnDash_Settings_Metabox_Quiz_Results_Options' ) ) ) { $metaboxes['LearnDash_Settings_Metabox_Quiz_Results_Options'] = LearnDash_Settings_Metabox_Quiz_Results_Options::add_metabox_instance(); } return $metaboxes; }, 50, 1 ); } settings-metaboxes/class-ld-settings-metabox-lesson-display-content.php 0000666 00000102266 15214240575 0022533 0 ustar 00 <?php /** * LearnDash Settings Metabox for Lesson Display and Content Options. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Lesson_Display_Content' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Lesson_Display_Content extends LearnDash_Settings_Metabox { /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->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 ); } settings-metaboxes/class-ld-settings-metabox-quiz-progress-settings.php 0000666 00000046464 15214240575 0022614 0 ustar 00 <?php /** * LearnDash Settings Metabox for Quiz Progess Settings. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'LearnDash_Settings_Metabox_Quiz_Progress_Settings' ) ) ) { /** * Class to create the settings section. */ class LearnDash_Settings_Metabox_Quiz_Progress_Settings extends LearnDash_Settings_Metabox { protected $quiz_edit = null; /** * Public constructor for class */ public function __construct() { // What screen ID are we showing on. $this->settings_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' => '<div style="margin-top: 15px;"><input class="button-secondary" type="button" name="resetQuizLock" value="'. esc_html__('Reset the user identification', 'learndash') .'"><span id="resetLockMsg" style="display:none; background-color: rgb(255, 255, 173); border: 1px solid rgb(143, 143, 143); padding: 4px; margin-left: 5px; ">'. esc_html__('User identification has been reset.', 'learndash') .'</span><p class="description"></p></div>', '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' => '<div><input class="button-secondary" type="button" name="resetQuizLock" value="' . esc_html__( 'Reset the user identification', 'learndash' ) . '"><span id="resetLockMsg" style="display:none; background-color: rgb(255, 255, 173); border: 1px solid rgb(143, 143, 143); padding: 4px; margin-left: 5px; ">' . esc_html__( 'User identification has been reset.', 'learndash' ) . '</span><p class="description"></p></div>', '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 ); } settings-fields/class-ld-settings-fields-url.php 0000666 00000004246 15214240575 0016004 0 ustar 00 <?php /** * LearnDash Settings field URL. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_URL' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_URL extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input autocomplete="off" '; $html .= $this->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' ); } ); settings-fields/class-ld-settings-fields-media-upload.php 0000666 00000007337 15214240575 0017547 0 ustar 00 <?php /** * LearnDash Settings field Media Upload. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Media_Upload' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Media_Upload extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<fieldset>'; $html .= $this->get_field_legend( $field_args ); $html .= '<div class="learndash-section-field-media-upload_wrapper" '; $html .= ' id="' . $this->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 .= '<div class="image-preview-wrapper">'; $html .= '<img class="image-preview" src="' . $image_url . '" style="max-width: 100%; max-height: 200px; border: 1px dashed #ccc;" data-default="' . $default_img_url . '"/>'; $html .= '</div>'; $html .= '<input type="button" class="button image-remove-button" title="' . esc_html__( 'remove image', 'learndash' ) . '" value="' . esc_html_x( 'X', 'placeholder: clear image', 'learndash' ) . '" />'; $html .= '<input type="button" class="button image-upload-button" title="' . esc_html__( 'Select/upload image', 'learndash' ) . '" value="' . esc_html__( 'Select image', 'learndash' ) . '" />'; $html .= '<input '; $html .= ' type="hidden" '; $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( $image_id ) ) && ( ! empty( $image_id ) ) ) { $html .= ' value="' . $image_id . '" '; } else { $html .= ' value="" '; } $html .= ' />'; $html .= '</div>'; $html .= '</fieldset>'; $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' ); } ); settings-fields/class-ld-settings-fields-select.php 0000666 00000011217 15214240575 0016455 0 ustar 00 <?php /** * LearnDash Settings administration field Select. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Select' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Select extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<span class="ld-select">'; $html .= '<select autocomplete="off" '; $html .= $this->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 ); 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 ); //if ( ( isset( $field_args['multiple'] ) ) && ( true === $field_args['multiple'] ) ) { // $html .= ' multiple="multiple" '; //} $html .= $this->get_field_sub_trigger( $field_args ); $html .= $this->get_field_inner_trigger( $field_args ); $html .= ' >'; $html_sub_fields = ''; foreach ( $field_args['options'] as $option_key => $option_label ) { $selected_item = ''; if ( is_array( $field_args['value'] ) ) { if ( in_array( $option_key, $field_args['value'] ) ) { $selected_item = ' selected="" '; } } else { $selected_item = selected( $option_key, $field_args['value'], false ); } if ( is_array( $option_label ) ) { if ( ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '<option value="' . $option_key . '" ' . $selected_item . '>' . $option_label['label'] . '</option>'; } 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 .= '<div class="ld-settings-inner ld-settings-inner-' . $sub_field_key . ' ld-settings-inner-state-' . $inner_section_state . '">'; $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 .= '</div>'; } } } elseif ( is_string( $option_label ) ) { $html .= '<option value="' . $option_key . '" ' . $selected_item . '>' . $option_label . '</option>'; } } $html .= '</select>'; $html .= '</span>'; $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' ); } ); settings-fields/class-ld-settings-fields-quiz-templates-load.php 0000666 00000014701 15214240575 0021100 0 ustar 00 <?php /** * LearnDash Settings field Quiz Load Templates. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Quiz_Templates_Load' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Quiz_Templates_Load extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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() ); } } } /* <input autocomplete="off" type="checkbox" id="learndash-quiz-access-settings_startOnlyRegisteredUser-on" name="learndash-quiz-access-settings[startOnlyRegisteredUser]" class="learndash-section-field learndash-section-field-checkbox ld-checkbox-input" value="on"> <select autocomplete="off" type="select" name="learndash-quiz-progress-settings[certificate]" id="learndash-quiz-progress-settings_certificate" class="learndash-section-field learndash-section-field-select select2-hidden-accessible" data-ld-select2="1" data-settings-sub-trigger="ld-settings-sub-certificate" data-settings-inner-trigger="ld-settings-inner-certificate" tabindex="-1" aria-hidden="true"><option value="-1">Search or select a certificate…</option><option value="3136" selected="selected">Cert Test</option><option value="2047">Course Certificate</option><option value="2317">Quiz Certificate</option></select> */ $html .= '<span class="ld-select">'; // $html .= '<select class="learndash-section-field-select" data-ld-select2="1" name="templateLoadId">'; $html .= '<select autocomplete="off" '; $html .= $this->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 .= '<option value="' . $template_url . '">' . sprintf( // translators: Quiz Title. esc_html_x( 'Revert: %s', 'placeholder: Quiz Title', 'learndash' ), get_the_title( $_GET['post'] ) ) . '</option>'; } else { if ( ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === apply_filters( 'learndash_select2_lib', LEARNDASH_SELECT2_LIB ) ) ) { $html .= '<option value="-1">' . esc_html__( 'Search or select a template…', 'learndash' ) . '</option>'; } else { $html .= '<option value="">' . esc_html__( 'Select a Template to load', 'learndash' ) . '</option>'; } } 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 .= '<option ' . $selected . ' value="' . $template_url . '">' . $template_name . '</option>'; } } $html .= '</select>'; $html .= '</span><br />'; $html .= '<input type="submit" name="templateLoad" value="' . esc_html__( 'load template', 'learndash' ) . '" class="button-primary"></p>'; $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' ); } ); settings-fields/class-ld-settings-fields-quiz-templates-save.php 0000666 00000011062 15214240575 0021114 0 ustar 00 <?php /** * LearnDash Settings field Quiz / Question Templates. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Quiz_Templates_Save' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Quiz_Templates_Save extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<span class="ld-select">'; //$html .= '<select name="templateSaveList" class="learndash-section-field-select" data-ld-select2="1">'; $html .= '<select autocomplete="off" '; $html .= $this->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 .= ' <option value="-1">'; } else { $html .= ' <option value="">'; } $html .= esc_html__( 'Select a templates to save or new', 'learndash' ) . '</option>'; $html .= ' <option value="0">=== ' . esc_html__( 'Create new template', 'learndash' ) . ' === </option>'; if ( ! empty( $select_template_options ) ) { foreach ( $select_template_options as $template_id => $template_name ) { $html .= '<option value="' . $template_id . '">' . $template_name . '</option>'; } } $html .= '</select>'; $html .= '</span><br />'; $html .= '<input type="text" placeholder="' . esc_html__( 'new template name', 'learndash' ) . '" class="regular-text -medium" name="templateName">'; $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' ); } ); settings-fields/class-ld-settings-fields-checkbox.php 0000666 00000010666 15214240575 0016773 0 ustar 00 <?php /** * LearnDash Settings field Checkbox. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Checkbox' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Checkbox extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<fieldset>'; $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 .= '<p class="learndash-section-field-checkbox-p">'; $html .= '<input autocomplete="off" '; $html .= $this->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 .= '<label class="ld-checkbox-input__label" for="' . $field_args['id'] . '-' . $option_key . '" >'; if ( is_string( $option_label ) ) { $html .= '<span>' . $option_label . '</span></label></p>'; } elseif ( ( is_array( $option_label ) ) && ( ! empty( $option_label ) ) ) { if ( ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '<span>' . $option_label['label'] . '</span></label>'; } $html .= '</p>'; if ( ( isset( $option_label['description'] ) ) && ( ! empty( $option_label['description'] ) ) ) { $html .= '<p class="ld-checkbox-description">' . $option_label['description'] . '</p>'; } } else { $html .= '</p>'; } } //$html .= $this->get_field_attribute_input_label( $field_args ); $html .= '</fieldset>'; } $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' ); } ); settings-fields/class-ld-settings-fields-checkbox-switch.php 0000666 00000015572 15214240575 0020273 0 ustar 00 <?php /** * LearnDash Settings field Checkbox Switch / Toggle. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Checkbox_Switch' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Checkbox_Switch extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<fieldset>'; $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 .= ' <label for="' . $field_args['id'] . '" >'; $html .= '<div class="ld-switch-wrapper">'; $html .= '<span class="ld-switch'; if ( isset( $field_args['attrs']['disabled'] ) ) { $html .= ' -disabled'; } foreach ( $field_args['options'] as $option_key => $option_label ) { if ( ( ! empty( $option_key ) ) && ( isset( $option_label['tooltip'] ) ) && ( ! empty( $option_label['tooltip'] ) ) ) { $html .= ' tooltip'; } } $html .= '">'; $html .= '<input '; $html .= ' type="checkbox" autocomplete="off" '; $html .= $this->get_field_attribute_id( $field_args ); $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 ); foreach ( $field_args['options'] as $option_key => $option_label ) { if ( ! empty( $option_key ) ) { $html .= ' value="' . $option_key . '" '; break; } } if ( ! empty( $sel_option_key ) ) { $html .= ' ' . checked( $sel_option_key, $field_args['value'], false ) . ' '; } $html_sub_fields = ''; if ( ( isset( $field_args['inline_fields'] ) ) && ( ! empty( $field_args['inline_fields'] ) ) ) { foreach ( $field_args['inline_fields'] as $sub_field_key => $sub_fields ) { $html .= ' data-settings-inner-trigger="ld-settings-inner-' . $sub_field_key . '" '; if ( ( isset( $field_args['inner_section_state'] ) ) && ( 'open' === $field_args['inner_section_state'] ) ) { $inner_section_state = 'open'; } else { $inner_section_state = 'closed'; } $html_sub_fields .= '<div class="ld-settings-inner ld-settings-inner-' . $sub_field_key . ' ld-settings-inner-state-' . $inner_section_state . '">'; $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 .= '</div>'; } } else { $html .= ' data-settings-sub-trigger="ld-settings-sub-' . $field_args['name'] . '" '; } $html .= ' />'; $html .= '<span class="ld-switch__track"></span>'; $html .= '<span class="ld-switch__thumb"></span>'; $html .= '<span class="ld-switch__on-off"></span>'; foreach ( $field_args['options'] as $option_key => $option_label ) { if ( ( ! empty( $option_key ) ) && ( isset( $option_label['tooltip'] ) ) && ( ! empty( $option_label['tooltip'] ) ) ) { $html .= '<span class="tooltiptext">' . $option_label['tooltip'] . '</span>'; break; } } $html .= '</span>'; // end of ld-switch $html .= '<span class="label-text'; if ( count( $field_args['options'] ) > 1 ) { $html .= ' label-text-multple'; } $html .= '">'; if ( count( $field_args['options'] ) > 1 ) { foreach ( $field_args['options'] as $option_key => $option_label ) { $label_display_state = ''; if ( $option_key !== $sel_option_key ) { $label_display_state = ' style="display:none;" '; } if ( is_string( $option_label ) ) { $html .= '<span class="ld-label-text ld-label-text-' . $option_key . '"' . $label_display_state . '>' . $option_label . '</span>'; } elseif ( ( is_array( $option_label ) ) && ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '<span class="ld-label-text ld-label-text-' . $option_key . '"' . $label_display_state . '>' . $option_label['label'] . '</span>'; } } } else { if ( is_string( $sel_option_label ) ) { $html .= $sel_option_label; } elseif ( ( is_array( $sel_option_label ) ) && ( isset( $sel_option_label['label'] ) ) && ( ! empty( $sel_option_label['label'] ) ) ) { $html .= $sel_option_label['label']; } } $html .= '</span>'; $html .= '</div></label>'; $html .= $html_sub_fields; $html .= '</fieldset>'; } $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' ); } ); settings-fields/class-ld-settings-fields-date-entry.php 0000666 00000014662 15214240575 0017261 0 ustar 00 <?php /** * LearnDash Settings field Date Entry. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Date_Entry' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Date_Entry extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 = '<span class="screen-reader-text">' . esc_html__( 'Month', 'learndash' ) . '</span><select class="ld_date_mm ' . $field_class . '" name="' . $field_name . '[mm]" ><option value="">' . esc_html__( 'MM', 'learndash' ) . '</option>'; for ( $i = 1; $i < 13; $i = $i + 1 ) { $monthnum = zeroise( $i, 2 ); $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); $month_field .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $value_mm, false ) . '>'; /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ $month_field .= sprintf( esc_html_x( '%1$s-%2$s', 'placeholder: month number, month text', 'learndash' ), $monthnum, $monthtext ) . "</option>\n"; } $month_field .= '</select>'; $day_field = '<span class="screen-reader-text">' . esc_html__( 'Day', 'learndash' ) . '</span><input type="number" placeholder="DD" min="1" max="31" class="ld_date_jj ' . $field_class . '" name="' . $field_name . '[jj]" value="' . $value_jj . '" size="2" maxlength="2" autocomplete="off" />'; $year_field = '<span class="screen-reader-text">' . esc_html__( 'Year', 'learndash' ) . '</span><input type="number" placeholder="YYYY" min="0000" max="9999" class="ld_date_aa ' . $field_class . '" name="' . $field_name . '[aa]" value="' . $value_aa . '" size="4" maxlength="4" autocomplete="off" />'; $hour_field = '<span class="screen-reader-text">' . esc_html__( 'Hour', 'learndash' ) . '</span><input type="number" min="0" max="23" placeholder="HH" class="ld_date_hh ' . $field_class . '" name="' . $field_name . '[hh]" value="' . $value_hh . '" size="2" maxlength="2" autocomplete="off" />'; $minute_field = '<span class="screen-reader-text">' . esc_html__( 'Minute', 'learndash' ) . '</span><input type="number" min="0" max="59" placeholder="MN" class="ld_date_mn ' . $field_class . '" name="' . $field_name . '[mn]" value="' . $value_mn . '" size="2" maxlength="2" autocomplete="off" />'; $html .= '<div class="ld_date_selector">' . 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 ) . '</div>'; $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' ); } ); settings-fields/settings-fields-loader.php 0000666 00000003145 15214240575 0014745 0 ustar 00 <?php /** * LearnDash Settings Fields Loader. * * @package LearnDash * @subpackage Settings */ // All known LD setting field type (for now). require_once __DIR__ . '/class-ld-settings-fields-text.php'; require_once __DIR__ . '/class-ld-settings-fields-email.php'; require_once __DIR__ . '/class-ld-settings-fields-html.php'; require_once __DIR__ . '/class-ld-settings-fields-number.php'; require_once __DIR__ . '/class-ld-settings-fields-hidden.php'; require_once __DIR__ . '/class-ld-settings-fields-checkbox.php'; require_once __DIR__ . '/class-ld-settings-fields-radio.php'; require_once __DIR__ . '/class-ld-settings-fields-textarea.php'; require_once __DIR__ . '/class-ld-settings-fields-select.php'; require_once __DIR__ . '/class-ld-settings-fields-multiselect.php'; require_once __DIR__ . '/class-ld-settings-fields-wpeditor.php'; require_once __DIR__ . '/class-ld-settings-fields-colorpicker.php'; require_once __DIR__ . '/class-ld-settings-fields-media-upload.php'; require_once __DIR__ . '/class-ld-settings-fields-url.php'; require_once __DIR__ . '/class-ld-settings-fields-checkbox-switch.php'; // Specialty fields. require_once __DIR__ . '/class-ld-settings-fields-custom.php'; require_once __DIR__ . '/class-ld-settings-fields-date-entry.php'; require_once __DIR__ . '/class-ld-settings-fields-timer-entry.php'; require_once __DIR__ . '/class-ld-settings-fields-select-edit-delete.php'; require_once __DIR__ . '/class-ld-settings-fields-quiz-custom-fields.php'; require_once __DIR__ . '/class-ld-settings-fields-quiz-templates-load.php'; require_once __DIR__ . '/class-ld-settings-fields-quiz-templates-save.php'; settings-fields/class-ld-settings-fields-number.php 0000666 00000006320 15214240575 0016465 0 ustar 00 <?php /** * LearnDash Settings field input Number. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Number' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Number extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input autocomplete="off" '; $html .= $this->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' ); } ); settings-fields/class-ld-settings-fields-quiz-custom-fields.php 0000666 00000020053 15214240575 0020740 0 ustar 00 <?php /** * LearnDash Settings field Quiz Custom Fields. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Quiz_Custom_Fields' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Quiz_Custom_Fields extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<div class="form_table_wrapper"> <table style=" width: 100%; text-align: left; " id="form_table">'; $html .= '<thead> <tr> <th><span class="screen-reader-text">' . esc_html__( 'Move', 'learndash' ) . '</span></th> <th>' . esc_html__( 'ID', 'learndash' ) . '</th> <th>' . esc_html__( 'Field name', 'learndash' ) . '</th> <th>' . esc_html__( 'Type', 'learndash' ) . '</th> <th>' . esc_html__( 'Required?', 'learndash' ) . '</th> <th></th> </tr> </thead> <tbody>'; foreach ( $forms as $form ) { $html .= '<tr '; if ( $index++ == 0 ) { $html .= 'style="color: red; display: none;"'; } $html .= '>'; $html .= '<td><a class="form_move" href="#" style="cursor:move;"> <svg width="10" height="6" xmlns="http://www.w3.org/2000/svg" viewBox="4 6 10 6" role="img" aria-hidden="true" focusable="false"><path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path></svg> <span class="screen-reader-text">Move</span> </a></td>'; $form_id = $form->getFormId(); if ( empty( $form_id ) ) { $form_id = ''; } $html .= ' <td>' . esc_attr( $form_id ) . '</td>'; $html .= ' <td>'; $html .= ' <input type="text" name="form[][fieldname]" value="' . esc_attr( $form->getFieldname() ) . '" class="regular-text"/> </td>'; $html .= ' <td style="position: relative;">'; $html .= ' <select name="form[][type]">'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_TEXT . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_TEXT, false ) . '>' . esc_html__( 'Text', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA, false ) . '>' . esc_html__( 'Textarea', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX, false ) . '>' . esc_html__( 'Checkbox', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_SELECT . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_SELECT, false ) . '>' . esc_html__( 'Drop-Down menu', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_RADIO . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_RADIO, false ) . '>' . esc_html__( 'Radio', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_NUMBER . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_NUMBER, false ) . '>' . esc_html__( 'Number', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_EMAIL . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_EMAIL, false ) . '>' . esc_html__( 'Email', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_YES_NO . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_YES_NO, false ) . '>' . esc_html__( 'Yes/No', 'learndash' ) . '</option>'; $html .= '<option value="' . WpProQuiz_Model_Form::FORM_TYPE_DATE . '" ' . selected( $form->getType(), WpProQuiz_Model_Form::FORM_TYPE_DATE, false ) . '> ' . esc_html__( 'Date', 'learndash' ) . '</option>'; $html .= '</select>'; $html .= '<a href="#" class="editDropDown">' . esc_html__( 'Edit list', 'learndash' ) . '</a>'; $html .= '<div class="dropDownEditBox" style="position: absolute; border: 1px solid #AFAFAF; background: #EBEBEB; padding: 5px; bottom: 0;right: 0;box-shadow: 1px 1px 1px 1px #AFAFAF; display: none;"> <h4> ' . esc_html__( 'One entry per line', 'learndash' ) . '</h4> <div>'; if ( $form->getData() === null ) { $form_data = ''; } else { $form_data = esc_textarea( implode( "\n", $form->getData() ) ); } $html .= '<textarea rows="5" cols="50" name="form[][data]">' . $form_data . '</textarea>'; $html .= '</div> <input type="button" value="' . esc_html__( 'OK', 'learndash' ) . '" class="button-primary"> </div> </td> <td> <!-- Wrap checkbox input element --> <div class="ld-switch-wrapper"> <span class="ld-switch"> <input type="checkbox" class="ld-switch__input" name="form[][required]" value="1" ' . checked( $form->isRequired(), 1, false ) . '> <span class="ld-switch__track"></span> <span class="ld-switch__thumb"></span> <span class="ld-switch__on-off"></span> </span> <label for="setting-1" class="screen-reader-text">Required</label> </div> <!-- End wrap checkbox input element --> </td> <td> <input type="button" name="form_delete" value="' . esc_html__( 'Remove', 'learndash' ) . '" class="form_delete"><!-- classname update --> <!-- Remove the move link --> <input type="hidden" name="form[][form_id]" value="' . $form->getFormId() . '"> <input type="hidden" name="form[][form_delete]" value="0"> </td> </tr>'; } $html .= '</tbody> </table> <div id="form_add_wrapper"> <input type="button" name="form_add" id="form_add" value="' . esc_html__( 'Add field', 'learndash' ) . '" class="button-secondary"> </div> </div>'; $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' ); } ); settings-fields/class-ld-settings-fields-hidden.php 0000666 00000003160 15214240575 0016427 0 ustar 00 <?php /** * LearnDash Settings field Hidden. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Hidden' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Hidden extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input '; $html .= $this->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' ); } ); settings-fields/class-ld-settings-fields-timer-entry.php 0000666 00000010411 15214240575 0017450 0 ustar 00 <?php /** * LearnDash Settings field Timer Entry. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Timer_Entry' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Timer_Entry extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 = '<span class="screen-reader-text">' . esc_html__( 'Hour', 'learndash' ) . '</span><input type="number" min="0" max="23" placeholder="HH" class="ld_date_hh ' . $field_class . '" name="' . $field_name . '[hh]" value="' . $value_hh . '" size="2" maxlength="2" autocomplete="off" />'; $minute_field = '<span class="screen-reader-text">' . esc_html__( 'Minute', 'learndash' ) . '</span><input type="number" min="0" max="59" placeholder="MM" class="ld_date_mn ' . $field_class . '" name="' . $field_name . '[mn]" value="' . $value_mn . '" size="2" maxlength="2" autocomplete="off" />'; $second_field = '<span class="screen-reader-text">' . esc_html__( 'Seconds', 'learndash' ) . '</span><input type="number" min="0" max="59" placeholder="SS" class="ld_date_ss ' . $field_class . '" name="' . $field_name . '[ss]" value="' . $value_ss . '" size="2" maxlength="2" autocomplete="off" />'; $html .= '<div class="ld_timer_selector">' . sprintf( // translators: placeholders: Hour, Minute, Second. esc_html__( '%1$s:%2$s:%3$s' ), $hour_field, $minute_field, $second_field ) . '</div>'; $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' ); } ); settings-fields/class-ld-settings-fields-input-select.php 0000666 00000005202 15214240575 0017607 0 ustar 00 <?php /** * LearnDash Settings administration field Input and Select. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Input_Select' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Input_Select extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input autocomplete="off" '; $html .= $this->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 .= '<span class="ld-select">'; $html .= '<select autocomplete="off" '; $html .= $this->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 ); $html .= $this->get_field_attribute_required( $field_args ); $html .= ' >'; foreach ( $field_args['options'] as $option_key => $option_label ) { $html .= '<option value="' . $option_key . '" ' . selected( $option_key, $field_args['value'], false ) . '>' . $option_label . '</option>'; } $html .= '</select>'; $html .= '</span>'; } $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' ); } ); settings-fields/class-ld-settings-fields-multiselect.php 0000666 00000007213 15214240575 0017531 0 ustar 00 <?php /** * LearnDash Settings administration field Multiselect. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Multiselect' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Multiselect extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<span class="ld-select ld-select-multiple">'; $html .= '<select multiple autocomplete="off" '; //$html .= $this->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 ); 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 ); //if ( ( isset( $field_args['multiple'] ) ) && ( true === $field_args['multiple'] ) ) { // $html .= ' multiple="multiple" '; //} $html .= ' >'; foreach ( $field_args['options'] as $option_key => $option_label ) { if ( ( '' === $option_key ) && ( defined( 'LEARNDASH_SELECT2_LIB' ) ) && ( true === LEARNDASH_SELECT2_LIB ) ) { continue; } $selected_item = ''; if ( is_string( $field_args['value'] ) ) { $selected_item = selected( $option_key, $field_args['value'], false ); } elseif ( is_array( $field_args['value'] ) ) { if ( in_array( $option_key, $field_args['value'] ) ) { $selected_item = ' selected="" '; } } $html .= '<option value="' . $option_key . '" ' . $selected_item . '>' . $option_label . '</option>'; } $html .= '</select>'; $html .= '</span>'; } $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' ); } ); settings-fields/class-ld-settings-fields-textarea.php 0000666 00000004575 15214240575 0017024 0 ustar 00 <?php /** * LearnDash Settings field Textarea. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Textarea' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Textarea extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<textarea '; $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_required( $field_args ); $html .= $this->get_field_attribute_misc( $field_args ); $html .= ' >'; if ( isset( $field_args['value'] ) ) { $html .= $field_args['value']; } $html .= '</textarea>'; $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' ); } ); settings-fields/class-ld-settings-fields-text.php 0000666 00000004300 15214240575 0016155 0 ustar 00 <?php /** * LearnDash Settings field Text / Input. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Text' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Text extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input autocomplete="off" '; $html .= $this->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' ); } ); settings-fields/class-ld-settings-fields-custom.php 0000666 00000003164 15214240575 0016512 0 ustar 00 <?php /** * LearnDash Settings field Custom. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Custom' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Custom extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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' ); } ); settings-fields/class-ld-settings-fields-html.php 0000666 00000004152 15214240575 0016142 0 ustar 00 <?php /** * LearnDash Settings field HTML. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Html' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Html extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '</' . $field_type . '>'; 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' ); } ); settings-fields/class-ld-settings-fields-wpeditor.php 0000666 00000004441 15214240575 0017034 0 ustar 00 <?php /** * LearnDash Settings field WPEditor. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_WPEditor' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_WPEditor extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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' ); } ); settings-fields/class-ld-settings-fields-email.php 0000666 00000002304 15214240575 0016262 0 ustar 00 <?php /** * LearnDash Settings field Email. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields_Text' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Email' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Email extends LearnDash_Settings_Fields_Text { /** * Public constructor for class */ public function __construct() { $this->field_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' ); } ); settings-fields/class-ld-settings-fields-radio.php 0000666 00000011270 15214240575 0016273 0 ustar 00 <?php /** * LearnDash Settings administration field Radio. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Radio' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Radio extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<fieldset>'; $html .= $this->get_field_legend( $field_args ); foreach ( $field_args['options'] as $option_key => $option_label ) { $html .= '<p class="ld-radio-input-wrapper">'; $html .= '<input autocomplete="off" '; $html .= $this->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 .= '<div class="ld-settings-inner ld-settings-inner-' . $sub_field_key . ' ld-settings-inner-state-' . $inner_section_state . '">'; $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 .= '</div>'; } } } $html .= ' />'; $html .= '<label class="ld-radio-input__label" for="' . $field_args['id'] . '-' . $option_key . '" >'; if ( is_string( $option_label ) ) { $html .= '<span>' . $option_label . '</span></label><p>'; } elseif ( ( is_array( $option_label ) ) && ( ! empty( $option_label ) ) ) { if ( ( isset( $option_label['label'] ) ) && ( ! empty( $option_label['label'] ) ) ) { $html .= '<span>' . $option_label['label'] . '</span></label>'; } $html .= '</p>'; if ( ( isset( $option_label['description'] ) ) && ( ! empty( $option_label['description'] ) ) ) { $html .= '<p class="ld-radio-description">' . $option_label['description'] . '</p>'; } } $html .= $html_sub_fields; } $html .= '</fieldset>'; } $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' ); } ); settings-fields/class-ld-settings-fields-select-edit-delete.php 0000666 00000006730 15214240575 0020644 0 ustar 00 <?php /** * LearnDash Settings administration field Select with Edit and Delete. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Select_Edit_Delete' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Select_Edit_Delete extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<select '; $html .= $this->get_field_attribute_type( $field_args ); $html .= $this->get_field_attribute_name( $field_args ); $html .= ' id="' . $field_id_base . '_select" '; $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 .= '" '; $html .= ' >'; foreach ( $field_args['options'] as $option_key => $option_label ) { $html .= '<option value="' . $option_key . '" ' . selected( $option_key, $field_args['value'], false ) . '>' . $option_label . '</option>'; } $html .= '</select>'; $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 .= '<input class="ajax_data" type="hidden" data-ajax="' . htmlspecialchars( json_encode( $ajax_data, JSON_FORCE_OBJECT ) ) . '" />'; $html .= '<div class="ld-setting-field-sub"> <input disabled="disabled" type="text" value="" id="' . $field_id_base . '_input" name="' . $field_id_base . '_input" class="medium-text ld-settings-field-input" /> </div>'; if ( ( isset( $field_args['buttons'] ) ) && ( ! empty( $field_args['buttons'] ) ) ) { $html .= '<div class="ld-setting-field-sub">'; foreach ( $field_args['buttons'] as $button_key => $button_label ) { $html .= '<input type="button" disabled="disabled" value="' . $button_label . '" class="button-secondary ld-settings-fiels-button" data-action="' . $button_key . '" />'; } // Add spinner field to be shown during the AJAX processing. $html .= '<span class="spinner"></span>'; $html .= '</div>'; // end of setting-field-sub. // Add an update message holder. This will be filled in with the updated message after the AJAX processing. $html .= '<div class="message" style="display:none"></div>'; } } $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' ); } ); settings-fields/class-ld-settings-fields-colorpicker.php 0000666 00000004214 15214240575 0017511 0 ustar 00 <?php /** * LearnDash Settings field Color Picker. * * @package LearnDash * @subpackage Settings */ if ( ( class_exists( 'LearnDash_Settings_Fields' ) ) && ( ! class_exists( 'LearnDash_Settings_Fields_Colorpicker' ) ) ) { /** * Class to create the settings field. */ class LearnDash_Settings_Fields_Colorpicker extends LearnDash_Settings_Fields { /** * Public constructor for class */ public function __construct() { $this->field_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 .= '<input '; $html .= $this->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' ); } ); class-ld-shortcodes-tinymce.php 0000666 00000032307 15214240575 0012616 0 ustar 00 <?php if ( ! class_exists( 'LearnDash_Shortcodes_TinyMCE' ) ) { class LearnDash_Shortcodes_TinyMCE { //protected $post_types = array( 'sfwd-courses', 'sfwd-lessons', 'sfwd-topic', 'sfwd-quiz', 'sfwd-question', 'sfwd-certificates', 'page', 'post' ); //protected $pages = array( 'widgets.php' ); protected $learndash_admin_shortcodes_assets = array(); public function __construct() { add_action( 'wp_enqueue_editor', array( $this, 'wp_enqueue_editor' ) ); add_filter( 'mce_external_plugins', array( $this, 'add_tinymce_plugin' ), 1 ); add_filter( 'mce_buttons', array( $this, 'register_button' ), 1 ); add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) ); add_action( 'admin_print_footer_scripts', array( $this, 'qt_button_script' ) ); add_action( 'wp_ajax_learndash_generate_shortcodes_content', array( $this, 'learndash_generate_shortcodes_content' ) ); } protected function shortcodes_assets_init() { global $typenow, $pagenow, $post; if ( empty( $this->learndash_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() { ?> <script type="text/javascript"> if (typeof QTags !== 'undefined') { QTags.addButton( 'learndash_shortcodes', '[ld]', learndash_shortcodes_qt_callback, '', '', '', 'LearnDash Shortcodes' ); // In the QTags.addButton we need to call this intermediate function because learndash_shortcodes is now loaded yet. function learndash_shortcodes_qt_callback() { learndash_shortcodes.qt_callback(); } } </script> <?php } public function add_button() { add_filter( 'mce_external_plugins', array( $this, 'add_tinymce_plugin' ), 1 ); add_filter( 'mce_buttons', array( $this, 'register_button' ), 1 ); } public function add_tinymce_plugin( $plugin_array ) { $plugin_array['learndash_shortcodes_tinymce'] = LEARNDASH_LMS_PLUGIN_URL . 'assets/js/learndash-admin-shortcodes-tinymce' . leardash_min_asset() . '.js'; return $plugin_array; } public function register_button( $buttons ) { array_push( $buttons, 'learndash_shortcodes_tinymce' ); return $buttons; } public function load_admin_scripts() { global $typenow, $pagenow; global $learndash_assets_loaded; wp_enqueue_style( 'sfwd-module-style', LEARNDASH_LMS_PLUGIN_URL . '/assets/css/sfwd_module' . leardash_min_asset() . '.css', array(), LEARNDASH_SCRIPT_VERSION_TOKEN ); $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__; $data = array(); if ( ! isset( $data['ajaxurl'] ) ) { $data['ajaxurl'] = admin_url( 'admin-ajax.php' ); } $data = array( 'json' => 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 ); ?> <div id="learndash_shortcodes_wrap" class="wrap sfwd_options"> <div id="learndash_shortcodes_tabs"> <ul> <?php foreach ( $shortcode_sections as $section ) { ?> <li><a data-nav="<?php echo $section->get_shortcodes_section_key(); ?>" href="#"><?php echo $section->get_shortcodes_section_title(); ?></a></li> <?php } ?> </ul> </div> <div id="learndash_shortcodes_sections"> <?php foreach ( $shortcode_sections as $section ) { ?> <div id="tabs-<?php echo $section->get_shortcodes_section_key(); ?>" class="hidable wrap" style="display: none;"> <?php echo $section->show_section_fields(); ?> </div> <?php } ?> </div> </div> <?php //} die(); } // End of functions } } add_action( 'plugins_loaded', function() { new LearnDash_Shortcodes_TinyMCE(); } ); class-ld-settings-sections.php 0000666 00000064701 15214240575 0012463 0 ustar 00 <?php /** * LearnDash Settings Page Abstract Class. * * @package LearnDash * @subpackage Settings */ //require_once LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/class-ld-settings-section-fields.php'; if ( ! class_exists( 'LearnDash_Settings_Section' ) ) { /** * Absract for LearnDash Settings Sections. */ abstract class LearnDash_Settings_Section { /** * Static array of section instances. * * @var array $_instances */ protected static $_instances = array(); /** * Match the WP Screen ID * * @var string $settings_screen_id Settings Screen ID. */ protected $settings_screen_id = ''; /** * Match the Settings Page ID * * @var string $settings_page_id Settings Page ID. */ protected $settings_page_id = ''; /** * Store for all the fields in this section * * @var array $setting_option_fields Array of section fields. */ protected $setting_option_fields = array(); /** * Holds the values for the fields. Read in from the wp_options item. * * @var array $setting_option_values Array of section values. */ protected $setting_option_values = array(); /** * Flag for if settings values have been loaded. * * @var boolean $settings_values_loaded Flag. */ protected $settings_values_loaded = false; /** * Flag for if settings fields have been loaded. * * @var boolean $settings_fields_loaded Flag. */ protected $settings_fields_loaded = false; /** * This is the 'option_name' key used to store the section values. * * @var string setting_option_key */ protected $setting_option_key = ''; /** * This is the HTML form field prefix used. * * @var string setting_field_prefix */ protected $setting_field_prefix = ''; /** * This is used as the option_name when the settings * are saved to the options table. * * @var string $settings_section_key */ protected $settings_section_key = ''; /** * Section label/header * This setting is used to show in the title of the metabox or section. * * @var string $settings_section_label */ protected $settings_section_label = ''; /** * Used to show the section description above the fields. Can be empty. * * @var string $settings_section_description */ protected $settings_section_description = ''; /** * Used to transition settings from one class to another. Can be empty. * Set at the class then combined into the $settings_deprecated array. * * @var string $settings_deprecated */ protected $settings_deprecated = array(); /** * Unique ID used for metabox on page. Will be derived from * settings_option_key + setting_section_key * * @var string $metabox_key */ protected $metabox_key = ''; /** * Controls metabox context on page * See WordPress add_meta_box() function 'context' parameter. * * @var string $metabox_context */ protected $metabox_context = 'normal'; /** * Controls metabox priority on page * See WordPress add_meta_box() function 'priority' parameter. * * @var string $metabox_priority */ protected $metabox_priority = 'default'; /** * Lets the section define it's own display function instead of using the Settings API * * @var mixed $settings_fields_callback */ protected $settings_fields_callback = null; /** * Used on submit metaboxes to display reset confirmation popup message. * * @var string $reset_confirm_message */ protected $reset_confirm_message = ''; /** * Static array of deprecated section and fields. * * @var array $settings_deprecated */ protected static $_settings_deprecated = array(); /** * Public constructor for class */ protected function __construct() { add_action( 'init', array( $this, 'init' ) ); add_action( 'learndash_settings_page_init', array( $this, 'settings_page_init' ) ); if ( defined( 'LEARNDASH_SETTINGS_SECTION_TYPE' ) && ( 'metabox' === LEARNDASH_SETTINGS_SECTION_TYPE ) ) { add_action( 'learndash_add_meta_boxes', array( $this, 'add_meta_boxes' ) ); } add_filter( 'pre_update_option_' . $this->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<pre>'. print_r($setting_option_field, true) .'</pre>'); } $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 '<div class="ld-metabox-description">' . wpautop( $this->settings_section_description ) . '</div>'; } } /** * 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 ), ) ); ?> <p class="delete-action sfwd_input"> <a href="<?php echo esc_url( $reset_url ); ?>" class="button-secondary submitdelete deletion" data-confirm="<?php echo esc_html( $this->reset_confirm_message ); ?>"><?php esc_html_e( 'Reset Settings', 'learndash' ); ?></a> </p> <?php } } /** * 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->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 '<div class="sfwd sfwd_options ' . esc_attr( $this->settings_section_key ) . '">'; 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 '</div>'; 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; } } }
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings