Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML API: CSS matching #11

Draft
wants to merge 116 commits into
base: trunk
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
6383964
I18N: Load admin translations for auto update emails.
swissspidy Dec 2, 2024
daad863
Plugins: Make more plugin-related functions available early on.
swissspidy Dec 2, 2024
d93b275
Customize: Begin HTML markup before Customizer script hooks.
SergeyBiryukov Dec 2, 2024
8eb8d63
External Libraries: Upgrade PHPMailer to version 6.9.3.
SergeyBiryukov Dec 3, 2024
1d49212
Block Hooks: Fix context in `update_ignored_hooked_blocks_postmeta`.
ockham Dec 4, 2024
d576e24
Build/Test Tools: Add `repository` input to support JSON reading work…
desrosj Dec 4, 2024
ea80ac8
Build/Test Tools: Support older MariaDB versions in local Docker envi…
desrosj Dec 4, 2024
9558c1f
Build/Test Tools: Run install tests when JSON reading workflow is cha…
desrosj Dec 4, 2024
7d3ce7a
Docs: Remove blank line at the end of `wp_prepare_attachment_for_js()…
SergeyBiryukov Dec 4, 2024
b67c76e
Plugins: Load `wp-admin/includes/plugin.php` earlier.
swissspidy Dec 5, 2024
e585c95
Build/Test Tools: Properly escape `$` characters in Docker compose file.
desrosj Dec 5, 2024
5adbb3e
Build/Test Tools: Use newer versions for `include` jobs.
desrosj Dec 5, 2024
2d8d21f
Build/Test Tools: Support `trunk` as a version.
desrosj Dec 5, 2024
29ec312
Build/Test Tools: Introduce workflow for testing the local Docker env…
desrosj Dec 5, 2024
9c7d008
Embeds: ensure correct thumbnail height.
swissspidy Dec 5, 2024
59a6b5e
I18N: Add new `WP_Locale::get_month_genitive()` method.
swissspidy Dec 5, 2024
0e8c4fb
WIP class skeleton
sirreal Nov 19, 2024
2d3d283
Document class
sirreal Nov 20, 2024
40222d3
Do not support namespaced selectors
sirreal Nov 21, 2024
6092642
Flesh out stuff
sirreal Nov 22, 2024
3e3b2b2
Starting to actually parse
sirreal Nov 22, 2024
967557f
Add ident tests
sirreal Nov 22, 2024
2ec1db3
Fix ident non-ascii bug
sirreal Nov 22, 2024
ee2c7ce
Use class after defined
sirreal Nov 22, 2024
0f708ba
Fix some char stuff
sirreal Nov 22, 2024
3cb455d
Improve tests
sirreal Nov 22, 2024
5609e50
Housekeeping
sirreal Nov 22, 2024
4f25bc2
Require new file in WP
sirreal Nov 22, 2024
943293f
Fix offset type
sirreal Nov 22, 2024
24c9744
Add more tests and invalid tests
sirreal Nov 22, 2024
a7c10b9
Fix wrong offset var usage
sirreal Nov 22, 2024
dd718b7
comment tweak
sirreal Nov 22, 2024
5884aca
Implement codepoint escape with strspn
sirreal Nov 22, 2024
a9a077f
Test with UPPER HEX
sirreal Nov 22, 2024
5f53e0a
Add ID tests
sirreal Nov 25, 2024
effbbbe
Improve tests
sirreal Nov 25, 2024
62ec5bb
Add class selector tests
sirreal Nov 25, 2024
153f009
Add class selector
sirreal Nov 25, 2024
fcc6401
Simplify id selector parse
sirreal Nov 25, 2024
21c67e5
Improve ident tests
sirreal Nov 25, 2024
728d798
Add type selector tests
sirreal Nov 25, 2024
e1e8e09
Add docs and remove unreachable line
sirreal Nov 25, 2024
13ac3c1
Add type selector class
sirreal Nov 25, 2024
a3c25e8
Add attribute selector tests
sirreal Nov 25, 2024
ad5c600
improve attr tests
sirreal Nov 25, 2024
6758704
Fix expectation argument order
sirreal Nov 25, 2024
e97842c
Add test and fix is_ident
sirreal Nov 25, 2024
ef00856
Add parse_string stub
sirreal Nov 26, 2024
463e799
Add attribute selector parsing
sirreal Nov 26, 2024
0f5b28c
Fix test expectations
sirreal Nov 26, 2024
f4a491a
More and improved attribute tests
sirreal Nov 26, 2024
b680b1b
Implement parse_string
sirreal Nov 26, 2024
e7da05f
Add string parse tests
sirreal Nov 26, 2024
d5e7e60
Remove covers annotations
sirreal Nov 26, 2024
08187c6
Remove unused line
sirreal Nov 26, 2024
5a5066c
Improve tests for 100% coverage on parse methods
sirreal Nov 26, 2024
2f8bd19
Improve documentation
sirreal Nov 26, 2024
8b0ac55
Fix parse return type and return annotations
sirreal Nov 26, 2024
dffcac6
Update documentation links and grammar
sirreal Nov 27, 2024
9f81744
Update documentation and class name
sirreal Nov 27, 2024
d4c6f38
Add selector class
sirreal Nov 27, 2024
6432056
Implement complex selector
sirreal Nov 27, 2024
5c746cd
Working and tested
sirreal Nov 27, 2024
501102a
Selector parsing should allow cap I,S modifier
sirreal Nov 28, 2024
f98fbb3
CSS Add matches to selector classes
sirreal Nov 28, 2024
c8f16e1
Match is successful on _any_ match in selector list
sirreal Nov 28, 2024
c689c9c
PICKME: Add is_quirks_mode method to processor
sirreal Nov 28, 2024
1221efa
ID matches depend on quirks mode
sirreal Nov 28, 2024
e5e94b1
has_class may return null, coerce to bool
sirreal Nov 28, 2024
1e888ba
Update docs to only allow subclass selectors in final complex selecto…
sirreal Nov 28, 2024
dd4fcb0
Restrict complex selectors to only allow subclass selectors in final …
sirreal Nov 28, 2024
256c55a
Work on complex selector handling
sirreal Nov 28, 2024
465cc36
Implement descendent selector matching
sirreal Nov 28, 2024
467d45d
Add null check for subclass selectors
sirreal Nov 29, 2024
44bfc64
CSS selector reformat ternaries
sirreal Nov 29, 2024
ca4531c
Implement ~= attribute matching
sirreal Nov 29, 2024
489db93
CSS fix return type
sirreal Nov 29, 2024
e57a211
Fix static analysis problems
sirreal Nov 29, 2024
509e648
Fix and annotate things (static analysis)
sirreal Nov 29, 2024
58c1698
update tests
sirreal Nov 29, 2024
c9b9145
Id attribute must be a string to match id selector
sirreal Nov 29, 2024
e5cac63
Coerce boolean attributes to ""
sirreal Nov 29, 2024
2bafae9
Fix a few more static analysis things
sirreal Nov 29, 2024
8fe57e3
Add select method
sirreal Nov 28, 2024
ab2fe0d
Unify parsing under single class
sirreal Dec 3, 2024
6a6969f
Rename files to align with class name
sirreal Dec 3, 2024
27ca891
Add html processor select test suite
sirreal Dec 3, 2024
9ff2769
Fix select types
sirreal Dec 3, 2024
d1a276b
Update class doc
sirreal Dec 4, 2024
4909b56
Improve select_ method arguments, docs, implementation
sirreal Dec 4, 2024
1d45225
Split classes into their own files
sirreal Dec 4, 2024
0b277b4
Remove redundant see phpdoc annotations
sirreal Dec 4, 2024
0c53c42
Fix docs and return type on select_all
sirreal Dec 4, 2024
d966e9a
Improve html select test docs
sirreal Dec 4, 2024
5201ba9
Add select support to tag processor
sirreal Dec 4, 2024
2036a83
Simplify whitspace splitting function
sirreal Dec 4, 2024
3421a4e
Remove unreachable code
sirreal Dec 4, 2024
784b2d9
Add a lot of selector integration tests
sirreal Dec 4, 2024
4d4c5fe
Extract normalize input method
sirreal Dec 4, 2024
dbc37fc
tests
sirreal Dec 4, 2024
d241f31
Add nonfinal subclass selector test
sirreal Dec 4, 2024
663070b
Fix logic bug in child selector exploration
sirreal Dec 5, 2024
5478af9
Improve selector integration tests
sirreal Dec 5, 2024
4f6bf94
Try abstract class instead of interface
sirreal Dec 5, 2024
fe07dfd
Revert "Try abstract class instead of interface"
sirreal Dec 5, 2024
143e092
Clean up and document attribute selector
sirreal Dec 5, 2024
32ee2a7
Update ticket number in tests
sirreal Dec 5, 2024
5922494
Improve some types
sirreal Dec 5, 2024
e492aa6
Fix and improve string token parsing
sirreal Dec 5, 2024
81c6758
Update attribute selector tests
sirreal Dec 5, 2024
7bccf3e
Revert "Update attribute selector tests"
sirreal Dec 5, 2024
3949cc5
Improve some complex selector match tests
sirreal Dec 5, 2024
8f2a2ca
Merge branch 'html-api/add-css-selector-parser' into html-api/work-on…
sirreal Nov 28, 2024
cf6ffef
DROPME: phpstan setup
sirreal Nov 29, 2024
9782e10
Max phpstan level
sirreal Nov 29, 2024
f38704e
DROPME: ignore code coverage HTML API
sirreal Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Plugins: Make more plugin-related functions available early on.
This is a follow-up to [59461], which moved `get_plugin_data()` from `wp-admin/includes/plugin.php` to `wp-includes/functions.php` so it's available during the plugin loading process.

Related functions like `is_plugin_active()` are often used together and should therefore be moved as well, to improve backward compatibility for plugins which load `wp-admin/includes/plugin.php` only conditionally.

Props johnbillion, dd32, swissspidy.
See #62244.

git-svn-id: https://develop.svn.wordpress.org/trunk@59479 602fd350-edb4-49c9-b593-d223f7449a82
swissspidy committed Dec 2, 2024
commit daad8631f707f730530711ed874efe94c7fec968
91 changes: 0 additions & 91 deletions src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
@@ -304,97 +304,6 @@ function _get_dropins() {
return $dropins;
}

/**
* Determines whether a plugin is active.
*
* Only plugins installed in the plugins/ folder can be active.
*
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
* return false for those plugins.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 2.5.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True, if in the active plugins list. False, not in the list.
*/
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}

/**
* Determines whether the plugin is inactive.
*
* Reverse of is_plugin_active(). Used as a callback.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 3.1.0
*
* @see is_plugin_active()
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if inactive. False if active.
*/
function is_plugin_inactive( $plugin ) {
return ! is_plugin_active( $plugin );
}

/**
* Determines whether the plugin is active for the entire network.
*
* Only plugins installed in the plugins/ folder can be active.
*
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
* return false for those plugins.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 3.0.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if active for the network, otherwise false.
*/
function is_plugin_active_for_network( $plugin ) {
if ( ! is_multisite() ) {
return false;
}

$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}

return false;
}

/**
* Checks for "Network: true" in the plugin header to see if this should
* be activated only as a network wide plugin. The plugin would also work
* when Multisite is not enabled.
*
* Checks for "Site Wide Only: true" for backward compatibility.
*
* @since 3.0.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if plugin is network only, false otherwise.
*/
function is_network_only_plugin( $plugin ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_data ) {
return $plugin_data['Network'];
}
return false;
}

/**
* Attempts activation of plugin in a "sandbox" and redirects on success.
*
91 changes: 91 additions & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
@@ -7145,6 +7145,97 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
return $plugin_data;
}

/**
* Determines whether a plugin is active.
*
* Only plugins installed in the plugins/ folder can be active.
*
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
* return false for those plugins.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 2.5.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True, if in the active plugins list. False, not in the list.
*/
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}

/**
* Determines whether the plugin is inactive.
*
* Reverse of is_plugin_active(). Used as a callback.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 3.1.0
*
* @see is_plugin_active()
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if inactive. False if active.
*/
function is_plugin_inactive( $plugin ) {
return ! is_plugin_active( $plugin );
}

/**
* Determines whether the plugin is active for the entire network.
*
* Only plugins installed in the plugins/ folder can be active.
*
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
* return false for those plugins.
*
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
*
* @since 3.0.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if active for the network, otherwise false.
*/
function is_plugin_active_for_network( $plugin ) {
if ( ! is_multisite() ) {
return false;
}

$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}

return false;
}

/**
* Checks for "Network: true" in the plugin header to see if this should
* be activated only as a network wide plugin. The plugin would also work
* when Multisite is not enabled.
*
* Checks for "Site Wide Only: true" for backward compatibility.
*
* @since 3.0.0
*
* @param string $plugin Path to the plugin file relative to the plugins directory.
* @return bool True if plugin is network only, false otherwise.
*/
function is_network_only_plugin( $plugin ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_data ) {
return $plugin_data['Network'];
}
return false;
}

/**
* Returns true.
*