PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.0
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / inc / wpseo-non-ajax-functions.php

wpseo-non-ajax-functions.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.0, at inc/wpseo-non-ajax-functions.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Internals
6 */
7
8 if ( ! defined( 'WPSEO_VERSION' ) ) {
9 header( 'Status: 403 Forbidden' );
10 header( 'HTTP/1.1 403 Forbidden' );
11 exit();
12 }
13
14 /**
15 * Initializes the admin bar.
16 *
17 * @return void
18 */
19 function wpseo_initialize_admin_bar() {
20 $admin_bar_menu = new WPSEO_Admin_Bar_Menu();
21 $admin_bar_menu->register_hooks();
22 }
23 add_action( 'wp_loaded', 'wpseo_initialize_admin_bar' );
24
25 /**
26 * Allows editing of the meta fields through weblog editors like Marsedit.
27 *
28 * @param array $required_capabilities Capabilities that must all be true to allow action.
29 * @param array $capabilities Array of capabilities to be checked, unused here.
30 * @param array $args List of arguments for the specific capabilities to be checked.
31 *
32 * @return array Filtered capabilities.
33 */
34 function allow_custom_field_edits( $required_capabilities, $capabilities, $args ) {
35 if ( ! in_array( $args[0], [ 'edit_post_meta', 'add_post_meta' ], true ) ) {
36 return $required_capabilities;
37 }
38
39 // If this is provided, it is the post ID.
40 if ( empty( $args[2] ) ) {
41 return $required_capabilities;
42 }
43
44 // If this is provided, it is the custom field.
45 if ( empty( $args[3] ) ) {
46 return $required_capabilities;
47 }
48
49 // If the meta key is part of the plugin, grant capabilities accordingly.
50 if ( strpos( $args[3], WPSEO_Meta::$meta_prefix ) === 0 && current_user_can( 'edit_post', $args[2] ) ) {
51 $required_capabilities[ $args[0] ] = true;
52 }
53
54 return $required_capabilities;
55 }
56
57 add_filter( 'user_has_cap', 'allow_custom_field_edits', 0, 3 );
58