*/ // Enqueue styles add_action( 'admin_enqueue_scripts', 'enqueue_styles_reading_progressbar_admin' ); function enqueue_styles_reading_progressbar_admin() { wp_enqueue_style( 'wp-color-picker' ); // wp_enqueue_style( 'rp-admin-styles', plugin_dir_url( __FILE__ ) . 'css/rp-admin.css', array(), '', 'all' ); } // Enqueue scripts add_action( 'admin_enqueue_scripts', 'enqueue_scripts_reading_progressbar_admin' ); function enqueue_scripts_reading_progressbar_admin() { wp_enqueue_script( 'rp-admin-scripts', plugin_dir_url( __FILE__ ) . 'js/rp-admin.js', array( 'jquery', 'wp-color-picker' ), '', false ); } /** * * Plugin options in reading section * */ add_action( 'admin_menu', 'rp_add_admin_menu' ); add_action( 'admin_init', 'rp_settings_init' ); function rp_add_admin_menu( ) { add_options_page( __('Reading progressbar options', 'reading-progress-bar'), __('Reading progressbar', 'reading-progress-bar'), 'manage_options', 'reading-progressbar', 'rp_options_page' ); } function rp_settings_init( ) { register_setting( 'pluginPage', 'rp_settings' ); add_settings_section( 'rp_pluginPage_section', __( 'Reading progressbar options', 'reading-progress-bar' ), 'rp_settings_section_callback', 'pluginPage' ); add_settings_field( 'rp_field_height', __( 'Progressbar height (pixels)', 'reading-progress-bar' ), 'rp_field_height_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_fg_color', __( 'Foreground color', 'reading-progress-bar' ), 'rp_field_fg_color_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_bg_color', __( 'Background color', 'reading-progress-bar' ), 'rp_field_bg_color_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_position', __( 'Progressbar position', 'reading-progress-bar' ), 'rp_field_position_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_custom_position', __( 'Target fixed HTML element class/id to stick the bar on it’s bottom', 'reading-progress-bar' ), 'rp_field_custom_position_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_templates', __( 'Select templates to apply progressbar', 'reading-progress-bar' ), 'rp_field_templates_render', 'pluginPage', 'rp_pluginPage_section' ); add_settings_field( 'rp_field_posttypes', __( 'Select post types to apply progressbar', 'reading-progress-bar' ), 'rp_field_posttypes_render', 'pluginPage', 'rp_pluginPage_section' ); /* add_settings_field( 'rp_field_mobile', __( 'Display progressbar on mobile devices?', 'reading-progress-bar' ), 'rp_field_mobile_render', 'pluginPage', 'rp_pluginPage_section' );*/ } function rp_field_height_render( ) { $options = get_option( 'rp_settings' ); if (isset($options['rp_field_height'])) { $optionHeight = $options['rp_field_height']; } else { $optionHeight = ''; } ?>
You may need some custom CSS to put the progressbar on the right place as it uses absolute positionning.', 'reading-progress-bar'); ?>
custom position before, instead of top or bottom', 'reading-progress-bar'); ?>
value='1' />
value='1' />
value='1' />
value='1' />
true ), 'objects' ); foreach ( $post_types as $type => $obj ) { if (isset($optionPostTypes[$obj->name])) : $optionNamePostType = $optionPostTypes[$obj->name]; else : $optionNamePostType = ''; endif; ?>
value='1' /> labels->name; ?>
true ), 'objects' ); foreach ( $post_types as $type => $obj ) { ?>labels->name; ?>
value='1' /> Yes, please