Skip to content

Commit 8d7862a

Browse files
authored
Add docblocks to constants (#4441)
* docs: document constants * chore: document constant in esp integration * chore: lint
1 parent aaf47b2 commit 8d7862a

33 files changed

Lines changed: 510 additions & 9 deletions

includes/author-filter/class-author-filter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ private static function get_options_from_users( $capability ) {
132132
}
133133
}
134134

135+
/**
136+
* Disables the author filter feature which provides enhanced
137+
* author filtering and search capabilities in the admin.
138+
*
139+
* @constant NEWSPACK_DISABLE_AUTHORS_FILTER
140+
* @type bool
141+
* @default Authors filter enabled
142+
* @status draft
143+
*
144+
* @example define( 'NEWSPACK_DISABLE_AUTHORS_FILTER', true );
145+
*/
135146
if ( ! defined( 'NEWSPACK_DISABLE_AUTHORS_FILTER' ) || ! NEWSPACK_DISABLE_AUTHORS_FILTER ) {
136147
Author_Filter::init();
137148
}

includes/bylines/class-bylines.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ public static function init() {
5353
* @return bool True if the feature is enabled, false otherwise.
5454
*/
5555
public static function is_enabled() {
56+
/**
57+
* Disables Newspack's custom bylines feature which provides enhanced
58+
* author attribution capabilities beyond standard WordPress.
59+
*
60+
* @constant NEWSPACK_CUSTOM_BYLINES_DISABLED
61+
* @type bool
62+
* @default Custom bylines feature enabled
63+
* @status draft
64+
*
65+
* @example define( 'NEWSPACK_CUSTOM_BYLINES_DISABLED', true );
66+
*/
5667
return ! defined( 'NEWSPACK_CUSTOM_BYLINES_DISABLED' ) || ! NEWSPACK_CUSTOM_BYLINES_DISABLED;
5768
}
5869

includes/class-admin-plugins-screen.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,28 @@ public function enqueue_scripts_and_styles( $hook ) {
214214
$installed_plugins = array_values( array_intersect( array_keys( Plugin_Manager::get_managed_plugins() ), array_keys( Plugin_Manager::get_installed_plugins() ) ) );
215215
$installed_plugins[] = 'newspack';
216216

217+
/**
218+
* URL to a plugin review request form. When set, displays a link
219+
* on the plugins screen for users to request plugin reviews.
220+
*
221+
* @constant NEWSPACK_PLUGIN_REVIEW_FORM_URL
222+
* @type string
223+
* @default No review form link shown
224+
* @status draft
225+
*
226+
* @example define( 'NEWSPACK_PLUGIN_REVIEW_FORM_URL', 'https://example.com/plugin-review' );
227+
*/
228+
/**
229+
* URL to an approved plugins list. When set, displays a link
230+
* on the plugins screen to view pre-approved plugins.
231+
*
232+
* @constant NEWSPACK_APPROVED_PLUGINS_LIST_LINK
233+
* @type string
234+
* @default No approved plugins list link shown
235+
* @status draft
236+
*
237+
* @example define( 'NEWSPACK_APPROVED_PLUGINS_LIST_LINK', 'https://example.com/approved-plugins' );
238+
*/
217239
$newspack_plugin_info = [
218240
'plugins' => $plugins,
219241
'installed_plugins' => $installed_plugins,

includes/class-amp-enhancements.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ public static function should_use_amp_plus() {
6262
* @return bool Is AMP plus mode configured.
6363
*/
6464
public static function is_amp_plus_configured() {
65+
/**
66+
* Enables AMP Plus mode which allows certain non-AMP-compatible scripts
67+
* to run on AMP pages. This includes Jetpack modules and Gravity Forms.
68+
* Use with caution as it may affect AMP validation.
69+
*
70+
* @constant NEWSPACK_AMP_PLUS_ENABLED
71+
* @type bool
72+
* @default AMP Plus mode disabled
73+
* @status draft
74+
*
75+
* @example define( 'NEWSPACK_AMP_PLUS_ENABLED', true );
76+
*/
6577
return defined( 'NEWSPACK_AMP_PLUS_ENABLED' ) && NEWSPACK_AMP_PLUS_ENABLED;
6678
}
6779

includes/class-logger.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ class Logger {
2121
* @param string $type Type of the message.
2222
*/
2323
public static function log( $payload, $header = 'NEWSPACK', $type = 'info' ) {
24+
/**
25+
* Controls logging verbosity across Newspack plugins.
26+
*
27+
* Levels:
28+
* - 0: Disabled (default)
29+
* - 1: Basic logging
30+
* - 2: Include caller function info
31+
* - 3+: Include data payload
32+
*
33+
* @constant NEWSPACK_LOG_LEVEL
34+
* @type int
35+
* @default Logging disabled (0)
36+
* @status draft
37+
*
38+
* @example define( 'NEWSPACK_LOG_LEVEL', 2 );
39+
*/
2440
if ( ! defined( 'NEWSPACK_LOG_LEVEL' ) || 0 >= (int) NEWSPACK_LOG_LEVEL ) {
2541
return;
2642
}

includes/class-newspack.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ public static function load_textdomain() {
6363
private function define_constants() {
6464
define( 'NEWSPACK_VERSION', '0.0.1' );
6565
define( 'NEWSPACK_ABSPATH', dirname( NEWSPACK_PLUGIN_FILE ) . '/' );
66+
/**
67+
* Path to Composer's vendor directory. Override to use a shared vendor directory
68+
* across multiple plugins.
69+
*
70+
* @constant NEWSPACK_COMPOSER_ABSPATH
71+
* @type string
72+
* @default Plugin's vendor/ directory
73+
* @status draft
74+
*
75+
* @example define( 'NEWSPACK_COMPOSER_ABSPATH', '/path/to/shared/vendor/' );
76+
*/
6677
if ( ! defined( 'NEWSPACK_COMPOSER_ABSPATH' ) ) {
6778
define( 'NEWSPACK_COMPOSER_ABSPATH', dirname( NEWSPACK_PLUGIN_FILE ) . '/vendor/' );
6879
}
@@ -331,6 +342,18 @@ public function deactivation_hook() {
331342
* @param WP_Screen $current_screen Current WP_Screen object.
332343
*/
333344
public static function restrict_user_access( $current_screen ) {
345+
/**
346+
* Array of user IDs allowed to access plugin management screens
347+
* (plugins, plugin-install, plugin-editor). When defined, only listed
348+
* users can access these screens; others are redirected to the dashboard.
349+
*
350+
* @constant NEWSPACK_ALLOWED_PLUGIN_EDITORS
351+
* @type array
352+
* @default All users with appropriate capabilities can access plugin screens
353+
* @status draft
354+
*
355+
* @example define( 'NEWSPACK_ALLOWED_PLUGIN_EDITORS', [ 1, 2, 3 ] );
356+
*/
334357
if ( ! defined( 'NEWSPACK_ALLOWED_PLUGIN_EDITORS' ) ) {
335358
return;
336359
}

includes/class-performance.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ public static function optimise_homepage_posts_block( $attributes ) {
9191
* Process the HTML output.
9292
*/
9393
public static function process_output_html() {
94+
/**
95+
* Disables HTML output processing for performance optimizations.
96+
* Set to true to bypass any filters registered on 'newspack_output_html'.
97+
*
98+
* @constant NEWSPACK_DISABLE_HTML_PERF_PROCESSING
99+
* @type bool
100+
* @default HTML performance processing enabled
101+
* @status draft
102+
*
103+
* @example define( 'NEWSPACK_DISABLE_HTML_PERF_PROCESSING', true );
104+
*/
94105
if ( defined( 'NEWSPACK_DISABLE_HTML_PERF_PROCESSING' ) && NEWSPACK_DISABLE_HTML_PERF_PROCESSING ) {
95106
return;
96107
}

includes/class-starter-content.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ public static function upload_logo() {
226226
* @return bool E2E testing environment?
227227
*/
228228
public static function is_e2e() {
229+
/**
230+
* Indicates the site is running in E2E (end-to-end) testing mode.
231+
* Used to adjust behavior during automated testing.
232+
*
233+
* @constant NEWSPACK_IS_E2E
234+
* @type bool
235+
* @default Normal operation
236+
* @status draft
237+
*
238+
* @example define( 'NEWSPACK_IS_E2E', true );
239+
*/
229240
return defined( 'NEWSPACK_IS_E2E' ) && NEWSPACK_IS_E2E;
230241
}
231242
}

includes/content-gate/class-content-gate.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public static function init() {
9292
* @return bool
9393
*/
9494
public static function is_newspack_feature_enabled() {
95+
/**
96+
* Enables the content gating feature which allows restricting
97+
* content access based on membership, donations, or other criteria.
98+
*
99+
* @constant NEWSPACK_CONTENT_GATES
100+
* @type bool
101+
* @default Content gates disabled
102+
* @status draft
103+
*
104+
* @example define( 'NEWSPACK_CONTENT_GATES', true );
105+
*/
95106
return defined( 'NEWSPACK_CONTENT_GATES' ) && NEWSPACK_CONTENT_GATES;
96107
}
97108

includes/oauth/class-google-oauth.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@ public static function remove_credentials() {
469469
* Is Google OAuth configured?
470470
*/
471471
public static function is_oauth_configured() {
472+
/**
473+
* Disables Google OAuth integration even if the OAuth proxy is configured.
474+
* Use this to prevent Google sign-in on specific environments.
475+
*
476+
* @constant NEWSPACK_DISABLE_GOOGLE_OAUTH
477+
* @type bool
478+
* @default Google OAuth enabled (if proxy configured)
479+
* @status draft
480+
*
481+
* @example define( 'NEWSPACK_DISABLE_GOOGLE_OAUTH', true );
482+
*/
472483
return OAuth::is_proxy_configured( 'google' ) && ( ! defined( 'NEWSPACK_DISABLE_GOOGLE_OAUTH' ) || ! NEWSPACK_DISABLE_GOOGLE_OAUTH );
473484
}
474485
}

0 commit comments

Comments
 (0)