array( 'date' => true, 'time' => true, 'modified_date' => false, 'modified_time' => false ), 'date_format' => 'd m y, l', 'custom_date_format' => '' ); $default_opts = apply_filters('npd_modify_default_opts', $default_opts); $this->opts = get_option('npd_opts', $default_opts); add_action('admin_init', array($this, 'register_settings')); add_filter('plugin_action_links_' . NEPALIPOSTDATE_BASENAME, array(&$this, 'add_settings_link')); } /** * Function that is hooked into the admin initialisation and registers settings * * @return void * @author Padam Shankhadev * @since 1.0 */ public function register_settings() { add_settings_section( 'npd_opts', __( 'Nepali Post Date Options', 'npdate'), array(&$this, 'settings_section_info' ), 'general' ); add_settings_field( 'npd_opts[active]', __( 'Apply Nepali Date format to', 'npdate'), array(&$this, 'active_callback' ), 'general', 'npd_opts', $this->opts['active'] ); add_settings_field( 'npd_opts[date_format]', __( 'Apply Date Format', 'npdate' ), array(&$this, 'date_format_callback' ), 'general', 'npd_opts', $this->opts['date_format'] ); add_settings_field( 'npd_opts[custom_date_format]', __( 'Custom Date Format', 'npdate' ), array(&$this, 'custom_date_format_callback' ), 'general', 'npd_opts', $this->opts['custom_date_format'] ); add_settings_field( 'npd_opts[today_date_format]', __( 'Today Date Format', 'npdate' ), array(&$this, 'today_date_format_callback' ), 'general', 'npd_opts', $this->opts['today_date_format'] ); add_settings_section( 'npd_description', __( 'How to use shortcode and function in theme template and files.', 'npdate'), array(&$this, 'settings_section_usage' ), 'general' ); register_setting( 'general', 'npd_opts', array(&$this, 'sanitize_opts' ) ); } /** * Function that displays the section heading information * * @author Padam Shankhadev * @since 1.0 */ public function settings_section_info() { echo '
'.htmlentities('').'
convert AD into nepali BS (bikram sambat) date.'.htmlentities('').'
convert AD into nepali BS (bikram sambat) date.'.htmlentities('').'
get today BS (bikram sambat) date.'.htmlentities('').'
get today BS (bikram sambat) date.'.htmlentities('').'
convert any english number into nepali number.'.htmlentities('').'
convert any english number into nepali number.[Note: d = गते (१), m = महिना (बैशाख), y = बर्ष (२०७७), l = दिन (शनिबार)]
'; } /** * Display today date setting * * @since 1.1 */ public function today_date_format_callback( $custom_date_format ) { echo ' (e.g: d m y, l)[Note: d = गते (१), m = महिना (बैशाख), y = बर्ष (२०७७), l = दिन (शनिबार)]
'; } /** * Function that sanitizes plugin options on save * * @author Padam Shankhadev * @since 1.0 * @param array $opts Nepali Post Date options * @return array $opts Sanitized options array * */ public function sanitize_opts( $opts ) { if ( isset( $opts['active']['date'] ) ) { $opts['active']['date'] = true; } else { $opts['active']['date'] = false; } if ( isset( $opts['active']['time'] ) ) { $opts['active']['time'] = true; } else { $opts['active']['time'] = false; } if ( isset( $opts['active']['modified_date'] ) ) { $opts['active']['modified_date'] = true; } else { $opts['active']['modified_date'] = false; } if ( isset( $opts['active']['modified_time'] ) ) { $opts['active']['modified_time'] = true; } else { $opts['active']['modified_time'] = false; } $opts['custom_date_format'] = esc_html( $opts['custom_date_format'] ); $opts['today_date_format'] = esc_html( $opts['today_date_format'] ); return $opts; } public function add_settings_link( $links ) { $admin_url = admin_url(); $link = array( 'Settings' ); return array_merge( $links, $link ); } } ?>