Changeset 12335
- Timestamp:
- 12/15/2022 05:55:50 PM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
- Files:
-
- 1 added
- 4 edited
-
admin-edit.php (modified) (2 diffs)
-
class-themes-api.php (modified) (6 diffs)
-
rest-api.php (modified) (1 diff)
-
rest-api/class-theme-categorization.php (added)
-
theme-directory.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/admin-edit.php
r11430 r12335 61 61 * @param array $caps Returns the user's actual capabilities. 62 62 * @param string $cap Capability name. 63 * @param int $user_id The user ID. 64 * @param mixed $context Adds the context to the cap. Typically the object ID. 63 65 * @return array 64 66 */ 65 function wporg_themes_map_meta_cap( $caps, $cap ) {67 function wporg_themes_map_meta_cap( $caps, $cap, $user_id, $context ) { 66 68 switch ( $cap ) { 67 69 case 'delete_categories': … … 83 85 unset( $caps[ array_search( $cap, $caps ) ] ); 84 86 break; 87 88 case 'theme_configure_categorization_options': 89 // Protect against a cap call without a theme context. 90 $post = $context ? get_post( $context[0] ) : false; 91 if ( ! $post ) { 92 return [ 'do_not_allow' ]; 93 } 94 95 // The current user instance. 96 $user = new \WP_User( $user_id ); 97 98 // Shortcut, if no user specified, we can't help. 99 if ( ! $user_id || ! $user->exists() ) { 100 return [ 'do_not_allow' ]; 101 } 102 103 // Post must be a published theme. 104 if ( 'publish' !== $post->post_status || 'repopackage' !== $post->post_type ) { 105 return [ 'do_not_allow' ]; 106 } 107 108 // User must be able to edit theme or be the theme owner. 109 if ( ! ( user_can( $user->ID, 'edit_post', $post ) || $user->ID === $post->post_author ) ) { 110 return [ 'do_not_allow' ]; 111 } 112 113 // Start over, we'll specify all caps below. 114 $caps = []; 115 116 // At this point, user is allowed. 117 $caps[] = 'exist'; 118 break; 85 119 } 86 120 87 121 return $caps; 88 122 } 89 add_filter( 'map_meta_cap', 'wporg_themes_map_meta_cap', 10, 2);123 add_filter( 'map_meta_cap', 'wporg_themes_map_meta_cap', 10, 4 ); 90 124 91 125 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php
r11373 r12335 65 65 'requires_php' => false, 66 66 'trac_tickets' => false, 67 'is_commercial' => false, 68 'is_community' => false, 69 'external_repository_url' => false, 70 'external_support_url' => false, 71 'can_configure_categorization_options' => false, 67 72 ); 68 73 … … 72 77 * @var string 73 78 */ 74 private $cache_group = 'theme-info'; 79 // private $cache_group = 'theme-info'; 80 private $cache_group = 'test-theme-info'; // Don't pollute production cache. 75 81 76 82 /** … … 79 85 * @var int 80 86 */ 81 private $cache_life = 600; // 10 minutes. 87 // private $cache_life = 600; // 10 minutes. 88 private $cache_life = 1; // Disable caching. 82 89 83 90 /** … … 460 467 $defaults['requires_php'] = true; 461 468 $defaults['creation_time'] = true; 469 $defaults['is_commercial'] = true; 470 $defaults['is_community'] = true; 471 $defaults['external_repository_url'] = true; 472 $defaults['external_support_url'] = true; 473 $defaults['can_configure_categorization_options'] = true; 462 474 } 463 475 … … 526 538 $defaults['requires'] = true; 527 539 $defaults['requires_php'] = true; 540 $defaults['is_commercial'] = true; 541 $defaults['is_community'] = true; 542 $defaults['external_repository_url'] = true; 543 $defaults['external_support_url'] = true; 544 $defaults['can_configure_categorization_options'] = true; 528 545 } 529 546 … … 880 897 } 881 898 899 if ( $this->fields['is_commercial'] ) { 900 $phil->is_commercial = has_term( 'commercial', 'theme_business_model', $theme ); 901 } 902 903 if ( $this->fields['external_support_url'] ) { 904 // Only return external_support_url value if theme is commercial. 905 if ( ! empty( $phil->is_commercial ) ) { 906 $phil->external_support_url = get_post_meta( $theme->ID, 'external_support_url', true ); 907 } else { 908 $phil->external_support_url = false; 909 } 910 } 911 912 if ( $this->fields['is_community'] ) { 913 $phil->is_community = has_term( 'community', 'theme_business_model', $theme ); 914 } 915 916 if ( $this->fields['external_repository_url'] ) { 917 // Only return external_repository_url value if theme is community. 918 if ( ! empty( $phil->is_community ) ) { 919 $phil->external_repository_url = get_post_meta( $theme->ID, 'external_repository_url', true ); 920 } else { 921 $phil->external_repository_url = ''; 922 } 923 } 924 925 if ( $this->fields['can_configure_categorization_options'] ) { 926 $phil->can_configure_categorization_options = current_user_can( 'theme_configure_categorization_options', $theme ); 927 } 928 882 929 if ( class_exists( 'GlotPress_Translate_Bridge' ) ) { 883 930 $glotpress_project = "wp-themes/{$phil->slug}"; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api.php
r11856 r12335 54 54 include __DIR__ . '/rest-api/class-tags-endpoint.php'; 55 55 include __DIR__ . '/rest-api/class-themes-auto-review.php'; 56 include __DIR__ . '/rest-api/class-theme-categorization.php'; 56 57 include __DIR__ . '/rest-api/class-theme-review-stats.php'; 57 58 } ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r12311 r12335 905 905 'requires' => true, 906 906 'requires_php' => true, 907 'is_commercial' => true, 908 'external_support_url' => true, 909 'is_community' => true, 910 'external_repository_url' => true, 911 'can_configure_categorization_options' => true, 907 912 ); 908 913 … … 946 951 'requires' => true, 947 952 'requires_php' => true, 953 'is_commercial' => true, 954 'external_support_url' => true, 955 'is_community' => true, 956 'external_repository_url' => true, 957 'can_configure_categorization_model_options' => true, 948 958 ) 949 959 ) );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)