芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/wp-parsidate/includes/settings.php
'disable', 'user_lang' => 'disable', 'persian_date' => 'disable', 'disable_widget_block' => 'disable', 'submenu_move' => 'disable', 'dev_mode' => 'disable', 'enable_fonts' => 'disable', 'conv_title' => 'disable', 'conv_contents' => 'disable', 'conv_excerpt' => 'disable', 'conv_comments' => 'disable', 'conv_comment_count' => 'disable', 'conv_dates' => 'disable', 'conv_cats' => 'disable', 'conv_arabic' => 'disable', 'conv_permalinks' => 'disable', 'news_source' => 'parsi' ) ); } return apply_filters( 'wpp_get_settings', $settings ); } /** * Registers settings in WP core * * @return void * @since 2.0 */ function wpp_register_settings() { if ( false === get_option( 'wpp_settings' ) ) { add_option( 'wpp_settings', array() ); } foreach ( wpp_get_registered_settings() as $tab => $settings ) { add_settings_section( 'wpp_settings_' . $tab, __return_null(), '__return_false', 'wpp_settings_' . $tab ); foreach ( $settings as $option ) { $name = $option['name'] ?? ''; add_settings_field( 'wpp_settings[' . $option['id'] . ']', $name, function_exists( 'wpp_' . $option['type'] . '_callback' ) ? 'wpp_' . $option['type'] . '_callback' : 'wpp_missing_callback', 'wpp_settings_' . $tab, 'wpp_settings_' . $tab, array( 'id' => $option['id'] ?? null, 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', 'name' => $option['name'] ?? null, 'section' => $tab, 'size' => $option['size'] ?? null, 'options' => $option['options'] ?? '', 'std' => $option['std'] ?? '' ) ); register_setting( 'wpp_settings', 'wpp_settings', 'wpp_settings_sanitize' ); } } } add_action( 'admin_init', 'wpp_register_settings' ); /** * Gets settings tabs * * @return array Tabs list * @since 2.0 */ function wpp_get_tabs() { return array( 'core' => sprintf( __( '%s Core', 'wp-parsidate' ), '
' ), 'conv' => sprintf( __( '%s Converts', 'wp-parsidate' ), '
' ), 'tools' => sprintf( __( '%s Tools', 'wp-parsidate' ), '
' ), 'plugins' => sprintf( __( '%s Plugins compatibility', 'wp-parsidate' ), '
' ), 'about' => sprintf( __( '%s About', 'wp-parsidate' ), '
' ), ); } /** * Sanitizes and saves settings after submit * * @param array $input Settings input * * @return array New settings * @since 2.0 * */ function wpp_settings_sanitize( $input = array() ) { global $wpp_settings; if ( empty( $_POST['_wp_http_referer'] ) ) { return $input; } parse_str( $_POST['_wp_http_referer'], $referrer ); $settings = wpp_get_registered_settings(); $tab = $referrer['tab'] ?? 'core'; $input = $input ?: array(); $input = apply_filters( 'wpp_settings_' . $tab . '_sanitize', $input ); // Loop through each setting being saved and pass it through a sanitization filter foreach ( $input as $key => $value ) { // Get the setting type (checkbox, select, etc.) $type = $settings[ $tab ][ $key ]['type'] ?? false; if ( $type ) { // Field type specific filter $input[ $key ] = apply_filters( 'wpp_settings_sanitize_' . $type, $value, $key ); } // General filter $input[ $key ] = apply_filters( 'wpp_settings_sanitize', $value, $key ); } // Loop through the whitelist and unset any that are empty for the tab being saved if ( ! empty( $settings[ $tab ] ) ) { foreach ( $settings[ $tab ] as $key => $value ) { // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work if ( is_numeric( $key ) ) { $key = $value['id']; } if ( ! isset( $input[ $key ] ) ) { unset( $wpp_settings[ $key ] ); } } } // Merge our new settings with the existing return array_merge( $wpp_settings, $input ); } /** * Get settings fields * * @return array Fields * @since 2.0 */ function wpp_get_registered_settings() { return apply_filters( 'wpp_registered_settings', array( 'core' => apply_filters( 'wpp_core_settings', array( 'admin_lang' => array( 'id' => 'admin_lang', 'name' => __( 'Change Locale in admin', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'This option change WordPress locale to Persian in Admin', 'wp-parsidate' ), ), 'user_lang' => array( 'id' => 'user_lang', 'name' => __( 'Change Locale in theme', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'This option change WordPress locale to Persian in theme', 'wp-parsidate' ), ), 'persian_date' => array( 'id' => 'persian_date', 'name' => __( 'Shamsi date', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate' ), ), 'months_name_type' => array( 'id' => 'months_name_type', 'name' => __( 'Months name type', 'wp-parsidate' ), 'type' => 'select', 'options' => array( 'persian' => __( 'Persian', 'wp-parsidate' ), 'dari' => __( 'Dari', 'wp-parsidate' ), 'kurdish' => __( 'Kurdish', 'wp-parsidate' ), 'pashto' => __( 'Pashto', 'wp-parsidate' ), ), 'std' => 0, ), 'disable_widget_block' => array( 'id' => 'disable_widget_block', 'name' => __( 'Disable Widget Block', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this, Widget Block Editor disabled', 'wp-parsidate' ), ), 'submenu_move' => array( 'id' => 'submenu_move', 'name' => __( 'Move page to submenu?', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this option, page item will be moved to Settings menu as submenu.', 'wp-parsidate' ), ), 'dev_mode' => array( 'id' => 'dev_mode', 'name' => __( 'Debug Mode', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this option, the uncompressed version of the JS and CSS files will be loaded.', 'wp-parsidate' ), ), 'enable_fonts' => array( 'id' => 'enable_fonts', 'name' => __( 'Vazir Font', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this option, the Vazir font will be enable in whole admin area.', 'wp-parsidate' ), ), ) ), 'conv' => apply_filters( 'wpp_conv_settings', array( 'conv_nums' => array( 'id' => 'conv_nums', 'name' => __( 'Persian digits', 'wp-parsidate' ), 'type' => 'header', ), 'conv_page_title' => array( 'id' => 'conv_page_title', 'name' => __( 'Page title', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_title' => array( 'id' => 'conv_title', 'name' => __( 'Post title', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_contents' => array( 'id' => 'conv_contents', 'name' => __( 'Post content', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 'enable', 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_excerpt' => array( 'id' => 'conv_excerpt', 'name' => __( 'Post excerpt', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_comments' => array( 'id' => 'conv_comments', 'name' => __( 'Comments text', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_comment_count' => array( 'id' => 'conv_comment_count', 'name' => __( 'Comments count', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_dates' => array( 'id' => 'conv_dates', 'name' => __( 'Dates', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'conv_cats' => array( 'id' => 'conv_cats', 'name' => __( 'Categories', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'Active', 'wp-parsidate' ), ), 'sep' => array( 'id' => 'sep', 'type' => 'header', ), 'conv_arabic' => array( 'id' => 'conv_arabic', 'name' => __( 'Fix arabic characters', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 'disable', 'desc' => __( 'Fixes arabic characters caused by wrong keyboard layouts', 'wp-parsidate' ), ), 'conv_permalinks' => array( 'id' => 'conv_permalinks', 'name' => __( 'Fix permalinks dates', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( 'By enabling this, dates in permalinks converted to Shamsi (Jalali) date', 'wp-parsidate' ), ), 'sep_font' => array( 'id' => 'sep_font', 'type' => 'header', ), ) ), 'tools' => apply_filters( 'wpp_tools_settings', array( 'advanced_tools' => array( 'id' => 'advanced_tools', 'name' => __( 'Advanced Tools', 'wp-parsidate' ), 'type' => 'header' ), 'date_in_admin_bar' => array( 'id' => 'date_in_admin_bar', 'name' => __( "Display date in the admin bar", 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 'disable', 'desc' => __( "Display today's Jalali date in the WordPress admin bar.", 'wp-parsidate' ), ), 'sep_admin_bar_ate' => array( 'id' => 'sep_admin_bar_ate', 'type' => 'header', ), 'disable_copy' => array( 'id' => 'disable_copy', 'name' => __( 'Prevent users from copying site content', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 'disable', 'desc' => __( "Simply protect your site's content from those who want to copy it.", 'wp-parsidate' ), ), 'disable_right_click' => array( 'id' => 'disable_right_click', 'name' => __( 'Disable right click on website pages', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 'enable', 'std' => 0, 'desc' => __( "Don't worry about downloading website images and other files anymore, this option prevents users from right clicking", 'wp-parsidate' ), ), ) ), 'plugins' => apply_filters( 'wpp_plugins_compatibility_settings', array() ), ) ); } /* Form Callbacks Made by EDD Development Team */ /** * @param $args */ function wpp_header_callback( $args ) { echo '
'; } /** * Generates checkbox field * * @param $args */ function wpp_checkbox_callback( $args ) { global $wpp_settings; if ( isset( $wpp_settings[ $args['id'] ] ) ) { $checked = ! is_array( $wpp_settings[ $args['id'] ] ) ? checked( 'enable', $wpp_settings[ $args['id'] ], false ) : checked( 'enable', $wpp_settings[ $args['parent'] ][ $args['id'] ], false ); } else { $checked = ''; } $is_multiple = ! empty( $args['is_multiple'] ) ? ' checkbox-list' : ''; $html = sprintf( '
' . '
%5$s
', ! $is_multiple ? '[' . $args['id'] . ']' : '[' . $args['parent'] . '][' . $args['id'] . ']', $checked, empty( $args['desc'] ) ? 'empty-label' : '', $is_multiple, $args['desc'], ); echo $html; } /** * Generates multiple checkboxes fields * * @param $args */ function wpp_multicheck_callback( $args ) { global $wpp_settings; $html = '
'; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? array(); foreach ( $args['options'] as $key => $option ) { $html .= sprintf( '
%4$s
%5$s
', $args['id'], $key, in_array( $key, $value ) ? 'checked="checked"' : '', $option, $args['desc'] ); } echo $html . '
'; } /** * @param $args */ function wpp_radio_callback( $args ) { global $wpp_settings; foreach ( $args['options'] as $key => $option ) : $checked = false; if ( isset( $wpp_settings[ $args['id'] ] ) && $wpp_settings[ $args['id'] ] == $key ) { $checked = true; } elseif ( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpp_settings[ $args['id'] ] ) ) { $checked = true; } echo '
'; echo '
' . $option . '
'; endforeach; echo '
' . $args['desc'] . '
'; } /** * @param $args */ function wpp_text_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_number_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $max = $args['max'] ?? 999999; $min = $args['min'] ?? 0; $step = $args['step'] ?? 1; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_textarea_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_password_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args * * @return false */ function wpp_missing_callback( $args ) { echo '–'; return false; } /** * @param $args */ function wpp_select_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $html = '
'; foreach ( $args['options'] as $option => $name ) : $selected = selected( $option, $value, false ); $html .= '
' . $name . '
'; endforeach; $html .= ''; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_color_select_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $html = '
'; foreach ( $args['options'] as $option => $color ) : $selected = selected( $option, $value, false ); $html .= '
' . $color['label'] . '
'; endforeach; $html .= ''; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_rich_editor_callback( $args ) { global $wpp_settings, $wp_version; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { ob_start(); wp_editor( stripslashes( $value ), 'wpp_settings[' . $args['id'] . ']', array( 'textarea_name' => 'wpp_settings[' . $args['id'] . ']' ) ); $html = ob_get_contents(); ob_end_clean(); } else { $html = '
' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; } $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_upload_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= '
'; $html .= '
' . $args['desc'] . '
'; echo $html; } /** * @param $args */ function wpp_color_callback( $args ) { global $wpp_settings; $value = $wpp_settings[ $args['id'] ] ?? $args['std'] ?? ''; $default = $args['std'] ?? ''; $size = ( isset( $args['size'] ) ) ? $args['size'] : 'regular'; $html = '
'; $html .= '
' . $args['desc'] . '
'; echo $html; } function wpp_render_settings() { $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], wpp_get_tabs() ) ? $_GET['tab'] : 'core'; ob_start(); ?>
$tab_name ) { $tab_url = add_query_arg( array( 'settings-updated' => false, 'tab' => $tab_id, ) ); $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; echo '
'; echo $tab_name; echo '
'; } ?>
array( 'id' => 'wpp_multilingual_support', 'name' => __( 'Multilingual compatibility', 'wp-parsidate' ), 'type' => 'checkbox', 'options' => 1, 'std' => 0, 'desc' => __( 'By enabling this, ParsiDate options only work in persian locale', 'wp-parsidate' ) ), ); return array_merge( $old_settings, $settings ); } return $old_settings; } add_filter( 'wpp_core_settings', 'wpp_multilingual_compatibility_option' );