Changeset 2529515
- Timestamp:
- 05/11/2021 07:22:31 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postpage-specific-custom-css/tags/0.2.2/post-page-specific-custom-css.php
r2529500 r2529515 16 16 namespace Phylax\WPPlugin\PPCustomCSS; 17 17 18 use WP_Post; 18 19 use const DOING_AUTOSAVE; 19 20 … … 42 43 43 44 const NONCE_HIDE_BIRTHDAY = 'ppscc_hide_birthday'; 45 46 const CAP_MANAGE_OPTIONS = 'manage_options'; 47 const CAP_EDIT_OTHERS_PAGES = 'edit_others_pages'; 44 48 45 49 private $isBirthday = false; … … 545 549 546 550 public function current_user_already_seen_message(): bool { 547 if ( ! current_user_can( 'manage_options') ) {551 if ( ! current_user_can( self::CAP_MANAGE_OPTIONS ) ) { 548 552 // Always return true for non-administrators 549 553 return true; … … 612 616 613 617 public function add_options_page() { 614 $sub_menu_suffix = add_submenu_page( self::PARENT_MENU_SLUG, __( 'Post/Page specific custom CSS', 'postpage-specific-custom-css' ), __( 'Post/Page CSS', 'postpage-specific-custom-css' ), 'manage_options', self::MENU_SLUG, [618 $sub_menu_suffix = add_submenu_page( self::PARENT_MENU_SLUG, __( 'Post/Page specific custom CSS', 'postpage-specific-custom-css' ), __( 'Post/Page CSS', 'postpage-specific-custom-css' ), self::CAP_MANAGE_OPTIONS, self::MENU_SLUG, [ 615 619 $this, 616 620 'options_page_view', … … 675 679 return $content; 676 680 } 677 /** @var \WP_Post $post */681 /** @var WP_Post $post */ 678 682 $phylax_ppsccss_single_only = get_post_meta( $post->ID, self::POST_META_SINGLE, true ); 679 683 $phylax_ppsccss_css = get_post_meta( $post->ID, self::POST_META_CSS, true ); … … 722 726 } 723 727 724 public function allowedToView() {728 public function allowedToView(): bool { 725 729 $settings = (array) get_option( self::OPTION_NAME ); 726 730 $allow_editors = (bool) ( $settings[ self::OPT_CONTROL_USER_EDITOR ] ?? 0 ); 727 731 if ( 728 current_user_can( 'manage_options') ||732 current_user_can( self::CAP_MANAGE_OPTIONS ) || 729 733 ( 730 734 $allow_editors && 731 current_user_can( 'edit_others_pages')735 current_user_can( self::CAP_EDIT_OTHERS_PAGES ) 732 736 ) 733 737 ) { … … 881 885 public function init() { 882 886 load_plugin_textdomain( 'postpage-specific-custom-css', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 883 if ( current_user_can( 'manage_options') ) {887 if ( current_user_can( self::CAP_MANAGE_OPTIONS ) ) { 884 888 $ppscc_birthday = (string) ( get_user_meta( get_current_user_id(), 'ppscc_birthday', true ) ?? '' ); 885 889 if ( 'hide' === $ppscc_birthday ) { … … 894 898 exit; 895 899 } 896 if ( ! current_user_can( 'manage_options') ) {900 if ( ! current_user_can( self::CAP_MANAGE_OPTIONS ) ) { 897 901 exit; 898 902 } … … 905 909 906 910 public function update_user_meta() { 907 if ( ! current_user_can( 'manage_options') ) {911 if ( ! current_user_can( self::CAP_MANAGE_OPTIONS ) ) { 908 912 return; 909 913 }
Note: See TracChangeset
for help on using the changeset viewer.