Server : Apache System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.7 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/plugins/diva/src/Admin/ |
<?php /** * Class UserRESTEndpointExtension * * @package AmpProject\AmpWP * @since 2.2 */ namespace AmpProject\AmpWP\Admin; use AMP_Theme_Support; use AmpProject\AmpWP\Infrastructure\Delayed; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use WP_User; /** * Service which registers additional REST API fields for the user endpoint. * * @since 2.2 * @internal */ class UserRESTEndpointExtension implements Service, Registerable, Delayed { /** * User meta key that stores a template mode for which the "Review" panel was dismissed. * * @var string */ const USER_FIELD_REVIEW_PANEL_DISMISSED_FOR_TEMPLATE_MODE = 'amp_review_panel_dismissed_for_template_mode'; /** * Get registration action. * * @return string */ public static function get_registration_action() { return 'rest_api_init'; } /** * Register. */ public function register() { $this->register_rest_field(); } /** * Register REST field for storing a template mode for which the "Review" panel was dismissed. */ public function register_rest_field() { register_rest_field( 'user', self::USER_FIELD_REVIEW_PANEL_DISMISSED_FOR_TEMPLATE_MODE, [ 'get_callback' => [ $this, 'get_review_panel_dismissed_for_template_mode' ], 'update_callback' => [ $this, 'update_review_panel_dismissed_for_template_mode' ], 'schema' => [ 'description' => __( 'The template mode for which the Review panel on the Settings screen was dismissed by a user.', 'amp' ), 'type' => 'string', 'enum' => [ '', AMP_Theme_Support::READER_MODE_SLUG, AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::TRANSITIONAL_MODE_SLUG, ], ], ] ); } /** * Provides a template mode for which the "Review" panel has been dismissed by a user. * * @param array $user Array of user data prepared for REST. * * @return string Template mode for which the panel is dismissed, empty string if the option has not been set. */ public function get_review_panel_dismissed_for_template_mode( $user ) { return get_user_meta( $user['id'], self::USER_FIELD_REVIEW_PANEL_DISMISSED_FOR_TEMPLATE_MODE, true ); } /** * Updates a user's setting determining for which template mode the "Review" panel was dismissed. * * @param string $template_mode Template mode or empty string. * @param WP_User $user The WP user to update. * * @return bool The result of updating or deleting the user meta. */ public function update_review_panel_dismissed_for_template_mode( $template_mode, WP_User $user ) { if ( empty( $template_mode ) ) { return delete_user_meta( $user->ID, self::USER_FIELD_REVIEW_PANEL_DISMISSED_FOR_TEMPLATE_MODE ); } return (bool) update_user_meta( $user->ID, self::USER_FIELD_REVIEW_PANEL_DISMISSED_FOR_TEMPLATE_MODE, $template_mode ); } }