diff --git a/build/wp-5.9.data b/build/wp-5.9.data old mode 100755 new mode 100644 index fca3ff5829..3be71a44c0 --- a/build/wp-5.9.data +++ b/build/wp-5.9.data @@ -13217,10 +13217,10 @@ if ( current_user_can( 'customize' ) ) { printf( ' get_error_data(); if ( ! empty( $data ) ) { wp_die( '

' . $comment->get_error_message() . '

', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true, ) ); } else { exit; } } $user = wp_get_current_user(); $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) ); do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { $location = add_query_arg( array( 'unapproved' => $comment->comment_ID, 'moderation-hash' => wp_hash( $comment->comment_date_gmt ), ), $location ); } $location = apply_filters( 'comment_post_redirect', $location, $comment ); wp_safe_redirect( $location ); exit; Gravatar
.1comment �/��-d,U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-03 17:20:332023-01-03 17:20:33

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a.� 33�M#  # 33 M 2023-01-03 17:20:332023-01-03 17:20:33 +Commenter avatars come from Gravatar.1comment �1����0w.d-U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-30 20:07:122023-01-30 20:07:12

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a/� 33�M#  # 33 M 2023-01-30 20:07:122023-01-30 20:07:12

This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

@@ -13238,9 +13238,9 @@ Commenter avatars come from Gravatar.1comment

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!

-Sample Pagepublishclosedopensample-page2023-01-03 17:20:332023-01-03 17:20:33http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-03 17:20:332023-01-03 17:20:33 +Sample Pagepublishclosedopensample-page2023-01-30 20:07:122023-01-30 20:07:12http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-30 20:07:122023-01-30 20:07:12

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

-Hello world!publishopenopenhello-world2023-01-03 17:20:332023-01-03 17:20:33http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( +Hello world!publishopenopenhello-world2023-01-30 20:07:122023-01-30 20:07:12http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( option_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , option_name text NOT NULL default '', option_value text NOT NULL, @@ -13317,7 +13317,7 @@ CREATE TABLE wp_comments ( user_activation_key text NOT NULL default '', user_status integer NOT NULL default '0', display_name text NOT NULL default '' -) �x ��]�j�z=�.�W�� �A�x�U �I � �S!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)Y#)uindexmeta_key_33wp_commentmetaCREATE INDEX meta_key_33 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)S##oindexmeta_key_30wp_termmetaCREATE INDEX meta_key_30 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( +) �x ��]�j�z=�.�W�� �A�x�U �j � � RS!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)Y#)uindexmeta_key_25wp_commentmetaCREATE INDEX meta_key_25 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)S##oindexmeta_key_37wp_termmetaCREATE INDEX meta_key_37 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , post_author integer NOT NULL default '0', post_date text NOT NULL default '0000-00-00 00:00:00', @@ -13346,7 +13346,7 @@ CREATE TABLE wp_comments ( post_id integer NOT NULL default '0', meta_key text default NULL, meta_value text -)�P(#oindexpost_authorwp_posts+CREATE INDEX post_author ON wp_posts(post_author)P'#oindexpost_parentwp_posts*CREATE INDEX post_parent ON wp_posts(post_parent)r&-�'indextype_status_datewp_posts)CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J%gindexpost_namewp_posts(CREATE INDEX post_name ON wp_posts(post_name)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) +)�P)#oindexpost_authorwp_posts,CREATE INDEX post_author ON wp_posts(post_author)P(#oindexpost_parentwp_posts+CREATE INDEX post_parent ON wp_posts(post_parent)r'-�'indextype_status_datewp_posts*CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J&gindexpost_namewp_posts)CREATE INDEX post_name ON wp_posts(post_name)Q%!#mindexmeta_key_5wp_postmeta(CREATE INDEX meta_key_5 ON wp_postmeta(meta_key)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) �� admin �� admin ��3 admin@localhost.com @@ -13365,36 +13365,38 @@ CREATE TABLE wp_comments (   �� -��3 12023-01-03 17:20:33 -��3 2023-01-03 17:20:33 +��3 12023-01-30 20:07:12 +��3 2023-01-30 20:07:12 �� ��; wapuu@wordpress.example  -g� }��hO4 m � � Q�� k +{���A�a }��hO4 m � � Q�� k � � F A� �C -mH ��� +m�H ��� S  7�k � �� W� 7 �� � / � K \ {��� -  1 � � � � +  1 � � � ��� � � � � \X1 W � � %� I�� 0 �  � � -� � � �8 � � a � q~n ��� - � +� � � �8 � � a � q~n ��X�l +{A*���� ��� -���-sidebars_widgetsg%widget_blockf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email +����!G_site_transient_update_themes}C_site_transient_theme_roots|'S_site_transient_timeout_theme_roots{#C_site_transient_update_corey7_transient_doing_cronw1widget_custom_htmlv+widget_nav_menuu-widget_tag_cloudt!nonce_salts nonce_keyr'widget_searchq#widget_metap1widget_media_videoo5widget_media_galleryn1widget_media_imagem1widget_media_audiol+widget_archivesk+widget_calendarj%widget_pagesicronh-sidebars_widgetsg%widget_blockf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email #use_smilies +use_balanceTags'start_of_week#admin_email1users_can_register+blogdescription blognamehome  siteurl -g �� � % ����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � �yesgyesfyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes + B{ -� � %  w p I ; 4 -����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � � � � � � � � � � � ~ h ` X P Pno}no|no{noyyeswyesvyesuyestnosnoryesqyespyesoyesnyesmyeslyeskyesjyesiyeshyesgyesfyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes yes yesyesyesyesyesyesyes yes ���  +���/_wp_page_template/ _wp_page_template ����)privacy-policy#sample-page# hello-world -����$3pagedraft2023-01-03 17:20:33&3pagepublish2023-01-03 17:20:33$3 postpublish2023-01-03 17:20:33 +����$3pagedraft2023-01-30 20:07:12&3pagepublish2023-01-30 20:07:12$3 postpublish2023-01-30 20:07:12 ���� -����   mU-���]@�����f> � � � � v V < !  � � � � kY>&����qY8�����aL6������fM3�����hA����pT3�����vW-���v^8 -���kJJI3ipermalink_structure/index.php/%year%/%monthnum%/%day%/%postname%/yesJ1(UKfinished_splitting_shared_terms1yesT5link_manager_enabled0yesS3default_post_format0yesR'page_on_front0yesQ)page_for_posts0yesP+ timezone_stringyesO/uninstall_pluginsa:0:{}noN!widget_rssa:0:{}yesM#widget_texta:0:{}yesL/widget_categoriesa:0:{}yesK%sticky_postsa:0:{}yesJ'comment_orderascyes#I7default_comments_pagenewestyesH/comments_per_page50yesG'page_comments0yesF7thread_comments_depth5yesE+thread_comments1yes!D;close_comments_days_old14yes%CEclose_comments_for_old_posts0yesB3 image_default_alignyesA1 image_default_sizeyes#@;image_default_link_typenoneyes?%large_size_h1024yes>%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version51917yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes!)!+stylesheettwentytwentyoneyes(+templatetwentytwentyoneyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyes!)active_pluginsa:0:{}yes + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes -1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes2+CblogdescriptionJust another WordPress siteyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version51917yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1688318432yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where we send your data

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-03 17:20:332023-01-03 17:20:33http://127.0.0.1:8000/?page_id=3page  w w n �e!fresh_site1yes�_g-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�f%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes0DENY FROM ALL � � � � v V < !  � � � � kY>& ����qY8�����aL6������fM3�����hA����pT3�����vW-���v^8 +���kJJI3ipermalink_structure/index.php/%year%/%monthnum%/%day%/%postname%/yesJ1(UKfinished_splitting_shared_terms1yesT5link_manager_enabled0yesS3default_post_format0yesR'page_on_front0yesQ)page_for_posts0yesP+ timezone_stringyesO/uninstall_pluginsa:0:{}noN!widget_rssa:0:{}yesM#widget_texta:0:{}yesL/widget_categoriesa:0:{}yesK%sticky_postsa:0:{}yesJ'comment_orderascyes#I7default_comments_pagenewestyesH/comments_per_page50yesG'page_comments0yesF7thread_comments_depth5yesE+thread_comments1yes!D;close_comments_days_old14yes%CEclose_comments_for_old_posts0yesB3 image_default_alignyesA1 image_default_sizeyes#@;image_default_link_typenoneyes?%large_size_h1024yes>%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version51917yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes!)!+stylesheettwentytwentyoneyes(+templatetwentytwentyoneyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyesm + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�R!)�active_pluginsa:1:{i:0;s:41:"wordpress-importer/wordpress-importer.php";}yes' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes +1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes2+CblogdescriptionJust another WordPress siteyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version51917yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1690661232yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where we send your data

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-30 20:07:122023-01-30 20:07:12http://127.0.0.1:8000/?page_id=3page �# w n �# � � I ��_,��P�� 7 +��h�ucrona:3:{i:1675109244;a:6:{s:32:"recovery_mode_clean_expired_keys";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}s:18:"wp_https_detection";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:34:"wp_privacy_delete_old_export_files";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"hourly";s:4:"args";a:0:{}s:8:"interval";i:3600;}}s:16:"wp_version_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:17:"wp_update_plugins";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:16:"wp_update_themes";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}}i:1675195644;a:1:{s:30:"wp_site_health_scheduled_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"weekly";s:4:"args";a:0:{}s:8:"interval";i:604800;}}}s:7:"version";i:2;}yes8v1Iwidget_custom_htmla:1:{s:12:"_multiwidget";i:1;}yes5u+Iwidget_nav_menua:1:{s:12:"_multiwidget";i:1;}yes6t-Iwidget_tag_clouda:1:{s:12:"_multiwidget";i:1;}yesRs!� nonce_salt yY;.4TYsY=.ZJuj2^+(9>s>F^:ltEC$W4&yW9hEm?$BD=_-c*SNJs-(P^sWRUMznoQr� nonce_key-wdV@ K$D`p`N1CFIl W[Q|TV#h+j%S>.l=H8gLZMt5bOUT[ e!)lONlAnWcG*bGno3q'Iwidget_searcha:1:{s:12:"_multiwidget";i:1;}yes1p#Iwidget_metaa:1:{s:12:"_multiwidget";i:1;}yes8o1Iwidget_media_videoa:1:{s:12:"_multiwidget";i:1;}yes:n5Iwidget_media_gallerya:1:{s:12:"_multiwidget";i:1;}yes8m1Iwidget_media_imagea:1:{s:12:"_multiwidget";i:1;}yes8l1Iwidget_media_audioa:1:{s:12:"_multiwidget";i:1;}yes5k+Iwidget_archivesa:1:{s:12:"_multiwidget";i:1;}yes5j+Iwidget_calendara:1:{s:12:"_multiwidget";i:1;}yes2i%Iwidget_pagesa:1:{s:12:"_multiwidget";i:1;}yesL>w7O_transient_doing_cron1675109244.0978488922119140625000yese!fresh_site1yes�_g-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�f%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes �a+���y}G�5_site_transient_update_themesO:8:"stdClass":5:{s:12:"last_checked";i:1675109247;s:7:"checked";a:1:{s:15:"twentytwentyone";s:3:"1.5";}s:8:"response";a:1:{s:15:"twentytwentyone";a:6:{s:5:"theme";s:15:"twentytwentyone";s:11:"new_version";s:3:"1.7";s:3:"url";s:45:"https://wordpress.org/themes/twentytwentyone/";s:7:"package";s:61:"https://downloads.wordpress.org/theme/twentytwentyone.1.7.zip";s:8:"requires";s:3:"5.3";s:12:"requires_php";s:3:"5.6";}}s:9:"no_update";a:0:{}s:12:"translations";a:0:{}}noM|Cc_site_transient_theme_rootsa:1:{s:15:"twentytwentyone";s:7:"/themes";}no4{S!_site_transient_timeout_theme_roots1675111047no�yC�_site_transient_update_coreO:8:"stdClass":4:{s:7:"updates";a:4:{i:0;O:8:"stdClass":10:{s:8:"response";s:7:"upgrade";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.1.1-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.1.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.1.1";s:7:"version";s:5:"6.1.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";}i:1;O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.1.1-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.1.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.1.1";s:7:"version";s:5:"6.1.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";s:9:"new_files";s:1:"1";}i:2;O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:57:"https://downloads.wordpress.org/release/wordpress-6.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:57:"https://downloads.wordpress.org/release/wordpress-6.1.zip";s:10:"no_content";s:68:"https://downloads.wordpress.org/release/wordpress-6.1-no-content.zip";s:11:"new_bundled";s:69:"https://downloads.wordpress.org/release/wordpress-6.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:3:"6.1";s:7:"version";s:3:"6.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";s:9:"new_files";s:1:"1";}i:3;O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.0.3.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.0.3.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.0.3-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.0.3-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.0.3";s:7:"version";s:5:"6.0.3";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";s:9:"new_files";s:1:"1";}}s:12:"last_checked";i:1675109246;s:15:"version_checked";s:5:"5.9.5";s:12:"translations";a:0:{}}noDENY FROM ALL @@ -14051,6 +14053,2670 @@ Dolly'll never go away again"; $lyrics = explode( "\n", $lyrics ); return wptext } "; } add_action( 'admin_head', 'dolly_css' ); header(); + + $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step']; + switch ( $step ) { + case 0: + $this->greet(); + break; + case 1: + check_admin_referer( 'import-upload' ); + if ( $this->handle_upload() ) { + $this->import_options(); + } + break; + case 2: + check_admin_referer( 'import-wordpress' ); + $this->fetch_attachments = ( ! empty( $_POST['fetch_attachments'] ) && $this->allow_fetch_attachments() ); + $this->id = (int) $_POST['import_id']; + $file = get_attached_file( $this->id ); + set_time_limit( 0 ); + $this->import( $file ); + break; + } + + $this->footer(); + } + + /** + * The main controller for the actual import stage. + * + * @param string $file Path to the WXR file for importing + */ + function import( $file ) { + add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) ); + add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) ); + + $this->import_start( $file ); + + $this->get_author_mapping(); + + wp_suspend_cache_invalidation( true ); + $this->process_categories(); + $this->process_tags(); + $this->process_terms(); + $this->process_posts(); + wp_suspend_cache_invalidation( false ); + + // update incorrect/missing information in the DB + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->remap_featured_images(); + + $this->import_end(); + } + + /** + * Parses the WXR file and prepares us for the task of processing parsed data + * + * @param string $file Path to the WXR file for importing + */ + function import_start( $file ) { + if ( ! is_file( $file ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo __( 'The file does not exist, please try again.', 'wordpress-importer' ) . '

'; + $this->footer(); + die(); + } + + $import_data = $this->parse( $file ); + + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + $this->footer(); + die(); + } + + $this->version = $import_data['version']; + $this->get_authors_from_import( $import_data ); + $this->posts = $import_data['posts']; + $this->terms = $import_data['terms']; + $this->categories = $import_data['categories']; + $this->tags = $import_data['tags']; + $this->base_url = esc_url( $import_data['base_url'] ); + + wp_defer_term_counting( true ); + wp_defer_comment_counting( true ); + + do_action( 'import_start' ); + } + + /** + * Performs post-import cleanup of files and the cache + */ + function import_end() { + wp_import_cleanup( $this->id ); + + wp_cache_flush(); + foreach ( get_taxonomies() as $tax ) { + delete_option( "{$tax}_children" ); + _get_term_hierarchy( $tax ); + } + + wp_defer_term_counting( false ); + wp_defer_comment_counting( false ); + + echo '

' . __( 'All done.', 'wordpress-importer' ) . ' ' . __( 'Have fun!', 'wordpress-importer' ) . '' . '

'; + echo '

' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '

'; + + do_action( 'import_end' ); + } + + /** + * Handles the WXR upload and initial parsing of the file to prepare for + * displaying author import options + * + * @return bool False if error uploading or invalid file, true otherwise + */ + function handle_upload() { + $file = wp_import_handle_upload(); + + if ( isset( $file['error'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $file['error'] ) . '

'; + return false; + } elseif ( ! file_exists( $file['file'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + printf( __( 'The export file could not be found at %s. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file['file'] ) ); + echo '

'; + return false; + } + + $this->id = (int) $file['id']; + $import_data = $this->parse( $file['file'] ); + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + return false; + } + + $this->version = $import_data['version']; + if ( $this->version > $this->max_wxr_version ) { + echo '

'; + printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html( $import_data['version'] ) ); + echo '

'; + } + + $this->get_authors_from_import( $import_data ); + + return true; + } + + /** + * Retrieve authors from parsed WXR data + * + * Uses the provided author information from WXR 1.1 files + * or extracts info from each post for WXR 1.0 files + * + * @param array $import_data Data returned by a WXR parser + */ + function get_authors_from_import( $import_data ) { + if ( ! empty( $import_data['authors'] ) ) { + $this->authors = $import_data['authors']; + // no author information, grab it from the posts + } else { + foreach ( $import_data['posts'] as $post ) { + $login = sanitize_user( $post['post_author'], true ); + if ( empty( $login ) ) { + printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post['post_author'] ) ); + echo '
'; + continue; + } + + if ( ! isset( $this->authors[ $login ] ) ) { + $this->authors[ $login ] = array( + 'author_login' => $login, + 'author_display_name' => $post['post_author'], + ); + } + } + } + } + + /** + * Display pre-import options, author importing/mapping and option to + * fetch attachments + */ + function import_options() { + $j = 0; + // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect + ?> +
+ + + +authors ) ) : ?> +

+

+allow_create_users() ) : ?> +

+ +
    +authors as $author ) : ?> +
  1. author_select( $j++, $author ); ?>
  2. + +
+ + +allow_fetch_attachments() ) : ?> +

+

+ + +

+ + +

+
+ ' . esc_html( $author['author_display_name'] ); + if ( '1.0' != $this->version ) { + echo ' (' . esc_html( $author['author_login'] ) . ')'; + } + echo '
'; + + if ( '1.0' != $this->version ) { + echo '
'; + } + + $create_users = $this->allow_create_users(); + if ( $create_users ) { + echo ''; + + echo '
'; + } + + echo ''; + + echo ' ' . wp_dropdown_users( + array( + 'name' => "user_map[$n]", + 'id' => 'imported_authors_' . $n, + 'multi' => true, + 'show_option_all' => __( '- Select -', 'wordpress-importer' ), + 'show' => 'display_name_with_login', + 'echo' => 0, + ) + ); + + echo ''; + + if ( '1.0' != $this->version ) { + echo '
'; + } + } + + /** + * Map old author logins to local user IDs based on decisions made + * in import options form. Can map to an existing user, create a new user + * or falls back to the current user in case of error with either of the previous + */ + function get_author_mapping() { + if ( ! isset( $_POST['imported_authors'] ) ) { + return; + } + + $create_users = $this->allow_create_users(); + + foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) { + // Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts. + $santized_old_login = sanitize_user( $old_login, true ); + $old_id = isset( $this->authors[ $old_login ]['author_id'] ) ? intval( $this->authors[ $old_login ]['author_id'] ) : false; + + if ( ! empty( $_POST['user_map'][ $i ] ) ) { + $user = get_userdata( intval( $_POST['user_map'][ $i ] ) ); + if ( isset( $user->ID ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user->ID; + } + $this->author_mapping[ $santized_old_login ] = $user->ID; + } + } elseif ( $create_users ) { + if ( ! empty( $_POST['user_new'][ $i ] ) ) { + $user_id = wp_create_user( $_POST['user_new'][ $i ], wp_generate_password() ); + } elseif ( '1.0' != $this->version ) { + $user_data = array( + 'user_login' => $old_login, + 'user_pass' => wp_generate_password(), + 'user_email' => isset( $this->authors[ $old_login ]['author_email'] ) ? $this->authors[ $old_login ]['author_email'] : '', + 'display_name' => $this->authors[ $old_login ]['author_display_name'], + 'first_name' => isset( $this->authors[ $old_login ]['author_first_name'] ) ? $this->authors[ $old_login ]['author_first_name'] : '', + 'last_name' => isset( $this->authors[ $old_login ]['author_last_name'] ) ? $this->authors[ $old_login ]['author_last_name'] : '', + ); + $user_id = wp_insert_user( $user_data ); + } + + if ( ! is_wp_error( $user_id ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user_id; + } + $this->author_mapping[ $santized_old_login ] = $user_id; + } else { + printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $this->authors[ $old_login ]['author_display_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ' ' . $user_id->get_error_message(); + } + echo '
'; + } + } + + // failsafe: if the user_id was invalid, default to the current user + if ( ! isset( $this->author_mapping[ $santized_old_login ] ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = (int) get_current_user_id(); + } + $this->author_mapping[ $santized_old_login ] = (int) get_current_user_id(); + } + } + } + + /** + * Create new categories based on import information + * + * Doesn't create a new category if its slug already exists + */ + function process_categories() { + $this->categories = apply_filters( 'wp_import_categories', $this->categories ); + + if ( empty( $this->categories ) ) { + return; + } + + foreach ( $this->categories as $cat ) { + // if the category already exists leave it alone + $term_id = term_exists( $cat['category_nicename'], 'category' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $parent = empty( $cat['category_parent'] ) ? 0 : category_exists( $cat['category_parent'] ); + $description = isset( $cat['category_description'] ) ? $cat['category_description'] : ''; + + $data = array( + 'category_nicename' => $cat['category_nicename'], + 'category_parent' => $parent, + 'cat_name' => wp_slash( $cat['cat_name'] ), + 'category_description' => wp_slash( $description ), + ); + + $id = wp_insert_category( $data, true ); + if ( ! is_wp_error( $id ) && $id > 0 ) { + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = $id; + } + } else { + printf( __( 'Failed to import category %s', 'wordpress-importer' ), esc_html( $cat['category_nicename'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $cat, $id ); + } + + unset( $this->categories ); + } + + /** + * Create new post tags based on import information + * + * Doesn't create a tag if its slug already exists + */ + function process_tags() { + $this->tags = apply_filters( 'wp_import_tags', $this->tags ); + + if ( empty( $this->tags ) ) { + return; + } + + foreach ( $this->tags as $tag ) { + // if the tag already exists leave it alone + $term_id = term_exists( $tag['tag_slug'], 'post_tag' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $description = isset( $tag['tag_description'] ) ? $tag['tag_description'] : ''; + $args = array( + 'slug' => $tag['tag_slug'], + 'description' => wp_slash( $description ), + ); + + $id = wp_insert_term( wp_slash( $tag['tag_name'] ), 'post_tag', $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import post tag %s', 'wordpress-importer' ), esc_html( $tag['tag_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $tag, $id['term_id'] ); + } + + unset( $this->tags ); + } + + /** + * Create new terms based on import information + * + * Doesn't create a term its slug already exists + */ + function process_terms() { + $this->terms = apply_filters( 'wp_import_terms', $this->terms ); + + if ( empty( $this->terms ) ) { + return; + } + + foreach ( $this->terms as $term ) { + // if the term already exists in the correct taxonomy leave it alone + $term_id = term_exists( $term['slug'], $term['term_taxonomy'] ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = (int) $term_id; + } + continue; + } + + if ( empty( $term['term_parent'] ) ) { + $parent = 0; + } else { + $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] ); + if ( is_array( $parent ) ) { + $parent = $parent['term_id']; + } + } + + $description = isset( $term['term_description'] ) ? $term['term_description'] : ''; + $args = array( + 'slug' => $term['slug'], + 'description' => wp_slash( $description ), + 'parent' => (int) $parent, + ); + + $id = wp_insert_term( wp_slash( $term['term_name'] ), $term['term_taxonomy'], $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $term['term_taxonomy'] ), esc_html( $term['term_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $term, $id['term_id'] ); + } + + unset( $this->terms ); + } + + /** + * Add metadata to imported term. + * + * @since 0.6.2 + * + * @param array $term Term data from WXR import. + * @param int $term_id ID of the newly created term. + */ + protected function process_termmeta( $term, $term_id ) { + if ( ! isset( $term['termmeta'] ) ) { + $term['termmeta'] = array(); + } + + /** + * Filters the metadata attached to an imported term. + * + * @since 0.6.2 + * + * @param array $termmeta Array of term meta. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term ); + + if ( empty( $term['termmeta'] ) ) { + return; + } + + foreach ( $term['termmeta'] as $meta ) { + /** + * Filters the meta key for an imported piece of term meta. + * + * @since 0.6.2 + * + * @param string $meta_key Meta key. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term ); + if ( ! $key ) { + continue; + } + + // Export gets meta straight from the DB so could have a serialized string + $value = maybe_unserialize( $meta['value'] ); + + add_term_meta( $term_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + /** + * Fires after term meta is imported. + * + * @since 0.6.2 + * + * @param int $term_id ID of the newly created term. + * @param string $key Meta key. + * @param mixed $value Meta value. + */ + do_action( 'import_term_meta', $term_id, $key, $value ); + } + } + + /** + * Create new posts based on import information + * + * Posts marked as having a parent which doesn't exist will become top level items. + * Doesn't create a new post if: the post type doesn't exist, the given post ID + * is already noted as imported or a post with the same title and date already exists. + * Note that new/updated terms, comments and meta are imported for the last of the above. + */ + function process_posts() { + $this->posts = apply_filters( 'wp_import_posts', $this->posts ); + + foreach ( $this->posts as $post ) { + $post = apply_filters( 'wp_import_post_data_raw', $post ); + + if ( ! post_type_exists( $post['post_type'] ) ) { + printf( + __( 'Failed to import “%1$s”: Invalid post type %2$s', 'wordpress-importer' ), + esc_html( $post['post_title'] ), + esc_html( $post['post_type'] ) + ); + echo '
'; + do_action( 'wp_import_post_exists', $post ); + continue; + } + + if ( isset( $this->processed_posts[ $post['post_id'] ] ) && ! empty( $post['post_id'] ) ) { + continue; + } + + if ( 'auto-draft' == $post['status'] ) { + continue; + } + + if ( 'nav_menu_item' == $post['post_type'] ) { + $this->process_menu_item( $post ); + continue; + } + + $post_type_object = get_post_type_object( $post['post_type'] ); + + $post_exists = post_exists( $post['post_title'], '', $post['post_date'] ); + + /** + * Filter ID of the existing post corresponding to post currently importing. + * + * Return 0 to force the post to be imported. Filter the ID to be something else + * to override which existing post is mapped to the imported post. + * + * @see post_exists() + * @since 0.6.2 + * + * @param int $post_exists Post ID, or 0 if post did not exist. + * @param array $post The post array to be inserted. + */ + $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post ); + + if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) { + printf( __( '%1$s “%2$s” already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) ); + echo '
'; + $comment_post_id = $post_exists; + $post_id = $post_exists; + $this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists ); + } else { + $post_parent = (int) $post['post_parent']; + if ( $post_parent ) { + // if we already know the parent, map it to the new local ID + if ( isset( $this->processed_posts[ $post_parent ] ) ) { + $post_parent = $this->processed_posts[ $post_parent ]; + // otherwise record the parent for later + } else { + $this->post_orphans[ intval( $post['post_id'] ) ] = $post_parent; + $post_parent = 0; + } + } + + // map the post author + $author = sanitize_user( $post['post_author'], true ); + if ( isset( $this->author_mapping[ $author ] ) ) { + $author = $this->author_mapping[ $author ]; + } else { + $author = (int) get_current_user_id(); + } + + $postdata = array( + 'import_id' => $post['post_id'], + 'post_author' => $author, + 'post_date' => $post['post_date'], + 'post_date_gmt' => $post['post_date_gmt'], + 'post_content' => $post['post_content'], + 'post_excerpt' => $post['post_excerpt'], + 'post_title' => $post['post_title'], + 'post_status' => $post['status'], + 'post_name' => $post['post_name'], + 'comment_status' => $post['comment_status'], + 'ping_status' => $post['ping_status'], + 'guid' => $post['guid'], + 'post_parent' => $post_parent, + 'menu_order' => $post['menu_order'], + 'post_type' => $post['post_type'], + 'post_password' => $post['post_password'], + ); + + $original_post_id = $post['post_id']; + $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post ); + + $postdata = wp_slash( $postdata ); + + if ( 'attachment' == $postdata['post_type'] ) { + $remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid']; + + // try to use _wp_attached file for upload folder placement to ensure the same location as the export site + // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload() + $postdata['upload_date'] = $post['post_date']; + if ( isset( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + if ( '_wp_attached_file' == $meta['key'] ) { + if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) { + $postdata['upload_date'] = $matches[0]; + } + break; + } + } + } + + $comment_post_id = $this->process_attachment( $postdata, $remote_url ); + $post_id = $comment_post_id; + } else { + $comment_post_id = wp_insert_post( $postdata, true ); + $post_id = $comment_post_id; + do_action( 'wp_import_insert_post', $post_id, $original_post_id, $postdata, $post ); + } + + if ( is_wp_error( $post_id ) ) { + printf( + __( 'Failed to import %1$s “%2$s”', 'wordpress-importer' ), + $post_type_object->labels->singular_name, + esc_html( $post['post_title'] ) + ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $post_id->get_error_message(); + } + echo '
'; + continue; + } + + if ( 1 == $post['is_sticky'] ) { + stick_post( $post_id ); + } + } + + // map pre-import ID to local ID + $this->processed_posts[ intval( $post['post_id'] ) ] = (int) $post_id; + + if ( ! isset( $post['terms'] ) ) { + $post['terms'] = array(); + } + + $post['terms'] = apply_filters( 'wp_import_post_terms', $post['terms'], $post_id, $post ); + + // add categories, tags and other terms + if ( ! empty( $post['terms'] ) ) { + $terms_to_set = array(); + foreach ( $post['terms'] as $term ) { + // back compat with WXR 1.0 map 'tag' to 'post_tag' + $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain']; + $term_exists = term_exists( $term['slug'], $taxonomy ); + $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists; + if ( ! $term_id ) { + $t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) ); + if ( ! is_wp_error( $t ) ) { + $term_id = $t['term_id']; + do_action( 'wp_import_insert_term', $t, $term, $post_id, $post ); + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term['name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $t->get_error_message(); + } + echo '
'; + do_action( 'wp_import_insert_term_failed', $t, $term, $post_id, $post ); + continue; + } + } + $terms_to_set[ $taxonomy ][] = intval( $term_id ); + } + + foreach ( $terms_to_set as $tax => $ids ) { + $tt_ids = wp_set_post_terms( $post_id, $ids, $tax ); + do_action( 'wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post ); + } + unset( $post['terms'], $terms_to_set ); + } + + if ( ! isset( $post['comments'] ) ) { + $post['comments'] = array(); + } + + $post['comments'] = apply_filters( 'wp_import_post_comments', $post['comments'], $post_id, $post ); + + // add/update comments + if ( ! empty( $post['comments'] ) ) { + $num_comments = 0; + $inserted_comments = array(); + foreach ( $post['comments'] as $comment ) { + $comment_id = $comment['comment_id']; + $newcomments[ $comment_id ]['comment_post_ID'] = $comment_post_id; + $newcomments[ $comment_id ]['comment_author'] = $comment['comment_author']; + $newcomments[ $comment_id ]['comment_author_email'] = $comment['comment_author_email']; + $newcomments[ $comment_id ]['comment_author_IP'] = $comment['comment_author_IP']; + $newcomments[ $comment_id ]['comment_author_url'] = $comment['comment_author_url']; + $newcomments[ $comment_id ]['comment_date'] = $comment['comment_date']; + $newcomments[ $comment_id ]['comment_date_gmt'] = $comment['comment_date_gmt']; + $newcomments[ $comment_id ]['comment_content'] = $comment['comment_content']; + $newcomments[ $comment_id ]['comment_approved'] = $comment['comment_approved']; + $newcomments[ $comment_id ]['comment_type'] = $comment['comment_type']; + $newcomments[ $comment_id ]['comment_parent'] = $comment['comment_parent']; + $newcomments[ $comment_id ]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array(); + if ( isset( $this->processed_authors[ $comment['comment_user_id'] ] ) ) { + $newcomments[ $comment_id ]['user_id'] = $this->processed_authors[ $comment['comment_user_id'] ]; + } + } + ksort( $newcomments ); + + foreach ( $newcomments as $key => $comment ) { + // if this is a new post we can skip the comment_exists() check + if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) { + if ( isset( $inserted_comments[ $comment['comment_parent'] ] ) ) { + $comment['comment_parent'] = $inserted_comments[ $comment['comment_parent'] ]; + } + + $comment_data = wp_slash( $comment ); + unset( $comment_data['commentmeta'] ); // Handled separately, wp_insert_comment() also expects `comment_meta`. + $comment_data = wp_filter_comment( $comment_data ); + + $inserted_comments[ $key ] = wp_insert_comment( $comment_data ); + + do_action( 'wp_import_insert_comment', $inserted_comments[ $key ], $comment, $comment_post_id, $post ); + + foreach ( $comment['commentmeta'] as $meta ) { + $value = maybe_unserialize( $meta['value'] ); + + add_comment_meta( $inserted_comments[ $key ], wp_slash( $meta['key'] ), wp_slash_strings_only( $value ) ); + } + + $num_comments++; + } + } + unset( $newcomments, $inserted_comments, $post['comments'] ); + } + + if ( ! isset( $post['postmeta'] ) ) { + $post['postmeta'] = array(); + } + + $post['postmeta'] = apply_filters( 'wp_import_post_meta', $post['postmeta'], $post_id, $post ); + + // add/update post meta + if ( ! empty( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + $key = apply_filters( 'import_post_meta_key', $meta['key'], $post_id, $post ); + $value = false; + + if ( '_edit_last' == $key ) { + if ( isset( $this->processed_authors[ intval( $meta['value'] ) ] ) ) { + $value = $this->processed_authors[ intval( $meta['value'] ) ]; + } else { + $key = false; + } + } + + if ( $key ) { + // export gets meta straight from the DB so could have a serialized string + if ( ! $value ) { + $value = maybe_unserialize( $meta['value'] ); + } + + add_post_meta( $post_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + do_action( 'import_post_meta', $post_id, $key, $value ); + + // if the post has a featured image, take note of this in case of remap + if ( '_thumbnail_id' == $key ) { + $this->featured_images[ $post_id ] = (int) $value; + } + } + } + } + } + + unset( $this->posts ); + } + + /** + * Attempt to create a new menu item from import data + * + * Fails for draft, orphaned menu items and those without an associated nav_menu + * or an invalid nav_menu term. If the post type or term object which the menu item + * represents doesn't exist then the menu item will not be imported (waits until the + * end of the import to retry again before discarding). + * + * @param array $item Menu item details from WXR file + */ + function process_menu_item( $item ) { + // skip draft, orphaned menu items + if ( 'draft' == $item['status'] ) { + return; + } + + $menu_slug = false; + if ( isset( $item['terms'] ) ) { + // loop through terms, assume first nav_menu term is correct menu + foreach ( $item['terms'] as $term ) { + if ( 'nav_menu' == $term['domain'] ) { + $menu_slug = $term['slug']; + break; + } + } + } + + // no nav_menu term associated with this menu item + if ( ! $menu_slug ) { + _e( 'Menu item skipped due to missing menu slug', 'wordpress-importer' ); + echo '
'; + return; + } + + $menu_id = term_exists( $menu_slug, 'nav_menu' ); + if ( ! $menu_id ) { + printf( __( 'Menu item skipped due to invalid menu slug: %s', 'wordpress-importer' ), esc_html( $menu_slug ) ); + echo '
'; + return; + } else { + $menu_id = is_array( $menu_id ) ? $menu_id['term_id'] : $menu_id; + } + + foreach ( $item['postmeta'] as $meta ) { + ${$meta['key']} = $meta['value']; + } + + if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_terms[ intval( $_menu_item_object_id ) ]; + } elseif ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_posts[ intval( $_menu_item_object_id ) ]; + } elseif ( 'custom' != $_menu_item_type ) { + // associated object is missing or not imported yet, we'll retry later + $this->missing_menu_items[] = $item; + return; + } + + if ( isset( $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ] ) ) { + $_menu_item_menu_item_parent = $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ]; + } elseif ( $_menu_item_menu_item_parent ) { + $this->menu_item_orphans[ intval( $item['post_id'] ) ] = (int) $_menu_item_menu_item_parent; + $_menu_item_menu_item_parent = 0; + } + + // wp_update_nav_menu_item expects CSS classes as a space separated string + $_menu_item_classes = maybe_unserialize( $_menu_item_classes ); + if ( is_array( $_menu_item_classes ) ) { + $_menu_item_classes = implode( ' ', $_menu_item_classes ); + } + + $args = array( + 'menu-item-object-id' => $_menu_item_object_id, + 'menu-item-object' => $_menu_item_object, + 'menu-item-parent-id' => $_menu_item_menu_item_parent, + 'menu-item-position' => intval( $item['menu_order'] ), + 'menu-item-type' => $_menu_item_type, + 'menu-item-title' => $item['post_title'], + 'menu-item-url' => $_menu_item_url, + 'menu-item-description' => $item['post_content'], + 'menu-item-attr-title' => $item['post_excerpt'], + 'menu-item-target' => $_menu_item_target, + 'menu-item-classes' => $_menu_item_classes, + 'menu-item-xfn' => $_menu_item_xfn, + 'menu-item-status' => $item['status'], + ); + + $id = wp_update_nav_menu_item( $menu_id, 0, $args ); + if ( $id && ! is_wp_error( $id ) ) { + $this->processed_menu_items[ intval( $item['post_id'] ) ] = (int) $id; + } + } + + /** + * If fetching attachments is enabled then attempt to create a new attachment + * + * @param array $post Attachment post details from WXR + * @param string $url URL to fetch attachment from + * @return int|WP_Error Post ID on success, WP_Error otherwise + */ + function process_attachment( $post, $url ) { + if ( ! $this->fetch_attachments ) { + return new WP_Error( + 'attachment_processing_error', + __( 'Fetching attachments is not enabled', 'wordpress-importer' ) + ); + } + + // if the URL is absolute, but does not contain address, then upload it assuming base_site_url + if ( preg_match( '|^/[\w\W]+$|', $url ) ) { + $url = rtrim( $this->base_url, '/' ) . $url; + } + + $upload = $this->fetch_remote_file( $url, $post ); + if ( is_wp_error( $upload ) ) { + return $upload; + } + + $info = wp_check_filetype( $upload['file'] ); + if ( $info ) { + $post['post_mime_type'] = $info['type']; + } else { + return new WP_Error( 'attachment_processing_error', __( 'Invalid file type', 'wordpress-importer' ) ); + } + + $post['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment( $post, $upload['file'] ); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap resized image URLs, works by stripping the extension and remapping the URL stub. + if ( preg_match( '!^image/!', $info['type'] ) ) { + $parts = pathinfo( $url ); + $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2 + + $parts_new = pathinfo( $upload['url'] ); + $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" ); + + $this->url_remap[ $parts['dirname'] . '/' . $name ] = $parts_new['dirname'] . '/' . $name_new; + } + + return $post_id; + } + + /** + * Attempt to download a remote file attachment + * + * @param string $url URL of item to fetch + * @param array $post Attachment details + * @return array|WP_Error Local file location details on success, WP_Error otherwise + */ + function fetch_remote_file( $url, $post ) { + // Extract the file name from the URL. + $path = parse_url( $url, PHP_URL_PATH ); + $file_name = ''; + if ( is_string( $path ) ) { + $file_name = basename( $path ); + } + + if ( ! $file_name ) { + $file_name = md5( $url ); + } + + $tmp_file_name = wp_tempnam( $file_name ); + if ( ! $tmp_file_name ) { + return new WP_Error( 'import_no_file', __( 'Could not create temporary file.', 'wordpress-importer' ) ); + } + + // Fetch the remote URL and write it to the placeholder file. + $remote_response = wp_safe_remote_get( + $url, + array( + 'timeout' => 300, + 'stream' => true, + 'filename' => $tmp_file_name, + 'headers' => array( + 'Accept-Encoding' => 'identity', + ), + ) + ); + + if ( is_wp_error( $remote_response ) ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The WordPress error message. 2: The WordPress error code. */ + __( 'Request failed due to an error: %1$s (%2$s)', 'wordpress-importer' ), + esc_html( $remote_response->get_error_message() ), + esc_html( $remote_response->get_error_code() ) + ) + ); + } + + $remote_response_code = (int) wp_remote_retrieve_response_code( $remote_response ); + + // Make sure the fetch was successful. + if ( 200 !== $remote_response_code ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The HTTP error message. 2: The HTTP error code. */ + __( 'Remote server returned the following unexpected result: %1$s (%2$s)', 'wordpress-importer' ), + get_status_header_desc( $remote_response_code ), + esc_html( $remote_response_code ) + ) + ); + } + + $headers = wp_remote_retrieve_headers( $remote_response ); + + // Request failed. + if ( ! $headers ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Remote server did not respond', 'wordpress-importer' ) ); + } + + $filesize = (int) filesize( $tmp_file_name ); + + if ( 0 === $filesize ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) ); + } + + if ( ! isset( $headers['content-encoding'] ) && isset( $headers['content-length'] ) && $filesize !== (int) $headers['content-length'] ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Downloaded file has incorrect size', 'wordpress-importer' ) ); + } + + $max_size = (int) $this->max_attachment_size(); + if ( ! empty( $max_size ) && $filesize > $max_size ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) ) ); + } + + // Override file name with Content-Disposition header value. + if ( ! empty( $headers['content-disposition'] ) ) { + $file_name_from_disposition = self::get_filename_from_disposition( (array) $headers['content-disposition'] ); + if ( $file_name_from_disposition ) { + $file_name = $file_name_from_disposition; + } + } + + // Set file extension if missing. + $file_ext = pathinfo( $file_name, PATHINFO_EXTENSION ); + if ( ! $file_ext && ! empty( $headers['content-type'] ) ) { + $extension = self::get_file_extension_by_mime_type( $headers['content-type'] ); + if ( $extension ) { + $file_name = "{$file_name}.{$extension}"; + } + } + + // Handle the upload like _wp_handle_upload() does. + $wp_filetype = wp_check_filetype_and_ext( $tmp_file_name, $file_name ); + $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; + $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; + $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; + + // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect. + if ( $proper_filename ) { + $file_name = $proper_filename; + } + + if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) { + return new WP_Error( 'import_file_error', __( 'Sorry, this file type is not permitted for security reasons.', 'wordpress-importer' ) ); + } + + $uploads = wp_upload_dir( $post['upload_date'] ); + if ( ! ( $uploads && false === $uploads['error'] ) ) { + return new WP_Error( 'upload_dir_error', $uploads['error'] ); + } + + // Move the file to the uploads dir. + $file_name = wp_unique_filename( $uploads['path'], $file_name ); + $new_file = $uploads['path'] . "/$file_name"; + $move_new_file = copy( $tmp_file_name, $new_file ); + + if ( ! $move_new_file ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'The uploaded file could not be moved', 'wordpress-importer' ) ); + } + + // Set correct file permissions. + $stat = stat( dirname( $new_file ) ); + $perms = $stat['mode'] & 0000666; + chmod( $new_file, $perms ); + + $upload = array( + 'file' => $new_file, + 'url' => $uploads['url'] . "/$file_name", + 'type' => $wp_filetype['type'], + 'error' => false, + ); + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[ $url ] = $upload['url']; + $this->url_remap[ $post['guid'] ] = $upload['url']; // r13735, really needed? + // keep track of the destination if the remote url is redirected somewhere else + if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) { + $this->url_remap[ $headers['x-final-location'] ] = $upload['url']; + } + + return $upload; + } + + /** + * Attempt to associate posts and menu items with previously missing parents + * + * An imported post's parent may not have been imported when it was first created + * so try again. Similarly for child menu items and menu items which were missing + * the object (e.g. post) they represent in the menu + */ + function backfill_parents() { + global $wpdb; + + // find parents for post orphans + foreach ( $this->post_orphans as $child_id => $parent_id ) { + $local_child_id = false; + $local_parent_id = false; + if ( isset( $this->processed_posts[ $child_id ] ) ) { + $local_child_id = $this->processed_posts[ $child_id ]; + } + if ( isset( $this->processed_posts[ $parent_id ] ) ) { + $local_parent_id = $this->processed_posts[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + $wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' ); + clean_post_cache( $local_child_id ); + } + } + + // all other posts/terms are imported, retry menu items with missing associated object + $missing_menu_items = $this->missing_menu_items; + foreach ( $missing_menu_items as $item ) { + $this->process_menu_item( $item ); + } + + // find parents for menu item orphans + foreach ( $this->menu_item_orphans as $child_id => $parent_id ) { + $local_child_id = 0; + $local_parent_id = 0; + if ( isset( $this->processed_menu_items[ $child_id ] ) ) { + $local_child_id = $this->processed_menu_items[ $child_id ]; + } + if ( isset( $this->processed_menu_items[ $parent_id ] ) ) { + $local_parent_id = $this->processed_menu_items[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + update_post_meta( $local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id ); + } + } + } + + /** + * Use stored mapping information to update old attachment URLs + */ + function backfill_attachment_urls() { + global $wpdb; + // make sure we do the longest urls first, in case one is a substring of another + uksort( $this->url_remap, array( &$this, 'cmpr_strlen' ) ); + + foreach ( $this->url_remap as $from_url => $to_url ) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url ) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url ) ); + } + } + + /** + * Update _thumbnail_id meta to new, imported attachment IDs + */ + function remap_featured_images() { + // cycle through posts that have a featured image + foreach ( $this->featured_images as $post_id => $value ) { + if ( isset( $this->processed_posts[ $value ] ) ) { + $new_id = $this->processed_posts[ $value ]; + // only update if there's a difference + if ( $new_id != $value ) { + update_post_meta( $post_id, '_thumbnail_id', $new_id ); + } + } + } + } + + /** + * Parse a WXR file + * + * @param string $file Path to WXR file for parsing + * @return array Information gathered from the WXR file + */ + function parse( $file ) { + $parser = new WXR_Parser(); + return $parser->parse( $file ); + } + + // Display import page title + function header() { + echo '
'; + echo '

' . __( 'Import WordPress', 'wordpress-importer' ) . '

'; + + $updates = get_plugin_updates(); + $basename = plugin_basename( __FILE__ ); + if ( isset( $updates[ $basename ] ) ) { + $update = $updates[ $basename ]; + echo '

'; + printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version ); + echo '

'; + } + } + + // Close div.wrap + function footer() { + echo '
'; + } + + /** + * Display introductory text and file upload form + */ + function greet() { + echo '
'; + echo '

' . __( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ) . '

'; + echo '

' . __( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ) . '

'; + wp_import_upload_form( 'admin.php?import=wordpress&step=1' ); + echo '
'; + } + + /** + * Decide if the given meta key maps to information we will want to import + * + * @param string $key The meta key to check + * @return string|bool The key if we do want to import, false if not + */ + function is_valid_meta_key( $key ) { + // skip attachment metadata since we'll regenerate it from scratch + // skip _edit_lock as not relevant for import + if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ), true ) ) { + return false; + } + return $key; + } + + /** + * Decide whether or not the importer is allowed to create users. + * Default is true, can be filtered via import_allow_create_users + * + * @return bool True if creating users is allowed + */ + function allow_create_users() { + return apply_filters( 'import_allow_create_users', true ); + } + + /** + * Decide whether or not the importer should attempt to download attachment files. + * Default is true, can be filtered via import_allow_fetch_attachments. The choice + * made at the import options screen must also be true, false here hides that checkbox. + * + * @return bool True if downloading attachments is allowed + */ + function allow_fetch_attachments() { + return apply_filters( 'import_allow_fetch_attachments', true ); + } + + /** + * Decide what the maximum file size for downloaded attachments is. + * Default is 0 (unlimited), can be filtered via import_attachment_size_limit + * + * @return int Maximum attachment file size to import + */ + function max_attachment_size() { + return apply_filters( 'import_attachment_size_limit', 0 ); + } + + /** + * Added to http_request_timeout filter to force timeout at 60 seconds during import + * @return int 60 + */ + function bump_request_timeout( $val ) { + return 60; + } + + // return the difference in length between two strings + function cmpr_strlen( $a, $b ) { + return strlen( $b ) - strlen( $a ); + } + + /** + * Parses filename from a Content-Disposition header value. + * + * As per RFC6266: + * + * content-disposition = "Content-Disposition" ":" + * disposition-type *( ";" disposition-parm ) + * + * disposition-type = "inline" | "attachment" | disp-ext-type + * ; case-insensitive + * disp-ext-type = token + * + * disposition-parm = filename-parm | disp-ext-parm + * + * filename-parm = "filename" "=" value + * | "filename*" "=" ext-value + * + * disp-ext-parm = token "=" value + * | ext-token "=" ext-value + * ext-token = + * + * @since 0.7.0 + * + * @see WP_REST_Attachments_Controller::get_filename_from_disposition() + * + * @link http://tools.ietf.org/html/rfc2388 + * @link http://tools.ietf.org/html/rfc6266 + * + * @param string[] $disposition_header List of Content-Disposition header values. + * @return string|null Filename if available, or null if not found. + */ + protected static function get_filename_from_disposition( $disposition_header ) { + // Get the filename. + $filename = null; + + foreach ( $disposition_header as $value ) { + $value = trim( $value ); + + if ( strpos( $value, ';' ) === false ) { + continue; + } + + list( $type, $attr_parts ) = explode( ';', $value, 2 ); + + $attr_parts = explode( ';', $attr_parts ); + $attributes = array(); + + foreach ( $attr_parts as $part ) { + if ( strpos( $part, '=' ) === false ) { + continue; + } + + list( $key, $value ) = explode( '=', $part, 2 ); + + $attributes[ trim( $key ) ] = trim( $value ); + } + + if ( empty( $attributes['filename'] ) ) { + continue; + } + + $filename = trim( $attributes['filename'] ); + + // Unquote quoted filename, but after trimming. + if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) { + $filename = substr( $filename, 1, -1 ); + } + } + + return $filename; + } + + /** + * Retrieves file extension by mime type. + * + * @since 0.7.0 + * + * @param string $mime_type Mime type to search extension for. + * @return string|null File extension if available, or null if not found. + */ + protected static function get_file_extension_by_mime_type( $mime_type ) { + static $map = null; + + if ( is_array( $map ) ) { + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } + + $mime_types = wp_get_mime_types(); + $map = array_flip( $mime_types ); + + // Some types have multiple extensions, use only the first one. + foreach ( $map as $type => $extensions ) { + $map[ $type ] = strtok( $extensions, '|' ); + } + + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } +} +has_gzip = is_callable( 'gzopen' ); + } + + function parse( $file ) { + $wxr_version = false; + $in_multiline = false; + + $multiline_content = ''; + + $multiline_tags = array( + 'item' => array( 'posts', array( $this, 'process_post' ) ), + 'wp:category' => array( 'categories', array( $this, 'process_category' ) ), + 'wp:tag' => array( 'tags', array( $this, 'process_tag' ) ), + 'wp:term' => array( 'terms', array( $this, 'process_term' ) ), + ); + + $fp = $this->fopen( $file, 'r' ); + if ( $fp ) { + while ( ! $this->feof( $fp ) ) { + $is_tag_line = false; + $importline = rtrim( $this->fgets( $fp ) ); + + if ( ! $wxr_version && preg_match( '|(\d+\.\d+)|', $importline, $version ) ) { + $wxr_version = $version[1]; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $url ); + $this->base_url = $url[1]; + continue; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $blog_url ); + $this->base_blog_url = $blog_url[1]; + continue; + } elseif ( empty( $this->base_blog_url ) ) { + $this->base_blog_url = $this->base_url; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $author ); + $a = $this->process_author( $author[1] ); + $this->authors[ $a['author_login'] ] = $a; + continue; + } + + foreach ( $multiline_tags as $tag => $handler ) { + // Handle multi-line tags on a singular line + $pos = strpos( $importline, "<$tag>" ); + $pos_closing = strpos( $importline, "" ); + if ( preg_match( '|<' . $tag . '>(.*?)|is', $importline, $matches ) ) { + $this->{$handler[0]}[] = call_user_func( $handler[1], $matches[1] ); + + } elseif ( false !== $pos ) { + // Take note of any content after the opening tag + $multiline_content = trim( substr( $importline, $pos + strlen( $tag ) + 2 ) ); + + // We don't want to have this line added to `$is_multiline` below. + $in_multiline = $tag; + $is_tag_line = true; + + } elseif ( false !== $pos_closing ) { + $in_multiline = false; + $multiline_content .= trim( substr( $importline, 0, $pos_closing ) ); + + $this->{$handler[0]}[] = call_user_func( $handler[1], $multiline_content ); + } + } + + if ( $in_multiline && ! $is_tag_line ) { + $multiline_content .= $importline . "\n"; + } + } + + $this->fclose( $fp ); + } + + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->categories, + 'tags' => $this->tags, + 'terms' => $this->terms, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $wxr_version, + ); + } + + function get_tag( $string, $tag ) { + preg_match( "|<$tag.*?>(.*?)|is", $string, $return ); + if ( isset( $return[1] ) ) { + if ( substr( $return[1], 0, 9 ) == '' ) !== false ) { + preg_match_all( '||s', $return[1], $matches ); + $return = ''; + foreach ( $matches[1] as $match ) { + $return .= $match; + } + } else { + $return = preg_replace( '|^$|s', '$1', $return[1] ); + } + } else { + $return = $return[1]; + } + } else { + $return = ''; + } + return $return; + } + + function process_category( $c ) { + $term = array( + 'term_id' => $this->get_tag( $c, 'wp:term_id' ), + 'cat_name' => $this->get_tag( $c, 'wp:cat_name' ), + 'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ), + 'category_parent' => $this->get_tag( $c, 'wp:category_parent' ), + 'category_description' => $this->get_tag( $c, 'wp:category_description' ), + ); + + $term_meta = $this->process_meta( $c, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_tag( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'tag_name' => $this->get_tag( $t, 'wp:tag_name' ), + 'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ), + 'tag_description' => $this->get_tag( $t, 'wp:tag_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_term( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ), + 'slug' => $this->get_tag( $t, 'wp:term_slug' ), + 'term_parent' => $this->get_tag( $t, 'wp:term_parent' ), + 'term_name' => $this->get_tag( $t, 'wp:term_name' ), + 'term_description' => $this->get_tag( $t, 'wp:term_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_meta( $string, $tag ) { + $parsed_meta = array(); + + preg_match_all( "|<$tag>(.+?)|is", $string, $meta ); + + if ( ! isset( $meta[1] ) ) { + return $parsed_meta; + } + + foreach ( $meta[1] as $m ) { + $parsed_meta[] = array( + 'key' => $this->get_tag( $m, 'wp:meta_key' ), + 'value' => $this->get_tag( $m, 'wp:meta_value' ), + ); + } + + return $parsed_meta; + } + + function process_author( $a ) { + return array( + 'author_id' => $this->get_tag( $a, 'wp:author_id' ), + 'author_login' => $this->get_tag( $a, 'wp:author_login' ), + 'author_email' => $this->get_tag( $a, 'wp:author_email' ), + 'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ), + 'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ), + 'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ), + ); + } + + function process_post( $post ) { + $post_id = $this->get_tag( $post, 'wp:post_id' ); + $post_title = $this->get_tag( $post, 'title' ); + $post_date = $this->get_tag( $post, 'wp:post_date' ); + $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); + $comment_status = $this->get_tag( $post, 'wp:comment_status' ); + $ping_status = $this->get_tag( $post, 'wp:ping_status' ); + $status = $this->get_tag( $post, 'wp:status' ); + $post_name = $this->get_tag( $post, 'wp:post_name' ); + $post_parent = $this->get_tag( $post, 'wp:post_parent' ); + $menu_order = $this->get_tag( $post, 'wp:menu_order' ); + $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); + $is_sticky = $this->get_tag( $post, 'wp:is_sticky' ); + $guid = $this->get_tag( $post, 'guid' ); + $post_author = $this->get_tag( $post, 'dc:creator' ); + + $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); + $post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + + $post_content = $this->get_tag( $post, 'content:encoded' ); + $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + + $postdata = compact( + 'post_id', + 'post_author', + 'post_date', + 'post_date_gmt', + 'post_content', + 'post_excerpt', + 'post_title', + 'status', + 'post_name', + 'comment_status', + 'ping_status', + 'guid', + 'post_parent', + 'menu_order', + 'post_type', + 'post_password', + 'is_sticky' + ); + + $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( $attachment_url ) { + $postdata['attachment_url'] = $attachment_url; + } + + preg_match_all( '|(.+?)|is', $post, $terms, PREG_SET_ORDER ); + foreach ( $terms as $t ) { + $post_terms[] = array( + 'slug' => $t[2], + 'domain' => $t[1], + 'name' => str_replace( array( '' ), '', $t[3] ), + ); + } + if ( ! empty( $post_terms ) ) { + $postdata['terms'] = $post_terms; + } + + preg_match_all( '|(.+?)|is', $post, $comments ); + $comments = $comments[1]; + if ( $comments ) { + foreach ( $comments as $comment ) { + $post_comments[] = array( + 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), + 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), + 'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ), + 'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ), + 'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ), + 'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ), + 'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ), + 'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ), + 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), + 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), + 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), + 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), + 'commentmeta' => $this->process_meta( $comment, 'wp:commentmeta' ), + ); + } + } + if ( ! empty( $post_comments ) ) { + $postdata['comments'] = $post_comments; + } + + $post_meta = $this->process_meta( $post, 'wp:postmeta' ); + if ( ! empty( $post_meta ) ) { + $postdata['postmeta'] = $post_meta; + } + + return $postdata; + } + + function _normalize_tag( $matches ) { + return '<' . strtolower( $matches[1] ); + } + + function fopen( $filename, $mode = 'r' ) { + if ( $this->has_gzip ) { + return gzopen( $filename, $mode ); + } + return fopen( $filename, $mode ); + } + + function feof( $fp ) { + if ( $this->has_gzip ) { + return gzeof( $fp ); + } + return feof( $fp ); + } + + function fgets( $fp, $len = 8192 ) { + if ( $this->has_gzip ) { + return gzgets( $fp, $len ); + } + return fgets( $fp, $len ); + } + + function fclose( $fp ) { + if ( $this->has_gzip ) { + return gzclose( $fp ); + } + return fclose( $fp ); + } +} +loadXML( file_get_contents( $file ) ); + if ( ! is_null( $old_value ) ) { + libxml_disable_entity_loader( $old_value ); + } + + if ( ! $success || isset( $dom->doctype ) ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $xml = simplexml_import_dom( $dom ); + unset( $dom ); + + // halt if loading produces an error + if ( ! $xml ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $wxr_version = $xml->xpath( '/rss/channel/wp:wxr_version' ); + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $wxr_version = (string) trim( $wxr_version[0] ); + // confirm that we are dealing with the correct file format + if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $base_url = $xml->xpath( '/rss/channel/wp:base_site_url' ); + $base_url = (string) trim( isset( $base_url[0] ) ? $base_url[0] : '' ); + + $base_blog_url = $xml->xpath( '/rss/channel/wp:base_blog_url' ); + if ( $base_blog_url ) { + $base_blog_url = (string) trim( $base_blog_url[0] ); + } else { + $base_blog_url = $base_url; + } + + $namespaces = $xml->getDocNamespaces(); + if ( ! isset( $namespaces['wp'] ) ) { + $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; + } + if ( ! isset( $namespaces['excerpt'] ) ) { + $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; + } + + // grab authors + foreach ( $xml->xpath( '/rss/channel/wp:author' ) as $author_arr ) { + $a = $author_arr->children( $namespaces['wp'] ); + $login = (string) $a->author_login; + $authors[ $login ] = array( + 'author_id' => (int) $a->author_id, + 'author_login' => $login, + 'author_email' => (string) $a->author_email, + 'author_display_name' => (string) $a->author_display_name, + 'author_first_name' => (string) $a->author_first_name, + 'author_last_name' => (string) $a->author_last_name, + ); + } + + // grab cats, tags and terms + foreach ( $xml->xpath( '/rss/channel/wp:category' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $category = array( + 'term_id' => (int) $t->term_id, + 'category_nicename' => (string) $t->category_nicename, + 'category_parent' => (string) $t->category_parent, + 'cat_name' => (string) $t->cat_name, + 'category_description' => (string) $t->category_description, + ); + + foreach ( $t->termmeta as $meta ) { + $category['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $categories[] = $category; + } + + foreach ( $xml->xpath( '/rss/channel/wp:tag' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $tag = array( + 'term_id' => (int) $t->term_id, + 'tag_slug' => (string) $t->tag_slug, + 'tag_name' => (string) $t->tag_name, + 'tag_description' => (string) $t->tag_description, + ); + + foreach ( $t->termmeta as $meta ) { + $tag['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $tags[] = $tag; + } + + foreach ( $xml->xpath( '/rss/channel/wp:term' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $term = array( + 'term_id' => (int) $t->term_id, + 'term_taxonomy' => (string) $t->term_taxonomy, + 'slug' => (string) $t->term_slug, + 'term_parent' => (string) $t->term_parent, + 'term_name' => (string) $t->term_name, + 'term_description' => (string) $t->term_description, + ); + + foreach ( $t->termmeta as $meta ) { + $term['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $terms[] = $term; + } + + // grab posts + foreach ( $xml->channel->item as $item ) { + $post = array( + 'post_title' => (string) $item->title, + 'guid' => (string) $item->guid, + ); + + $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); + $post['post_author'] = (string) $dc->creator; + + $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' ); + $excerpt = $item->children( $namespaces['excerpt'] ); + $post['post_content'] = (string) $content->encoded; + $post['post_excerpt'] = (string) $excerpt->encoded; + + $wp = $item->children( $namespaces['wp'] ); + $post['post_id'] = (int) $wp->post_id; + $post['post_date'] = (string) $wp->post_date; + $post['post_date_gmt'] = (string) $wp->post_date_gmt; + $post['comment_status'] = (string) $wp->comment_status; + $post['ping_status'] = (string) $wp->ping_status; + $post['post_name'] = (string) $wp->post_name; + $post['status'] = (string) $wp->status; + $post['post_parent'] = (int) $wp->post_parent; + $post['menu_order'] = (int) $wp->menu_order; + $post['post_type'] = (string) $wp->post_type; + $post['post_password'] = (string) $wp->post_password; + $post['is_sticky'] = (int) $wp->is_sticky; + + if ( isset( $wp->attachment_url ) ) { + $post['attachment_url'] = (string) $wp->attachment_url; + } + + foreach ( $item->category as $c ) { + $att = $c->attributes(); + if ( isset( $att['nicename'] ) ) { + $post['terms'][] = array( + 'name' => (string) $c, + 'slug' => (string) $att['nicename'], + 'domain' => (string) $att['domain'], + ); + } + } + + foreach ( $wp->postmeta as $meta ) { + $post['postmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + foreach ( $wp->comment as $comment ) { + $meta = array(); + if ( isset( $comment->commentmeta ) ) { + foreach ( $comment->commentmeta as $m ) { + $meta[] = array( + 'key' => (string) $m->meta_key, + 'value' => (string) $m->meta_value, + ); + } + } + + $post['comments'][] = array( + 'comment_id' => (int) $comment->comment_id, + 'comment_author' => (string) $comment->comment_author, + 'comment_author_email' => (string) $comment->comment_author_email, + 'comment_author_IP' => (string) $comment->comment_author_IP, + 'comment_author_url' => (string) $comment->comment_author_url, + 'comment_date' => (string) $comment->comment_date, + 'comment_date_gmt' => (string) $comment->comment_date_gmt, + 'comment_content' => (string) $comment->comment_content, + 'comment_approved' => (string) $comment->comment_approved, + 'comment_type' => (string) $comment->comment_type, + 'comment_parent' => (string) $comment->comment_parent, + 'comment_user_id' => (int) $comment->comment_user_id, + 'commentmeta' => $meta, + ); + } + + $posts[] = $post; + } + + return array( + 'authors' => $authors, + 'posts' => $posts, + 'categories' => $categories, + 'tags' => $tags, + 'terms' => $terms, + 'base_url' => $base_url, + 'base_blog_url' => $base_blog_url, + 'version' => $wxr_version, + ); + } +} +wxr_version = false; + $this->in_post = false; + $this->cdata = false; + $this->data = false; + $this->sub_data = false; + $this->in_tag = false; + $this->in_sub_tag = false; + $this->authors = array(); + $this->posts = array(); + $this->term = array(); + $this->category = array(); + $this->tag = array(); + + $xml = xml_parser_create( 'UTF-8' ); + xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 ); + xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 ); + xml_set_object( $xml, $this ); + xml_set_character_data_handler( $xml, 'cdata' ); + xml_set_element_handler( $xml, 'tag_open', 'tag_close' ); + + if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) { + $current_line = xml_get_current_line_number( $xml ); + $current_column = xml_get_current_column_number( $xml ); + $error_code = xml_get_error_code( $xml ); + $error_string = xml_error_string( $error_code ); + return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) ); + } + xml_parser_free( $xml ); + + if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->category, + 'tags' => $this->tag, + 'terms' => $this->term, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $this->wxr_version, + ); + } + + function tag_open( $parse, $tag, $attr ) { + if ( in_array( $tag, $this->wp_tags, true ) ) { + $this->in_tag = substr( $tag, 3 ); + return; + } + + if ( in_array( $tag, $this->wp_sub_tags, true ) ) { + $this->in_sub_tag = substr( $tag, 3 ); + return; + } + + switch ( $tag ) { + case 'category': + if ( isset( $attr['domain'], $attr['nicename'] ) ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data['domain'] = $attr['domain']; + $this->sub_data['slug'] = $attr['nicename']; + } + break; + case 'item': + $this->in_post = true; + break; + case 'title': + if ( $this->in_post ) { + $this->in_tag = 'post_title'; + } + break; + case 'guid': + $this->in_tag = 'guid'; + break; + case 'dc:creator': + $this->in_tag = 'post_author'; + break; + case 'content:encoded': + $this->in_tag = 'post_content'; + break; + case 'excerpt:encoded': + $this->in_tag = 'post_excerpt'; + break; + + case 'wp:term_slug': + $this->in_tag = 'slug'; + break; + case 'wp:meta_key': + $this->in_sub_tag = 'key'; + break; + case 'wp:meta_value': + $this->in_sub_tag = 'value'; + break; + } + } + + function cdata( $parser, $cdata ) { + if ( ! trim( $cdata ) ) { + return; + } + + if ( false !== $this->in_tag || false !== $this->in_sub_tag ) { + $this->cdata .= $cdata; + } else { + $this->cdata .= trim( $cdata ); + } + } + + function tag_close( $parser, $tag ) { + switch ( $tag ) { + case 'wp:comment': + unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data + if ( ! empty( $this->sub_data ) ) { + $this->data['comments'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:commentmeta': + $this->sub_data['commentmeta'][] = array( + 'key' => $this->sub_data['key'], + 'value' => $this->sub_data['value'], + ); + break; + case 'category': + if ( ! empty( $this->sub_data ) ) { + $this->sub_data['name'] = $this->cdata; + $this->data['terms'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:postmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['postmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'item': + $this->posts[] = $this->data; + $this->data = false; + break; + case 'wp:category': + case 'wp:tag': + case 'wp:term': + $n = substr( $tag, 3 ); + array_push( $this->$n, $this->data ); + $this->data = false; + break; + case 'wp:termmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['termmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:author': + if ( ! empty( $this->data['author_login'] ) ) { + $this->authors[ $this->data['author_login'] ] = $this->data; + } + $this->data = false; + break; + case 'wp:base_site_url': + $this->base_url = $this->cdata; + if ( ! isset( $this->base_blog_url ) ) { + $this->base_blog_url = $this->cdata; + } + break; + case 'wp:base_blog_url': + $this->base_blog_url = $this->cdata; + break; + case 'wp:wxr_version': + $this->wxr_version = $this->cdata; + break; + + default: + if ( $this->in_sub_tag ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data[ $this->in_sub_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_sub_tag = false; + } elseif ( $this->in_tag ) { + if ( false === $this->data ) { + $this->data = array(); + } + + $this->data[ $this->in_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_tag = false; + } + } + + $this->cdata = false; + } +} +parse( $file ); + + // If SimpleXML succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) { + return $result; + } + } elseif ( extension_loaded( 'xml' ) ) { + $parser = new WXR_Parser_XML; + $result = $parser->parse( $file ); + + // If XMLParser succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) { + return $result; + } + } + + // We have a malformed XML file, so display the error and fallthrough to regex + if ( isset( $result ) && defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo '
';
+			if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
+				foreach ( $result->get_error_data() as $error ) {
+					echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
+				}
+			} elseif ( 'XML_parse_error' == $result->get_error_code() ) {
+				$error = $result->get_error_data();
+				echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
+			}
+			echo '
'; + echo '

' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '
'; + echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '

'; + } + + // use regular expressions if nothing else available or this is bad XML + $parser = new WXR_Parser_Regex; + return $parser->parse( $file ); + } +} +=== WordPress Importer === +Contributors: wordpressdotorg +Donate link: https://wordpressfoundation.org/donate/ +Tags: importer, wordpress +Requires at least: 5.2 +Tested up to: 6.1 +Requires PHP: 5.6 +Stable tag: 0.8 +License: GPLv2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html + +Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. + +== Description == + +The WordPress Importer will import the following content from a WordPress export file: + +* Posts, pages and other custom post types +* Comments and comment meta +* Custom fields and post meta +* Categories, tags and terms from custom taxonomies and term meta +* Authors + +For further information and instructions please see the [documention on Importing Content](https://wordpress.org/support/article/importing-content/#wordpress). + +== Installation == + +The quickest method for installing the importer is: + +1. Visit Tools -> Import in the WordPress dashboard +1. Click on the WordPress link in the list of importers +1. Click "Install Now" +1. Finally click "Activate Plugin & Run Importer" + +If you would prefer to do things manually then follow these instructions: + +1. Upload the `wordpress-importer` folder to the `/wp-content/plugins/` directory +1. Activate the plugin through the 'Plugins' menu in WordPress +1. Go to the Tools -> Import screen, click on WordPress + +== Changelog == + += 0.8 = +* Update minimum WordPress requirement to 5.2. +* Update minimum PHP requirement to 5.6. +* Update compatibility tested-up-to to WordPress 6.1. +* PHP 8.0, 8.1, and 8.2 compatibility fixes. +* Fix a bug causing blank lines in content to be ignored when using the Regex Parser. +* Fix a bug resulting in a PHP fatal error when IMPORT_DEBUG is enabled and a category creation error occurs. +* Improved Unit testing & automated testing. + += 0.7 = +* Update minimum WordPress requirement to 3.7 and ensure compatibility with PHP 7.4. +* Fix bug that caused not importing term meta. +* Fix bug that caused slashes to be stripped from imported meta data. +* Fix bug that prevented import of serialized meta data. +* Fix file size check after download of remote files with HTTP compression enabled. +* Improve accessibility of form fields by adding missing labels. +* Improve imports for remote file URLs without name and/or extension. +* Add support for `wp:base_blog_url` field to allow importing multiple files with WP-CLI. +* Add support for term meta parsing when using the regular expressions or XML parser. +* Developers: All PHP classes have been moved into their own files. +* Developers: Allow to change `IMPORT_DEBUG` via `wp-config.php` and change default value to the value of `WP_DEBUG`. + += 0.6.4 = +* Improve PHP7 compatibility. +* Fix bug that caused slashes to be stripped from imported comments. +* Fix for various deprecation notices including `wp_get_http()` and `screen_icon()`. +* Fix for importing export files with multiline term meta data. + += 0.6.3 = +* Add support for import term metadata. +* Fix bug that caused slashes to be stripped from imported content. +* Fix bug that caused characters to be stripped inside of CDATA in some cases. +* Fix PHP notices. + += 0.6.2 = +* Add `wp_import_existing_post` filter, see [Trac ticket #33721](https://core.trac.wordpress.org/ticket/33721). + += 0.6 = +* Support for WXR 1.2 and multiple CDATA sections +* Post aren't duplicates if their post_type's are different + += 0.5.2 = +* Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when +an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used. + += 0.5 = +* Import comment meta (requires export from WordPress 3.2) +* Minor bugfixes and enhancements + += 0.4 = +* Map comment user_id where possible +* Import attachments from `wp:attachment_url` +* Upload attachments to correct directory +* Remap resized image URLs correctly + += 0.3 = +* Use an XML Parser if possible +* Proper import support for nav menus +* ... and much more, see [Trac ticket #15197](https://core.trac.wordpress.org/ticket/15197) + += 0.1 = +* Initial release + +== Frequently Asked Questions == + += Help! I'm getting out of memory errors or a blank screen. = +If your exported file is very large, the import script may run into your host's configured memory limit for PHP. + +A message like "Fatal error: Allowed memory size of 8388608 bytes exhausted" indicates that the script can't successfully import your XML file under the current PHP memory limit. If you have access to the php.ini file, you can manually increase the limit; if you do not (your WordPress installation is hosted on a shared server, for instance), you might have to break your exported XML file into several smaller pieces and run the import script one at a time. + +For those with shared hosting, the best alternative may be to consult hosting support to determine the safest approach for running the import. A host may be willing to temporarily lift the memory limit and/or run the process directly from their end. + +-- [Support Article: Importing Content](https://wordpress.org/support/article/importing-content/#before-importing) + +== Filters == + +The importer has a couple of filters to allow you to completely enable/block certain features: + +* `import_allow_create_users`: return false if you only want to allow mapping to existing users +* `import_allow_fetch_attachments`: return false if you do not wish to allow importing and downloading of attachments +* `import_attachment_size_limit`: return an integer value for the maximum file size in bytes to save (default is 0, which is unlimited) + +There are also a few actions available to hook into: + +* `import_start`: occurs after the export file has been uploaded and author import settings have been chosen +* `import_end`: called after the last output from the importer +posts, pages, comments, custom fields, categories, and tags from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); +} +add_action( 'admin_init', 'wordpress_importer_init' ); { "extends": [ "@wordpress/stylelint-config" diff --git a/build/wp-5.9.js b/build/wp-5.9.js old mode 100755 new mode 100644 index d49af852b7..5a65528f1b --- a/build/wp-5.9.js +++ b/build/wp-5.9.js @@ -1,6 +1,6 @@ // The number of bytes to download, which is just the size of the `wp.data` file. // Populated by the Dockerfile. -export const dependenciesTotalSize = 10334829; +export const dependenciesTotalSize = 10428080; // The final wp.data filename – populated by the Dockerfile. export const dependencyFilename = 'wp-5.9.data'; @@ -33,8 +33,8 @@ export default function(PHPModule) { // web worker PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/'); } - var PACKAGE_NAME = '/root/output//wp-5.9.data?'; - var REMOTE_PACKAGE_BASE = '/wp-5.9.data?'; + var PACKAGE_NAME = '/root/output//wp-5.9.data?58fbe5afc757c080e9a8274fd62fa01f'; + var REMOTE_PACKAGE_BASE = '/wp-5.9.data?58fbe5afc757c080e9a8274fd62fa01f'; if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) { Module['locateFile'] = Module['locateFilePackage']; err('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); @@ -123,6 +123,8 @@ Module['FS_createPath']("/wordpress/wp-content", "database", true, true); Module['FS_createPath']("/wordpress/wp-content", "plugins", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins", "akismet", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins/akismet", "views", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins", "wordpress-importer", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins/wordpress-importer", "parsers", true, true); Module['FS_createPath']("/wordpress/wp-content", "themes", true, true); Module['FS_createPath']("/wordpress/wp-content/themes", "twentytwentyone", true, true); Module['FS_createPath']("/wordpress/wp-content/themes/twentytwentyone", "classes", true, true); @@ -318,10 +320,10 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); var files = metadata['files']; for (var i = 0; i < files.length; ++i) { DataRequest.prototype.requests[files[i].filename].onload(); - } Module['removeRunDependency']('datafile_/root/output//wp-5.9.data?'); + } Module['removeRunDependency']('datafile_/root/output//wp-5.9.data?58fbe5afc757c080e9a8274fd62fa01f'); }; - Module['addRunDependency']('datafile_/root/output//wp-5.9.data?'); + Module['addRunDependency']('datafile_/root/output//wp-5.9.data?58fbe5afc757c080e9a8274fd62fa01f'); if (!Module.preloadResults) Module.preloadResults = {}; @@ -342,7 +344,7 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); } } - loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4836}, {"filename": "/wordpress/index.php", "start": 4836, "end": 4917}, {"filename": "/wordpress/readme.html", "start": 4917, "end": 12354}, {"filename": "/wordpress/wp-activate.php", "start": 12354, "end": 18336}, {"filename": "/wordpress/wp-admin/about.php", "start": 18336, "end": 33432}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 33432, "end": 37146}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 37146, "end": 38326}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 38326, "end": 38469}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 38469, "end": 43872}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 43872, "end": 44519}, {"filename": "/wordpress/wp-admin/admin.php", "start": 44519, "end": 50473}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 50473, "end": 54155}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 54155, "end": 61388}, {"filename": "/wordpress/wp-admin/comment.php", "start": 61388, "end": 71152}, {"filename": "/wordpress/wp-admin/credits.php", "start": 71152, "end": 74458}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 74458, "end": 74637}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 74637, "end": 74820}, {"filename": "/wordpress/wp-admin/customize.php", "start": 74820, "end": 83690}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 83690, "end": 96208}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 96208, "end": 120113}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 120113, "end": 127688}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 127688, "end": 134827}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 134827, "end": 140351}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 140351, "end": 146107}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 146107, "end": 162353}, {"filename": "/wordpress/wp-admin/edit.php", "start": 162353, "end": 178379}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 178379, "end": 185091}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 185091, "end": 191774}, {"filename": "/wordpress/wp-admin/export.php", "start": 191774, "end": 201590}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 201590, "end": 205507}, {"filename": "/wordpress/wp-admin/import.php", "start": 205507, "end": 211375}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 211375, "end": 217286}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 217286, "end": 219358}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 219358, "end": 328867}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 328867, "end": 335621}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 335621, "end": 336896}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 336896, "end": 338036}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 338036, "end": 339226}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 339226, "end": 343293}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 343293, "end": 352074}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 352074, "end": 369739}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 369739, "end": 407162}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 407162, "end": 408924}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 408924, "end": 413039}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 413039, "end": 420036}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 420036, "end": 443058}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 443058, "end": 444524}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 444524, "end": 453486}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 453486, "end": 542545}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 542545, "end": 551075}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 551075, "end": 552920}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 552920, "end": 564541}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 564541, "end": 573705}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 573705, "end": 576370}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 576370, "end": 590568}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 590568, "end": 592822}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 592822, "end": 596476}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 596476, "end": 606615}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 606615, "end": 608347}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 608347, "end": 612032}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 612032, "end": 639936}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 639936, "end": 661740}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 661740, "end": 668959}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 668959, "end": 712718}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 712718, "end": 720275}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 720275, "end": 726955}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 726955, "end": 737002}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 737002, "end": 744150}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 744150, "end": 753888}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 753888, "end": 758554}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 758554, "end": 760956}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 760956, "end": 765752}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 765752, "end": 766480}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 766480, "end": 791496}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 791496, "end": 808072}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 808072, "end": 821017}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 821017, "end": 838649}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 838649, "end": 847667}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 847667, "end": 864560}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 864560, "end": 893133}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 893133, "end": 894091}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 894091, "end": 933793}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 933793, "end": 937972}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 937972, "end": 942189}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 942189, "end": 965594}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 965594, "end": 973867}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 973867, "end": 993804}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 993804, "end": 1002210}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1002210, "end": 1061705}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1061705, "end": 1064312}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1064312, "end": 1076560}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1076560, "end": 1086708}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1086708, "end": 1094408}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1094408, "end": 1097503}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1097503, "end": 1098425}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1098425, "end": 1114098}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1114098, "end": 1125372}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1125372, "end": 1129208}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1129208, "end": 1149442}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1149442, "end": 1153228}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1153228, "end": 1198800}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1198800, "end": 1218833}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1218833, "end": 1219935}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1219935, "end": 1235445}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1235445, "end": 1284017}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1284017, "end": 1311847}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1311847, "end": 1330428}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1330428, "end": 1334674}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1334674, "end": 1336308}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1336308, "end": 1420659}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1420659, "end": 1425894}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1425894, "end": 1473656}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1473656, "end": 1499990}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1499990, "end": 1501070}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1501070, "end": 1502438}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1502438, "end": 1525629}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1525629, "end": 1560859}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1560859, "end": 1581370}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1581370, "end": 1581967}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1581967, "end": 1585667}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1585667, "end": 1607175}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1607175, "end": 1647000}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1647000, "end": 1697949}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1697949, "end": 1717497}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1717497, "end": 1727414}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1727414, "end": 1758336}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1758336, "end": 1761347}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1761347, "end": 1765115}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1765115, "end": 1819257}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1819257, "end": 1824633}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1824633, "end": 1850789}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1850789, "end": 1856681}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1856681, "end": 1905685}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1905685, "end": 1927642}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1927642, "end": 1998250}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 1998250, "end": 2011117}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2011117, "end": 2019817}, {"filename": "/wordpress/wp-admin/index.php", "start": 2019817, "end": 2026390}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2026390, "end": 2028300}, {"filename": "/wordpress/wp-admin/install.php", "start": 2028300, "end": 2042339}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2042339, "end": 2042890}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2042890, "end": 2046547}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2046547, "end": 2047969}, {"filename": "/wordpress/wp-admin/link.php", "start": 2047969, "end": 2049939}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2049939, "end": 2051469}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2051469, "end": 2053726}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2053726, "end": 2059667}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2059667, "end": 2062504}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2062504, "end": 2064024}, {"filename": "/wordpress/wp-admin/media.php", "start": 2064024, "end": 2069119}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2069119, "end": 2076287}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2076287, "end": 2089621}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2089621, "end": 2089758}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2089758, "end": 2089844}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2089844, "end": 2093407}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2093407, "end": 2093493}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2093493, "end": 2093589}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2093589, "end": 2093688}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2093688, "end": 2093788}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2093788, "end": 2093889}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2093889, "end": 2093988}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2093988, "end": 2097489}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2097489, "end": 2136517}, {"filename": "/wordpress/wp-admin/network.php", "start": 2136517, "end": 2141345}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2141345, "end": 2141429}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2141429, "end": 2142014}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2142014, "end": 2142100}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2142100, "end": 2142394}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2142394, "end": 2142481}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2142481, "end": 2145095}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2145095, "end": 2149315}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2149315, "end": 2149407}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2149407, "end": 2149612}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2149612, "end": 2149698}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2149698, "end": 2149784}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2149784, "end": 2149870}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2149870, "end": 2168964}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2168964, "end": 2169050}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2169050, "end": 2175188}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2175188, "end": 2182940}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2182940, "end": 2187574}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2187574, "end": 2192864}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2192864, "end": 2202666}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2202666, "end": 2213308}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2213308, "end": 2213399}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2213399, "end": 2213602}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2213602, "end": 2227829}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2227829, "end": 2227919}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2227919, "end": 2228184}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2228184, "end": 2231992}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2231992, "end": 2232080}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2232080, "end": 2236351}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2236351, "end": 2244078}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2244078, "end": 2257617}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2257617, "end": 2270730}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2270730, "end": 2270944}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2270944, "end": 2276789}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2276789, "end": 2293847}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2293847, "end": 2302326}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2302326, "end": 2310893}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2310893, "end": 2318532}, {"filename": "/wordpress/wp-admin/options.php", "start": 2318532, "end": 2328105}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2328105, "end": 2340396}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2340396, "end": 2345170}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2345170, "end": 2369782}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2369782, "end": 2371854}, {"filename": "/wordpress/wp-admin/post.php", "start": 2371854, "end": 2380134}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2380134, "end": 2382050}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2382050, "end": 2385353}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2385353, "end": 2387486}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2387486, "end": 2387569}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2387569, "end": 2391704}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2391704, "end": 2405280}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2405280, "end": 2408940}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2408940, "end": 2412577}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2412577, "end": 2420562}, {"filename": "/wordpress/wp-admin/term.php", "start": 2420562, "end": 2422500}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2422500, "end": 2436473}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2436473, "end": 2454893}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2454893, "end": 2494062}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2494062, "end": 2496811}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2496811, "end": 2533499}, {"filename": "/wordpress/wp-admin/update.php", "start": 2533499, "end": 2544022}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2544022, "end": 2544169}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2544169, "end": 2548523}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2548523, "end": 2561206}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2561206, "end": 2589978}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2589978, "end": 2610303}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2610303, "end": 2610387}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2610387, "end": 2610929}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2610929, "end": 2611015}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2611015, "end": 2611102}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2611102, "end": 2611186}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2611186, "end": 2611772}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2611772, "end": 2611858}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2611858, "end": 2611944}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2611944, "end": 2612032}, {"filename": "/wordpress/wp-admin/users.php", "start": 2612032, "end": 2630457}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2630457, "end": 2632143}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2632143, "end": 2649189}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2649189, "end": 2650071}, {"filename": "/wordpress/wp-blog-header.php", "start": 2650071, "end": 2650238}, {"filename": "/wordpress/wp-comments-post.php", "start": 2650238, "end": 2651649}, {"filename": "/wordpress/wp-config-sample.php", "start": 2651649, "end": 2652492}, {"filename": "/wordpress/wp-config.php", "start": 2652492, "end": 2653375}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2653375, "end": 2854079}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2854079, "end": 2854092}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2854092, "end": 2854120}, {"filename": "/wordpress/wp-content/db.php", "start": 2854120, "end": 2937510}, {"filename": "/wordpress/wp-content/index.php", "start": 2937510, "end": 2937516}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 2937516, "end": 2938651}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 2938651, "end": 2978806}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 2978806, "end": 2981839}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 2981839, "end": 2990006}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 2990006, "end": 2992837}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 2992837, "end": 3035813}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3035813, "end": 3035819}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3035819, "end": 3035996}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3035996, "end": 3047350}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3047350, "end": 3051848}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3051848, "end": 3052662}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3052662, "end": 3053417}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3053417, "end": 3065957}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3065957, "end": 3066220}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3066220, "end": 3066544}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3066544, "end": 3067351}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3067351, "end": 3068129}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3068129, "end": 3068254}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3068254, "end": 3074553}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3074553, "end": 3076288}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3076288, "end": 3076294}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/.stylelintrc-css.json", "start": 3076294, "end": 3076983}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/.stylelintrc.json", "start": 3076983, "end": 3077408}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/404.php", "start": 3077408, "end": 3077911}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/archive.php", "start": 3077911, "end": 3078687}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php", "start": 3078687, "end": 3081742}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize-color-control.php", "start": 3081742, "end": 3082265}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize-notice-control.php", "start": 3082265, "end": 3082849}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php", "start": 3082849, "end": 3085608}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php", "start": 3085608, "end": 3094547}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php", "start": 3094547, "end": 3143534}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/comments.php", "start": 3143534, "end": 3145438}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/footer.php", "start": 3145438, "end": 3147216}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/functions.php", "start": 3147216, "end": 3159349}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/header.php", "start": 3159349, "end": 3160017}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/image.php", "start": 3160017, "end": 3162322}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/back-compat.php", "start": 3162322, "end": 3163429}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/block-patterns.php", "start": 3163429, "end": 3182333}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/block-styles.php", "start": 3182333, "end": 3183998}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/custom-css.php", "start": 3183998, "end": 3184311}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/menu-functions.php", "start": 3184311, "end": 3186032}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/starter-content.php", "start": 3186032, "end": 3193467}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/template-functions.php", "start": 3193467, "end": 3204932}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/template-tags.php", "start": 3204932, "end": 3209885}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/index.php", "start": 3209885, "end": 3210462}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/package-lock.json", "start": 3210462, "end": 3445547}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/package.json", "start": 3445547, "end": 3447959}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/page.php", "start": 3447959, "end": 3448174}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/search.php", "start": 3448174, "end": 3449039}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/searchform.php", "start": 3449039, "end": 3449803}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/single.php", "start": 3449803, "end": 3450976}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/style.css", "start": 3450976, "end": 3607365}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-excerpt.php", "start": 3607365, "end": 3607839}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-none.php", "start": 3607839, "end": 3609170}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-page.php", "start": 3609170, "end": 3610333}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-single.php", "start": 3610333, "end": 3611194}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content.php", "start": 3611194, "end": 3612179}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-aside.php", "start": 3612179, "end": 3612201}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-audio.php", "start": 3612201, "end": 3612587}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-chat.php", "start": 3612587, "end": 3612769}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-gallery.php", "start": 3612769, "end": 3612935}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-image.php", "start": 3612935, "end": 3613146}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-link.php", "start": 3613146, "end": 3613325}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-quote.php", "start": 3613325, "end": 3613642}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-status.php", "start": 3613642, "end": 3613664}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-video.php", "start": 3613664, "end": 3614050}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt.php", "start": 3614050, "end": 3614072}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/footer/footer-widgets.php", "start": 3614072, "end": 3614245}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/entry-header.php", "start": 3614245, "end": 3614302}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/excerpt-header.php", "start": 3614302, "end": 3614653}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-branding.php", "start": 3614653, "end": 3615999}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-header.php", "start": 3615999, "end": 3616525}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-nav.php", "start": 3616525, "end": 3617558}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/post/author-bio.php", "start": 3617558, "end": 3618421}, {"filename": "/wordpress/wp-cron.php", "start": 3618421, "end": 3620417}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3620417, "end": 3657027}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3657027, "end": 3703775}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3703775, "end": 3783811}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3783811, "end": 3800526}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3800526, "end": 3859477}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3859477, "end": 3970367}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 3970367, "end": 4058550}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 4058550, "end": 4084486}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 4084486, "end": 4091936}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 4091936, "end": 4105998}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 4105998, "end": 4180532}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 4180532, "end": 4214643}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 4214643, "end": 4229367}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 4229367, "end": 4239506}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 4239506, "end": 4329610}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 4329610, "end": 4338393}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 4338393, "end": 4338635}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 4338635, "end": 4341563}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 4341563, "end": 4342189}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 4342189, "end": 4343412}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 4343412, "end": 4344075}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 4344075, "end": 4347193}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 4347193, "end": 4351788}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 4351788, "end": 4352425}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 4352425, "end": 4356725}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 4356725, "end": 4358870}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 4358870, "end": 4359089}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 4359089, "end": 4433887}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4433887, "end": 4450879}, {"filename": "/wordpress/wp-includes/Requests/Auth.php", "start": 4450879, "end": 4450963}, {"filename": "/wordpress/wp-includes/Requests/Auth/Basic.php", "start": 4450963, "end": 4451849}, {"filename": "/wordpress/wp-includes/Requests/Cookie.php", "start": 4451849, "end": 4457704}, {"filename": "/wordpress/wp-includes/Requests/Cookie/Jar.php", "start": 4457704, "end": 4459685}, {"filename": "/wordpress/wp-includes/Requests/Exception.php", "start": 4459685, "end": 4460027}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP.php", "start": 4460027, "end": 4460682}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/304.php", "start": 4460682, "end": 4460818}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/305.php", "start": 4460818, "end": 4460951}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/306.php", "start": 4460951, "end": 4461087}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/400.php", "start": 4461087, "end": 4461222}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/401.php", "start": 4461222, "end": 4461358}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/402.php", "start": 4461358, "end": 4461498}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/403.php", "start": 4461498, "end": 4461631}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/404.php", "start": 4461631, "end": 4461764}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/405.php", "start": 4461764, "end": 4461906}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/406.php", "start": 4461906, "end": 4462044}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/407.php", "start": 4462044, "end": 4462197}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/408.php", "start": 4462197, "end": 4462336}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/409.php", "start": 4462336, "end": 4462468}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/410.php", "start": 4462468, "end": 4462596}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/411.php", "start": 4462596, "end": 4462735}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/412.php", "start": 4462735, "end": 4462878}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/413.php", "start": 4462878, "end": 4463026}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/414.php", "start": 4463026, "end": 4463171}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/415.php", "start": 4463171, "end": 4463317}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/416.php", "start": 4463317, "end": 4463472}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/417.php", "start": 4463472, "end": 4463614}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/418.php", "start": 4463614, "end": 4463750}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/428.php", "start": 4463750, "end": 4463895}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/429.php", "start": 4463895, "end": 4464036}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/431.php", "start": 4464036, "end": 4464191}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/500.php", "start": 4464191, "end": 4464336}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/501.php", "start": 4464336, "end": 4464475}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/502.php", "start": 4464475, "end": 4464610}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/503.php", "start": 4464610, "end": 4464753}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/504.php", "start": 4464753, "end": 4464892}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/505.php", "start": 4464892, "end": 4465042}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/511.php", "start": 4465042, "end": 4465197}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/Unknown.php", "start": 4465197, "end": 4465507}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport.php", "start": 4465507, "end": 4465580}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport/cURL.php", "start": 4465580, "end": 4466221}, {"filename": "/wordpress/wp-includes/Requests/Hooker.php", "start": 4466221, "end": 4466373}, {"filename": "/wordpress/wp-includes/Requests/Hooks.php", "start": 4466373, "end": 4467021}, {"filename": "/wordpress/wp-includes/Requests/IDNAEncoder.php", "start": 4467021, "end": 4472282}, {"filename": "/wordpress/wp-includes/Requests/IPv6.php", "start": 4472282, "end": 4474572}, {"filename": "/wordpress/wp-includes/Requests/IRI.php", "start": 4474572, "end": 4490300}, {"filename": "/wordpress/wp-includes/Requests/Proxy.php", "start": 4490300, "end": 4490385}, {"filename": "/wordpress/wp-includes/Requests/Proxy/HTTP.php", "start": 4490385, "end": 4492023}, {"filename": "/wordpress/wp-includes/Requests/Response.php", "start": 4492023, "end": 4492928}, {"filename": "/wordpress/wp-includes/Requests/Response/Headers.php", "start": 4492928, "end": 4493802}, {"filename": "/wordpress/wp-includes/Requests/SSL.php", "start": 4493802, "end": 4495145}, {"filename": "/wordpress/wp-includes/Requests/Session.php", "start": 4495145, "end": 4498157}, {"filename": "/wordpress/wp-includes/Requests/Transport.php", "start": 4498157, "end": 4498371}, {"filename": "/wordpress/wp-includes/Requests/Transport/cURL.php", "start": 4498371, "end": 4508776}, {"filename": "/wordpress/wp-includes/Requests/Transport/fsockopen.php", "start": 4508776, "end": 4517286}, {"filename": "/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php", "start": 4517286, "end": 4518172}, {"filename": "/wordpress/wp-includes/Requests/Utility/FilteredIterator.php", "start": 4518172, "end": 4518679}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4518679, "end": 4519235}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4519235, "end": 4520361}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4520361, "end": 4520637}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4520637, "end": 4522703}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4522703, "end": 4523741}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4523741, "end": 4525109}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4525109, "end": 4526512}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4526512, "end": 4534869}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4534869, "end": 4536520}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4536520, "end": 4537410}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4537410, "end": 4538039}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4538039, "end": 4542483}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4542483, "end": 4542901}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4542901, "end": 4542950}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4542950, "end": 4543513}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4543513, "end": 4555433}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4555433, "end": 4569029}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4569029, "end": 4569083}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4569083, "end": 4575484}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4575484, "end": 4581827}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4581827, "end": 4597958}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4597958, "end": 4670955}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4670955, "end": 4680710}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4680710, "end": 4722027}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4722027, "end": 4724393}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4724393, "end": 4737527}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4737527, "end": 4759921}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4759921, "end": 4760351}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4760351, "end": 4762606}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4762606, "end": 4763223}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4763223, "end": 4775368}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4775368, "end": 4791969}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4791969, "end": 4795397}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4795397, "end": 4798465}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4798465, "end": 4804009}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4804009, "end": 4810582}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4810582, "end": 4812873}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4812873, "end": 4816872}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4816872, "end": 4817604}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4817604, "end": 4820676}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4820676, "end": 4823390}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4823390, "end": 4846391}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4846391, "end": 4857456}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4857456, "end": 4864995}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4864995, "end": 4871514}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4871514, "end": 4882892}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4882892, "end": 4883208}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4883208, "end": 4886413}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4886413, "end": 4887353}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4887353, "end": 4889301}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4889301, "end": 4890313}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4890313, "end": 4892312}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4892312, "end": 4893439}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4893439, "end": 4894211}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4894211, "end": 4894948}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4894948, "end": 4895959}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4895959, "end": 4899498}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4899498, "end": 4903865}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4903865, "end": 4904909}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4904909, "end": 4906087}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4906087, "end": 4915618}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 4915618, "end": 4917055}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 4917055, "end": 4917840}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 4917840, "end": 4923824}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 4923824, "end": 4925830}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 4925830, "end": 4932532}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 4932532, "end": 4951036}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 4951036, "end": 4956137}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 4956137, "end": 4978212}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 4978212, "end": 4980333}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 4980333, "end": 4980769}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 4980769, "end": 4980809}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 4980809, "end": 4980857}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 4980857, "end": 4981800}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 4981800, "end": 4981845}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 4981845, "end": 4981986}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 4981986, "end": 4982125}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 4982125, "end": 4983080}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 4983080, "end": 4983512}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 4983512, "end": 4983874}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 4983874, "end": 4985700}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 4985700, "end": 4986877}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 4986877, "end": 4988969}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 4988969, "end": 4989654}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 4989654, "end": 4990660}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 4990660, "end": 4991735}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 4991735, "end": 4994390}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 4994390, "end": 4994763}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 4994763, "end": 4995172}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 4995172, "end": 4997138}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 4997138, "end": 4997745}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 4997745, "end": 4997830}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 4997830, "end": 4997926}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 4997926, "end": 4998872}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 4998872, "end": 4998952}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 4998952, "end": 4999087}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 4999087, "end": 4999774}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 4999774, "end": 5000471}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 5000471, "end": 5000924}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 5000924, "end": 5002924}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 5002924, "end": 5004568}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 5004568, "end": 5006049}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 5006049, "end": 5018625}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 5018625, "end": 5019374}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 5019374, "end": 5020319}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 5020319, "end": 5021922}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 5021922, "end": 5022061}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 5022061, "end": 5022539}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 5022539, "end": 5023773}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 5023773, "end": 5024407}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 5024407, "end": 5025064}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 5025064, "end": 5025159}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 5025159, "end": 5025254}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 5025254, "end": 5026729}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 5026729, "end": 5027111}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 5027111, "end": 5036165}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 5036165, "end": 5036994}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 5036994, "end": 5039086}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 5039086, "end": 5042800}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 5042800, "end": 5057147}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 5057147, "end": 5057280}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 5057280, "end": 5058171}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 5058171, "end": 5058440}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 5058440, "end": 5058478}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 5058478, "end": 5058540}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 5058540, "end": 5059845}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 5059845, "end": 5060019}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 5060019, "end": 5060437}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 5060437, "end": 5061172}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 5061172, "end": 5061717}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 5061717, "end": 5063552}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 5063552, "end": 5066215}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 5066215, "end": 5067789}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 5067789, "end": 5067928}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 5067928, "end": 5070803}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 5070803, "end": 5074060}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 5074060, "end": 5074754}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 5074754, "end": 5075673}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 5075673, "end": 5080937}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 5080937, "end": 5082581}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 5082581, "end": 5082794}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 5082794, "end": 5084646}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 5084646, "end": 5087980}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 5087980, "end": 5088481}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 5088481, "end": 5089816}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 5089816, "end": 5089906}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 5089906, "end": 5090803}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 5090803, "end": 5091258}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 5091258, "end": 5093079}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 5093079, "end": 5093637}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 5093637, "end": 5095866}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 5095866, "end": 5096375}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 5096375, "end": 5096884}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 5096884, "end": 5097615}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 5097615, "end": 5105710}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 5105710, "end": 5106852}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 5106852, "end": 5108830}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 5108830, "end": 5108927}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 5108927, "end": 5116289}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 5116289, "end": 5117402}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 5117402, "end": 5118506}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 5118506, "end": 5133777}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 5133777, "end": 5136214}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 5136214, "end": 5145944}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 5145944, "end": 5159518}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5159518, "end": 5159613}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5159613, "end": 5159708}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5159708, "end": 5168973}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5168973, "end": 5169373}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5169373, "end": 5169965}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5169965, "end": 5179833}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5179833, "end": 5180503}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5180503, "end": 5181765}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5181765, "end": 5182127}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5182127, "end": 5183230}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5183230, "end": 5183560}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5183560, "end": 5184023}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5184023, "end": 5184581}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5184581, "end": 5184850}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5184850, "end": 5186540}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5186540, "end": 5187610}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5187610, "end": 5187946}, {"filename": "/wordpress/wp-includes/blocks/post-comments.php", "start": 5187946, "end": 5189471}, {"filename": "/wordpress/wp-includes/blocks/post-comments/block.json", "start": 5189471, "end": 5190240}, {"filename": "/wordpress/wp-includes/blocks/post-comments/style.min.css", "start": 5190240, "end": 5192017}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5192017, "end": 5193198}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5193198, "end": 5193582}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5193582, "end": 5194596}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5194596, "end": 5195388}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5195388, "end": 5196893}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5196893, "end": 5197806}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5197806, "end": 5197892}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5197892, "end": 5197947}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5197947, "end": 5199410}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5199410, "end": 5200215}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5200215, "end": 5203935}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5203935, "end": 5204240}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5204240, "end": 5206283}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5206283, "end": 5207148}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5207148, "end": 5209182}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5209182, "end": 5209793}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5209793, "end": 5209887}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5209887, "end": 5211236}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5211236, "end": 5212362}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5212362, "end": 5213125}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5213125, "end": 5213178}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5213178, "end": 5214283}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5214283, "end": 5215429}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5215429, "end": 5215473}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5215473, "end": 5216279}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5216279, "end": 5216384}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5216384, "end": 5217580}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5217580, "end": 5218085}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5218085, "end": 5219355}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5219355, "end": 5219622}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5219622, "end": 5221540}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5221540, "end": 5222280}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5222280, "end": 5224151}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5224151, "end": 5224542}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5224542, "end": 5224746}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5224746, "end": 5226232}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5226232, "end": 5226984}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5226984, "end": 5227447}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5227447, "end": 5228248}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5228248, "end": 5229017}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5229017, "end": 5229961}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5229961, "end": 5230864}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5230864, "end": 5231751}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5231751, "end": 5231907}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5231907, "end": 5232981}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5232981, "end": 5233122}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5233122, "end": 5234375}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5234375, "end": 5234785}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5234785, "end": 5235253}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5235253, "end": 5237966}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5237966, "end": 5238816}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5238816, "end": 5239252}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5239252, "end": 5239951}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5239951, "end": 5249373}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5249373, "end": 5250470}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5250470, "end": 5250727}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5250727, "end": 5252000}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5252000, "end": 5252057}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5252057, "end": 5252738}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5252738, "end": 5252835}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5252835, "end": 5253238}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5253238, "end": 5253583}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5253583, "end": 5253907}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5253907, "end": 5254317}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5254317, "end": 5255341}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5255341, "end": 5259167}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5259167, "end": 5260323}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5260323, "end": 5263027}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5263027, "end": 5263379}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5263379, "end": 5264035}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5264035, "end": 5264981}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5264981, "end": 5265049}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5265049, "end": 5266255}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5266255, "end": 5267498}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5267498, "end": 5267564}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5267564, "end": 5324810}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5324810, "end": 5325378}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5325378, "end": 5325741}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5325741, "end": 5327293}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5327293, "end": 5329219}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5329219, "end": 5338640}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5338640, "end": 5339092}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5339092, "end": 5339916}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5339916, "end": 5339944}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5339944, "end": 5343112}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5343112, "end": 5344871}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5344871, "end": 5347138}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5347138, "end": 5347452}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5347452, "end": 5348325}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5348325, "end": 5348848}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5348848, "end": 5349106}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5349106, "end": 5353525}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5353525, "end": 5354067}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5354067, "end": 5356311}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5356311, "end": 5356402}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5356402, "end": 5357169}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5357169, "end": 5357757}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5357757, "end": 5358432}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5358432, "end": 5358518}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5358518, "end": 5358970}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5358970, "end": 5359989}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5359989, "end": 5360063}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5360063, "end": 5361621}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5361621, "end": 5363942}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5363942, "end": 5364204}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5364204, "end": 5364343}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5364343, "end": 5365719}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5365719, "end": 5366038}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5366038, "end": 5371524}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5371524, "end": 5379924}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5379924, "end": 5380186}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5380186, "end": 5382152}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5382152, "end": 5405362}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5405362, "end": 5422312}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5422312, "end": 5442913}, {"filename": "/wordpress/wp-includes/category.php", "start": 5442913, "end": 5447384}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5447384, "end": 5680615}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5680615, "end": 5681241}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5681241, "end": 5681681}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5681681, "end": 5681828}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5681828, "end": 5695827}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5695827, "end": 5695978}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5695978, "end": 5699724}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5699724, "end": 5700240}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5700240, "end": 5710817}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5710817, "end": 5725388}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5725388, "end": 5781588}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5781588, "end": 5781908}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5781908, "end": 5803347}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5803347, "end": 5804303}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5804303, "end": 5807927}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5807927, "end": 5815739}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5815739, "end": 5819052}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5819052, "end": 5819918}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5819918, "end": 5823305}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5823305, "end": 5834318}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5834318, "end": 5836645}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5836645, "end": 5842512}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5842512, "end": 5842712}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5842712, "end": 5844066}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5844066, "end": 5850272}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5850272, "end": 5851956}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5851956, "end": 5853920}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5853920, "end": 5856067}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5856067, "end": 5859277}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5859277, "end": 5859608}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5859608, "end": 5861610}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5861610, "end": 5863803}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5863803, "end": 5867656}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5867656, "end": 5889196}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5889196, "end": 5892194}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5892194, "end": 5905287}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5905287, "end": 6029557}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 6029557, "end": 6068432}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 6068432, "end": 6072407}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 6072407, "end": 6076691}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 6076691, "end": 6089221}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 6089221, "end": 6130268}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6130268, "end": 6145421}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6145421, "end": 6146126}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6146126, "end": 6188457}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6188457, "end": 6196033}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6196033, "end": 6198832}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6198832, "end": 6201722}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6201722, "end": 6202647}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6202647, "end": 6203032}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6203032, "end": 6209139}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6209139, "end": 6211977}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6211977, "end": 6219594}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6219594, "end": 6222212}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6222212, "end": 6224618}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6224618, "end": 6226555}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6226555, "end": 6227118}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6227118, "end": 6229173}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6229173, "end": 6230053}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6230053, "end": 6240928}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6240928, "end": 6257521}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6257521, "end": 6266696}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6266696, "end": 6281274}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6281274, "end": 6287710}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6287710, "end": 6290734}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6290734, "end": 6292709}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6292709, "end": 6298010}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6298010, "end": 6298748}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6298748, "end": 6311844}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6311844, "end": 6313710}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6313710, "end": 6322635}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6322635, "end": 6327761}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6327761, "end": 6332833}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6332833, "end": 6336552}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6336552, "end": 6350326}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6350326, "end": 6352856}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6352856, "end": 6361400}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6361400, "end": 6364356}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6364356, "end": 6437098}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6437098, "end": 6440629}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6440629, "end": 6446425}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6446425, "end": 6448484}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6448484, "end": 6450059}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6450059, "end": 6456160}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6456160, "end": 6480941}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6480941, "end": 6481599}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6481599, "end": 6485123}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6485123, "end": 6487631}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6487631, "end": 6488921}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6488921, "end": 6489776}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6489776, "end": 6503720}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6503720, "end": 6506407}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6506407, "end": 6515587}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6515587, "end": 6521494}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6521494, "end": 6538657}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6538657, "end": 6540861}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6540861, "end": 6541198}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6541198, "end": 6549222}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6549222, "end": 6556256}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6556256, "end": 6558085}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6558085, "end": 6591490}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6591490, "end": 6618673}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6618673, "end": 6620135}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6620135, "end": 6637632}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6637632, "end": 6638638}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6638638, "end": 6647537}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6647537, "end": 6653139}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6653139, "end": 6654538}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6654538, "end": 6661915}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6661915, "end": 6789179}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6789179, "end": 6803155}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6803155, "end": 6808550}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6808550, "end": 6817486}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6817486, "end": 6822624}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6822624, "end": 6860231}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6860231, "end": 6920438}, {"filename": "/wordpress/wp-includes/compat.php", "start": 6920438, "end": 6925993}, {"filename": "/wordpress/wp-includes/cron.php", "start": 6925993, "end": 6939711}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 6939711, "end": 6940349}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 6940349, "end": 6940561}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 6940561, "end": 6942800}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 6942800, "end": 6944041}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 6944041, "end": 6945768}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 6945768, "end": 6946337}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 6946337, "end": 6948514}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 6948514, "end": 6954985}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 6954985, "end": 6955095}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 6955095, "end": 6961712}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 6961712, "end": 6962645}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 6962645, "end": 6963109}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 6963109, "end": 6969829}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 6969829, "end": 6970440}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 6970440, "end": 6971825}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 6971825, "end": 6977077}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 6977077, "end": 6993472}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 6993472, "end": 6995017}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 6995017, "end": 6996994}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 6996994, "end": 6997622}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 6997622, "end": 6997886}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 6997886, "end": 7007476}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 7007476, "end": 7009504}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7009504, "end": 7010088}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7010088, "end": 7010824}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7010824, "end": 7013510}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7013510, "end": 7018991}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7018991, "end": 7019329}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7019329, "end": 7021637}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7021637, "end": 7030454}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7030454, "end": 7032658}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7032658, "end": 7037307}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7037307, "end": 7037785}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7037785, "end": 7037939}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7037939, "end": 7039039}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7039039, "end": 7040287}, {"filename": "/wordpress/wp-includes/date.php", "start": 7040287, "end": 7040446}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7040446, "end": 7046070}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7046070, "end": 7074108}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7074108, "end": 7075559}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7075559, "end": 7131636}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7131636, "end": 7131785}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7131785, "end": 7149852}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7149852, "end": 7151738}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7151738, "end": 7155663}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7155663, "end": 7158181}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7158181, "end": 7160309}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7160309, "end": 7161240}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7161240, "end": 7164063}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7164063, "end": 7166788}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7166788, "end": 7176374}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7176374, "end": 7383056}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7383056, "end": 7496595}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7496595, "end": 7501135}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7501135, "end": 7503174}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7503174, "end": 7574872}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7574872, "end": 7577843}, {"filename": "/wordpress/wp-includes/http.php", "start": 7577843, "end": 7586163}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7586163, "end": 7589225}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7589225, "end": 7590902}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7590902, "end": 7591647}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7591647, "end": 7593499}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7593499, "end": 7626455}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7626455, "end": 7648031}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7648031, "end": 7708587}, {"filename": "/wordpress/wp-includes/load.php", "start": 7708587, "end": 7731800}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7731800, "end": 7731858}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7731858, "end": 7787834}, {"filename": "/wordpress/wp-includes/media.php", "start": 7787834, "end": 7874046}, {"filename": "/wordpress/wp-includes/meta.php", "start": 7874046, "end": 7896483}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 7896483, "end": 7909834}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 7909834, "end": 7912806}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 7912806, "end": 7918441}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 7918441, "end": 7929688}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 7929688, "end": 7931847}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 7931847, "end": 7975997}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 7975997, "end": 7984699}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 7984699, "end": 7986105}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 7986105, "end": 7988074}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 7988074, "end": 8005743}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8005743, "end": 8019321}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8019321, "end": 8043932}, {"filename": "/wordpress/wp-includes/option.php", "start": 8043932, "end": 8076936}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8076936, "end": 8077123}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8077123, "end": 8079605}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8079605, "end": 8126874}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8126874, "end": 8135250}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8135250, "end": 8136795}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8136795, "end": 8143029}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8143029, "end": 8147257}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8147257, "end": 8156965}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8156965, "end": 8161392}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8161392, "end": 8167052}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8167052, "end": 8170999}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8170999, "end": 8200756}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8200756, "end": 8203759}, {"filename": "/wordpress/wp-includes/post.php", "start": 8203759, "end": 8325207}, {"filename": "/wordpress/wp-includes/query.php", "start": 8325207, "end": 8337953}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8337953, "end": 8339937}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8339937, "end": 8340398}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8340398, "end": 8340648}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8340648, "end": 8343345}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8343345, "end": 8344031}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8344031, "end": 8345212}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8345212, "end": 8345886}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8345886, "end": 8346574}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8346574, "end": 8347064}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8347064, "end": 8348198}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8348198, "end": 8348311}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8348311, "end": 8348424}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8348424, "end": 8403153}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8403153, "end": 8414228}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8414228, "end": 8416689}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8416689, "end": 8441359}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8441359, "end": 8456227}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8456227, "end": 8485079}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8485079, "end": 8492964}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8492964, "end": 8499130}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8499130, "end": 8502657}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8502657, "end": 8516823}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8516823, "end": 8517695}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8517695, "end": 8556449}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8556449, "end": 8565269}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8565269, "end": 8566431}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8566431, "end": 8577138}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8577138, "end": 8600021}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8600021, "end": 8605116}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8605116, "end": 8615934}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8615934, "end": 8621946}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8621946, "end": 8640984}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8640984, "end": 8647547}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8647547, "end": 8655476}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8655476, "end": 8718887}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8718887, "end": 8735226}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8735226, "end": 8742108}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8742108, "end": 8746855}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8746855, "end": 8756494}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8756494, "end": 8762402}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8762402, "end": 8771263}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8771263, "end": 8790272}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8790272, "end": 8811130}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8811130, "end": 8823773}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8823773, "end": 8832029}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8832029, "end": 8863264}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 8863264, "end": 8874569}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 8874569, "end": 8890642}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 8890642, "end": 8890892}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 8890892, "end": 8901341}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 8901341, "end": 8901698}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 8901698, "end": 8902090}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 8902090, "end": 8902328}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 8902328, "end": 8904268}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 8904268, "end": 8907040}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 8907040, "end": 8907488}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 8907488, "end": 8909701}, {"filename": "/wordpress/wp-includes/revision.php", "start": 8909701, "end": 8921093}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 8921093, "end": 8928856}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 8928856, "end": 8930172}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 8930172, "end": 8930335}, {"filename": "/wordpress/wp-includes/rss.php", "start": 8930335, "end": 8944776}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 8944776, "end": 9024561}, {"filename": "/wordpress/wp-includes/session.php", "start": 9024561, "end": 9024755}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9024755, "end": 9032655}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9032655, "end": 9033855}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9033855, "end": 9034632}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9034632, "end": 9036295}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9036295, "end": 9036891}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9036891, "end": 9040447}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9040447, "end": 9047392}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9047392, "end": 9050635}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9050635, "end": 9053095}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9053095, "end": 9055290}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9055290, "end": 9056779}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9056779, "end": 9057639}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9057639, "end": 9058058}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9058058, "end": 9059639}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9059639, "end": 9061247}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9061247, "end": 9065405}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9065405, "end": 9065956}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9065956, "end": 9087699}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9087699, "end": 9092295}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9092295, "end": 9096458}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9096458, "end": 9107676}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9107676, "end": 9108291}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9108291, "end": 9108375}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9108375, "end": 9108471}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9108471, "end": 9108569}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9108569, "end": 9108675}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9108675, "end": 9108789}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9108789, "end": 9108891}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9108891, "end": 9108999}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9108999, "end": 9109121}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9109121, "end": 9109239}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9109239, "end": 9109353}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9109353, "end": 9109467}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9109467, "end": 9109591}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9109591, "end": 9109697}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9109697, "end": 9109793}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9109793, "end": 9109893}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9109893, "end": 9109991}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9109991, "end": 9110089}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9110089, "end": 9110199}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9110199, "end": 9110295}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9110295, "end": 9110391}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9110391, "end": 9110481}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9110481, "end": 9110575}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9110575, "end": 9110675}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9110675, "end": 9110773}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9110773, "end": 9110857}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9110857, "end": 9110937}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9110937, "end": 9192012}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9192012, "end": 9202679}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9202679, "end": 9205639}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9205639, "end": 9209074}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9209074, "end": 9212509}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9212509, "end": 9217709}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9217709, "end": 9219745}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9219745, "end": 9220451}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9220451, "end": 9299101}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9299101, "end": 9300384}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9300384, "end": 9301207}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9301207, "end": 9301948}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9301948, "end": 9302543}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9302543, "end": 9303280}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9303280, "end": 9303969}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9303969, "end": 9393009}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9393009, "end": 9401673}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9401673, "end": 9404239}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9404239, "end": 9406703}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9406703, "end": 9407478}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9407478, "end": 9414324}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9414324, "end": 9426852}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9426852, "end": 9431726}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9431726, "end": 9433831}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9433831, "end": 9437142}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9437142, "end": 9449254}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9449254, "end": 9453969}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9453969, "end": 9455566}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9455566, "end": 9456048}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9456048, "end": 9465429}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9465429, "end": 9470933}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9470933, "end": 9473698}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9473698, "end": 9474552}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9474552, "end": 9557526}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9557526, "end": 9560089}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9560089, "end": 9560932}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9560932, "end": 9561689}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9561689, "end": 9562300}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9562300, "end": 9563057}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9563057, "end": 9563759}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9563759, "end": 9652110}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9652110, "end": 9659768}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9659768, "end": 9662844}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9662844, "end": 9666852}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9666852, "end": 9680263}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9680263, "end": 9697837}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9697837, "end": 9698622}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9698622, "end": 9707251}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9707251, "end": 9713844}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9713844, "end": 9715977}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9715977, "end": 9718746}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9718746, "end": 9718905}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9718905, "end": 9724903}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9724903, "end": 9725763}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9725763, "end": 9726251}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9726251, "end": 9750798}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9750798, "end": 9775654}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9775654, "end": 9805062}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9805062, "end": 9806718}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9806718, "end": 9806818}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9806818, "end": 9806928}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9806928, "end": 9879376}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 9879376, "end": 9879702}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 9879702, "end": 9881427}, {"filename": "/wordpress/wp-includes/template.php", "start": 9881427, "end": 9888269}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 9888269, "end": 9889897}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 9889897, "end": 9890419}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 9890419, "end": 9892409}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 9892409, "end": 9892623}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 9892623, "end": 9892678}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 9892678, "end": 9893354}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 9893354, "end": 9893684}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 9893684, "end": 9895243}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 9895243, "end": 9898368}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 9898368, "end": 9899293}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 9899293, "end": 9902998}, {"filename": "/wordpress/wp-includes/theme.json", "start": 9902998, "end": 9908734}, {"filename": "/wordpress/wp-includes/theme.php", "start": 9908734, "end": 9977326}, {"filename": "/wordpress/wp-includes/update.php", "start": 9977326, "end": 9996077}, {"filename": "/wordpress/wp-includes/user.php", "start": 9996077, "end": 10065820}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10065820, "end": 10069781}, {"filename": "/wordpress/wp-includes/version.php", "start": 10069781, "end": 10069939}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10069939, "end": 10102683}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10102683, "end": 10106545}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10106545, "end": 10110784}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10110784, "end": 10113989}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10113989, "end": 10115475}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10115475, "end": 10120006}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10120006, "end": 10127148}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10127148, "end": 10132585}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10132585, "end": 10136813}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10136813, "end": 10141953}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10141953, "end": 10150796}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10150796, "end": 10156885}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10156885, "end": 10164430}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10164430, "end": 10166628}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10166628, "end": 10170205}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10170205, "end": 10174315}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10174315, "end": 10178199}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10178199, "end": 10181377}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10181377, "end": 10182769}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10182769, "end": 10187018}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10187018, "end": 10199420}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10199420, "end": 10200465}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10200465, "end": 10250134}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10250134, "end": 10250483}, {"filename": "/wordpress/wp-links-opml.php", "start": 10250483, "end": 10252095}, {"filename": "/wordpress/wp-load.php", "start": 10252095, "end": 10253823}, {"filename": "/wordpress/wp-login.php", "start": 10253823, "end": 10287315}, {"filename": "/wordpress/wp-mail.php", "start": 10287315, "end": 10293271}, {"filename": "/wordpress/wp-settings.php", "start": 10293271, "end": 10309060}, {"filename": "/wordpress/wp-signup.php", "start": 10309060, "end": 10329650}, {"filename": "/wordpress/wp-trackback.php", "start": 10329650, "end": 10333008}, {"filename": "/wordpress/xmlrpc.php", "start": 10333008, "end": 10334829}], "remote_package_size": 10334829}); + loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4836}, {"filename": "/wordpress/index.php", "start": 4836, "end": 4917}, {"filename": "/wordpress/readme.html", "start": 4917, "end": 12354}, {"filename": "/wordpress/wp-activate.php", "start": 12354, "end": 18336}, {"filename": "/wordpress/wp-admin/about.php", "start": 18336, "end": 33432}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 33432, "end": 37146}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 37146, "end": 38326}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 38326, "end": 38469}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 38469, "end": 43872}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 43872, "end": 44519}, {"filename": "/wordpress/wp-admin/admin.php", "start": 44519, "end": 50473}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 50473, "end": 54155}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 54155, "end": 61388}, {"filename": "/wordpress/wp-admin/comment.php", "start": 61388, "end": 71152}, {"filename": "/wordpress/wp-admin/credits.php", "start": 71152, "end": 74458}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 74458, "end": 74637}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 74637, "end": 74820}, {"filename": "/wordpress/wp-admin/customize.php", "start": 74820, "end": 83690}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 83690, "end": 96208}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 96208, "end": 120113}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 120113, "end": 127688}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 127688, "end": 134827}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 134827, "end": 140351}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 140351, "end": 146107}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 146107, "end": 162353}, {"filename": "/wordpress/wp-admin/edit.php", "start": 162353, "end": 178379}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 178379, "end": 185091}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 185091, "end": 191774}, {"filename": "/wordpress/wp-admin/export.php", "start": 191774, "end": 201590}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 201590, "end": 205507}, {"filename": "/wordpress/wp-admin/import.php", "start": 205507, "end": 211375}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 211375, "end": 217286}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 217286, "end": 219358}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 219358, "end": 328867}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 328867, "end": 335621}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 335621, "end": 336896}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 336896, "end": 338036}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 338036, "end": 339226}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 339226, "end": 343293}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 343293, "end": 352074}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 352074, "end": 369739}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 369739, "end": 407162}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 407162, "end": 408924}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 408924, "end": 413039}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 413039, "end": 420036}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 420036, "end": 443058}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 443058, "end": 444524}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 444524, "end": 453486}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 453486, "end": 542545}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 542545, "end": 551075}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 551075, "end": 552920}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 552920, "end": 564541}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 564541, "end": 573705}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 573705, "end": 576370}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 576370, "end": 590568}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 590568, "end": 592822}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 592822, "end": 596476}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 596476, "end": 606615}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 606615, "end": 608347}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 608347, "end": 612032}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 612032, "end": 639936}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 639936, "end": 661740}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 661740, "end": 668959}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 668959, "end": 712718}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 712718, "end": 720275}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 720275, "end": 726955}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 726955, "end": 737002}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 737002, "end": 744150}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 744150, "end": 753888}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 753888, "end": 758554}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 758554, "end": 760956}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 760956, "end": 765752}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 765752, "end": 766480}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 766480, "end": 791496}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 791496, "end": 808072}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 808072, "end": 821017}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 821017, "end": 838649}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 838649, "end": 847667}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 847667, "end": 864560}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 864560, "end": 893133}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 893133, "end": 894091}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 894091, "end": 933793}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 933793, "end": 937972}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 937972, "end": 942189}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 942189, "end": 965594}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 965594, "end": 973867}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 973867, "end": 993804}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 993804, "end": 1002210}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1002210, "end": 1061705}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1061705, "end": 1064312}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1064312, "end": 1076560}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1076560, "end": 1086708}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1086708, "end": 1094408}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1094408, "end": 1097503}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1097503, "end": 1098425}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1098425, "end": 1114098}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1114098, "end": 1125372}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1125372, "end": 1129208}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1129208, "end": 1149442}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1149442, "end": 1153228}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1153228, "end": 1198800}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1198800, "end": 1218833}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1218833, "end": 1219935}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1219935, "end": 1235445}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1235445, "end": 1284017}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1284017, "end": 1311847}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1311847, "end": 1330428}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1330428, "end": 1334674}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1334674, "end": 1336308}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1336308, "end": 1420659}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1420659, "end": 1425894}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1425894, "end": 1473656}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1473656, "end": 1499990}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1499990, "end": 1501070}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1501070, "end": 1502438}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1502438, "end": 1525629}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1525629, "end": 1560859}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1560859, "end": 1581370}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1581370, "end": 1581967}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1581967, "end": 1585667}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1585667, "end": 1607175}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1607175, "end": 1647000}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1647000, "end": 1697949}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1697949, "end": 1717497}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1717497, "end": 1727414}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1727414, "end": 1758336}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1758336, "end": 1761347}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1761347, "end": 1765115}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1765115, "end": 1819257}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1819257, "end": 1824633}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1824633, "end": 1850789}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1850789, "end": 1856681}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1856681, "end": 1905685}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1905685, "end": 1927642}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1927642, "end": 1998250}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 1998250, "end": 2011117}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2011117, "end": 2019817}, {"filename": "/wordpress/wp-admin/index.php", "start": 2019817, "end": 2026390}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2026390, "end": 2028300}, {"filename": "/wordpress/wp-admin/install.php", "start": 2028300, "end": 2042339}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2042339, "end": 2042890}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2042890, "end": 2046547}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2046547, "end": 2047969}, {"filename": "/wordpress/wp-admin/link.php", "start": 2047969, "end": 2049939}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2049939, "end": 2051469}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2051469, "end": 2053726}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2053726, "end": 2059667}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2059667, "end": 2062504}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2062504, "end": 2064024}, {"filename": "/wordpress/wp-admin/media.php", "start": 2064024, "end": 2069119}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2069119, "end": 2076287}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2076287, "end": 2089621}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2089621, "end": 2089758}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2089758, "end": 2089844}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2089844, "end": 2093407}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2093407, "end": 2093493}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2093493, "end": 2093589}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2093589, "end": 2093688}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2093688, "end": 2093788}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2093788, "end": 2093889}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2093889, "end": 2093988}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2093988, "end": 2097489}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2097489, "end": 2136517}, {"filename": "/wordpress/wp-admin/network.php", "start": 2136517, "end": 2141345}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2141345, "end": 2141429}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2141429, "end": 2142014}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2142014, "end": 2142100}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2142100, "end": 2142394}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2142394, "end": 2142481}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2142481, "end": 2145095}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2145095, "end": 2149315}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2149315, "end": 2149407}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2149407, "end": 2149612}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2149612, "end": 2149698}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2149698, "end": 2149784}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2149784, "end": 2149870}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2149870, "end": 2168964}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2168964, "end": 2169050}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2169050, "end": 2175188}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2175188, "end": 2182940}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2182940, "end": 2187574}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2187574, "end": 2192864}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2192864, "end": 2202666}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2202666, "end": 2213308}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2213308, "end": 2213399}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2213399, "end": 2213602}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2213602, "end": 2227829}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2227829, "end": 2227919}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2227919, "end": 2228184}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2228184, "end": 2231992}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2231992, "end": 2232080}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2232080, "end": 2236351}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2236351, "end": 2244078}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2244078, "end": 2257617}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2257617, "end": 2270730}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2270730, "end": 2270944}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2270944, "end": 2276789}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2276789, "end": 2293847}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2293847, "end": 2302326}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2302326, "end": 2310893}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2310893, "end": 2318532}, {"filename": "/wordpress/wp-admin/options.php", "start": 2318532, "end": 2328105}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2328105, "end": 2340396}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2340396, "end": 2345170}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2345170, "end": 2369782}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2369782, "end": 2371854}, {"filename": "/wordpress/wp-admin/post.php", "start": 2371854, "end": 2380134}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2380134, "end": 2382050}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2382050, "end": 2385353}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2385353, "end": 2387486}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2387486, "end": 2387569}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2387569, "end": 2391704}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2391704, "end": 2405280}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2405280, "end": 2408940}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2408940, "end": 2412577}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2412577, "end": 2420562}, {"filename": "/wordpress/wp-admin/term.php", "start": 2420562, "end": 2422500}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2422500, "end": 2436473}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2436473, "end": 2454893}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2454893, "end": 2494062}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2494062, "end": 2496811}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2496811, "end": 2533499}, {"filename": "/wordpress/wp-admin/update.php", "start": 2533499, "end": 2544022}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2544022, "end": 2544169}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2544169, "end": 2548523}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2548523, "end": 2561206}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2561206, "end": 2589978}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2589978, "end": 2610303}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2610303, "end": 2610387}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2610387, "end": 2610929}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2610929, "end": 2611015}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2611015, "end": 2611102}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2611102, "end": 2611186}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2611186, "end": 2611772}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2611772, "end": 2611858}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2611858, "end": 2611944}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2611944, "end": 2612032}, {"filename": "/wordpress/wp-admin/users.php", "start": 2612032, "end": 2630457}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2630457, "end": 2632143}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2632143, "end": 2649189}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2649189, "end": 2650071}, {"filename": "/wordpress/wp-blog-header.php", "start": 2650071, "end": 2650238}, {"filename": "/wordpress/wp-comments-post.php", "start": 2650238, "end": 2651649}, {"filename": "/wordpress/wp-config-sample.php", "start": 2651649, "end": 2652492}, {"filename": "/wordpress/wp-config.php", "start": 2652492, "end": 2653375}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2653375, "end": 2858175}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2858175, "end": 2858188}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2858188, "end": 2858196}, {"filename": "/wordpress/wp-content/db.php", "start": 2858196, "end": 2941586}, {"filename": "/wordpress/wp-content/index.php", "start": 2941586, "end": 2941592}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 2941592, "end": 2942727}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 2942727, "end": 2982882}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 2982882, "end": 2985915}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 2985915, "end": 2994082}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 2994082, "end": 2996913}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 2996913, "end": 3039889}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3039889, "end": 3039895}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3039895, "end": 3040072}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3040072, "end": 3051426}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3051426, "end": 3055924}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3055924, "end": 3056738}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3056738, "end": 3057493}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3057493, "end": 3070033}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3070033, "end": 3070296}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3070296, "end": 3070620}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3070620, "end": 3071427}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3071427, "end": 3072205}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3072205, "end": 3072330}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3072330, "end": 3078629}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3078629, "end": 3080364}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3080364, "end": 3080370}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php", "start": 3080370, "end": 3131799}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/compat.php", "start": 3131799, "end": 3132663}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers.php", "start": 3132663, "end": 3133244}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php", "start": 3133244, "end": 3144546}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php", "start": 3144546, "end": 3152725}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-xml.php", "start": 3152725, "end": 3159612}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser.php", "start": 3159612, "end": 3161516}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/readme.txt", "start": 3161516, "end": 3167337}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/wordpress-importer.php", "start": 3167337, "end": 3169545}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/.stylelintrc-css.json", "start": 3169545, "end": 3170234}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/.stylelintrc.json", "start": 3170234, "end": 3170659}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/404.php", "start": 3170659, "end": 3171162}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/archive.php", "start": 3171162, "end": 3171938}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php", "start": 3171938, "end": 3174993}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize-color-control.php", "start": 3174993, "end": 3175516}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize-notice-control.php", "start": 3175516, "end": 3176100}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php", "start": 3176100, "end": 3178859}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php", "start": 3178859, "end": 3187798}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php", "start": 3187798, "end": 3236785}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/comments.php", "start": 3236785, "end": 3238689}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/footer.php", "start": 3238689, "end": 3240467}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/functions.php", "start": 3240467, "end": 3252600}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/header.php", "start": 3252600, "end": 3253268}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/image.php", "start": 3253268, "end": 3255573}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/back-compat.php", "start": 3255573, "end": 3256680}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/block-patterns.php", "start": 3256680, "end": 3275584}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/block-styles.php", "start": 3275584, "end": 3277249}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/custom-css.php", "start": 3277249, "end": 3277562}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/menu-functions.php", "start": 3277562, "end": 3279283}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/starter-content.php", "start": 3279283, "end": 3286718}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/template-functions.php", "start": 3286718, "end": 3298183}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/inc/template-tags.php", "start": 3298183, "end": 3303136}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/index.php", "start": 3303136, "end": 3303713}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/package-lock.json", "start": 3303713, "end": 3538798}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/package.json", "start": 3538798, "end": 3541210}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/page.php", "start": 3541210, "end": 3541425}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/search.php", "start": 3541425, "end": 3542290}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/searchform.php", "start": 3542290, "end": 3543054}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/single.php", "start": 3543054, "end": 3544227}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/style.css", "start": 3544227, "end": 3700616}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-excerpt.php", "start": 3700616, "end": 3701090}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-none.php", "start": 3701090, "end": 3702421}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-page.php", "start": 3702421, "end": 3703584}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content-single.php", "start": 3703584, "end": 3704445}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/content/content.php", "start": 3704445, "end": 3705430}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-aside.php", "start": 3705430, "end": 3705452}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-audio.php", "start": 3705452, "end": 3705838}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-chat.php", "start": 3705838, "end": 3706020}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-gallery.php", "start": 3706020, "end": 3706186}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-image.php", "start": 3706186, "end": 3706397}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-link.php", "start": 3706397, "end": 3706576}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-quote.php", "start": 3706576, "end": 3706893}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-status.php", "start": 3706893, "end": 3706915}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt-video.php", "start": 3706915, "end": 3707301}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/excerpt/excerpt.php", "start": 3707301, "end": 3707323}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/footer/footer-widgets.php", "start": 3707323, "end": 3707496}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/entry-header.php", "start": 3707496, "end": 3707553}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/excerpt-header.php", "start": 3707553, "end": 3707904}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-branding.php", "start": 3707904, "end": 3709250}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-header.php", "start": 3709250, "end": 3709776}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/header/site-nav.php", "start": 3709776, "end": 3710809}, {"filename": "/wordpress/wp-content/themes/twentytwentyone/template-parts/post/author-bio.php", "start": 3710809, "end": 3711672}, {"filename": "/wordpress/wp-cron.php", "start": 3711672, "end": 3713668}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3713668, "end": 3750278}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3750278, "end": 3797026}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3797026, "end": 3877062}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3877062, "end": 3893777}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3893777, "end": 3952728}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3952728, "end": 4063618}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 4063618, "end": 4151801}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 4151801, "end": 4177737}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 4177737, "end": 4185187}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 4185187, "end": 4199249}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 4199249, "end": 4273783}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 4273783, "end": 4307894}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 4307894, "end": 4322618}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 4322618, "end": 4332757}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 4332757, "end": 4422861}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 4422861, "end": 4431644}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 4431644, "end": 4431886}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 4431886, "end": 4434814}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 4434814, "end": 4435440}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 4435440, "end": 4436663}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 4436663, "end": 4437326}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 4437326, "end": 4440444}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 4440444, "end": 4445039}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 4445039, "end": 4445676}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 4445676, "end": 4449976}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 4449976, "end": 4452121}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 4452121, "end": 4452340}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 4452340, "end": 4527138}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4527138, "end": 4544130}, {"filename": "/wordpress/wp-includes/Requests/Auth.php", "start": 4544130, "end": 4544214}, {"filename": "/wordpress/wp-includes/Requests/Auth/Basic.php", "start": 4544214, "end": 4545100}, {"filename": "/wordpress/wp-includes/Requests/Cookie.php", "start": 4545100, "end": 4550955}, {"filename": "/wordpress/wp-includes/Requests/Cookie/Jar.php", "start": 4550955, "end": 4552936}, {"filename": "/wordpress/wp-includes/Requests/Exception.php", "start": 4552936, "end": 4553278}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP.php", "start": 4553278, "end": 4553933}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/304.php", "start": 4553933, "end": 4554069}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/305.php", "start": 4554069, "end": 4554202}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/306.php", "start": 4554202, "end": 4554338}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/400.php", "start": 4554338, "end": 4554473}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/401.php", "start": 4554473, "end": 4554609}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/402.php", "start": 4554609, "end": 4554749}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/403.php", "start": 4554749, "end": 4554882}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/404.php", "start": 4554882, "end": 4555015}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/405.php", "start": 4555015, "end": 4555157}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/406.php", "start": 4555157, "end": 4555295}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/407.php", "start": 4555295, "end": 4555448}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/408.php", "start": 4555448, "end": 4555587}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/409.php", "start": 4555587, "end": 4555719}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/410.php", "start": 4555719, "end": 4555847}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/411.php", "start": 4555847, "end": 4555986}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/412.php", "start": 4555986, "end": 4556129}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/413.php", "start": 4556129, "end": 4556277}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/414.php", "start": 4556277, "end": 4556422}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/415.php", "start": 4556422, "end": 4556568}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/416.php", "start": 4556568, "end": 4556723}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/417.php", "start": 4556723, "end": 4556865}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/418.php", "start": 4556865, "end": 4557001}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/428.php", "start": 4557001, "end": 4557146}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/429.php", "start": 4557146, "end": 4557287}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/431.php", "start": 4557287, "end": 4557442}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/500.php", "start": 4557442, "end": 4557587}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/501.php", "start": 4557587, "end": 4557726}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/502.php", "start": 4557726, "end": 4557861}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/503.php", "start": 4557861, "end": 4558004}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/504.php", "start": 4558004, "end": 4558143}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/505.php", "start": 4558143, "end": 4558293}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/511.php", "start": 4558293, "end": 4558448}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/Unknown.php", "start": 4558448, "end": 4558758}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport.php", "start": 4558758, "end": 4558831}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport/cURL.php", "start": 4558831, "end": 4559472}, {"filename": "/wordpress/wp-includes/Requests/Hooker.php", "start": 4559472, "end": 4559624}, {"filename": "/wordpress/wp-includes/Requests/Hooks.php", "start": 4559624, "end": 4560272}, {"filename": "/wordpress/wp-includes/Requests/IDNAEncoder.php", "start": 4560272, "end": 4565533}, {"filename": "/wordpress/wp-includes/Requests/IPv6.php", "start": 4565533, "end": 4567823}, {"filename": "/wordpress/wp-includes/Requests/IRI.php", "start": 4567823, "end": 4583551}, {"filename": "/wordpress/wp-includes/Requests/Proxy.php", "start": 4583551, "end": 4583636}, {"filename": "/wordpress/wp-includes/Requests/Proxy/HTTP.php", "start": 4583636, "end": 4585274}, {"filename": "/wordpress/wp-includes/Requests/Response.php", "start": 4585274, "end": 4586179}, {"filename": "/wordpress/wp-includes/Requests/Response/Headers.php", "start": 4586179, "end": 4587053}, {"filename": "/wordpress/wp-includes/Requests/SSL.php", "start": 4587053, "end": 4588396}, {"filename": "/wordpress/wp-includes/Requests/Session.php", "start": 4588396, "end": 4591408}, {"filename": "/wordpress/wp-includes/Requests/Transport.php", "start": 4591408, "end": 4591622}, {"filename": "/wordpress/wp-includes/Requests/Transport/cURL.php", "start": 4591622, "end": 4602027}, {"filename": "/wordpress/wp-includes/Requests/Transport/fsockopen.php", "start": 4602027, "end": 4610537}, {"filename": "/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php", "start": 4610537, "end": 4611423}, {"filename": "/wordpress/wp-includes/Requests/Utility/FilteredIterator.php", "start": 4611423, "end": 4611930}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4611930, "end": 4612486}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4612486, "end": 4613612}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4613612, "end": 4613888}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4613888, "end": 4615954}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4615954, "end": 4616992}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4616992, "end": 4618360}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4618360, "end": 4619763}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4619763, "end": 4628120}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4628120, "end": 4629771}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4629771, "end": 4630661}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4630661, "end": 4631290}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4631290, "end": 4635734}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4635734, "end": 4636152}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4636152, "end": 4636201}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4636201, "end": 4636764}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4636764, "end": 4648684}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4648684, "end": 4662280}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4662280, "end": 4662334}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4662334, "end": 4668735}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4668735, "end": 4675078}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4675078, "end": 4691209}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4691209, "end": 4764206}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4764206, "end": 4773961}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4773961, "end": 4815278}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4815278, "end": 4817644}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4817644, "end": 4830778}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4830778, "end": 4853172}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4853172, "end": 4853602}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4853602, "end": 4855857}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4855857, "end": 4856474}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4856474, "end": 4868619}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4868619, "end": 4885220}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4885220, "end": 4888648}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4888648, "end": 4891716}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4891716, "end": 4897260}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4897260, "end": 4903833}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4903833, "end": 4906124}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4906124, "end": 4910123}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4910123, "end": 4910855}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4910855, "end": 4913927}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4913927, "end": 4916641}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4916641, "end": 4939642}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4939642, "end": 4950707}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4950707, "end": 4958246}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4958246, "end": 4964765}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4964765, "end": 4976143}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4976143, "end": 4976459}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4976459, "end": 4979664}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4979664, "end": 4980604}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4980604, "end": 4982552}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4982552, "end": 4983564}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4983564, "end": 4985563}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4985563, "end": 4986690}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4986690, "end": 4987462}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4987462, "end": 4988199}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4988199, "end": 4989210}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4989210, "end": 4992749}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4992749, "end": 4997116}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4997116, "end": 4998160}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4998160, "end": 4999338}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4999338, "end": 5008869}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 5008869, "end": 5010306}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 5010306, "end": 5011091}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 5011091, "end": 5017075}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 5017075, "end": 5019081}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 5019081, "end": 5025783}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 5025783, "end": 5044287}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 5044287, "end": 5049388}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 5049388, "end": 5071463}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 5071463, "end": 5073584}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 5073584, "end": 5074020}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 5074020, "end": 5074060}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 5074060, "end": 5074108}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 5074108, "end": 5075051}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 5075051, "end": 5075096}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 5075096, "end": 5075237}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 5075237, "end": 5075376}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 5075376, "end": 5076331}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 5076331, "end": 5076763}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 5076763, "end": 5077125}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 5077125, "end": 5078951}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 5078951, "end": 5080128}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 5080128, "end": 5082220}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 5082220, "end": 5082905}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 5082905, "end": 5083911}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 5083911, "end": 5084986}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 5084986, "end": 5087641}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 5087641, "end": 5088014}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 5088014, "end": 5088423}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 5088423, "end": 5090389}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 5090389, "end": 5090996}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 5090996, "end": 5091081}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 5091081, "end": 5091177}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 5091177, "end": 5092123}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 5092123, "end": 5092203}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 5092203, "end": 5092338}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 5092338, "end": 5093025}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 5093025, "end": 5093722}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 5093722, "end": 5094175}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 5094175, "end": 5096175}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 5096175, "end": 5097819}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 5097819, "end": 5099300}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 5099300, "end": 5111876}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 5111876, "end": 5112625}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 5112625, "end": 5113570}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 5113570, "end": 5115173}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 5115173, "end": 5115312}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 5115312, "end": 5115790}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 5115790, "end": 5117024}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 5117024, "end": 5117658}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 5117658, "end": 5118315}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 5118315, "end": 5118410}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 5118410, "end": 5118505}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 5118505, "end": 5119980}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 5119980, "end": 5120362}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 5120362, "end": 5129416}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 5129416, "end": 5130245}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 5130245, "end": 5132337}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 5132337, "end": 5136051}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 5136051, "end": 5150398}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 5150398, "end": 5150531}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 5150531, "end": 5151422}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 5151422, "end": 5151691}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 5151691, "end": 5151729}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 5151729, "end": 5151791}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 5151791, "end": 5153096}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 5153096, "end": 5153270}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 5153270, "end": 5153688}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 5153688, "end": 5154423}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 5154423, "end": 5154968}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 5154968, "end": 5156803}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 5156803, "end": 5159466}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 5159466, "end": 5161040}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 5161040, "end": 5161179}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 5161179, "end": 5164054}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 5164054, "end": 5167311}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 5167311, "end": 5168005}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 5168005, "end": 5168924}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 5168924, "end": 5174188}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 5174188, "end": 5175832}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 5175832, "end": 5176045}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 5176045, "end": 5177897}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 5177897, "end": 5181231}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 5181231, "end": 5181732}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 5181732, "end": 5183067}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 5183067, "end": 5183157}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 5183157, "end": 5184054}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 5184054, "end": 5184509}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 5184509, "end": 5186330}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 5186330, "end": 5186888}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 5186888, "end": 5189117}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 5189117, "end": 5189626}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 5189626, "end": 5190135}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 5190135, "end": 5190866}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 5190866, "end": 5198961}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 5198961, "end": 5200103}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 5200103, "end": 5202081}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 5202081, "end": 5202178}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 5202178, "end": 5209540}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 5209540, "end": 5210653}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 5210653, "end": 5211757}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 5211757, "end": 5227028}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 5227028, "end": 5229465}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 5229465, "end": 5239195}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 5239195, "end": 5252769}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5252769, "end": 5252864}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5252864, "end": 5252959}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5252959, "end": 5262224}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5262224, "end": 5262624}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5262624, "end": 5263216}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5263216, "end": 5273084}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5273084, "end": 5273754}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5273754, "end": 5275016}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5275016, "end": 5275378}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5275378, "end": 5276481}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5276481, "end": 5276811}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5276811, "end": 5277274}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5277274, "end": 5277832}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5277832, "end": 5278101}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5278101, "end": 5279791}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5279791, "end": 5280861}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5280861, "end": 5281197}, {"filename": "/wordpress/wp-includes/blocks/post-comments.php", "start": 5281197, "end": 5282722}, {"filename": "/wordpress/wp-includes/blocks/post-comments/block.json", "start": 5282722, "end": 5283491}, {"filename": "/wordpress/wp-includes/blocks/post-comments/style.min.css", "start": 5283491, "end": 5285268}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5285268, "end": 5286449}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5286449, "end": 5286833}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5286833, "end": 5287847}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5287847, "end": 5288639}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5288639, "end": 5290144}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5290144, "end": 5291057}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5291057, "end": 5291143}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5291143, "end": 5291198}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5291198, "end": 5292661}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5292661, "end": 5293466}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5293466, "end": 5297186}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5297186, "end": 5297491}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5297491, "end": 5299534}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5299534, "end": 5300399}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5300399, "end": 5302433}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5302433, "end": 5303044}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5303044, "end": 5303138}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5303138, "end": 5304487}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5304487, "end": 5305613}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5305613, "end": 5306376}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5306376, "end": 5306429}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5306429, "end": 5307534}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5307534, "end": 5308680}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5308680, "end": 5308724}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5308724, "end": 5309530}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5309530, "end": 5309635}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5309635, "end": 5310831}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5310831, "end": 5311336}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5311336, "end": 5312606}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5312606, "end": 5312873}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5312873, "end": 5314791}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5314791, "end": 5315531}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5315531, "end": 5317402}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5317402, "end": 5317793}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5317793, "end": 5317997}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5317997, "end": 5319483}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5319483, "end": 5320235}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5320235, "end": 5320698}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5320698, "end": 5321499}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5321499, "end": 5322268}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5322268, "end": 5323212}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5323212, "end": 5324115}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5324115, "end": 5325002}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5325002, "end": 5325158}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5325158, "end": 5326232}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5326232, "end": 5326373}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5326373, "end": 5327626}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5327626, "end": 5328036}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5328036, "end": 5328504}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5328504, "end": 5331217}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5331217, "end": 5332067}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5332067, "end": 5332503}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5332503, "end": 5333202}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5333202, "end": 5342624}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5342624, "end": 5343721}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5343721, "end": 5343978}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5343978, "end": 5345251}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5345251, "end": 5345308}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5345308, "end": 5345989}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5345989, "end": 5346086}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5346086, "end": 5346489}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5346489, "end": 5346834}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5346834, "end": 5347158}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5347158, "end": 5347568}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5347568, "end": 5348592}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5348592, "end": 5352418}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5352418, "end": 5353574}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5353574, "end": 5356278}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5356278, "end": 5356630}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5356630, "end": 5357286}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5357286, "end": 5358232}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5358232, "end": 5358300}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5358300, "end": 5359506}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5359506, "end": 5360749}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5360749, "end": 5360815}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5360815, "end": 5418061}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5418061, "end": 5418629}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5418629, "end": 5418992}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5418992, "end": 5420544}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5420544, "end": 5422470}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5422470, "end": 5431891}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5431891, "end": 5432343}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5432343, "end": 5433167}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5433167, "end": 5433195}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5433195, "end": 5436363}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5436363, "end": 5438122}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5438122, "end": 5440389}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5440389, "end": 5440703}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5440703, "end": 5441576}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5441576, "end": 5442099}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5442099, "end": 5442357}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5442357, "end": 5446776}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5446776, "end": 5447318}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5447318, "end": 5449562}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5449562, "end": 5449653}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5449653, "end": 5450420}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5450420, "end": 5451008}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5451008, "end": 5451683}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5451683, "end": 5451769}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5451769, "end": 5452221}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5452221, "end": 5453240}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5453240, "end": 5453314}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5453314, "end": 5454872}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5454872, "end": 5457193}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5457193, "end": 5457455}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5457455, "end": 5457594}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5457594, "end": 5458970}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5458970, "end": 5459289}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5459289, "end": 5464775}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5464775, "end": 5473175}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5473175, "end": 5473437}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5473437, "end": 5475403}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5475403, "end": 5498613}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5498613, "end": 5515563}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5515563, "end": 5536164}, {"filename": "/wordpress/wp-includes/category.php", "start": 5536164, "end": 5540635}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5540635, "end": 5773866}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5773866, "end": 5774492}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5774492, "end": 5774932}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5774932, "end": 5775079}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5775079, "end": 5789078}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5789078, "end": 5789229}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5789229, "end": 5792975}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5792975, "end": 5793491}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5793491, "end": 5804068}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5804068, "end": 5818639}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5818639, "end": 5874839}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5874839, "end": 5875159}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5875159, "end": 5896598}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5896598, "end": 5897554}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5897554, "end": 5901178}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5901178, "end": 5908990}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5908990, "end": 5912303}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5912303, "end": 5913169}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5913169, "end": 5916556}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5916556, "end": 5927569}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5927569, "end": 5929896}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5929896, "end": 5935763}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5935763, "end": 5935963}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5935963, "end": 5937317}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5937317, "end": 5943523}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5943523, "end": 5945207}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5945207, "end": 5947171}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5947171, "end": 5949318}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5949318, "end": 5952528}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5952528, "end": 5952859}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5952859, "end": 5954861}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5954861, "end": 5957054}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5957054, "end": 5960907}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5960907, "end": 5982447}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5982447, "end": 5985445}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5985445, "end": 5998538}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5998538, "end": 6122808}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 6122808, "end": 6161683}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 6161683, "end": 6165658}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 6165658, "end": 6169942}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 6169942, "end": 6182472}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 6182472, "end": 6223519}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6223519, "end": 6238672}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6238672, "end": 6239377}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6239377, "end": 6281708}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6281708, "end": 6289284}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6289284, "end": 6292083}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6292083, "end": 6294973}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6294973, "end": 6295898}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6295898, "end": 6296283}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6296283, "end": 6302390}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6302390, "end": 6305228}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6305228, "end": 6312845}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6312845, "end": 6315463}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6315463, "end": 6317869}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6317869, "end": 6319806}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6319806, "end": 6320369}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6320369, "end": 6322424}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6322424, "end": 6323304}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6323304, "end": 6334179}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6334179, "end": 6350772}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6350772, "end": 6359947}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6359947, "end": 6374525}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6374525, "end": 6380961}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6380961, "end": 6383985}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6383985, "end": 6385960}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6385960, "end": 6391261}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6391261, "end": 6391999}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6391999, "end": 6405095}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6405095, "end": 6406961}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6406961, "end": 6415886}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6415886, "end": 6421012}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6421012, "end": 6426084}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6426084, "end": 6429803}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6429803, "end": 6443577}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6443577, "end": 6446107}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6446107, "end": 6454651}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6454651, "end": 6457607}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6457607, "end": 6530349}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6530349, "end": 6533880}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6533880, "end": 6539676}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6539676, "end": 6541735}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6541735, "end": 6543310}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6543310, "end": 6549411}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6549411, "end": 6574192}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6574192, "end": 6574850}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6574850, "end": 6578374}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6578374, "end": 6580882}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6580882, "end": 6582172}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6582172, "end": 6583027}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6583027, "end": 6596971}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6596971, "end": 6599658}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6599658, "end": 6608838}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6608838, "end": 6614745}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6614745, "end": 6631908}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6631908, "end": 6634112}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6634112, "end": 6634449}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6634449, "end": 6642473}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6642473, "end": 6649507}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6649507, "end": 6651336}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6651336, "end": 6684741}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6684741, "end": 6711924}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6711924, "end": 6713386}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6713386, "end": 6730883}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6730883, "end": 6731889}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6731889, "end": 6740788}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6740788, "end": 6746390}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6746390, "end": 6747789}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6747789, "end": 6755166}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6755166, "end": 6882430}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6882430, "end": 6896406}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6896406, "end": 6901801}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6901801, "end": 6910737}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6910737, "end": 6915875}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6915875, "end": 6953482}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6953482, "end": 7013689}, {"filename": "/wordpress/wp-includes/compat.php", "start": 7013689, "end": 7019244}, {"filename": "/wordpress/wp-includes/cron.php", "start": 7019244, "end": 7032962}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 7032962, "end": 7033600}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 7033600, "end": 7033812}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 7033812, "end": 7036051}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 7036051, "end": 7037292}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 7037292, "end": 7039019}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 7039019, "end": 7039588}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 7039588, "end": 7041765}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 7041765, "end": 7048236}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 7048236, "end": 7048346}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 7048346, "end": 7054963}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 7054963, "end": 7055896}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 7055896, "end": 7056360}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 7056360, "end": 7063080}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 7063080, "end": 7063691}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 7063691, "end": 7065076}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 7065076, "end": 7070328}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 7070328, "end": 7086723}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 7086723, "end": 7088268}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 7088268, "end": 7090245}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 7090245, "end": 7090873}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 7090873, "end": 7091137}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 7091137, "end": 7100727}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 7100727, "end": 7102755}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7102755, "end": 7103339}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7103339, "end": 7104075}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7104075, "end": 7106761}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7106761, "end": 7112242}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7112242, "end": 7112580}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7112580, "end": 7114888}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7114888, "end": 7123705}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7123705, "end": 7125909}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7125909, "end": 7130558}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7130558, "end": 7131036}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7131036, "end": 7131190}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7131190, "end": 7132290}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7132290, "end": 7133538}, {"filename": "/wordpress/wp-includes/date.php", "start": 7133538, "end": 7133697}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7133697, "end": 7139321}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7139321, "end": 7167359}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7167359, "end": 7168810}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7168810, "end": 7224887}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7224887, "end": 7225036}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7225036, "end": 7243103}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7243103, "end": 7244989}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7244989, "end": 7248914}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7248914, "end": 7251432}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7251432, "end": 7253560}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7253560, "end": 7254491}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7254491, "end": 7257314}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7257314, "end": 7260039}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7260039, "end": 7269625}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7269625, "end": 7476307}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7476307, "end": 7589846}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7589846, "end": 7594386}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7594386, "end": 7596425}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7596425, "end": 7668123}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7668123, "end": 7671094}, {"filename": "/wordpress/wp-includes/http.php", "start": 7671094, "end": 7679414}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7679414, "end": 7682476}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7682476, "end": 7684153}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7684153, "end": 7684898}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7684898, "end": 7686750}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7686750, "end": 7719706}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7719706, "end": 7741282}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7741282, "end": 7801838}, {"filename": "/wordpress/wp-includes/load.php", "start": 7801838, "end": 7825051}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7825051, "end": 7825109}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7825109, "end": 7881085}, {"filename": "/wordpress/wp-includes/media.php", "start": 7881085, "end": 7967297}, {"filename": "/wordpress/wp-includes/meta.php", "start": 7967297, "end": 7989734}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 7989734, "end": 8003085}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 8003085, "end": 8006057}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 8006057, "end": 8011692}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 8011692, "end": 8022939}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 8022939, "end": 8025098}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 8025098, "end": 8069248}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 8069248, "end": 8077950}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 8077950, "end": 8079356}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 8079356, "end": 8081325}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 8081325, "end": 8098994}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8098994, "end": 8112572}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8112572, "end": 8137183}, {"filename": "/wordpress/wp-includes/option.php", "start": 8137183, "end": 8170187}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8170187, "end": 8170374}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8170374, "end": 8172856}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8172856, "end": 8220125}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8220125, "end": 8228501}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8228501, "end": 8230046}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8230046, "end": 8236280}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8236280, "end": 8240508}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8240508, "end": 8250216}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8250216, "end": 8254643}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8254643, "end": 8260303}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8260303, "end": 8264250}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8264250, "end": 8294007}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8294007, "end": 8297010}, {"filename": "/wordpress/wp-includes/post.php", "start": 8297010, "end": 8418458}, {"filename": "/wordpress/wp-includes/query.php", "start": 8418458, "end": 8431204}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8431204, "end": 8433188}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8433188, "end": 8433649}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8433649, "end": 8433899}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8433899, "end": 8436596}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8436596, "end": 8437282}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8437282, "end": 8438463}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8438463, "end": 8439137}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8439137, "end": 8439825}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8439825, "end": 8440315}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8440315, "end": 8441449}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8441449, "end": 8441562}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8441562, "end": 8441675}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8441675, "end": 8496404}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8496404, "end": 8507479}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8507479, "end": 8509940}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8509940, "end": 8534610}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8534610, "end": 8549478}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8549478, "end": 8578330}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8578330, "end": 8586215}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8586215, "end": 8592381}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8592381, "end": 8595908}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8595908, "end": 8610074}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8610074, "end": 8610946}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8610946, "end": 8649700}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8649700, "end": 8658520}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8658520, "end": 8659682}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8659682, "end": 8670389}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8670389, "end": 8693272}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8693272, "end": 8698367}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8698367, "end": 8709185}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8709185, "end": 8715197}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8715197, "end": 8734235}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8734235, "end": 8740798}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8740798, "end": 8748727}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8748727, "end": 8812138}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8812138, "end": 8828477}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8828477, "end": 8835359}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8835359, "end": 8840106}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8840106, "end": 8849745}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8849745, "end": 8855653}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8855653, "end": 8864514}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8864514, "end": 8883523}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8883523, "end": 8904381}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8904381, "end": 8917024}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8917024, "end": 8925280}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8925280, "end": 8956515}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 8956515, "end": 8967820}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 8967820, "end": 8983893}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 8983893, "end": 8984143}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 8984143, "end": 8994592}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 8994592, "end": 8994949}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 8994949, "end": 8995341}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 8995341, "end": 8995579}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 8995579, "end": 8997519}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 8997519, "end": 9000291}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 9000291, "end": 9000739}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 9000739, "end": 9002952}, {"filename": "/wordpress/wp-includes/revision.php", "start": 9002952, "end": 9014344}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 9014344, "end": 9022107}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 9022107, "end": 9023423}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 9023423, "end": 9023586}, {"filename": "/wordpress/wp-includes/rss.php", "start": 9023586, "end": 9038027}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 9038027, "end": 9117812}, {"filename": "/wordpress/wp-includes/session.php", "start": 9117812, "end": 9118006}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9118006, "end": 9125906}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9125906, "end": 9127106}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9127106, "end": 9127883}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9127883, "end": 9129546}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9129546, "end": 9130142}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9130142, "end": 9133698}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9133698, "end": 9140643}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9140643, "end": 9143886}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9143886, "end": 9146346}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9146346, "end": 9148541}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9148541, "end": 9150030}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9150030, "end": 9150890}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9150890, "end": 9151309}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9151309, "end": 9152890}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9152890, "end": 9154498}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9154498, "end": 9158656}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9158656, "end": 9159207}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9159207, "end": 9180950}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9180950, "end": 9185546}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9185546, "end": 9189709}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9189709, "end": 9200927}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9200927, "end": 9201542}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9201542, "end": 9201626}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9201626, "end": 9201722}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9201722, "end": 9201820}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9201820, "end": 9201926}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9201926, "end": 9202040}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9202040, "end": 9202142}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9202142, "end": 9202250}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9202250, "end": 9202372}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9202372, "end": 9202490}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9202490, "end": 9202604}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9202604, "end": 9202718}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9202718, "end": 9202842}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9202842, "end": 9202948}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9202948, "end": 9203044}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9203044, "end": 9203144}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9203144, "end": 9203242}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9203242, "end": 9203340}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9203340, "end": 9203450}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9203450, "end": 9203546}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9203546, "end": 9203642}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9203642, "end": 9203732}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9203732, "end": 9203826}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9203826, "end": 9203926}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9203926, "end": 9204024}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9204024, "end": 9204108}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9204108, "end": 9204188}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9204188, "end": 9285263}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9285263, "end": 9295930}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9295930, "end": 9298890}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9298890, "end": 9302325}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9302325, "end": 9305760}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9305760, "end": 9310960}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9310960, "end": 9312996}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9312996, "end": 9313702}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9313702, "end": 9392352}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9392352, "end": 9393635}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9393635, "end": 9394458}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9394458, "end": 9395199}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9395199, "end": 9395794}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9395794, "end": 9396531}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9396531, "end": 9397220}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9397220, "end": 9486260}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9486260, "end": 9494924}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9494924, "end": 9497490}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9497490, "end": 9499954}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9499954, "end": 9500729}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9500729, "end": 9507575}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9507575, "end": 9520103}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9520103, "end": 9524977}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9524977, "end": 9527082}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9527082, "end": 9530393}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9530393, "end": 9542505}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9542505, "end": 9547220}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9547220, "end": 9548817}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9548817, "end": 9549299}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9549299, "end": 9558680}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9558680, "end": 9564184}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9564184, "end": 9566949}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9566949, "end": 9567803}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9567803, "end": 9650777}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9650777, "end": 9653340}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9653340, "end": 9654183}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9654183, "end": 9654940}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9654940, "end": 9655551}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9655551, "end": 9656308}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9656308, "end": 9657010}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9657010, "end": 9745361}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9745361, "end": 9753019}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9753019, "end": 9756095}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9756095, "end": 9760103}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9760103, "end": 9773514}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9773514, "end": 9791088}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9791088, "end": 9791873}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9791873, "end": 9800502}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9800502, "end": 9807095}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9807095, "end": 9809228}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9809228, "end": 9811997}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9811997, "end": 9812156}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9812156, "end": 9818154}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9818154, "end": 9819014}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9819014, "end": 9819502}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9819502, "end": 9844049}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9844049, "end": 9868905}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9868905, "end": 9898313}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9898313, "end": 9899969}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9899969, "end": 9900069}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9900069, "end": 9900179}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9900179, "end": 9972627}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 9972627, "end": 9972953}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 9972953, "end": 9974678}, {"filename": "/wordpress/wp-includes/template.php", "start": 9974678, "end": 9981520}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 9981520, "end": 9983148}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 9983148, "end": 9983670}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 9983670, "end": 9985660}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 9985660, "end": 9985874}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 9985874, "end": 9985929}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 9985929, "end": 9986605}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 9986605, "end": 9986935}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 9986935, "end": 9988494}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 9988494, "end": 9991619}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 9991619, "end": 9992544}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 9992544, "end": 9996249}, {"filename": "/wordpress/wp-includes/theme.json", "start": 9996249, "end": 10001985}, {"filename": "/wordpress/wp-includes/theme.php", "start": 10001985, "end": 10070577}, {"filename": "/wordpress/wp-includes/update.php", "start": 10070577, "end": 10089328}, {"filename": "/wordpress/wp-includes/user.php", "start": 10089328, "end": 10159071}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10159071, "end": 10163032}, {"filename": "/wordpress/wp-includes/version.php", "start": 10163032, "end": 10163190}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10163190, "end": 10195934}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10195934, "end": 10199796}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10199796, "end": 10204035}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10204035, "end": 10207240}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10207240, "end": 10208726}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10208726, "end": 10213257}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10213257, "end": 10220399}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10220399, "end": 10225836}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10225836, "end": 10230064}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10230064, "end": 10235204}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10235204, "end": 10244047}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10244047, "end": 10250136}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10250136, "end": 10257681}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10257681, "end": 10259879}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10259879, "end": 10263456}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10263456, "end": 10267566}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10267566, "end": 10271450}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10271450, "end": 10274628}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10274628, "end": 10276020}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10276020, "end": 10280269}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10280269, "end": 10292671}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10292671, "end": 10293716}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10293716, "end": 10343385}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10343385, "end": 10343734}, {"filename": "/wordpress/wp-links-opml.php", "start": 10343734, "end": 10345346}, {"filename": "/wordpress/wp-load.php", "start": 10345346, "end": 10347074}, {"filename": "/wordpress/wp-login.php", "start": 10347074, "end": 10380566}, {"filename": "/wordpress/wp-mail.php", "start": 10380566, "end": 10386522}, {"filename": "/wordpress/wp-settings.php", "start": 10386522, "end": 10402311}, {"filename": "/wordpress/wp-signup.php", "start": 10402311, "end": 10422901}, {"filename": "/wordpress/wp-trackback.php", "start": 10422901, "end": 10426259}, {"filename": "/wordpress/xmlrpc.php", "start": 10426259, "end": 10428080}], "remote_package_size": 10428080}); })(); // See esm-prefix.js diff --git a/build/wp-6.0.data b/build/wp-6.0.data old mode 100755 new mode 100644 index a2ce2a5b5f..00999e01cd --- a/build/wp-6.0.data +++ b/build/wp-6.0.data @@ -13248,10 +13248,10 @@ if ( current_user_can( 'customize' ) ) { printf( ' get_error_data(); if ( ! empty( $data ) ) { wp_die( '

' . $comment->get_error_message() . '

', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true, ) ); } else { exit; } } $user = wp_get_current_user(); $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) ); do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { $location = add_query_arg( array( 'unapproved' => $comment->comment_ID, 'moderation-hash' => wp_hash( $comment->comment_date_gmt ), ), $location ); } $location = apply_filters( 'comment_post_redirect', $location, $comment ); wp_safe_redirect( $location ); exit; Gravatar
.1comment �0��.d-U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-03 17:19:162023-01-03 17:19:16

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a/� 33�M#  # 33 M 2023-01-03 17:19:162023-01-03 17:19:16 +Commenter avatars come from Gravatar.1comment �1����0u.d-U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-30 20:05:132023-01-30 20:05:13

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a/� 33�M#  # 33 M 2023-01-30 20:05:132023-01-30 20:05:13

This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

@@ -13269,9 +13269,9 @@ Commenter avatars come from Gravatar.1com

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!

-Sample Pagepublishclosedopensample-page2023-01-03 17:19:162023-01-03 17:19:16http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-03 17:19:162023-01-03 17:19:16 +Sample Pagepublishclosedopensample-page2023-01-30 20:05:132023-01-30 20:05:13http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-30 20:05:132023-01-30 20:05:13

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

-Hello world!publishopenopenhello-world2023-01-03 17:19:162023-01-03 17:19:16http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( +Hello world!publishopenopenhello-world2023-01-30 20:05:132023-01-30 20:05:13http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( option_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , option_name text NOT NULL default '', option_value text NOT NULL, @@ -13348,7 +13348,7 @@ CREATE TABLE wp_comments ( user_activation_key text NOT NULL default '', user_status integer NOT NULL default '0', display_name text NOT NULL default '' -) �x ��]�j�z=�.�W�� �A�x�U �h � � PS!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)Y#)uindexmeta_key_30wp_commentmetaCREATE INDEX meta_key_30 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)S##oindexmeta_key_39wp_termmetaCREATE INDEX meta_key_39 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( +) �x ��]�j�z=�.�W�� �A�x�U �h � � PS!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)Y#)uindexmeta_key_34wp_commentmetaCREATE INDEX meta_key_34 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)S##oindexmeta_key_13wp_termmetaCREATE INDEX meta_key_13 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , post_author integer NOT NULL default '0', post_date text NOT NULL default '0000-00-00 00:00:00', @@ -13377,7 +13377,7 @@ CREATE TABLE wp_comments ( post_id integer NOT NULL default '0', meta_key text default NULL, meta_value text -)�P)#oindexpost_authorwp_posts,CREATE INDEX post_author ON wp_posts(post_author)P(#oindexpost_parentwp_posts+CREATE INDEX post_parent ON wp_posts(post_parent)r'-�'indextype_status_datewp_posts*CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J&gindexpost_namewp_posts)CREATE INDEX post_name ON wp_posts(post_name)S%##oindexmeta_key_24wp_postmeta(CREATE INDEX meta_key_24 ON wp_postmeta(meta_key)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) +)�P)#oindexpost_authorwp_posts,CREATE INDEX post_author ON wp_posts(post_author)P(#oindexpost_parentwp_posts+CREATE INDEX post_parent ON wp_posts(post_parent)r'-�'indextype_status_datewp_posts*CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J&gindexpost_namewp_posts)CREATE INDEX post_name ON wp_posts(post_name)S%##oindexmeta_key_16wp_postmeta(CREATE INDEX meta_key_16 ON wp_postmeta(meta_key)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) �� admin �� admin ��3 admin@localhost.com @@ -13396,37 +13396,38 @@ CREATE TABLE wp_comments (   �� -��3 12023-01-03 17:19:16 -��3 2023-01-03 17:19:16 +��3 12023-01-30 20:05:13 +��3 2023-01-30 20:05:13 �� ��; wapuu@wordpress.example  -h� }��hO4 m � � Q�� k +|���2�R }��hO4 m � � Q�� k � � F A� �C -mH ��� +m�H ��� S  7�k � �� W� 7 �� � / � K \ {��� -  1 � � � � +  1 � � � ��� � � � � \X1 W � � %� I�� 0 �  � � -� � � �8 � � a � q~n ���� - � +� � � �8 � � a � q~n ���I�] +l2���q ��� -���-sidebars_widgetsh%widget_blockg!user_countf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email +����!G_site_transient_update_themes~C_site_transient_theme_roots}'S_site_transient_timeout_theme_roots|#C_site_transient_update_corez7_transient_doing_cronx1widget_custom_htmlw+widget_nav_menuv-widget_tag_cloudu!nonce_saltt nonce_keys'widget_searchr#widget_metaq1widget_media_videop5widget_media_galleryo1widget_media_imagen1widget_media_audiom+widget_archivesl+widget_calendark%widget_pagesjcroni-sidebars_widgetsh%widget_blockg!user_countf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email #use_smilies +use_balanceTags'start_of_week#admin_email1users_can_register+blogdescription blognamehome  siteurl -h �� � %  �����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � �yeshyesgnofyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes + ;| &� � %  � p i B 4 - &����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � � � � � � � � � �  w a Y Q I Ino~no}no|nozyesxyeswyesvyesunotnosyesryesqyespyesoyesnyesmyeslyeskyesjyesiyeshyesgnofyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes yes yesyesyesyesyesyesyes yes ���  ���/_wp_page_template/ _wp_page_template ����)privacy-policy#sample-page# hello-world -����$3pagedraft2023-01-03 17:19:16&3pagepublish2023-01-03 17:19:16$3 postpublish2023-01-03 17:19:16 +����$3pagedraft2023-01-30 20:05:13&3pagepublish2023-01-30 20:05:13$3 postpublish2023-01-30 20:05:13 ���� -����   mU-���]@�����f> � � � � v V < !  � � � � kY>&����qY8�����aL6������fM3�����hA����pT3�����vW-���v^8 -���kJJI3ipermalink_structure/index.php/%year%/%monthnum%/%day%/%postname%/yesJ1(UKfinished_splitting_shared_terms1yesT5link_manager_enabled0yesS3default_post_format0yesR'page_on_front0yesQ)page_for_posts0yesP+ timezone_stringyesO/uninstall_pluginsa:0:{}noN!widget_rssa:0:{}yesM#widget_texta:0:{}yesL/widget_categoriesa:0:{}yesK%sticky_postsa:0:{}yesJ'comment_orderascyes#I7default_comments_pagenewestyesH/comments_per_page50yesG'page_comments0yesF7thread_comments_depth5yesE+thread_comments1yes!D;close_comments_days_old14yes%CEclose_comments_for_old_posts0yesB3 image_default_alignyesA1 image_default_sizeyes#@;image_default_link_typenoneyes?%large_size_h1024yes>%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version53496yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes!)!+stylesheettwentytwentytwoyes(+templatetwentytwentytwoyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyes!)active_pluginsa:0:{}yes + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes -1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes2+CblogdescriptionJust another WordPress siteyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version53496yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1688318356yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-03 17:19:162023-01-03 17:19:16http://127.0.0.1:8000/?page_id=3page  c w c n �f!user_count1noe!fresh_site1yes�_h-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�g%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes1DENY FROM ALL � � � � v V < !  � � � � kY>& ����qY8�����aL6������fM3�����hA����pT3�����vW-���v^8 +���kJJI3ipermalink_structure/index.php/%year%/%monthnum%/%day%/%postname%/yesJ1(UKfinished_splitting_shared_terms1yesT5link_manager_enabled0yesS3default_post_format0yesR'page_on_front0yesQ)page_for_posts0yesP+ timezone_stringyesO/uninstall_pluginsa:0:{}noN!widget_rssa:0:{}yesM#widget_texta:0:{}yesL/widget_categoriesa:0:{}yesK%sticky_postsa:0:{}yesJ'comment_orderascyes#I7default_comments_pagenewestyesH/comments_per_page50yesG'page_comments0yesF7thread_comments_depth5yesE+thread_comments1yes!D;close_comments_days_old14yes%CEclose_comments_for_old_posts0yesB3 image_default_alignyesA1 image_default_sizeyes#@;image_default_link_typenoneyes?%large_size_h1024yes>%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version53496yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes!)!+stylesheettwentytwentytwoyes(+templatetwentytwentytwoyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyesm + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�R!)�active_pluginsa:1:{i:0;s:41:"wordpress-importer/wordpress-importer.php";}yes' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes +1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes2+CblogdescriptionJust another WordPress siteyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version53496yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1690661113yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-30 20:05:132023-01-30 20:05:13http://127.0.0.1:8000/?page_id=3page � w c n � � l 5���K��<�� # +��i�ucrona:3:{i:1675109124;a:6:{s:32:"recovery_mode_clean_expired_keys";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}s:18:"wp_https_detection";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:34:"wp_privacy_delete_old_export_files";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"hourly";s:4:"args";a:0:{}s:8:"interval";i:3600;}}s:16:"wp_version_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:17:"wp_update_plugins";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:16:"wp_update_themes";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}}i:1675195524;a:1:{s:30:"wp_site_health_scheduled_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"weekly";s:4:"args";a:0:{}s:8:"interval";i:604800;}}}s:7:"version";i:2;}yes �q6u-Iwidget_tag_clouda:1:{s:12:"_multiwidget";i:1;}yesRt!� nonce_salt(_NEj`9Br@~~pl^<1a?m#4rMZ8RwuQX NdsW&]i:Y&|_ZbuIv,2cm YQZ&WB~Kz]noQs� nonce_keya9tG7W{%#MIWM@j*w4S[3/(@UpA;V0C7sv:NhdQdETU7+Au[lcH+@XjNJCzTKhlMno3r'Iwidget_searcha:1:{s:12:"_multiwidget";i:1;}yes1q#Iwidget_metaa:1:{s:12:"_multiwidget";i:1;}yes8p1Iwidget_media_videoa:1:{s:12:"_multiwidget";i:1;}yes:o5Iwidget_media_gallerya:1:{s:12:"_multiwidget";i:1;}yes8n1Iwidget_media_imagea:1:{s:12:"_multiwidget";i:1;}yes8m1Iwidget_media_audioa:1:{s:12:"_multiwidget";i:1;}yes5l+Iwidget_archivesa:1:{s:12:"_multiwidget";i:1;}yes5k+Iwidget_calendara:1:{s:12:"_multiwidget";i:1;}yes2j%Iwidget_pagesa:1:{s:12:"_multiwidget";i:1;}yes�f!user_count1noe!fresh_site1yes�_h-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�g%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes ���w(A���y~G�5_site_transient_update_themesO:8:"stdClass":5:{s:12:"last_checked";i:1675109128;s:7:"checked";a:1:{s:15:"twentytwentytwo";s:3:"1.2";}s:8:"response";a:1:{s:15:"twentytwentytwo";a:6:{s:5:"theme";s:15:"twentytwentytwo";s:11:"new_version";s:3:"1.3";s:3:"url";s:45:"https://wordpress.org/themes/twentytwentytwo/";s:7:"package";s:61:"https://downloads.wordpress.org/theme/twentytwentytwo.1.3.zip";s:8:"requires";s:3:"5.9";s:12:"requires_php";s:3:"5.6";}}s:9:"no_update";a:0:{}s:12:"translations";a:0:{}}noM}Cc_site_transient_theme_rootsa:1:{s:15:"twentytwentytwo";s:7:"/themes";}no4|S!_site_transient_timeout_theme_roots1675110927no>x7O_transient_doing_cron1675109124.7911980152130126953125yes8w1Iwidget_custom_htmla:1:{s:12:"_multiwidget";i:1;}yes5v+Iwidget_nav_menua:1:{s:12:"_multiwidget";i:1;}yes�UzC�q_site_transient_update_coreO:8:"stdClass":4:{s:7:"updates";a:3:{i:0;O:8:"stdClass":10:{s:8:"response";s:7:"upgrade";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.1.1-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.1.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.1.1";s:7:"version";s:5:"6.1.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";}i:1;O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.1.1-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.1.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.1.1";s:7:"version";s:5:"6.1.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";s:9:"new_files";s:1:"1";}i:2;O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:57:"https://downloads.wordpress.org/release/wordpress-6.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:57:"https://downloads.wordpress.org/release/wordpress-6.1.zip";s:10:"no_content";s:68:"https://downloads.wordpress.org/release/wordpress-6.1-no-content.zip";s:11:"new_bundled";s:69:"https://downloads.wordpress.org/release/wordpress-6.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:3:"6.1";s:7:"version";s:3:"6.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";s:9:"new_files";s:1:"1";}}s:12:"last_checked";i:1675109127;s:15:"version_checked";s:5:"6.0.3";s:12:"translations";a:0:{}}noDENY FROM ALL @@ -14097,6 +14098,2670 @@ Dolly'll never go away again"; $lyrics = explode( "\n", $lyrics ); return wptext } "; } add_action( 'admin_head', 'dolly_css' ); header(); + + $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step']; + switch ( $step ) { + case 0: + $this->greet(); + break; + case 1: + check_admin_referer( 'import-upload' ); + if ( $this->handle_upload() ) { + $this->import_options(); + } + break; + case 2: + check_admin_referer( 'import-wordpress' ); + $this->fetch_attachments = ( ! empty( $_POST['fetch_attachments'] ) && $this->allow_fetch_attachments() ); + $this->id = (int) $_POST['import_id']; + $file = get_attached_file( $this->id ); + set_time_limit( 0 ); + $this->import( $file ); + break; + } + + $this->footer(); + } + + /** + * The main controller for the actual import stage. + * + * @param string $file Path to the WXR file for importing + */ + function import( $file ) { + add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) ); + add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) ); + + $this->import_start( $file ); + + $this->get_author_mapping(); + + wp_suspend_cache_invalidation( true ); + $this->process_categories(); + $this->process_tags(); + $this->process_terms(); + $this->process_posts(); + wp_suspend_cache_invalidation( false ); + + // update incorrect/missing information in the DB + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->remap_featured_images(); + + $this->import_end(); + } + + /** + * Parses the WXR file and prepares us for the task of processing parsed data + * + * @param string $file Path to the WXR file for importing + */ + function import_start( $file ) { + if ( ! is_file( $file ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo __( 'The file does not exist, please try again.', 'wordpress-importer' ) . '

'; + $this->footer(); + die(); + } + + $import_data = $this->parse( $file ); + + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + $this->footer(); + die(); + } + + $this->version = $import_data['version']; + $this->get_authors_from_import( $import_data ); + $this->posts = $import_data['posts']; + $this->terms = $import_data['terms']; + $this->categories = $import_data['categories']; + $this->tags = $import_data['tags']; + $this->base_url = esc_url( $import_data['base_url'] ); + + wp_defer_term_counting( true ); + wp_defer_comment_counting( true ); + + do_action( 'import_start' ); + } + + /** + * Performs post-import cleanup of files and the cache + */ + function import_end() { + wp_import_cleanup( $this->id ); + + wp_cache_flush(); + foreach ( get_taxonomies() as $tax ) { + delete_option( "{$tax}_children" ); + _get_term_hierarchy( $tax ); + } + + wp_defer_term_counting( false ); + wp_defer_comment_counting( false ); + + echo '

' . __( 'All done.', 'wordpress-importer' ) . ' ' . __( 'Have fun!', 'wordpress-importer' ) . '' . '

'; + echo '

' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '

'; + + do_action( 'import_end' ); + } + + /** + * Handles the WXR upload and initial parsing of the file to prepare for + * displaying author import options + * + * @return bool False if error uploading or invalid file, true otherwise + */ + function handle_upload() { + $file = wp_import_handle_upload(); + + if ( isset( $file['error'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $file['error'] ) . '

'; + return false; + } elseif ( ! file_exists( $file['file'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + printf( __( 'The export file could not be found at %s. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file['file'] ) ); + echo '

'; + return false; + } + + $this->id = (int) $file['id']; + $import_data = $this->parse( $file['file'] ); + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + return false; + } + + $this->version = $import_data['version']; + if ( $this->version > $this->max_wxr_version ) { + echo '

'; + printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html( $import_data['version'] ) ); + echo '

'; + } + + $this->get_authors_from_import( $import_data ); + + return true; + } + + /** + * Retrieve authors from parsed WXR data + * + * Uses the provided author information from WXR 1.1 files + * or extracts info from each post for WXR 1.0 files + * + * @param array $import_data Data returned by a WXR parser + */ + function get_authors_from_import( $import_data ) { + if ( ! empty( $import_data['authors'] ) ) { + $this->authors = $import_data['authors']; + // no author information, grab it from the posts + } else { + foreach ( $import_data['posts'] as $post ) { + $login = sanitize_user( $post['post_author'], true ); + if ( empty( $login ) ) { + printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post['post_author'] ) ); + echo '
'; + continue; + } + + if ( ! isset( $this->authors[ $login ] ) ) { + $this->authors[ $login ] = array( + 'author_login' => $login, + 'author_display_name' => $post['post_author'], + ); + } + } + } + } + + /** + * Display pre-import options, author importing/mapping and option to + * fetch attachments + */ + function import_options() { + $j = 0; + // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect + ?> +
+ + + +authors ) ) : ?> +

+

+allow_create_users() ) : ?> +

+ +
    +authors as $author ) : ?> +
  1. author_select( $j++, $author ); ?>
  2. + +
+ + +allow_fetch_attachments() ) : ?> +

+

+ + +

+ + +

+
+ ' . esc_html( $author['author_display_name'] ); + if ( '1.0' != $this->version ) { + echo ' (' . esc_html( $author['author_login'] ) . ')'; + } + echo '
'; + + if ( '1.0' != $this->version ) { + echo '
'; + } + + $create_users = $this->allow_create_users(); + if ( $create_users ) { + echo ''; + + echo '
'; + } + + echo ''; + + echo ' ' . wp_dropdown_users( + array( + 'name' => "user_map[$n]", + 'id' => 'imported_authors_' . $n, + 'multi' => true, + 'show_option_all' => __( '- Select -', 'wordpress-importer' ), + 'show' => 'display_name_with_login', + 'echo' => 0, + ) + ); + + echo ''; + + if ( '1.0' != $this->version ) { + echo '
'; + } + } + + /** + * Map old author logins to local user IDs based on decisions made + * in import options form. Can map to an existing user, create a new user + * or falls back to the current user in case of error with either of the previous + */ + function get_author_mapping() { + if ( ! isset( $_POST['imported_authors'] ) ) { + return; + } + + $create_users = $this->allow_create_users(); + + foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) { + // Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts. + $santized_old_login = sanitize_user( $old_login, true ); + $old_id = isset( $this->authors[ $old_login ]['author_id'] ) ? intval( $this->authors[ $old_login ]['author_id'] ) : false; + + if ( ! empty( $_POST['user_map'][ $i ] ) ) { + $user = get_userdata( intval( $_POST['user_map'][ $i ] ) ); + if ( isset( $user->ID ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user->ID; + } + $this->author_mapping[ $santized_old_login ] = $user->ID; + } + } elseif ( $create_users ) { + if ( ! empty( $_POST['user_new'][ $i ] ) ) { + $user_id = wp_create_user( $_POST['user_new'][ $i ], wp_generate_password() ); + } elseif ( '1.0' != $this->version ) { + $user_data = array( + 'user_login' => $old_login, + 'user_pass' => wp_generate_password(), + 'user_email' => isset( $this->authors[ $old_login ]['author_email'] ) ? $this->authors[ $old_login ]['author_email'] : '', + 'display_name' => $this->authors[ $old_login ]['author_display_name'], + 'first_name' => isset( $this->authors[ $old_login ]['author_first_name'] ) ? $this->authors[ $old_login ]['author_first_name'] : '', + 'last_name' => isset( $this->authors[ $old_login ]['author_last_name'] ) ? $this->authors[ $old_login ]['author_last_name'] : '', + ); + $user_id = wp_insert_user( $user_data ); + } + + if ( ! is_wp_error( $user_id ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user_id; + } + $this->author_mapping[ $santized_old_login ] = $user_id; + } else { + printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $this->authors[ $old_login ]['author_display_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ' ' . $user_id->get_error_message(); + } + echo '
'; + } + } + + // failsafe: if the user_id was invalid, default to the current user + if ( ! isset( $this->author_mapping[ $santized_old_login ] ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = (int) get_current_user_id(); + } + $this->author_mapping[ $santized_old_login ] = (int) get_current_user_id(); + } + } + } + + /** + * Create new categories based on import information + * + * Doesn't create a new category if its slug already exists + */ + function process_categories() { + $this->categories = apply_filters( 'wp_import_categories', $this->categories ); + + if ( empty( $this->categories ) ) { + return; + } + + foreach ( $this->categories as $cat ) { + // if the category already exists leave it alone + $term_id = term_exists( $cat['category_nicename'], 'category' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $parent = empty( $cat['category_parent'] ) ? 0 : category_exists( $cat['category_parent'] ); + $description = isset( $cat['category_description'] ) ? $cat['category_description'] : ''; + + $data = array( + 'category_nicename' => $cat['category_nicename'], + 'category_parent' => $parent, + 'cat_name' => wp_slash( $cat['cat_name'] ), + 'category_description' => wp_slash( $description ), + ); + + $id = wp_insert_category( $data, true ); + if ( ! is_wp_error( $id ) && $id > 0 ) { + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = $id; + } + } else { + printf( __( 'Failed to import category %s', 'wordpress-importer' ), esc_html( $cat['category_nicename'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $cat, $id ); + } + + unset( $this->categories ); + } + + /** + * Create new post tags based on import information + * + * Doesn't create a tag if its slug already exists + */ + function process_tags() { + $this->tags = apply_filters( 'wp_import_tags', $this->tags ); + + if ( empty( $this->tags ) ) { + return; + } + + foreach ( $this->tags as $tag ) { + // if the tag already exists leave it alone + $term_id = term_exists( $tag['tag_slug'], 'post_tag' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $description = isset( $tag['tag_description'] ) ? $tag['tag_description'] : ''; + $args = array( + 'slug' => $tag['tag_slug'], + 'description' => wp_slash( $description ), + ); + + $id = wp_insert_term( wp_slash( $tag['tag_name'] ), 'post_tag', $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import post tag %s', 'wordpress-importer' ), esc_html( $tag['tag_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $tag, $id['term_id'] ); + } + + unset( $this->tags ); + } + + /** + * Create new terms based on import information + * + * Doesn't create a term its slug already exists + */ + function process_terms() { + $this->terms = apply_filters( 'wp_import_terms', $this->terms ); + + if ( empty( $this->terms ) ) { + return; + } + + foreach ( $this->terms as $term ) { + // if the term already exists in the correct taxonomy leave it alone + $term_id = term_exists( $term['slug'], $term['term_taxonomy'] ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = (int) $term_id; + } + continue; + } + + if ( empty( $term['term_parent'] ) ) { + $parent = 0; + } else { + $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] ); + if ( is_array( $parent ) ) { + $parent = $parent['term_id']; + } + } + + $description = isset( $term['term_description'] ) ? $term['term_description'] : ''; + $args = array( + 'slug' => $term['slug'], + 'description' => wp_slash( $description ), + 'parent' => (int) $parent, + ); + + $id = wp_insert_term( wp_slash( $term['term_name'] ), $term['term_taxonomy'], $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $term['term_taxonomy'] ), esc_html( $term['term_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $term, $id['term_id'] ); + } + + unset( $this->terms ); + } + + /** + * Add metadata to imported term. + * + * @since 0.6.2 + * + * @param array $term Term data from WXR import. + * @param int $term_id ID of the newly created term. + */ + protected function process_termmeta( $term, $term_id ) { + if ( ! isset( $term['termmeta'] ) ) { + $term['termmeta'] = array(); + } + + /** + * Filters the metadata attached to an imported term. + * + * @since 0.6.2 + * + * @param array $termmeta Array of term meta. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term ); + + if ( empty( $term['termmeta'] ) ) { + return; + } + + foreach ( $term['termmeta'] as $meta ) { + /** + * Filters the meta key for an imported piece of term meta. + * + * @since 0.6.2 + * + * @param string $meta_key Meta key. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term ); + if ( ! $key ) { + continue; + } + + // Export gets meta straight from the DB so could have a serialized string + $value = maybe_unserialize( $meta['value'] ); + + add_term_meta( $term_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + /** + * Fires after term meta is imported. + * + * @since 0.6.2 + * + * @param int $term_id ID of the newly created term. + * @param string $key Meta key. + * @param mixed $value Meta value. + */ + do_action( 'import_term_meta', $term_id, $key, $value ); + } + } + + /** + * Create new posts based on import information + * + * Posts marked as having a parent which doesn't exist will become top level items. + * Doesn't create a new post if: the post type doesn't exist, the given post ID + * is already noted as imported or a post with the same title and date already exists. + * Note that new/updated terms, comments and meta are imported for the last of the above. + */ + function process_posts() { + $this->posts = apply_filters( 'wp_import_posts', $this->posts ); + + foreach ( $this->posts as $post ) { + $post = apply_filters( 'wp_import_post_data_raw', $post ); + + if ( ! post_type_exists( $post['post_type'] ) ) { + printf( + __( 'Failed to import “%1$s”: Invalid post type %2$s', 'wordpress-importer' ), + esc_html( $post['post_title'] ), + esc_html( $post['post_type'] ) + ); + echo '
'; + do_action( 'wp_import_post_exists', $post ); + continue; + } + + if ( isset( $this->processed_posts[ $post['post_id'] ] ) && ! empty( $post['post_id'] ) ) { + continue; + } + + if ( 'auto-draft' == $post['status'] ) { + continue; + } + + if ( 'nav_menu_item' == $post['post_type'] ) { + $this->process_menu_item( $post ); + continue; + } + + $post_type_object = get_post_type_object( $post['post_type'] ); + + $post_exists = post_exists( $post['post_title'], '', $post['post_date'] ); + + /** + * Filter ID of the existing post corresponding to post currently importing. + * + * Return 0 to force the post to be imported. Filter the ID to be something else + * to override which existing post is mapped to the imported post. + * + * @see post_exists() + * @since 0.6.2 + * + * @param int $post_exists Post ID, or 0 if post did not exist. + * @param array $post The post array to be inserted. + */ + $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post ); + + if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) { + printf( __( '%1$s “%2$s” already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) ); + echo '
'; + $comment_post_id = $post_exists; + $post_id = $post_exists; + $this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists ); + } else { + $post_parent = (int) $post['post_parent']; + if ( $post_parent ) { + // if we already know the parent, map it to the new local ID + if ( isset( $this->processed_posts[ $post_parent ] ) ) { + $post_parent = $this->processed_posts[ $post_parent ]; + // otherwise record the parent for later + } else { + $this->post_orphans[ intval( $post['post_id'] ) ] = $post_parent; + $post_parent = 0; + } + } + + // map the post author + $author = sanitize_user( $post['post_author'], true ); + if ( isset( $this->author_mapping[ $author ] ) ) { + $author = $this->author_mapping[ $author ]; + } else { + $author = (int) get_current_user_id(); + } + + $postdata = array( + 'import_id' => $post['post_id'], + 'post_author' => $author, + 'post_date' => $post['post_date'], + 'post_date_gmt' => $post['post_date_gmt'], + 'post_content' => $post['post_content'], + 'post_excerpt' => $post['post_excerpt'], + 'post_title' => $post['post_title'], + 'post_status' => $post['status'], + 'post_name' => $post['post_name'], + 'comment_status' => $post['comment_status'], + 'ping_status' => $post['ping_status'], + 'guid' => $post['guid'], + 'post_parent' => $post_parent, + 'menu_order' => $post['menu_order'], + 'post_type' => $post['post_type'], + 'post_password' => $post['post_password'], + ); + + $original_post_id = $post['post_id']; + $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post ); + + $postdata = wp_slash( $postdata ); + + if ( 'attachment' == $postdata['post_type'] ) { + $remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid']; + + // try to use _wp_attached file for upload folder placement to ensure the same location as the export site + // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload() + $postdata['upload_date'] = $post['post_date']; + if ( isset( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + if ( '_wp_attached_file' == $meta['key'] ) { + if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) { + $postdata['upload_date'] = $matches[0]; + } + break; + } + } + } + + $comment_post_id = $this->process_attachment( $postdata, $remote_url ); + $post_id = $comment_post_id; + } else { + $comment_post_id = wp_insert_post( $postdata, true ); + $post_id = $comment_post_id; + do_action( 'wp_import_insert_post', $post_id, $original_post_id, $postdata, $post ); + } + + if ( is_wp_error( $post_id ) ) { + printf( + __( 'Failed to import %1$s “%2$s”', 'wordpress-importer' ), + $post_type_object->labels->singular_name, + esc_html( $post['post_title'] ) + ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $post_id->get_error_message(); + } + echo '
'; + continue; + } + + if ( 1 == $post['is_sticky'] ) { + stick_post( $post_id ); + } + } + + // map pre-import ID to local ID + $this->processed_posts[ intval( $post['post_id'] ) ] = (int) $post_id; + + if ( ! isset( $post['terms'] ) ) { + $post['terms'] = array(); + } + + $post['terms'] = apply_filters( 'wp_import_post_terms', $post['terms'], $post_id, $post ); + + // add categories, tags and other terms + if ( ! empty( $post['terms'] ) ) { + $terms_to_set = array(); + foreach ( $post['terms'] as $term ) { + // back compat with WXR 1.0 map 'tag' to 'post_tag' + $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain']; + $term_exists = term_exists( $term['slug'], $taxonomy ); + $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists; + if ( ! $term_id ) { + $t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) ); + if ( ! is_wp_error( $t ) ) { + $term_id = $t['term_id']; + do_action( 'wp_import_insert_term', $t, $term, $post_id, $post ); + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term['name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $t->get_error_message(); + } + echo '
'; + do_action( 'wp_import_insert_term_failed', $t, $term, $post_id, $post ); + continue; + } + } + $terms_to_set[ $taxonomy ][] = intval( $term_id ); + } + + foreach ( $terms_to_set as $tax => $ids ) { + $tt_ids = wp_set_post_terms( $post_id, $ids, $tax ); + do_action( 'wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post ); + } + unset( $post['terms'], $terms_to_set ); + } + + if ( ! isset( $post['comments'] ) ) { + $post['comments'] = array(); + } + + $post['comments'] = apply_filters( 'wp_import_post_comments', $post['comments'], $post_id, $post ); + + // add/update comments + if ( ! empty( $post['comments'] ) ) { + $num_comments = 0; + $inserted_comments = array(); + foreach ( $post['comments'] as $comment ) { + $comment_id = $comment['comment_id']; + $newcomments[ $comment_id ]['comment_post_ID'] = $comment_post_id; + $newcomments[ $comment_id ]['comment_author'] = $comment['comment_author']; + $newcomments[ $comment_id ]['comment_author_email'] = $comment['comment_author_email']; + $newcomments[ $comment_id ]['comment_author_IP'] = $comment['comment_author_IP']; + $newcomments[ $comment_id ]['comment_author_url'] = $comment['comment_author_url']; + $newcomments[ $comment_id ]['comment_date'] = $comment['comment_date']; + $newcomments[ $comment_id ]['comment_date_gmt'] = $comment['comment_date_gmt']; + $newcomments[ $comment_id ]['comment_content'] = $comment['comment_content']; + $newcomments[ $comment_id ]['comment_approved'] = $comment['comment_approved']; + $newcomments[ $comment_id ]['comment_type'] = $comment['comment_type']; + $newcomments[ $comment_id ]['comment_parent'] = $comment['comment_parent']; + $newcomments[ $comment_id ]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array(); + if ( isset( $this->processed_authors[ $comment['comment_user_id'] ] ) ) { + $newcomments[ $comment_id ]['user_id'] = $this->processed_authors[ $comment['comment_user_id'] ]; + } + } + ksort( $newcomments ); + + foreach ( $newcomments as $key => $comment ) { + // if this is a new post we can skip the comment_exists() check + if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) { + if ( isset( $inserted_comments[ $comment['comment_parent'] ] ) ) { + $comment['comment_parent'] = $inserted_comments[ $comment['comment_parent'] ]; + } + + $comment_data = wp_slash( $comment ); + unset( $comment_data['commentmeta'] ); // Handled separately, wp_insert_comment() also expects `comment_meta`. + $comment_data = wp_filter_comment( $comment_data ); + + $inserted_comments[ $key ] = wp_insert_comment( $comment_data ); + + do_action( 'wp_import_insert_comment', $inserted_comments[ $key ], $comment, $comment_post_id, $post ); + + foreach ( $comment['commentmeta'] as $meta ) { + $value = maybe_unserialize( $meta['value'] ); + + add_comment_meta( $inserted_comments[ $key ], wp_slash( $meta['key'] ), wp_slash_strings_only( $value ) ); + } + + $num_comments++; + } + } + unset( $newcomments, $inserted_comments, $post['comments'] ); + } + + if ( ! isset( $post['postmeta'] ) ) { + $post['postmeta'] = array(); + } + + $post['postmeta'] = apply_filters( 'wp_import_post_meta', $post['postmeta'], $post_id, $post ); + + // add/update post meta + if ( ! empty( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + $key = apply_filters( 'import_post_meta_key', $meta['key'], $post_id, $post ); + $value = false; + + if ( '_edit_last' == $key ) { + if ( isset( $this->processed_authors[ intval( $meta['value'] ) ] ) ) { + $value = $this->processed_authors[ intval( $meta['value'] ) ]; + } else { + $key = false; + } + } + + if ( $key ) { + // export gets meta straight from the DB so could have a serialized string + if ( ! $value ) { + $value = maybe_unserialize( $meta['value'] ); + } + + add_post_meta( $post_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + do_action( 'import_post_meta', $post_id, $key, $value ); + + // if the post has a featured image, take note of this in case of remap + if ( '_thumbnail_id' == $key ) { + $this->featured_images[ $post_id ] = (int) $value; + } + } + } + } + } + + unset( $this->posts ); + } + + /** + * Attempt to create a new menu item from import data + * + * Fails for draft, orphaned menu items and those without an associated nav_menu + * or an invalid nav_menu term. If the post type or term object which the menu item + * represents doesn't exist then the menu item will not be imported (waits until the + * end of the import to retry again before discarding). + * + * @param array $item Menu item details from WXR file + */ + function process_menu_item( $item ) { + // skip draft, orphaned menu items + if ( 'draft' == $item['status'] ) { + return; + } + + $menu_slug = false; + if ( isset( $item['terms'] ) ) { + // loop through terms, assume first nav_menu term is correct menu + foreach ( $item['terms'] as $term ) { + if ( 'nav_menu' == $term['domain'] ) { + $menu_slug = $term['slug']; + break; + } + } + } + + // no nav_menu term associated with this menu item + if ( ! $menu_slug ) { + _e( 'Menu item skipped due to missing menu slug', 'wordpress-importer' ); + echo '
'; + return; + } + + $menu_id = term_exists( $menu_slug, 'nav_menu' ); + if ( ! $menu_id ) { + printf( __( 'Menu item skipped due to invalid menu slug: %s', 'wordpress-importer' ), esc_html( $menu_slug ) ); + echo '
'; + return; + } else { + $menu_id = is_array( $menu_id ) ? $menu_id['term_id'] : $menu_id; + } + + foreach ( $item['postmeta'] as $meta ) { + ${$meta['key']} = $meta['value']; + } + + if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_terms[ intval( $_menu_item_object_id ) ]; + } elseif ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_posts[ intval( $_menu_item_object_id ) ]; + } elseif ( 'custom' != $_menu_item_type ) { + // associated object is missing or not imported yet, we'll retry later + $this->missing_menu_items[] = $item; + return; + } + + if ( isset( $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ] ) ) { + $_menu_item_menu_item_parent = $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ]; + } elseif ( $_menu_item_menu_item_parent ) { + $this->menu_item_orphans[ intval( $item['post_id'] ) ] = (int) $_menu_item_menu_item_parent; + $_menu_item_menu_item_parent = 0; + } + + // wp_update_nav_menu_item expects CSS classes as a space separated string + $_menu_item_classes = maybe_unserialize( $_menu_item_classes ); + if ( is_array( $_menu_item_classes ) ) { + $_menu_item_classes = implode( ' ', $_menu_item_classes ); + } + + $args = array( + 'menu-item-object-id' => $_menu_item_object_id, + 'menu-item-object' => $_menu_item_object, + 'menu-item-parent-id' => $_menu_item_menu_item_parent, + 'menu-item-position' => intval( $item['menu_order'] ), + 'menu-item-type' => $_menu_item_type, + 'menu-item-title' => $item['post_title'], + 'menu-item-url' => $_menu_item_url, + 'menu-item-description' => $item['post_content'], + 'menu-item-attr-title' => $item['post_excerpt'], + 'menu-item-target' => $_menu_item_target, + 'menu-item-classes' => $_menu_item_classes, + 'menu-item-xfn' => $_menu_item_xfn, + 'menu-item-status' => $item['status'], + ); + + $id = wp_update_nav_menu_item( $menu_id, 0, $args ); + if ( $id && ! is_wp_error( $id ) ) { + $this->processed_menu_items[ intval( $item['post_id'] ) ] = (int) $id; + } + } + + /** + * If fetching attachments is enabled then attempt to create a new attachment + * + * @param array $post Attachment post details from WXR + * @param string $url URL to fetch attachment from + * @return int|WP_Error Post ID on success, WP_Error otherwise + */ + function process_attachment( $post, $url ) { + if ( ! $this->fetch_attachments ) { + return new WP_Error( + 'attachment_processing_error', + __( 'Fetching attachments is not enabled', 'wordpress-importer' ) + ); + } + + // if the URL is absolute, but does not contain address, then upload it assuming base_site_url + if ( preg_match( '|^/[\w\W]+$|', $url ) ) { + $url = rtrim( $this->base_url, '/' ) . $url; + } + + $upload = $this->fetch_remote_file( $url, $post ); + if ( is_wp_error( $upload ) ) { + return $upload; + } + + $info = wp_check_filetype( $upload['file'] ); + if ( $info ) { + $post['post_mime_type'] = $info['type']; + } else { + return new WP_Error( 'attachment_processing_error', __( 'Invalid file type', 'wordpress-importer' ) ); + } + + $post['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment( $post, $upload['file'] ); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap resized image URLs, works by stripping the extension and remapping the URL stub. + if ( preg_match( '!^image/!', $info['type'] ) ) { + $parts = pathinfo( $url ); + $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2 + + $parts_new = pathinfo( $upload['url'] ); + $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" ); + + $this->url_remap[ $parts['dirname'] . '/' . $name ] = $parts_new['dirname'] . '/' . $name_new; + } + + return $post_id; + } + + /** + * Attempt to download a remote file attachment + * + * @param string $url URL of item to fetch + * @param array $post Attachment details + * @return array|WP_Error Local file location details on success, WP_Error otherwise + */ + function fetch_remote_file( $url, $post ) { + // Extract the file name from the URL. + $path = parse_url( $url, PHP_URL_PATH ); + $file_name = ''; + if ( is_string( $path ) ) { + $file_name = basename( $path ); + } + + if ( ! $file_name ) { + $file_name = md5( $url ); + } + + $tmp_file_name = wp_tempnam( $file_name ); + if ( ! $tmp_file_name ) { + return new WP_Error( 'import_no_file', __( 'Could not create temporary file.', 'wordpress-importer' ) ); + } + + // Fetch the remote URL and write it to the placeholder file. + $remote_response = wp_safe_remote_get( + $url, + array( + 'timeout' => 300, + 'stream' => true, + 'filename' => $tmp_file_name, + 'headers' => array( + 'Accept-Encoding' => 'identity', + ), + ) + ); + + if ( is_wp_error( $remote_response ) ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The WordPress error message. 2: The WordPress error code. */ + __( 'Request failed due to an error: %1$s (%2$s)', 'wordpress-importer' ), + esc_html( $remote_response->get_error_message() ), + esc_html( $remote_response->get_error_code() ) + ) + ); + } + + $remote_response_code = (int) wp_remote_retrieve_response_code( $remote_response ); + + // Make sure the fetch was successful. + if ( 200 !== $remote_response_code ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The HTTP error message. 2: The HTTP error code. */ + __( 'Remote server returned the following unexpected result: %1$s (%2$s)', 'wordpress-importer' ), + get_status_header_desc( $remote_response_code ), + esc_html( $remote_response_code ) + ) + ); + } + + $headers = wp_remote_retrieve_headers( $remote_response ); + + // Request failed. + if ( ! $headers ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Remote server did not respond', 'wordpress-importer' ) ); + } + + $filesize = (int) filesize( $tmp_file_name ); + + if ( 0 === $filesize ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) ); + } + + if ( ! isset( $headers['content-encoding'] ) && isset( $headers['content-length'] ) && $filesize !== (int) $headers['content-length'] ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Downloaded file has incorrect size', 'wordpress-importer' ) ); + } + + $max_size = (int) $this->max_attachment_size(); + if ( ! empty( $max_size ) && $filesize > $max_size ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) ) ); + } + + // Override file name with Content-Disposition header value. + if ( ! empty( $headers['content-disposition'] ) ) { + $file_name_from_disposition = self::get_filename_from_disposition( (array) $headers['content-disposition'] ); + if ( $file_name_from_disposition ) { + $file_name = $file_name_from_disposition; + } + } + + // Set file extension if missing. + $file_ext = pathinfo( $file_name, PATHINFO_EXTENSION ); + if ( ! $file_ext && ! empty( $headers['content-type'] ) ) { + $extension = self::get_file_extension_by_mime_type( $headers['content-type'] ); + if ( $extension ) { + $file_name = "{$file_name}.{$extension}"; + } + } + + // Handle the upload like _wp_handle_upload() does. + $wp_filetype = wp_check_filetype_and_ext( $tmp_file_name, $file_name ); + $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; + $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; + $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; + + // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect. + if ( $proper_filename ) { + $file_name = $proper_filename; + } + + if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) { + return new WP_Error( 'import_file_error', __( 'Sorry, this file type is not permitted for security reasons.', 'wordpress-importer' ) ); + } + + $uploads = wp_upload_dir( $post['upload_date'] ); + if ( ! ( $uploads && false === $uploads['error'] ) ) { + return new WP_Error( 'upload_dir_error', $uploads['error'] ); + } + + // Move the file to the uploads dir. + $file_name = wp_unique_filename( $uploads['path'], $file_name ); + $new_file = $uploads['path'] . "/$file_name"; + $move_new_file = copy( $tmp_file_name, $new_file ); + + if ( ! $move_new_file ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'The uploaded file could not be moved', 'wordpress-importer' ) ); + } + + // Set correct file permissions. + $stat = stat( dirname( $new_file ) ); + $perms = $stat['mode'] & 0000666; + chmod( $new_file, $perms ); + + $upload = array( + 'file' => $new_file, + 'url' => $uploads['url'] . "/$file_name", + 'type' => $wp_filetype['type'], + 'error' => false, + ); + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[ $url ] = $upload['url']; + $this->url_remap[ $post['guid'] ] = $upload['url']; // r13735, really needed? + // keep track of the destination if the remote url is redirected somewhere else + if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) { + $this->url_remap[ $headers['x-final-location'] ] = $upload['url']; + } + + return $upload; + } + + /** + * Attempt to associate posts and menu items with previously missing parents + * + * An imported post's parent may not have been imported when it was first created + * so try again. Similarly for child menu items and menu items which were missing + * the object (e.g. post) they represent in the menu + */ + function backfill_parents() { + global $wpdb; + + // find parents for post orphans + foreach ( $this->post_orphans as $child_id => $parent_id ) { + $local_child_id = false; + $local_parent_id = false; + if ( isset( $this->processed_posts[ $child_id ] ) ) { + $local_child_id = $this->processed_posts[ $child_id ]; + } + if ( isset( $this->processed_posts[ $parent_id ] ) ) { + $local_parent_id = $this->processed_posts[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + $wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' ); + clean_post_cache( $local_child_id ); + } + } + + // all other posts/terms are imported, retry menu items with missing associated object + $missing_menu_items = $this->missing_menu_items; + foreach ( $missing_menu_items as $item ) { + $this->process_menu_item( $item ); + } + + // find parents for menu item orphans + foreach ( $this->menu_item_orphans as $child_id => $parent_id ) { + $local_child_id = 0; + $local_parent_id = 0; + if ( isset( $this->processed_menu_items[ $child_id ] ) ) { + $local_child_id = $this->processed_menu_items[ $child_id ]; + } + if ( isset( $this->processed_menu_items[ $parent_id ] ) ) { + $local_parent_id = $this->processed_menu_items[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + update_post_meta( $local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id ); + } + } + } + + /** + * Use stored mapping information to update old attachment URLs + */ + function backfill_attachment_urls() { + global $wpdb; + // make sure we do the longest urls first, in case one is a substring of another + uksort( $this->url_remap, array( &$this, 'cmpr_strlen' ) ); + + foreach ( $this->url_remap as $from_url => $to_url ) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url ) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url ) ); + } + } + + /** + * Update _thumbnail_id meta to new, imported attachment IDs + */ + function remap_featured_images() { + // cycle through posts that have a featured image + foreach ( $this->featured_images as $post_id => $value ) { + if ( isset( $this->processed_posts[ $value ] ) ) { + $new_id = $this->processed_posts[ $value ]; + // only update if there's a difference + if ( $new_id != $value ) { + update_post_meta( $post_id, '_thumbnail_id', $new_id ); + } + } + } + } + + /** + * Parse a WXR file + * + * @param string $file Path to WXR file for parsing + * @return array Information gathered from the WXR file + */ + function parse( $file ) { + $parser = new WXR_Parser(); + return $parser->parse( $file ); + } + + // Display import page title + function header() { + echo '
'; + echo '

' . __( 'Import WordPress', 'wordpress-importer' ) . '

'; + + $updates = get_plugin_updates(); + $basename = plugin_basename( __FILE__ ); + if ( isset( $updates[ $basename ] ) ) { + $update = $updates[ $basename ]; + echo '

'; + printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version ); + echo '

'; + } + } + + // Close div.wrap + function footer() { + echo '
'; + } + + /** + * Display introductory text and file upload form + */ + function greet() { + echo '
'; + echo '

' . __( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ) . '

'; + echo '

' . __( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ) . '

'; + wp_import_upload_form( 'admin.php?import=wordpress&step=1' ); + echo '
'; + } + + /** + * Decide if the given meta key maps to information we will want to import + * + * @param string $key The meta key to check + * @return string|bool The key if we do want to import, false if not + */ + function is_valid_meta_key( $key ) { + // skip attachment metadata since we'll regenerate it from scratch + // skip _edit_lock as not relevant for import + if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ), true ) ) { + return false; + } + return $key; + } + + /** + * Decide whether or not the importer is allowed to create users. + * Default is true, can be filtered via import_allow_create_users + * + * @return bool True if creating users is allowed + */ + function allow_create_users() { + return apply_filters( 'import_allow_create_users', true ); + } + + /** + * Decide whether or not the importer should attempt to download attachment files. + * Default is true, can be filtered via import_allow_fetch_attachments. The choice + * made at the import options screen must also be true, false here hides that checkbox. + * + * @return bool True if downloading attachments is allowed + */ + function allow_fetch_attachments() { + return apply_filters( 'import_allow_fetch_attachments', true ); + } + + /** + * Decide what the maximum file size for downloaded attachments is. + * Default is 0 (unlimited), can be filtered via import_attachment_size_limit + * + * @return int Maximum attachment file size to import + */ + function max_attachment_size() { + return apply_filters( 'import_attachment_size_limit', 0 ); + } + + /** + * Added to http_request_timeout filter to force timeout at 60 seconds during import + * @return int 60 + */ + function bump_request_timeout( $val ) { + return 60; + } + + // return the difference in length between two strings + function cmpr_strlen( $a, $b ) { + return strlen( $b ) - strlen( $a ); + } + + /** + * Parses filename from a Content-Disposition header value. + * + * As per RFC6266: + * + * content-disposition = "Content-Disposition" ":" + * disposition-type *( ";" disposition-parm ) + * + * disposition-type = "inline" | "attachment" | disp-ext-type + * ; case-insensitive + * disp-ext-type = token + * + * disposition-parm = filename-parm | disp-ext-parm + * + * filename-parm = "filename" "=" value + * | "filename*" "=" ext-value + * + * disp-ext-parm = token "=" value + * | ext-token "=" ext-value + * ext-token = + * + * @since 0.7.0 + * + * @see WP_REST_Attachments_Controller::get_filename_from_disposition() + * + * @link http://tools.ietf.org/html/rfc2388 + * @link http://tools.ietf.org/html/rfc6266 + * + * @param string[] $disposition_header List of Content-Disposition header values. + * @return string|null Filename if available, or null if not found. + */ + protected static function get_filename_from_disposition( $disposition_header ) { + // Get the filename. + $filename = null; + + foreach ( $disposition_header as $value ) { + $value = trim( $value ); + + if ( strpos( $value, ';' ) === false ) { + continue; + } + + list( $type, $attr_parts ) = explode( ';', $value, 2 ); + + $attr_parts = explode( ';', $attr_parts ); + $attributes = array(); + + foreach ( $attr_parts as $part ) { + if ( strpos( $part, '=' ) === false ) { + continue; + } + + list( $key, $value ) = explode( '=', $part, 2 ); + + $attributes[ trim( $key ) ] = trim( $value ); + } + + if ( empty( $attributes['filename'] ) ) { + continue; + } + + $filename = trim( $attributes['filename'] ); + + // Unquote quoted filename, but after trimming. + if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) { + $filename = substr( $filename, 1, -1 ); + } + } + + return $filename; + } + + /** + * Retrieves file extension by mime type. + * + * @since 0.7.0 + * + * @param string $mime_type Mime type to search extension for. + * @return string|null File extension if available, or null if not found. + */ + protected static function get_file_extension_by_mime_type( $mime_type ) { + static $map = null; + + if ( is_array( $map ) ) { + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } + + $mime_types = wp_get_mime_types(); + $map = array_flip( $mime_types ); + + // Some types have multiple extensions, use only the first one. + foreach ( $map as $type => $extensions ) { + $map[ $type ] = strtok( $extensions, '|' ); + } + + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } +} +has_gzip = is_callable( 'gzopen' ); + } + + function parse( $file ) { + $wxr_version = false; + $in_multiline = false; + + $multiline_content = ''; + + $multiline_tags = array( + 'item' => array( 'posts', array( $this, 'process_post' ) ), + 'wp:category' => array( 'categories', array( $this, 'process_category' ) ), + 'wp:tag' => array( 'tags', array( $this, 'process_tag' ) ), + 'wp:term' => array( 'terms', array( $this, 'process_term' ) ), + ); + + $fp = $this->fopen( $file, 'r' ); + if ( $fp ) { + while ( ! $this->feof( $fp ) ) { + $is_tag_line = false; + $importline = rtrim( $this->fgets( $fp ) ); + + if ( ! $wxr_version && preg_match( '|(\d+\.\d+)|', $importline, $version ) ) { + $wxr_version = $version[1]; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $url ); + $this->base_url = $url[1]; + continue; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $blog_url ); + $this->base_blog_url = $blog_url[1]; + continue; + } elseif ( empty( $this->base_blog_url ) ) { + $this->base_blog_url = $this->base_url; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $author ); + $a = $this->process_author( $author[1] ); + $this->authors[ $a['author_login'] ] = $a; + continue; + } + + foreach ( $multiline_tags as $tag => $handler ) { + // Handle multi-line tags on a singular line + $pos = strpos( $importline, "<$tag>" ); + $pos_closing = strpos( $importline, "" ); + if ( preg_match( '|<' . $tag . '>(.*?)|is', $importline, $matches ) ) { + $this->{$handler[0]}[] = call_user_func( $handler[1], $matches[1] ); + + } elseif ( false !== $pos ) { + // Take note of any content after the opening tag + $multiline_content = trim( substr( $importline, $pos + strlen( $tag ) + 2 ) ); + + // We don't want to have this line added to `$is_multiline` below. + $in_multiline = $tag; + $is_tag_line = true; + + } elseif ( false !== $pos_closing ) { + $in_multiline = false; + $multiline_content .= trim( substr( $importline, 0, $pos_closing ) ); + + $this->{$handler[0]}[] = call_user_func( $handler[1], $multiline_content ); + } + } + + if ( $in_multiline && ! $is_tag_line ) { + $multiline_content .= $importline . "\n"; + } + } + + $this->fclose( $fp ); + } + + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->categories, + 'tags' => $this->tags, + 'terms' => $this->terms, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $wxr_version, + ); + } + + function get_tag( $string, $tag ) { + preg_match( "|<$tag.*?>(.*?)|is", $string, $return ); + if ( isset( $return[1] ) ) { + if ( substr( $return[1], 0, 9 ) == '' ) !== false ) { + preg_match_all( '||s', $return[1], $matches ); + $return = ''; + foreach ( $matches[1] as $match ) { + $return .= $match; + } + } else { + $return = preg_replace( '|^$|s', '$1', $return[1] ); + } + } else { + $return = $return[1]; + } + } else { + $return = ''; + } + return $return; + } + + function process_category( $c ) { + $term = array( + 'term_id' => $this->get_tag( $c, 'wp:term_id' ), + 'cat_name' => $this->get_tag( $c, 'wp:cat_name' ), + 'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ), + 'category_parent' => $this->get_tag( $c, 'wp:category_parent' ), + 'category_description' => $this->get_tag( $c, 'wp:category_description' ), + ); + + $term_meta = $this->process_meta( $c, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_tag( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'tag_name' => $this->get_tag( $t, 'wp:tag_name' ), + 'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ), + 'tag_description' => $this->get_tag( $t, 'wp:tag_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_term( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ), + 'slug' => $this->get_tag( $t, 'wp:term_slug' ), + 'term_parent' => $this->get_tag( $t, 'wp:term_parent' ), + 'term_name' => $this->get_tag( $t, 'wp:term_name' ), + 'term_description' => $this->get_tag( $t, 'wp:term_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_meta( $string, $tag ) { + $parsed_meta = array(); + + preg_match_all( "|<$tag>(.+?)|is", $string, $meta ); + + if ( ! isset( $meta[1] ) ) { + return $parsed_meta; + } + + foreach ( $meta[1] as $m ) { + $parsed_meta[] = array( + 'key' => $this->get_tag( $m, 'wp:meta_key' ), + 'value' => $this->get_tag( $m, 'wp:meta_value' ), + ); + } + + return $parsed_meta; + } + + function process_author( $a ) { + return array( + 'author_id' => $this->get_tag( $a, 'wp:author_id' ), + 'author_login' => $this->get_tag( $a, 'wp:author_login' ), + 'author_email' => $this->get_tag( $a, 'wp:author_email' ), + 'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ), + 'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ), + 'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ), + ); + } + + function process_post( $post ) { + $post_id = $this->get_tag( $post, 'wp:post_id' ); + $post_title = $this->get_tag( $post, 'title' ); + $post_date = $this->get_tag( $post, 'wp:post_date' ); + $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); + $comment_status = $this->get_tag( $post, 'wp:comment_status' ); + $ping_status = $this->get_tag( $post, 'wp:ping_status' ); + $status = $this->get_tag( $post, 'wp:status' ); + $post_name = $this->get_tag( $post, 'wp:post_name' ); + $post_parent = $this->get_tag( $post, 'wp:post_parent' ); + $menu_order = $this->get_tag( $post, 'wp:menu_order' ); + $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); + $is_sticky = $this->get_tag( $post, 'wp:is_sticky' ); + $guid = $this->get_tag( $post, 'guid' ); + $post_author = $this->get_tag( $post, 'dc:creator' ); + + $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); + $post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + + $post_content = $this->get_tag( $post, 'content:encoded' ); + $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + + $postdata = compact( + 'post_id', + 'post_author', + 'post_date', + 'post_date_gmt', + 'post_content', + 'post_excerpt', + 'post_title', + 'status', + 'post_name', + 'comment_status', + 'ping_status', + 'guid', + 'post_parent', + 'menu_order', + 'post_type', + 'post_password', + 'is_sticky' + ); + + $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( $attachment_url ) { + $postdata['attachment_url'] = $attachment_url; + } + + preg_match_all( '|(.+?)|is', $post, $terms, PREG_SET_ORDER ); + foreach ( $terms as $t ) { + $post_terms[] = array( + 'slug' => $t[2], + 'domain' => $t[1], + 'name' => str_replace( array( '' ), '', $t[3] ), + ); + } + if ( ! empty( $post_terms ) ) { + $postdata['terms'] = $post_terms; + } + + preg_match_all( '|(.+?)|is', $post, $comments ); + $comments = $comments[1]; + if ( $comments ) { + foreach ( $comments as $comment ) { + $post_comments[] = array( + 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), + 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), + 'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ), + 'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ), + 'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ), + 'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ), + 'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ), + 'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ), + 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), + 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), + 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), + 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), + 'commentmeta' => $this->process_meta( $comment, 'wp:commentmeta' ), + ); + } + } + if ( ! empty( $post_comments ) ) { + $postdata['comments'] = $post_comments; + } + + $post_meta = $this->process_meta( $post, 'wp:postmeta' ); + if ( ! empty( $post_meta ) ) { + $postdata['postmeta'] = $post_meta; + } + + return $postdata; + } + + function _normalize_tag( $matches ) { + return '<' . strtolower( $matches[1] ); + } + + function fopen( $filename, $mode = 'r' ) { + if ( $this->has_gzip ) { + return gzopen( $filename, $mode ); + } + return fopen( $filename, $mode ); + } + + function feof( $fp ) { + if ( $this->has_gzip ) { + return gzeof( $fp ); + } + return feof( $fp ); + } + + function fgets( $fp, $len = 8192 ) { + if ( $this->has_gzip ) { + return gzgets( $fp, $len ); + } + return fgets( $fp, $len ); + } + + function fclose( $fp ) { + if ( $this->has_gzip ) { + return gzclose( $fp ); + } + return fclose( $fp ); + } +} +loadXML( file_get_contents( $file ) ); + if ( ! is_null( $old_value ) ) { + libxml_disable_entity_loader( $old_value ); + } + + if ( ! $success || isset( $dom->doctype ) ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $xml = simplexml_import_dom( $dom ); + unset( $dom ); + + // halt if loading produces an error + if ( ! $xml ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $wxr_version = $xml->xpath( '/rss/channel/wp:wxr_version' ); + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $wxr_version = (string) trim( $wxr_version[0] ); + // confirm that we are dealing with the correct file format + if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $base_url = $xml->xpath( '/rss/channel/wp:base_site_url' ); + $base_url = (string) trim( isset( $base_url[0] ) ? $base_url[0] : '' ); + + $base_blog_url = $xml->xpath( '/rss/channel/wp:base_blog_url' ); + if ( $base_blog_url ) { + $base_blog_url = (string) trim( $base_blog_url[0] ); + } else { + $base_blog_url = $base_url; + } + + $namespaces = $xml->getDocNamespaces(); + if ( ! isset( $namespaces['wp'] ) ) { + $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; + } + if ( ! isset( $namespaces['excerpt'] ) ) { + $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; + } + + // grab authors + foreach ( $xml->xpath( '/rss/channel/wp:author' ) as $author_arr ) { + $a = $author_arr->children( $namespaces['wp'] ); + $login = (string) $a->author_login; + $authors[ $login ] = array( + 'author_id' => (int) $a->author_id, + 'author_login' => $login, + 'author_email' => (string) $a->author_email, + 'author_display_name' => (string) $a->author_display_name, + 'author_first_name' => (string) $a->author_first_name, + 'author_last_name' => (string) $a->author_last_name, + ); + } + + // grab cats, tags and terms + foreach ( $xml->xpath( '/rss/channel/wp:category' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $category = array( + 'term_id' => (int) $t->term_id, + 'category_nicename' => (string) $t->category_nicename, + 'category_parent' => (string) $t->category_parent, + 'cat_name' => (string) $t->cat_name, + 'category_description' => (string) $t->category_description, + ); + + foreach ( $t->termmeta as $meta ) { + $category['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $categories[] = $category; + } + + foreach ( $xml->xpath( '/rss/channel/wp:tag' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $tag = array( + 'term_id' => (int) $t->term_id, + 'tag_slug' => (string) $t->tag_slug, + 'tag_name' => (string) $t->tag_name, + 'tag_description' => (string) $t->tag_description, + ); + + foreach ( $t->termmeta as $meta ) { + $tag['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $tags[] = $tag; + } + + foreach ( $xml->xpath( '/rss/channel/wp:term' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $term = array( + 'term_id' => (int) $t->term_id, + 'term_taxonomy' => (string) $t->term_taxonomy, + 'slug' => (string) $t->term_slug, + 'term_parent' => (string) $t->term_parent, + 'term_name' => (string) $t->term_name, + 'term_description' => (string) $t->term_description, + ); + + foreach ( $t->termmeta as $meta ) { + $term['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $terms[] = $term; + } + + // grab posts + foreach ( $xml->channel->item as $item ) { + $post = array( + 'post_title' => (string) $item->title, + 'guid' => (string) $item->guid, + ); + + $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); + $post['post_author'] = (string) $dc->creator; + + $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' ); + $excerpt = $item->children( $namespaces['excerpt'] ); + $post['post_content'] = (string) $content->encoded; + $post['post_excerpt'] = (string) $excerpt->encoded; + + $wp = $item->children( $namespaces['wp'] ); + $post['post_id'] = (int) $wp->post_id; + $post['post_date'] = (string) $wp->post_date; + $post['post_date_gmt'] = (string) $wp->post_date_gmt; + $post['comment_status'] = (string) $wp->comment_status; + $post['ping_status'] = (string) $wp->ping_status; + $post['post_name'] = (string) $wp->post_name; + $post['status'] = (string) $wp->status; + $post['post_parent'] = (int) $wp->post_parent; + $post['menu_order'] = (int) $wp->menu_order; + $post['post_type'] = (string) $wp->post_type; + $post['post_password'] = (string) $wp->post_password; + $post['is_sticky'] = (int) $wp->is_sticky; + + if ( isset( $wp->attachment_url ) ) { + $post['attachment_url'] = (string) $wp->attachment_url; + } + + foreach ( $item->category as $c ) { + $att = $c->attributes(); + if ( isset( $att['nicename'] ) ) { + $post['terms'][] = array( + 'name' => (string) $c, + 'slug' => (string) $att['nicename'], + 'domain' => (string) $att['domain'], + ); + } + } + + foreach ( $wp->postmeta as $meta ) { + $post['postmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + foreach ( $wp->comment as $comment ) { + $meta = array(); + if ( isset( $comment->commentmeta ) ) { + foreach ( $comment->commentmeta as $m ) { + $meta[] = array( + 'key' => (string) $m->meta_key, + 'value' => (string) $m->meta_value, + ); + } + } + + $post['comments'][] = array( + 'comment_id' => (int) $comment->comment_id, + 'comment_author' => (string) $comment->comment_author, + 'comment_author_email' => (string) $comment->comment_author_email, + 'comment_author_IP' => (string) $comment->comment_author_IP, + 'comment_author_url' => (string) $comment->comment_author_url, + 'comment_date' => (string) $comment->comment_date, + 'comment_date_gmt' => (string) $comment->comment_date_gmt, + 'comment_content' => (string) $comment->comment_content, + 'comment_approved' => (string) $comment->comment_approved, + 'comment_type' => (string) $comment->comment_type, + 'comment_parent' => (string) $comment->comment_parent, + 'comment_user_id' => (int) $comment->comment_user_id, + 'commentmeta' => $meta, + ); + } + + $posts[] = $post; + } + + return array( + 'authors' => $authors, + 'posts' => $posts, + 'categories' => $categories, + 'tags' => $tags, + 'terms' => $terms, + 'base_url' => $base_url, + 'base_blog_url' => $base_blog_url, + 'version' => $wxr_version, + ); + } +} +wxr_version = false; + $this->in_post = false; + $this->cdata = false; + $this->data = false; + $this->sub_data = false; + $this->in_tag = false; + $this->in_sub_tag = false; + $this->authors = array(); + $this->posts = array(); + $this->term = array(); + $this->category = array(); + $this->tag = array(); + + $xml = xml_parser_create( 'UTF-8' ); + xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 ); + xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 ); + xml_set_object( $xml, $this ); + xml_set_character_data_handler( $xml, 'cdata' ); + xml_set_element_handler( $xml, 'tag_open', 'tag_close' ); + + if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) { + $current_line = xml_get_current_line_number( $xml ); + $current_column = xml_get_current_column_number( $xml ); + $error_code = xml_get_error_code( $xml ); + $error_string = xml_error_string( $error_code ); + return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) ); + } + xml_parser_free( $xml ); + + if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->category, + 'tags' => $this->tag, + 'terms' => $this->term, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $this->wxr_version, + ); + } + + function tag_open( $parse, $tag, $attr ) { + if ( in_array( $tag, $this->wp_tags, true ) ) { + $this->in_tag = substr( $tag, 3 ); + return; + } + + if ( in_array( $tag, $this->wp_sub_tags, true ) ) { + $this->in_sub_tag = substr( $tag, 3 ); + return; + } + + switch ( $tag ) { + case 'category': + if ( isset( $attr['domain'], $attr['nicename'] ) ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data['domain'] = $attr['domain']; + $this->sub_data['slug'] = $attr['nicename']; + } + break; + case 'item': + $this->in_post = true; + break; + case 'title': + if ( $this->in_post ) { + $this->in_tag = 'post_title'; + } + break; + case 'guid': + $this->in_tag = 'guid'; + break; + case 'dc:creator': + $this->in_tag = 'post_author'; + break; + case 'content:encoded': + $this->in_tag = 'post_content'; + break; + case 'excerpt:encoded': + $this->in_tag = 'post_excerpt'; + break; + + case 'wp:term_slug': + $this->in_tag = 'slug'; + break; + case 'wp:meta_key': + $this->in_sub_tag = 'key'; + break; + case 'wp:meta_value': + $this->in_sub_tag = 'value'; + break; + } + } + + function cdata( $parser, $cdata ) { + if ( ! trim( $cdata ) ) { + return; + } + + if ( false !== $this->in_tag || false !== $this->in_sub_tag ) { + $this->cdata .= $cdata; + } else { + $this->cdata .= trim( $cdata ); + } + } + + function tag_close( $parser, $tag ) { + switch ( $tag ) { + case 'wp:comment': + unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data + if ( ! empty( $this->sub_data ) ) { + $this->data['comments'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:commentmeta': + $this->sub_data['commentmeta'][] = array( + 'key' => $this->sub_data['key'], + 'value' => $this->sub_data['value'], + ); + break; + case 'category': + if ( ! empty( $this->sub_data ) ) { + $this->sub_data['name'] = $this->cdata; + $this->data['terms'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:postmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['postmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'item': + $this->posts[] = $this->data; + $this->data = false; + break; + case 'wp:category': + case 'wp:tag': + case 'wp:term': + $n = substr( $tag, 3 ); + array_push( $this->$n, $this->data ); + $this->data = false; + break; + case 'wp:termmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['termmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:author': + if ( ! empty( $this->data['author_login'] ) ) { + $this->authors[ $this->data['author_login'] ] = $this->data; + } + $this->data = false; + break; + case 'wp:base_site_url': + $this->base_url = $this->cdata; + if ( ! isset( $this->base_blog_url ) ) { + $this->base_blog_url = $this->cdata; + } + break; + case 'wp:base_blog_url': + $this->base_blog_url = $this->cdata; + break; + case 'wp:wxr_version': + $this->wxr_version = $this->cdata; + break; + + default: + if ( $this->in_sub_tag ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data[ $this->in_sub_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_sub_tag = false; + } elseif ( $this->in_tag ) { + if ( false === $this->data ) { + $this->data = array(); + } + + $this->data[ $this->in_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_tag = false; + } + } + + $this->cdata = false; + } +} +parse( $file ); + + // If SimpleXML succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) { + return $result; + } + } elseif ( extension_loaded( 'xml' ) ) { + $parser = new WXR_Parser_XML; + $result = $parser->parse( $file ); + + // If XMLParser succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) { + return $result; + } + } + + // We have a malformed XML file, so display the error and fallthrough to regex + if ( isset( $result ) && defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo '
';
+			if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
+				foreach ( $result->get_error_data() as $error ) {
+					echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
+				}
+			} elseif ( 'XML_parse_error' == $result->get_error_code() ) {
+				$error = $result->get_error_data();
+				echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
+			}
+			echo '
'; + echo '

' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '
'; + echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '

'; + } + + // use regular expressions if nothing else available or this is bad XML + $parser = new WXR_Parser_Regex; + return $parser->parse( $file ); + } +} +=== WordPress Importer === +Contributors: wordpressdotorg +Donate link: https://wordpressfoundation.org/donate/ +Tags: importer, wordpress +Requires at least: 5.2 +Tested up to: 6.1 +Requires PHP: 5.6 +Stable tag: 0.8 +License: GPLv2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html + +Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. + +== Description == + +The WordPress Importer will import the following content from a WordPress export file: + +* Posts, pages and other custom post types +* Comments and comment meta +* Custom fields and post meta +* Categories, tags and terms from custom taxonomies and term meta +* Authors + +For further information and instructions please see the [documention on Importing Content](https://wordpress.org/support/article/importing-content/#wordpress). + +== Installation == + +The quickest method for installing the importer is: + +1. Visit Tools -> Import in the WordPress dashboard +1. Click on the WordPress link in the list of importers +1. Click "Install Now" +1. Finally click "Activate Plugin & Run Importer" + +If you would prefer to do things manually then follow these instructions: + +1. Upload the `wordpress-importer` folder to the `/wp-content/plugins/` directory +1. Activate the plugin through the 'Plugins' menu in WordPress +1. Go to the Tools -> Import screen, click on WordPress + +== Changelog == + += 0.8 = +* Update minimum WordPress requirement to 5.2. +* Update minimum PHP requirement to 5.6. +* Update compatibility tested-up-to to WordPress 6.1. +* PHP 8.0, 8.1, and 8.2 compatibility fixes. +* Fix a bug causing blank lines in content to be ignored when using the Regex Parser. +* Fix a bug resulting in a PHP fatal error when IMPORT_DEBUG is enabled and a category creation error occurs. +* Improved Unit testing & automated testing. + += 0.7 = +* Update minimum WordPress requirement to 3.7 and ensure compatibility with PHP 7.4. +* Fix bug that caused not importing term meta. +* Fix bug that caused slashes to be stripped from imported meta data. +* Fix bug that prevented import of serialized meta data. +* Fix file size check after download of remote files with HTTP compression enabled. +* Improve accessibility of form fields by adding missing labels. +* Improve imports for remote file URLs without name and/or extension. +* Add support for `wp:base_blog_url` field to allow importing multiple files with WP-CLI. +* Add support for term meta parsing when using the regular expressions or XML parser. +* Developers: All PHP classes have been moved into their own files. +* Developers: Allow to change `IMPORT_DEBUG` via `wp-config.php` and change default value to the value of `WP_DEBUG`. + += 0.6.4 = +* Improve PHP7 compatibility. +* Fix bug that caused slashes to be stripped from imported comments. +* Fix for various deprecation notices including `wp_get_http()` and `screen_icon()`. +* Fix for importing export files with multiline term meta data. + += 0.6.3 = +* Add support for import term metadata. +* Fix bug that caused slashes to be stripped from imported content. +* Fix bug that caused characters to be stripped inside of CDATA in some cases. +* Fix PHP notices. + += 0.6.2 = +* Add `wp_import_existing_post` filter, see [Trac ticket #33721](https://core.trac.wordpress.org/ticket/33721). + += 0.6 = +* Support for WXR 1.2 and multiple CDATA sections +* Post aren't duplicates if their post_type's are different + += 0.5.2 = +* Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when +an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used. + += 0.5 = +* Import comment meta (requires export from WordPress 3.2) +* Minor bugfixes and enhancements + += 0.4 = +* Map comment user_id where possible +* Import attachments from `wp:attachment_url` +* Upload attachments to correct directory +* Remap resized image URLs correctly + += 0.3 = +* Use an XML Parser if possible +* Proper import support for nav menus +* ... and much more, see [Trac ticket #15197](https://core.trac.wordpress.org/ticket/15197) + += 0.1 = +* Initial release + +== Frequently Asked Questions == + += Help! I'm getting out of memory errors or a blank screen. = +If your exported file is very large, the import script may run into your host's configured memory limit for PHP. + +A message like "Fatal error: Allowed memory size of 8388608 bytes exhausted" indicates that the script can't successfully import your XML file under the current PHP memory limit. If you have access to the php.ini file, you can manually increase the limit; if you do not (your WordPress installation is hosted on a shared server, for instance), you might have to break your exported XML file into several smaller pieces and run the import script one at a time. + +For those with shared hosting, the best alternative may be to consult hosting support to determine the safest approach for running the import. A host may be willing to temporarily lift the memory limit and/or run the process directly from their end. + +-- [Support Article: Importing Content](https://wordpress.org/support/article/importing-content/#before-importing) + +== Filters == + +The importer has a couple of filters to allow you to completely enable/block certain features: + +* `import_allow_create_users`: return false if you only want to allow mapping to existing users +* `import_allow_fetch_attachments`: return false if you do not wish to allow importing and downloading of attachments +* `import_attachment_size_limit`: return an integer value for the maximum file size in bytes to save (default is 0, which is unlimited) + +There are also a few actions available to hook into: + +* `import_start`: occurs after the export file has been uploaded and author import settings have been chosen +* `import_end`: called after the last output from the importer +posts, pages, comments, custom fields, categories, and tags from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); +} +add_action( 'admin_init', 'wordpress_importer_init' ); get( 'Version' ); $version_string = is_string( $theme_version ) ? $theme_version : false; wp_register_style( 'twentytwentytwo-style', get_template_directory_uri() . '/style.css', array(), $version_string ); wp_enqueue_style( 'twentytwentytwo-style' ); } endif; add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' ); require get_template_directory() . '/inc/block-patterns.php'; array( 'label' => __( 'Featured', 'twentytwentytwo' ) ), 'footer' => array( 'label' => __( 'Footers', 'twentytwentytwo' ) ), 'header' => array( 'label' => __( 'Headers', 'twentytwentytwo' ) ), 'query' => array( 'label' => __( 'Query', 'twentytwentytwo' ) ), 'pages' => array( 'label' => __( 'Pages', 'twentytwentytwo' ) ), ); $block_pattern_categories = apply_filters( 'twentytwentytwo_block_pattern_categories', $block_pattern_categories ); foreach ( $block_pattern_categories as $name => $properties ) { if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { register_block_pattern_category( $name, $properties ); } } $block_patterns = array( 'footer-default', 'footer-dark', 'footer-logo', 'footer-navigation', 'footer-title-tagline-social', 'footer-social-copyright', 'footer-navigation-copyright', 'footer-about-title-logo', 'footer-query-title-citation', 'footer-query-images-title-citation', 'footer-blog', 'general-subscribe', 'general-featured-posts', 'general-layered-images-with-duotone', 'general-wide-image-intro-buttons', 'general-large-list-names', 'general-video-header-details', 'general-list-events', 'general-two-images-text', 'general-image-with-caption', 'general-video-trailer', 'general-pricing-table', 'general-divider-light', 'general-divider-dark', 'header-default', 'header-large-dark', 'header-small-dark', 'header-image-background', 'header-image-background-overlay', 'header-with-tagline', 'header-text-only-green-background', 'header-text-only-salmon-background', 'header-title-and-button', 'header-text-only-with-tagline-black-background', 'header-logo-navigation-gray-background', 'header-logo-navigation-social-black-background', 'header-title-navigation-social', 'header-logo-navigation-offset-tagline', 'header-stacked', 'header-centered-logo', 'header-centered-logo-black-background', 'header-centered-title-navigation-social', 'header-title-and-button', 'hidden-404', 'hidden-bird', 'hidden-heading-and-bird', 'page-about-media-left', 'page-about-simple-dark', 'page-about-media-right', 'page-about-solid-color', 'page-about-links', 'page-about-links-dark', 'page-about-large-image-and-buttons', 'page-layout-image-and-text', 'page-layout-image-text-and-video', 'page-layout-two-columns', 'page-sidebar-poster', 'page-sidebar-grid-posts', 'page-sidebar-blog-posts', 'page-sidebar-blog-posts-right', 'query-default', 'query-simple-blog', 'query-grid', 'query-text-grid', 'query-image-grid', 'query-large-titles', 'query-irregular-grid', ); $block_patterns = apply_filters( 'twentytwentytwo_block_patterns', $block_patterns ); foreach ( $block_patterns as $block_pattern ) { $pattern_file = get_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' ); register_block_pattern( 'twentytwentytwo/' . $block_pattern, require $pattern_file ); } } add_action( 'init', 'twentytwentytwo_register_block_patterns', 9 ); get_error_data(); if ( ! empty( $data ) ) { wp_die( '

' . $comment->get_error_message() . '

', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true, ) ); } else { exit; } } $user = wp_get_current_user(); $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) ); do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { $location = add_query_arg( array( 'unapproved' => $comment->comment_ID, 'moderation-hash' => wp_hash( $comment->comment_date_gmt ), ), $location ); } $location = apply_filters( 'comment_post_redirect', $location, $comment ); wp_safe_redirect( $location ); exit; Gravatar.1comment �0��.d-U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-03 17:17:252023-01-03 17:17:25

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a/� 33�M#  # 33 M 2023-01-03 17:17:252023-01-03 17:17:25 +Commenter avatars come from Gravatar.1comment �1���0z.d-U ���/_wp_page_templatedefault/_wp_page_templatedefault � 8�( 33�u)  ) 33 M 2023-01-30 19:54:592023-01-30 19:54:59

Who we are

Suggested text: Our website address is: http://127.0.0.1:8000.

Comments

Suggested text: When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

Suggested text: If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download a/� 33�M#  # 33 M 2023-01-30 19:54:592023-01-30 19:54:59

This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

@@ -13504,9 +13504,9 @@ Commenter avatars come from Gravatar.1com

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!

-Sample Pagepublishclosedopensample-page2023-01-03 17:17:252023-01-03 17:17:25http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-03 17:17:252023-01-03 17:17:25 +Sample Pagepublishclosedopensample-page2023-01-30 19:54:592023-01-30 19:54:59http://127.0.0.1:8000/?page_id=2page�2 33�%  # 33 A 2023-01-30 19:54:592023-01-30 19:54:59

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

-Hello world!publishopenopenhello-world2023-01-03 17:17:252023-01-03 17:17:25http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( +Hello world!publishopenopenhello-world2023-01-30 19:54:592023-01-30 19:54:59http://127.0.0.1:8000/?p=1post � � � ! ��������U ##�qtablewp_post)�f !!�tablewp_optionswp_options CREATE TABLE wp_options ( option_id integer NOT NULL PRIMARY KEY AUTOINCREMENT , option_name text NOT NULL default '', option_value text NOT NULL, @@ -13583,7 +13583,7 @@ CREATE TABLE wp_comments ( user_activation_key text NOT NULL default '', user_status integer NOT NULL default '0', display_name text NOT NULL default '' -) �x ��]�j�z=�.�W�� �A�x�U �h � � PS!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)Y#)uindexmeta_key_24wp_commentmetaCREATE INDEX meta_key_24 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)S##oindexmeta_key_20wp_termmetaCREATE INDEX meta_key_20 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( +) �| ��]�j�|?�0�Y��E�|�U �h � � PS!%sindexlink_visiblewp_links$CREATE INDEX link_visible ON wp_links(link_visible)r 5#�indexcomment_author_emailwp_comments#CREATE INDEX comment_author_email ON wp_comments(comment_author_email)`)#�indexcomment_parentwp_comments"CREATE INDEX comment_parent ON wp_comments(comment_parent)f-#� indexcomment_date_gmtwp_comments!CREATE INDEX comment_date_gmt ON wp_comments(comment_date_gmt)� ?#�=indexcomment_approved_date_gmtwp_comments CREATE INDEX comment_approved_date_gmt ON wp_comments(comment_approved,comment_date_gmt)c+#�indexcomment_post_IDwp_commentsCREATE INDEX comment_post_ID ON wp_comments(comment_post_ID)W!)sindexmeta_key_2wp_commentmetaCREATE INDEX meta_key_2 ON wp_commentmeta(meta_key)Y!)windexcomment_idwp_commentmetaCREATE INDEX comment_id ON wp_commentmeta(comment_id)z-7�indexterm_taxonomy_idwp_term_relationshipsCREATE INDEX term_taxonomy_id ON wp_term_relationships(term_taxonomy_id)W-sindextaxonomywp_term_taxonomyCREATE INDEX taxonomy ON wp_term_taxonomy(taxonomy)w--�!indexterm_id_taxonomywp_term_taxonomyCREATE UNIQUE INDEX term_id_taxonomy ON wp_term_taxonomy(term_id,taxonomy);Sindexnamewp_termsCREATE INDEX name ON wp_terms(name);Sindexslugwp_termsCREATE INDEX slug ON wp_terms(slug)Q!#mindexmeta_key_7wp_termmetaCREATE INDEX meta_key_7 ON wp_termmeta(meta_key)J#eindexterm_idwp_termmetaCREATE INDEX term_id ON wp_termmeta(term_id)M#iindexmeta_keywp_usermetaCREATE INDEX meta_key ON wp_usermeta(meta_key)J#eindexuser_idwp_usermetaCREATE INDEX user_id ON wp_usermeta(user_id)M!kindexuser_emailwp_usersCREATE INDEX user_email ON wp_users(user_email)V'windexuser_nicenamewp_usersCREATE INDEX user_nicename ON wp_users(user_nicename)U)sindexuser_login_keywp_usersCREATE INDEX user_login_key ON wp_users(user_login)� �tablewp_postswp_postsCREATE TABLE wp_posts ( ID integer NOT NULL PRIMARY KEY AUTOINCREMENT , post_author integer NOT NULL default '0', post_date text NOT NULL default '0000-00-00 00:00:00', @@ -13612,7 +13612,7 @@ CREATE TABLE wp_comments ( post_id integer NOT NULL default '0', meta_key text default NULL, meta_value text -)�P)#oindexpost_authorwp_posts,CREATE INDEX post_author ON wp_posts(post_author)P(#oindexpost_parentwp_posts+CREATE INDEX post_parent ON wp_posts(post_parent)r'-�'indextype_status_datewp_posts*CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J&gindexpost_namewp_posts)CREATE INDEX post_name ON wp_posts(post_name)S%##oindexmeta_key_13wp_postmeta(CREATE INDEX meta_key_13 ON wp_postmeta(meta_key)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) +)�P)#oindexpost_authorwp_posts,CREATE INDEX post_author ON wp_posts(post_author)P(#oindexpost_parentwp_posts+CREATE INDEX post_parent ON wp_posts(post_parent)r'-�'indextype_status_datewp_posts*CREATE INDEX type_status_date ON wp_posts(post_type,post_status,post_date,ID)J&gindexpost_namewp_posts)CREATE INDEX post_name ON wp_posts(post_name)S%##oindexmeta_key_12wp_postmeta(CREATE INDEX meta_key_12 ON wp_postmeta(meta_key)J$#eindexpost_idwp_postmeta'CREATE INDEX post_id ON wp_postmeta(post_id)K#!gindexautoloadwp_options&CREATE INDEX autoload ON wp_options(autoload)\"#!�indexoption_namewp_options%CREATE UNIQUE INDEX option_name ON wp_options(option_name) �� admin �� admin ��3 admin@localhost.com @@ -13631,36 +13631,37 @@ CREATE TABLE wp_comments (   �� -��3 12023-01-03 17:17:25 -��3 2023-01-03 17:17:25 +��3 12023-01-30 19:54:59 +��3 2023-01-30 19:54:59 �� ��; wapuu@wordpress.example  -h� }��hO4 m � � Q�� k +�~q���q }��hO4 m � � Q�� k � � F A� �C -mH ��� +m�H ��� S  7�k � �� W� 7 �� � / � K \ {��� -  1 � � � � +  1 � � � ��� � � � � \X1 W � � %� I�� 0 �  � � -� � � �8 � � a � q~n ���� - � +� � � �8 � � a � q~n ���I�] +92��Pqy� ��d -���-sidebars_widgetsh%widget_blockg!user_countf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email +����"G_site_transient_update_themes�C_site_transient_theme_roots'S_site_transient_timeout_theme_roots~#C_site_transient_update_core|7_transient_doing_cronz1widget_custom_htmly+widget_nav_menux-widget_tag_cloudw9widget_recent-commentsv3widget_recent-postsu!nonce_saltt nonce_keys'widget_searchr#widget_metaq1widget_media_videop5widget_media_galleryo1widget_media_imagen1widget_media_audiom+widget_archivesl+widget_calendark%widget_pagesjcroni-sidebars_widgetsh%widget_blockg!user_countf!fresh_sitee'wp_user_rolesd1initial_db_versionc Ewp_force_deactivated_pluginsb9auto_update_core_majora9auto_update_core_minor`5auto_update_core_dev_#Kauto_plugin_theme_update_emails^Ccomment_previously_approved]+disallowed_keys\5admin_email_lifespan[ Eshow_comments_cookies_opt_inZAwp_page_for_privacy_policyY3medium_large_size_hX3medium_large_size_wW site_iconV#Kfinished_splitting_shared_termsU5link_manager_enabledT3default_post_formatS'page_on_frontR)page_for_postsQ+timezone_stringP/uninstall_pluginsO!widget_rssN#widget_textM/widget_categoriesL%sticky_postsK'comment_orderJ7default_comments_pageI/comments_per_pageH'page_commentsG7thread_comments_depthF+thread_commentsE;close_comments_days_oldD Eclose_comments_for_old_postsC3image_default_alignB1image_default_sizeA;image_default_link_type@%large_size_h?%large_size_w>)avatar_default='medium_size_h<'medium_size_w;)thumbnail_crop:-thumbnail_size_h9-thumbnail_size_w8+upload_url_path7'avatar_rating6%show_avatars5 tag_base4'show_on_front37default_link_category2#blog_public1#upload_path0!Guploads_use_yearmonth_folders/!db_version.%default_role-'use_trackback, html_type+5comment_registration*!stylesheet) template(+recently_edited'9default_email_category&!gmt_offset%/comment_max_links$!ping_sites#'category_base")active_plugins!+moderation_keys %blog_charset hack_file'rewrite_rules3permalink_structure/moderation_notify1comment_moderation?links_updated_date_format#time_format#date_format)posts_per_page7default_pingback_flag3default_ping_status9default_comment_status-default_category+mailserver_port+mailserver_pass-mailserver_login)mailserver_url+rss_use_excerpt 'posts_per_rss +comments_notify 1require_name_email #use_smilies +use_balanceTags'start_of_week#admin_email1users_can_register+blogdescription blognamehome  siteurl -h �� � %  �����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � �yeshyesgnofyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes + +~ � � %  � p i 2 $  ����������������yqiaYQIA91)! ���������������{skc[SKC;3+#  � � � � � � � � � � � � � � � | t l d \ T L D < 4 ,    � � � � � � � � � � � � � � �  w a Y Q I A 9 9no�nono~no|yeszyesyyesxyeswyesvyesunotnosyesryesqyespyesoyesnyesmyeslyeskyesjyesiyeshyesgnofyeseyesdyescyesbyesayes`yes_no^yes]no\yes[yesZyesYyesXyesWyesVyesUyesTyesSyesRyesQyesPnoOyesNyesMyesLyesKyesJyesIyesHyesGyesFyesEyesDyesCyesByesAyes@yes?yes>yes=yes<yes;yes:yes9yes8yes7yes6yes5yes4yes3yes2yes1yes0yes/yes.yes-yes,yes+yes*yes)yes(no'yes&yes%yes$yes#yes"yes!no yesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyesyes yes yes yes yes yesyesyesyesyesyesyes yes ���  ���/_wp_page_template/ _wp_page_template ����)privacy-policy#sample-page# hello-world -����$3pagedraft2023-01-03 17:17:25&3pagepublish2023-01-03 17:17:25$3 postpublish2023-01-03 17:17:25 +����$3pagedraft2023-01-30 19:54:59&3pagepublish2023-01-30 19:54:59$3 postpublish2023-01-30 19:54:59 ���� -����   �UD���x[3�����Y. � � � � q W < " � � � � �tYA# ����tQ, ����xcM-�����}dJ0����X5�����kJ/�����nD���uO!����aaI3ipermalink_structure/index.php/%year%/%monthnum%/%day%/%postname%/yesa1(UKfinished_splitting_shared_terms1yesT5link_manager_enabled0yesS3default_post_format0yesR'page_on_front0yesQ)page_for_posts0yesP+ timezone_stringyesO/uninstall_pluginsa:0:{}noN!widget_rssa:0:{}yesM#widget_texta:0:{}yesL/widget_categoriesa:0:{}yesK%sticky_postsa:0:{}yesJ'comment_orderascyes#I7default_comments_pagenewestyesH/comments_per_page50yesG'page_comments0yesF7thread_comments_depth5yesE+thread_comments1yes!D;close_comments_days_old14yes%CEclose_comments_for_old_posts0yesB3 image_default_alignyesA1 image_default_sizeyes#@;image_default_link_typenoneyes?%large_size_h1024yes>%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version53496yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes#)!/stylesheettwentytwentythreeyes!(/templatetwentytwentythreeyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyes!)active_pluginsa:0:{}yes + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes -1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes+ blogdescriptionyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version53496yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1688318244yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-03 17:17:252023-01-03 17:17:25http://127.0.0.1:8000/?page_id=3page  c w c n �f!user_count1noe!fresh_site1yes�_h-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�g%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes1DENY FROM ALL%large_size_w1024yes=)avatar_defaultmysteryyes<'medium_size_h300yes;'medium_size_w300yes:)thumbnail_crop1yes9-thumbnail_size_h150yes8-thumbnail_size_w150yes7+ upload_url_pathyes6'avatar_ratingGyes5%show_avatars1yes4 tag_baseyes3'show_on_frontpostsyes27default_link_category2yes1#blog_public1yes0# upload_pathyes&/Guploads_use_yearmonth_folders1yes.!db_version53496yes-%!default_rolesubscriberyes,'use_trackback0yes+html_typetext/htmlyes*5comment_registration0yes#)!/stylesheettwentytwentythreeyes!(/templatetwentytwentythreeyes'+ recently_editedno&9default_email_category1yes%!gmt_offset0yes$/comment_max_links2yes,#!Aping_siteshttp://rpc.pingomatic.com/yes"' category_baseyes� + moderation_keysno%blog_charsetUTF-8yeshack_file0yes�R!)�active_pluginsa:1:{i:0;s:41:"wordpress-importer/wordpress-importer.php";}yes' rewrite_rulesyes3 permalink_structureyes/moderation_notify1yes1comment_moderation0yes-?%links_updated_date_formatF j, Y g:i ayes#time_formatg:i ayes#date_formatF j, Yyes)posts_per_page10yes7default_pingback_flag1yes3default_ping_statusopenyes"9default_comment_statusopenyes-default_category1yes+mailserver_port110yes+mailserver_passpasswordyes)-/mailserver_loginlogin@example.comyes&)-mailserver_urlmail.example.comyes +rss_use_excerpt0yes 'posts_per_rss10yes +comments_notify1yes +1require_name_email1yes #use_smilies1yes+use_balanceTags0yes'start_of_week1yes&#3admin_emailadmin@localhost.comyes1users_can_register0yes+ blogdescriptionyes$5blognameMy WordPress Websiteyes!7homehttp://127.0.0.1:8000yes$7siteurlhttp://127.0.0.1:8000yes ��vX3 ���xS,���c1initial_db_version53496yes*bEwp_force_deactivated_pluginsa:0:{}yes%a9auto_update_core_majorenabledyes%`9auto_update_core_minorenabledyes#_5auto_update_core_devenabledyes,^Kauto_plugin_theme_update_emailsa:0:{}no$]Ccomment_previously_approved1yes\+ disallowed_keysno&[5!admin_email_lifespan1690660499yes%ZEshow_comments_cookies_opt_in1yes#YAwp_page_for_privacy_policy3yesX3medium_large_size_h0yesW3medium_large_size_w768yesVsite_icon0yes�Sd'�wp_user_rolesa:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}yesnd extract any location data from images on the website.

Cookies

Suggested text: If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Suggested text: Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

Suggested text: If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

Suggested text: If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

Suggested text: If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Suggested text: Visitor comments may be checked through an automated spam detection service.

Privacy Policydraftclosedopenprivacy-policy2023-01-30 19:54:592023-01-30 19:54:59http://127.0.0.1:8000/?page_id=3page �� w c n �� � l 5���K��<��T # +��i�ucrona:3:{i:1675108918;a:6:{s:32:"recovery_mode_clean_expired_keys";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}s:18:"wp_https_detection";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:34:"wp_privacy_delete_old_export_files";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"hourly";s:4:"args";a:0:{}s:8:"interval";i:3600;}}s:16:"wp_version_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:17:"wp_update_plugins";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:16:"wp_update_themes";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}}i:1675195318;a:1:{s:30:"wp_site_health_scheduled_check";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:6:"weekly";s:4:"args";a:0:{}s:8:"interval";i:604800;}}}s:7:"version";i:2;}yes8y1Iwidget_custom_htmla:1:{s:12:"_multiwidget";i:1;}yes5x+Iwidget_nav_menua:1:{s:12:"_multiwidget";i:1;}yes6w-Iwidget_tag_clouda:1:{s:12:"_multiwidget";i:1;}yes_Bbx*D##2FOfCk5BW7jsMU>BW)NogXiU%wh=]Dtg>QI]KX2&(N.V{r2hdpSkywnoQs� nonce_keyR7&1X,Lgz|9NC5^Y=ySI9Ktw%a=0uS:@B1vu,A}-Qz?U4/no3r'Iwidget_searcha:1:{s:12:"_multiwidget";i:1;}yes1q#Iwidget_metaa:1:{s:12:"_multiwidget";i:1;}yes8p1Iwidget_media_videoa:1:{s:12:"_multiwidget";i:1;}yes:o5Iwidget_media_gallerya:1:{s:12:"_multiwidget";i:1;}yes8n1Iwidget_media_imagea:1:{s:12:"_multiwidget";i:1;}yes8m1Iwidget_media_audioa:1:{s:12:"_multiwidget";i:1;}yes5l+Iwidget_archivesa:1:{s:12:"_multiwidget";i:1;}yes5k+Iwidget_calendara:1:{s:12:"_multiwidget";i:1;}yes2j%Iwidget_pagesa:1:{s:12:"_multiwidget";i:1;}yesL>z7O_transient_doing_cron1675108918.8238029479980468750000yesf!user_count1noe!fresh_site1yes�_h-�sidebars_widgetsa:4:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:7:"block-2";i:1;s:7:"block-3";i:2;s:7:"block-4";}s:9:"sidebar-2";a:2:{i:0;s:7:"block-5";i:1;s:7:"block-6";}s:13:"array_version";i:3;}yes�g%�widget_blocka:6:{i:2;a:1:{s:7:"content";s:19:"";}i:3;a:1:{s:7:"content";s:154:"

Recent Posts

";}i:4;a:1:{s:7:"content";s:227:"

Recent Comments

";}i:5;a:1:{s:7:"content";s:146:"

Archives

";}i:6;a:1:{s:7:"content";s:150:"

Categories

";}s:12:"_multiwidget";i:1;}yes F� ������G�I_site_transient_update_themesO:8:"stdClass":5:{s:12:"last_checked";i:1675108922;s:7:"checked";a:1:{s:17:"twentytwentythree";s:3:"1.0";}s:8:"response";a:0:{}s:9:"no_update";a:1:{s:17:"twentytwentythree";a:6:{s:5:"theme";s:17:"twentytwentythree";s:11:"new_version";s:3:"1.0";s:3:"url";s:47:"https://wordpress.org/themes/twentytwentythree/";s:7:"package";s:63:"https://downloads.wordpress.org/theme/twentytwentythree.1.0.zip";s:8:"requires";s:3:"6.1";s:12:"requires_php";s:3:"5.6";}}s:12:"translations";a:0:{}}noOCg_site_transient_theme_rootsa:1:{s:17:"twentytwentythree";s:7:"/themes";}no4~S!_site_transient_timeout_theme_roots1675110721no e�R|C�k_site_transient_update_coreO:8:"stdClass":4:{s:7:"updates";a:1:{i:0;O:8:"stdClass":10:{s:8:"response";s:6:"latest";s:8:"download";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:6:"locale";s:5:"en_US";s:8:"packages";O:8:"stdClass":5:{s:4:"full";s:59:"https://downloads.wordpress.org/release/wordpress-6.1.1.zip";s:10:"no_content";s:70:"https://downloads.wordpress.org/release/wordpress-6.1.1-no-content.zip";s:11:"new_bundled";s:71:"https://downloads.wordpress.org/release/wordpress-6.1.1-new-bundled.zip";s:7:"partial";s:0:"";s:8:"rollback";s:0:"";}s:7:"current";s:5:"6.1.1";s:7:"version";s:5:"6.1.1";s:11:"php_version";s:6:"5.6.20";s:13:"mysql_version";s:3:"5.0";s:11:"new_bundled";s:3:"6.1";s:15:"partial_version";s:0:"";}}s:12:"last_checked";i:1675108921;s:15:"version_checked";s:5:"6.1.1";s:12:"translations";a:0:{}}no1DENY FROM ALL @@ -14331,6 +14332,2670 @@ Dolly'll never go away again"; $lyrics = explode( "\n", $lyrics ); return wptext } "; } add_action( 'admin_head', 'dolly_css' ); header(); + + $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step']; + switch ( $step ) { + case 0: + $this->greet(); + break; + case 1: + check_admin_referer( 'import-upload' ); + if ( $this->handle_upload() ) { + $this->import_options(); + } + break; + case 2: + check_admin_referer( 'import-wordpress' ); + $this->fetch_attachments = ( ! empty( $_POST['fetch_attachments'] ) && $this->allow_fetch_attachments() ); + $this->id = (int) $_POST['import_id']; + $file = get_attached_file( $this->id ); + set_time_limit( 0 ); + $this->import( $file ); + break; + } + + $this->footer(); + } + + /** + * The main controller for the actual import stage. + * + * @param string $file Path to the WXR file for importing + */ + function import( $file ) { + add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) ); + add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) ); + + $this->import_start( $file ); + + $this->get_author_mapping(); + + wp_suspend_cache_invalidation( true ); + $this->process_categories(); + $this->process_tags(); + $this->process_terms(); + $this->process_posts(); + wp_suspend_cache_invalidation( false ); + + // update incorrect/missing information in the DB + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->remap_featured_images(); + + $this->import_end(); + } + + /** + * Parses the WXR file and prepares us for the task of processing parsed data + * + * @param string $file Path to the WXR file for importing + */ + function import_start( $file ) { + if ( ! is_file( $file ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo __( 'The file does not exist, please try again.', 'wordpress-importer' ) . '

'; + $this->footer(); + die(); + } + + $import_data = $this->parse( $file ); + + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + $this->footer(); + die(); + } + + $this->version = $import_data['version']; + $this->get_authors_from_import( $import_data ); + $this->posts = $import_data['posts']; + $this->terms = $import_data['terms']; + $this->categories = $import_data['categories']; + $this->tags = $import_data['tags']; + $this->base_url = esc_url( $import_data['base_url'] ); + + wp_defer_term_counting( true ); + wp_defer_comment_counting( true ); + + do_action( 'import_start' ); + } + + /** + * Performs post-import cleanup of files and the cache + */ + function import_end() { + wp_import_cleanup( $this->id ); + + wp_cache_flush(); + foreach ( get_taxonomies() as $tax ) { + delete_option( "{$tax}_children" ); + _get_term_hierarchy( $tax ); + } + + wp_defer_term_counting( false ); + wp_defer_comment_counting( false ); + + echo '

' . __( 'All done.', 'wordpress-importer' ) . ' ' . __( 'Have fun!', 'wordpress-importer' ) . '' . '

'; + echo '

' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '

'; + + do_action( 'import_end' ); + } + + /** + * Handles the WXR upload and initial parsing of the file to prepare for + * displaying author import options + * + * @return bool False if error uploading or invalid file, true otherwise + */ + function handle_upload() { + $file = wp_import_handle_upload(); + + if ( isset( $file['error'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $file['error'] ) . '

'; + return false; + } elseif ( ! file_exists( $file['file'] ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + printf( __( 'The export file could not be found at %s. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file['file'] ) ); + echo '

'; + return false; + } + + $this->id = (int) $file['id']; + $import_data = $this->parse( $file['file'] ); + if ( is_wp_error( $import_data ) ) { + echo '

' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
'; + echo esc_html( $import_data->get_error_message() ) . '

'; + return false; + } + + $this->version = $import_data['version']; + if ( $this->version > $this->max_wxr_version ) { + echo '

'; + printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html( $import_data['version'] ) ); + echo '

'; + } + + $this->get_authors_from_import( $import_data ); + + return true; + } + + /** + * Retrieve authors from parsed WXR data + * + * Uses the provided author information from WXR 1.1 files + * or extracts info from each post for WXR 1.0 files + * + * @param array $import_data Data returned by a WXR parser + */ + function get_authors_from_import( $import_data ) { + if ( ! empty( $import_data['authors'] ) ) { + $this->authors = $import_data['authors']; + // no author information, grab it from the posts + } else { + foreach ( $import_data['posts'] as $post ) { + $login = sanitize_user( $post['post_author'], true ); + if ( empty( $login ) ) { + printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post['post_author'] ) ); + echo '
'; + continue; + } + + if ( ! isset( $this->authors[ $login ] ) ) { + $this->authors[ $login ] = array( + 'author_login' => $login, + 'author_display_name' => $post['post_author'], + ); + } + } + } + } + + /** + * Display pre-import options, author importing/mapping and option to + * fetch attachments + */ + function import_options() { + $j = 0; + // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect + ?> +
+ + + +authors ) ) : ?> +

+

+allow_create_users() ) : ?> +

+ +
    +authors as $author ) : ?> +
  1. author_select( $j++, $author ); ?>
  2. + +
+ + +allow_fetch_attachments() ) : ?> +

+

+ + +

+ + +

+
+ ' . esc_html( $author['author_display_name'] ); + if ( '1.0' != $this->version ) { + echo ' (' . esc_html( $author['author_login'] ) . ')'; + } + echo '
'; + + if ( '1.0' != $this->version ) { + echo '
'; + } + + $create_users = $this->allow_create_users(); + if ( $create_users ) { + echo ''; + + echo '
'; + } + + echo ''; + + echo ' ' . wp_dropdown_users( + array( + 'name' => "user_map[$n]", + 'id' => 'imported_authors_' . $n, + 'multi' => true, + 'show_option_all' => __( '- Select -', 'wordpress-importer' ), + 'show' => 'display_name_with_login', + 'echo' => 0, + ) + ); + + echo ''; + + if ( '1.0' != $this->version ) { + echo '
'; + } + } + + /** + * Map old author logins to local user IDs based on decisions made + * in import options form. Can map to an existing user, create a new user + * or falls back to the current user in case of error with either of the previous + */ + function get_author_mapping() { + if ( ! isset( $_POST['imported_authors'] ) ) { + return; + } + + $create_users = $this->allow_create_users(); + + foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) { + // Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts. + $santized_old_login = sanitize_user( $old_login, true ); + $old_id = isset( $this->authors[ $old_login ]['author_id'] ) ? intval( $this->authors[ $old_login ]['author_id'] ) : false; + + if ( ! empty( $_POST['user_map'][ $i ] ) ) { + $user = get_userdata( intval( $_POST['user_map'][ $i ] ) ); + if ( isset( $user->ID ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user->ID; + } + $this->author_mapping[ $santized_old_login ] = $user->ID; + } + } elseif ( $create_users ) { + if ( ! empty( $_POST['user_new'][ $i ] ) ) { + $user_id = wp_create_user( $_POST['user_new'][ $i ], wp_generate_password() ); + } elseif ( '1.0' != $this->version ) { + $user_data = array( + 'user_login' => $old_login, + 'user_pass' => wp_generate_password(), + 'user_email' => isset( $this->authors[ $old_login ]['author_email'] ) ? $this->authors[ $old_login ]['author_email'] : '', + 'display_name' => $this->authors[ $old_login ]['author_display_name'], + 'first_name' => isset( $this->authors[ $old_login ]['author_first_name'] ) ? $this->authors[ $old_login ]['author_first_name'] : '', + 'last_name' => isset( $this->authors[ $old_login ]['author_last_name'] ) ? $this->authors[ $old_login ]['author_last_name'] : '', + ); + $user_id = wp_insert_user( $user_data ); + } + + if ( ! is_wp_error( $user_id ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = $user_id; + } + $this->author_mapping[ $santized_old_login ] = $user_id; + } else { + printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $this->authors[ $old_login ]['author_display_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ' ' . $user_id->get_error_message(); + } + echo '
'; + } + } + + // failsafe: if the user_id was invalid, default to the current user + if ( ! isset( $this->author_mapping[ $santized_old_login ] ) ) { + if ( $old_id ) { + $this->processed_authors[ $old_id ] = (int) get_current_user_id(); + } + $this->author_mapping[ $santized_old_login ] = (int) get_current_user_id(); + } + } + } + + /** + * Create new categories based on import information + * + * Doesn't create a new category if its slug already exists + */ + function process_categories() { + $this->categories = apply_filters( 'wp_import_categories', $this->categories ); + + if ( empty( $this->categories ) ) { + return; + } + + foreach ( $this->categories as $cat ) { + // if the category already exists leave it alone + $term_id = term_exists( $cat['category_nicename'], 'category' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $parent = empty( $cat['category_parent'] ) ? 0 : category_exists( $cat['category_parent'] ); + $description = isset( $cat['category_description'] ) ? $cat['category_description'] : ''; + + $data = array( + 'category_nicename' => $cat['category_nicename'], + 'category_parent' => $parent, + 'cat_name' => wp_slash( $cat['cat_name'] ), + 'category_description' => wp_slash( $description ), + ); + + $id = wp_insert_category( $data, true ); + if ( ! is_wp_error( $id ) && $id > 0 ) { + if ( isset( $cat['term_id'] ) ) { + $this->processed_terms[ intval( $cat['term_id'] ) ] = $id; + } + } else { + printf( __( 'Failed to import category %s', 'wordpress-importer' ), esc_html( $cat['category_nicename'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $cat, $id ); + } + + unset( $this->categories ); + } + + /** + * Create new post tags based on import information + * + * Doesn't create a tag if its slug already exists + */ + function process_tags() { + $this->tags = apply_filters( 'wp_import_tags', $this->tags ); + + if ( empty( $this->tags ) ) { + return; + } + + foreach ( $this->tags as $tag ) { + // if the tag already exists leave it alone + $term_id = term_exists( $tag['tag_slug'], 'post_tag' ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = (int) $term_id; + } + continue; + } + + $description = isset( $tag['tag_description'] ) ? $tag['tag_description'] : ''; + $args = array( + 'slug' => $tag['tag_slug'], + 'description' => wp_slash( $description ), + ); + + $id = wp_insert_term( wp_slash( $tag['tag_name'] ), 'post_tag', $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $tag['term_id'] ) ) { + $this->processed_terms[ intval( $tag['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import post tag %s', 'wordpress-importer' ), esc_html( $tag['tag_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $tag, $id['term_id'] ); + } + + unset( $this->tags ); + } + + /** + * Create new terms based on import information + * + * Doesn't create a term its slug already exists + */ + function process_terms() { + $this->terms = apply_filters( 'wp_import_terms', $this->terms ); + + if ( empty( $this->terms ) ) { + return; + } + + foreach ( $this->terms as $term ) { + // if the term already exists in the correct taxonomy leave it alone + $term_id = term_exists( $term['slug'], $term['term_taxonomy'] ); + if ( $term_id ) { + if ( is_array( $term_id ) ) { + $term_id = $term_id['term_id']; + } + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = (int) $term_id; + } + continue; + } + + if ( empty( $term['term_parent'] ) ) { + $parent = 0; + } else { + $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] ); + if ( is_array( $parent ) ) { + $parent = $parent['term_id']; + } + } + + $description = isset( $term['term_description'] ) ? $term['term_description'] : ''; + $args = array( + 'slug' => $term['slug'], + 'description' => wp_slash( $description ), + 'parent' => (int) $parent, + ); + + $id = wp_insert_term( wp_slash( $term['term_name'] ), $term['term_taxonomy'], $args ); + if ( ! is_wp_error( $id ) ) { + if ( isset( $term['term_id'] ) ) { + $this->processed_terms[ intval( $term['term_id'] ) ] = $id['term_id']; + } + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $term['term_taxonomy'] ), esc_html( $term['term_name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $id->get_error_message(); + } + echo '
'; + continue; + } + + $this->process_termmeta( $term, $id['term_id'] ); + } + + unset( $this->terms ); + } + + /** + * Add metadata to imported term. + * + * @since 0.6.2 + * + * @param array $term Term data from WXR import. + * @param int $term_id ID of the newly created term. + */ + protected function process_termmeta( $term, $term_id ) { + if ( ! isset( $term['termmeta'] ) ) { + $term['termmeta'] = array(); + } + + /** + * Filters the metadata attached to an imported term. + * + * @since 0.6.2 + * + * @param array $termmeta Array of term meta. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term ); + + if ( empty( $term['termmeta'] ) ) { + return; + } + + foreach ( $term['termmeta'] as $meta ) { + /** + * Filters the meta key for an imported piece of term meta. + * + * @since 0.6.2 + * + * @param string $meta_key Meta key. + * @param int $term_id ID of the newly created term. + * @param array $term Term data from the WXR import. + */ + $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term ); + if ( ! $key ) { + continue; + } + + // Export gets meta straight from the DB so could have a serialized string + $value = maybe_unserialize( $meta['value'] ); + + add_term_meta( $term_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + /** + * Fires after term meta is imported. + * + * @since 0.6.2 + * + * @param int $term_id ID of the newly created term. + * @param string $key Meta key. + * @param mixed $value Meta value. + */ + do_action( 'import_term_meta', $term_id, $key, $value ); + } + } + + /** + * Create new posts based on import information + * + * Posts marked as having a parent which doesn't exist will become top level items. + * Doesn't create a new post if: the post type doesn't exist, the given post ID + * is already noted as imported or a post with the same title and date already exists. + * Note that new/updated terms, comments and meta are imported for the last of the above. + */ + function process_posts() { + $this->posts = apply_filters( 'wp_import_posts', $this->posts ); + + foreach ( $this->posts as $post ) { + $post = apply_filters( 'wp_import_post_data_raw', $post ); + + if ( ! post_type_exists( $post['post_type'] ) ) { + printf( + __( 'Failed to import “%1$s”: Invalid post type %2$s', 'wordpress-importer' ), + esc_html( $post['post_title'] ), + esc_html( $post['post_type'] ) + ); + echo '
'; + do_action( 'wp_import_post_exists', $post ); + continue; + } + + if ( isset( $this->processed_posts[ $post['post_id'] ] ) && ! empty( $post['post_id'] ) ) { + continue; + } + + if ( 'auto-draft' == $post['status'] ) { + continue; + } + + if ( 'nav_menu_item' == $post['post_type'] ) { + $this->process_menu_item( $post ); + continue; + } + + $post_type_object = get_post_type_object( $post['post_type'] ); + + $post_exists = post_exists( $post['post_title'], '', $post['post_date'] ); + + /** + * Filter ID of the existing post corresponding to post currently importing. + * + * Return 0 to force the post to be imported. Filter the ID to be something else + * to override which existing post is mapped to the imported post. + * + * @see post_exists() + * @since 0.6.2 + * + * @param int $post_exists Post ID, or 0 if post did not exist. + * @param array $post The post array to be inserted. + */ + $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post ); + + if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) { + printf( __( '%1$s “%2$s” already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) ); + echo '
'; + $comment_post_id = $post_exists; + $post_id = $post_exists; + $this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists ); + } else { + $post_parent = (int) $post['post_parent']; + if ( $post_parent ) { + // if we already know the parent, map it to the new local ID + if ( isset( $this->processed_posts[ $post_parent ] ) ) { + $post_parent = $this->processed_posts[ $post_parent ]; + // otherwise record the parent for later + } else { + $this->post_orphans[ intval( $post['post_id'] ) ] = $post_parent; + $post_parent = 0; + } + } + + // map the post author + $author = sanitize_user( $post['post_author'], true ); + if ( isset( $this->author_mapping[ $author ] ) ) { + $author = $this->author_mapping[ $author ]; + } else { + $author = (int) get_current_user_id(); + } + + $postdata = array( + 'import_id' => $post['post_id'], + 'post_author' => $author, + 'post_date' => $post['post_date'], + 'post_date_gmt' => $post['post_date_gmt'], + 'post_content' => $post['post_content'], + 'post_excerpt' => $post['post_excerpt'], + 'post_title' => $post['post_title'], + 'post_status' => $post['status'], + 'post_name' => $post['post_name'], + 'comment_status' => $post['comment_status'], + 'ping_status' => $post['ping_status'], + 'guid' => $post['guid'], + 'post_parent' => $post_parent, + 'menu_order' => $post['menu_order'], + 'post_type' => $post['post_type'], + 'post_password' => $post['post_password'], + ); + + $original_post_id = $post['post_id']; + $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post ); + + $postdata = wp_slash( $postdata ); + + if ( 'attachment' == $postdata['post_type'] ) { + $remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid']; + + // try to use _wp_attached file for upload folder placement to ensure the same location as the export site + // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload() + $postdata['upload_date'] = $post['post_date']; + if ( isset( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + if ( '_wp_attached_file' == $meta['key'] ) { + if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) { + $postdata['upload_date'] = $matches[0]; + } + break; + } + } + } + + $comment_post_id = $this->process_attachment( $postdata, $remote_url ); + $post_id = $comment_post_id; + } else { + $comment_post_id = wp_insert_post( $postdata, true ); + $post_id = $comment_post_id; + do_action( 'wp_import_insert_post', $post_id, $original_post_id, $postdata, $post ); + } + + if ( is_wp_error( $post_id ) ) { + printf( + __( 'Failed to import %1$s “%2$s”', 'wordpress-importer' ), + $post_type_object->labels->singular_name, + esc_html( $post['post_title'] ) + ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $post_id->get_error_message(); + } + echo '
'; + continue; + } + + if ( 1 == $post['is_sticky'] ) { + stick_post( $post_id ); + } + } + + // map pre-import ID to local ID + $this->processed_posts[ intval( $post['post_id'] ) ] = (int) $post_id; + + if ( ! isset( $post['terms'] ) ) { + $post['terms'] = array(); + } + + $post['terms'] = apply_filters( 'wp_import_post_terms', $post['terms'], $post_id, $post ); + + // add categories, tags and other terms + if ( ! empty( $post['terms'] ) ) { + $terms_to_set = array(); + foreach ( $post['terms'] as $term ) { + // back compat with WXR 1.0 map 'tag' to 'post_tag' + $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain']; + $term_exists = term_exists( $term['slug'], $taxonomy ); + $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists; + if ( ! $term_id ) { + $t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) ); + if ( ! is_wp_error( $t ) ) { + $term_id = $t['term_id']; + do_action( 'wp_import_insert_term', $t, $term, $post_id, $post ); + } else { + printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term['name'] ) ); + if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo ': ' . $t->get_error_message(); + } + echo '
'; + do_action( 'wp_import_insert_term_failed', $t, $term, $post_id, $post ); + continue; + } + } + $terms_to_set[ $taxonomy ][] = intval( $term_id ); + } + + foreach ( $terms_to_set as $tax => $ids ) { + $tt_ids = wp_set_post_terms( $post_id, $ids, $tax ); + do_action( 'wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post ); + } + unset( $post['terms'], $terms_to_set ); + } + + if ( ! isset( $post['comments'] ) ) { + $post['comments'] = array(); + } + + $post['comments'] = apply_filters( 'wp_import_post_comments', $post['comments'], $post_id, $post ); + + // add/update comments + if ( ! empty( $post['comments'] ) ) { + $num_comments = 0; + $inserted_comments = array(); + foreach ( $post['comments'] as $comment ) { + $comment_id = $comment['comment_id']; + $newcomments[ $comment_id ]['comment_post_ID'] = $comment_post_id; + $newcomments[ $comment_id ]['comment_author'] = $comment['comment_author']; + $newcomments[ $comment_id ]['comment_author_email'] = $comment['comment_author_email']; + $newcomments[ $comment_id ]['comment_author_IP'] = $comment['comment_author_IP']; + $newcomments[ $comment_id ]['comment_author_url'] = $comment['comment_author_url']; + $newcomments[ $comment_id ]['comment_date'] = $comment['comment_date']; + $newcomments[ $comment_id ]['comment_date_gmt'] = $comment['comment_date_gmt']; + $newcomments[ $comment_id ]['comment_content'] = $comment['comment_content']; + $newcomments[ $comment_id ]['comment_approved'] = $comment['comment_approved']; + $newcomments[ $comment_id ]['comment_type'] = $comment['comment_type']; + $newcomments[ $comment_id ]['comment_parent'] = $comment['comment_parent']; + $newcomments[ $comment_id ]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array(); + if ( isset( $this->processed_authors[ $comment['comment_user_id'] ] ) ) { + $newcomments[ $comment_id ]['user_id'] = $this->processed_authors[ $comment['comment_user_id'] ]; + } + } + ksort( $newcomments ); + + foreach ( $newcomments as $key => $comment ) { + // if this is a new post we can skip the comment_exists() check + if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) { + if ( isset( $inserted_comments[ $comment['comment_parent'] ] ) ) { + $comment['comment_parent'] = $inserted_comments[ $comment['comment_parent'] ]; + } + + $comment_data = wp_slash( $comment ); + unset( $comment_data['commentmeta'] ); // Handled separately, wp_insert_comment() also expects `comment_meta`. + $comment_data = wp_filter_comment( $comment_data ); + + $inserted_comments[ $key ] = wp_insert_comment( $comment_data ); + + do_action( 'wp_import_insert_comment', $inserted_comments[ $key ], $comment, $comment_post_id, $post ); + + foreach ( $comment['commentmeta'] as $meta ) { + $value = maybe_unserialize( $meta['value'] ); + + add_comment_meta( $inserted_comments[ $key ], wp_slash( $meta['key'] ), wp_slash_strings_only( $value ) ); + } + + $num_comments++; + } + } + unset( $newcomments, $inserted_comments, $post['comments'] ); + } + + if ( ! isset( $post['postmeta'] ) ) { + $post['postmeta'] = array(); + } + + $post['postmeta'] = apply_filters( 'wp_import_post_meta', $post['postmeta'], $post_id, $post ); + + // add/update post meta + if ( ! empty( $post['postmeta'] ) ) { + foreach ( $post['postmeta'] as $meta ) { + $key = apply_filters( 'import_post_meta_key', $meta['key'], $post_id, $post ); + $value = false; + + if ( '_edit_last' == $key ) { + if ( isset( $this->processed_authors[ intval( $meta['value'] ) ] ) ) { + $value = $this->processed_authors[ intval( $meta['value'] ) ]; + } else { + $key = false; + } + } + + if ( $key ) { + // export gets meta straight from the DB so could have a serialized string + if ( ! $value ) { + $value = maybe_unserialize( $meta['value'] ); + } + + add_post_meta( $post_id, wp_slash( $key ), wp_slash_strings_only( $value ) ); + + do_action( 'import_post_meta', $post_id, $key, $value ); + + // if the post has a featured image, take note of this in case of remap + if ( '_thumbnail_id' == $key ) { + $this->featured_images[ $post_id ] = (int) $value; + } + } + } + } + } + + unset( $this->posts ); + } + + /** + * Attempt to create a new menu item from import data + * + * Fails for draft, orphaned menu items and those without an associated nav_menu + * or an invalid nav_menu term. If the post type or term object which the menu item + * represents doesn't exist then the menu item will not be imported (waits until the + * end of the import to retry again before discarding). + * + * @param array $item Menu item details from WXR file + */ + function process_menu_item( $item ) { + // skip draft, orphaned menu items + if ( 'draft' == $item['status'] ) { + return; + } + + $menu_slug = false; + if ( isset( $item['terms'] ) ) { + // loop through terms, assume first nav_menu term is correct menu + foreach ( $item['terms'] as $term ) { + if ( 'nav_menu' == $term['domain'] ) { + $menu_slug = $term['slug']; + break; + } + } + } + + // no nav_menu term associated with this menu item + if ( ! $menu_slug ) { + _e( 'Menu item skipped due to missing menu slug', 'wordpress-importer' ); + echo '
'; + return; + } + + $menu_id = term_exists( $menu_slug, 'nav_menu' ); + if ( ! $menu_id ) { + printf( __( 'Menu item skipped due to invalid menu slug: %s', 'wordpress-importer' ), esc_html( $menu_slug ) ); + echo '
'; + return; + } else { + $menu_id = is_array( $menu_id ) ? $menu_id['term_id'] : $menu_id; + } + + foreach ( $item['postmeta'] as $meta ) { + ${$meta['key']} = $meta['value']; + } + + if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_terms[ intval( $_menu_item_object_id ) ]; + } elseif ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[ intval( $_menu_item_object_id ) ] ) ) { + $_menu_item_object_id = $this->processed_posts[ intval( $_menu_item_object_id ) ]; + } elseif ( 'custom' != $_menu_item_type ) { + // associated object is missing or not imported yet, we'll retry later + $this->missing_menu_items[] = $item; + return; + } + + if ( isset( $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ] ) ) { + $_menu_item_menu_item_parent = $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ]; + } elseif ( $_menu_item_menu_item_parent ) { + $this->menu_item_orphans[ intval( $item['post_id'] ) ] = (int) $_menu_item_menu_item_parent; + $_menu_item_menu_item_parent = 0; + } + + // wp_update_nav_menu_item expects CSS classes as a space separated string + $_menu_item_classes = maybe_unserialize( $_menu_item_classes ); + if ( is_array( $_menu_item_classes ) ) { + $_menu_item_classes = implode( ' ', $_menu_item_classes ); + } + + $args = array( + 'menu-item-object-id' => $_menu_item_object_id, + 'menu-item-object' => $_menu_item_object, + 'menu-item-parent-id' => $_menu_item_menu_item_parent, + 'menu-item-position' => intval( $item['menu_order'] ), + 'menu-item-type' => $_menu_item_type, + 'menu-item-title' => $item['post_title'], + 'menu-item-url' => $_menu_item_url, + 'menu-item-description' => $item['post_content'], + 'menu-item-attr-title' => $item['post_excerpt'], + 'menu-item-target' => $_menu_item_target, + 'menu-item-classes' => $_menu_item_classes, + 'menu-item-xfn' => $_menu_item_xfn, + 'menu-item-status' => $item['status'], + ); + + $id = wp_update_nav_menu_item( $menu_id, 0, $args ); + if ( $id && ! is_wp_error( $id ) ) { + $this->processed_menu_items[ intval( $item['post_id'] ) ] = (int) $id; + } + } + + /** + * If fetching attachments is enabled then attempt to create a new attachment + * + * @param array $post Attachment post details from WXR + * @param string $url URL to fetch attachment from + * @return int|WP_Error Post ID on success, WP_Error otherwise + */ + function process_attachment( $post, $url ) { + if ( ! $this->fetch_attachments ) { + return new WP_Error( + 'attachment_processing_error', + __( 'Fetching attachments is not enabled', 'wordpress-importer' ) + ); + } + + // if the URL is absolute, but does not contain address, then upload it assuming base_site_url + if ( preg_match( '|^/[\w\W]+$|', $url ) ) { + $url = rtrim( $this->base_url, '/' ) . $url; + } + + $upload = $this->fetch_remote_file( $url, $post ); + if ( is_wp_error( $upload ) ) { + return $upload; + } + + $info = wp_check_filetype( $upload['file'] ); + if ( $info ) { + $post['post_mime_type'] = $info['type']; + } else { + return new WP_Error( 'attachment_processing_error', __( 'Invalid file type', 'wordpress-importer' ) ); + } + + $post['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment( $post, $upload['file'] ); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap resized image URLs, works by stripping the extension and remapping the URL stub. + if ( preg_match( '!^image/!', $info['type'] ) ) { + $parts = pathinfo( $url ); + $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2 + + $parts_new = pathinfo( $upload['url'] ); + $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" ); + + $this->url_remap[ $parts['dirname'] . '/' . $name ] = $parts_new['dirname'] . '/' . $name_new; + } + + return $post_id; + } + + /** + * Attempt to download a remote file attachment + * + * @param string $url URL of item to fetch + * @param array $post Attachment details + * @return array|WP_Error Local file location details on success, WP_Error otherwise + */ + function fetch_remote_file( $url, $post ) { + // Extract the file name from the URL. + $path = parse_url( $url, PHP_URL_PATH ); + $file_name = ''; + if ( is_string( $path ) ) { + $file_name = basename( $path ); + } + + if ( ! $file_name ) { + $file_name = md5( $url ); + } + + $tmp_file_name = wp_tempnam( $file_name ); + if ( ! $tmp_file_name ) { + return new WP_Error( 'import_no_file', __( 'Could not create temporary file.', 'wordpress-importer' ) ); + } + + // Fetch the remote URL and write it to the placeholder file. + $remote_response = wp_safe_remote_get( + $url, + array( + 'timeout' => 300, + 'stream' => true, + 'filename' => $tmp_file_name, + 'headers' => array( + 'Accept-Encoding' => 'identity', + ), + ) + ); + + if ( is_wp_error( $remote_response ) ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The WordPress error message. 2: The WordPress error code. */ + __( 'Request failed due to an error: %1$s (%2$s)', 'wordpress-importer' ), + esc_html( $remote_response->get_error_message() ), + esc_html( $remote_response->get_error_code() ) + ) + ); + } + + $remote_response_code = (int) wp_remote_retrieve_response_code( $remote_response ); + + // Make sure the fetch was successful. + if ( 200 !== $remote_response_code ) { + @unlink( $tmp_file_name ); + return new WP_Error( + 'import_file_error', + sprintf( + /* translators: 1: The HTTP error message. 2: The HTTP error code. */ + __( 'Remote server returned the following unexpected result: %1$s (%2$s)', 'wordpress-importer' ), + get_status_header_desc( $remote_response_code ), + esc_html( $remote_response_code ) + ) + ); + } + + $headers = wp_remote_retrieve_headers( $remote_response ); + + // Request failed. + if ( ! $headers ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Remote server did not respond', 'wordpress-importer' ) ); + } + + $filesize = (int) filesize( $tmp_file_name ); + + if ( 0 === $filesize ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) ); + } + + if ( ! isset( $headers['content-encoding'] ) && isset( $headers['content-length'] ) && $filesize !== (int) $headers['content-length'] ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'Downloaded file has incorrect size', 'wordpress-importer' ) ); + } + + $max_size = (int) $this->max_attachment_size(); + if ( ! empty( $max_size ) && $filesize > $max_size ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) ) ); + } + + // Override file name with Content-Disposition header value. + if ( ! empty( $headers['content-disposition'] ) ) { + $file_name_from_disposition = self::get_filename_from_disposition( (array) $headers['content-disposition'] ); + if ( $file_name_from_disposition ) { + $file_name = $file_name_from_disposition; + } + } + + // Set file extension if missing. + $file_ext = pathinfo( $file_name, PATHINFO_EXTENSION ); + if ( ! $file_ext && ! empty( $headers['content-type'] ) ) { + $extension = self::get_file_extension_by_mime_type( $headers['content-type'] ); + if ( $extension ) { + $file_name = "{$file_name}.{$extension}"; + } + } + + // Handle the upload like _wp_handle_upload() does. + $wp_filetype = wp_check_filetype_and_ext( $tmp_file_name, $file_name ); + $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; + $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; + $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; + + // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect. + if ( $proper_filename ) { + $file_name = $proper_filename; + } + + if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) { + return new WP_Error( 'import_file_error', __( 'Sorry, this file type is not permitted for security reasons.', 'wordpress-importer' ) ); + } + + $uploads = wp_upload_dir( $post['upload_date'] ); + if ( ! ( $uploads && false === $uploads['error'] ) ) { + return new WP_Error( 'upload_dir_error', $uploads['error'] ); + } + + // Move the file to the uploads dir. + $file_name = wp_unique_filename( $uploads['path'], $file_name ); + $new_file = $uploads['path'] . "/$file_name"; + $move_new_file = copy( $tmp_file_name, $new_file ); + + if ( ! $move_new_file ) { + @unlink( $tmp_file_name ); + return new WP_Error( 'import_file_error', __( 'The uploaded file could not be moved', 'wordpress-importer' ) ); + } + + // Set correct file permissions. + $stat = stat( dirname( $new_file ) ); + $perms = $stat['mode'] & 0000666; + chmod( $new_file, $perms ); + + $upload = array( + 'file' => $new_file, + 'url' => $uploads['url'] . "/$file_name", + 'type' => $wp_filetype['type'], + 'error' => false, + ); + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[ $url ] = $upload['url']; + $this->url_remap[ $post['guid'] ] = $upload['url']; // r13735, really needed? + // keep track of the destination if the remote url is redirected somewhere else + if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) { + $this->url_remap[ $headers['x-final-location'] ] = $upload['url']; + } + + return $upload; + } + + /** + * Attempt to associate posts and menu items with previously missing parents + * + * An imported post's parent may not have been imported when it was first created + * so try again. Similarly for child menu items and menu items which were missing + * the object (e.g. post) they represent in the menu + */ + function backfill_parents() { + global $wpdb; + + // find parents for post orphans + foreach ( $this->post_orphans as $child_id => $parent_id ) { + $local_child_id = false; + $local_parent_id = false; + if ( isset( $this->processed_posts[ $child_id ] ) ) { + $local_child_id = $this->processed_posts[ $child_id ]; + } + if ( isset( $this->processed_posts[ $parent_id ] ) ) { + $local_parent_id = $this->processed_posts[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + $wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' ); + clean_post_cache( $local_child_id ); + } + } + + // all other posts/terms are imported, retry menu items with missing associated object + $missing_menu_items = $this->missing_menu_items; + foreach ( $missing_menu_items as $item ) { + $this->process_menu_item( $item ); + } + + // find parents for menu item orphans + foreach ( $this->menu_item_orphans as $child_id => $parent_id ) { + $local_child_id = 0; + $local_parent_id = 0; + if ( isset( $this->processed_menu_items[ $child_id ] ) ) { + $local_child_id = $this->processed_menu_items[ $child_id ]; + } + if ( isset( $this->processed_menu_items[ $parent_id ] ) ) { + $local_parent_id = $this->processed_menu_items[ $parent_id ]; + } + + if ( $local_child_id && $local_parent_id ) { + update_post_meta( $local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id ); + } + } + } + + /** + * Use stored mapping information to update old attachment URLs + */ + function backfill_attachment_urls() { + global $wpdb; + // make sure we do the longest urls first, in case one is a substring of another + uksort( $this->url_remap, array( &$this, 'cmpr_strlen' ) ); + + foreach ( $this->url_remap as $from_url => $to_url ) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url ) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url ) ); + } + } + + /** + * Update _thumbnail_id meta to new, imported attachment IDs + */ + function remap_featured_images() { + // cycle through posts that have a featured image + foreach ( $this->featured_images as $post_id => $value ) { + if ( isset( $this->processed_posts[ $value ] ) ) { + $new_id = $this->processed_posts[ $value ]; + // only update if there's a difference + if ( $new_id != $value ) { + update_post_meta( $post_id, '_thumbnail_id', $new_id ); + } + } + } + } + + /** + * Parse a WXR file + * + * @param string $file Path to WXR file for parsing + * @return array Information gathered from the WXR file + */ + function parse( $file ) { + $parser = new WXR_Parser(); + return $parser->parse( $file ); + } + + // Display import page title + function header() { + echo '
'; + echo '

' . __( 'Import WordPress', 'wordpress-importer' ) . '

'; + + $updates = get_plugin_updates(); + $basename = plugin_basename( __FILE__ ); + if ( isset( $updates[ $basename ] ) ) { + $update = $updates[ $basename ]; + echo '

'; + printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version ); + echo '

'; + } + } + + // Close div.wrap + function footer() { + echo '
'; + } + + /** + * Display introductory text and file upload form + */ + function greet() { + echo '
'; + echo '

' . __( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ) . '

'; + echo '

' . __( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ) . '

'; + wp_import_upload_form( 'admin.php?import=wordpress&step=1' ); + echo '
'; + } + + /** + * Decide if the given meta key maps to information we will want to import + * + * @param string $key The meta key to check + * @return string|bool The key if we do want to import, false if not + */ + function is_valid_meta_key( $key ) { + // skip attachment metadata since we'll regenerate it from scratch + // skip _edit_lock as not relevant for import + if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ), true ) ) { + return false; + } + return $key; + } + + /** + * Decide whether or not the importer is allowed to create users. + * Default is true, can be filtered via import_allow_create_users + * + * @return bool True if creating users is allowed + */ + function allow_create_users() { + return apply_filters( 'import_allow_create_users', true ); + } + + /** + * Decide whether or not the importer should attempt to download attachment files. + * Default is true, can be filtered via import_allow_fetch_attachments. The choice + * made at the import options screen must also be true, false here hides that checkbox. + * + * @return bool True if downloading attachments is allowed + */ + function allow_fetch_attachments() { + return apply_filters( 'import_allow_fetch_attachments', true ); + } + + /** + * Decide what the maximum file size for downloaded attachments is. + * Default is 0 (unlimited), can be filtered via import_attachment_size_limit + * + * @return int Maximum attachment file size to import + */ + function max_attachment_size() { + return apply_filters( 'import_attachment_size_limit', 0 ); + } + + /** + * Added to http_request_timeout filter to force timeout at 60 seconds during import + * @return int 60 + */ + function bump_request_timeout( $val ) { + return 60; + } + + // return the difference in length between two strings + function cmpr_strlen( $a, $b ) { + return strlen( $b ) - strlen( $a ); + } + + /** + * Parses filename from a Content-Disposition header value. + * + * As per RFC6266: + * + * content-disposition = "Content-Disposition" ":" + * disposition-type *( ";" disposition-parm ) + * + * disposition-type = "inline" | "attachment" | disp-ext-type + * ; case-insensitive + * disp-ext-type = token + * + * disposition-parm = filename-parm | disp-ext-parm + * + * filename-parm = "filename" "=" value + * | "filename*" "=" ext-value + * + * disp-ext-parm = token "=" value + * | ext-token "=" ext-value + * ext-token = + * + * @since 0.7.0 + * + * @see WP_REST_Attachments_Controller::get_filename_from_disposition() + * + * @link http://tools.ietf.org/html/rfc2388 + * @link http://tools.ietf.org/html/rfc6266 + * + * @param string[] $disposition_header List of Content-Disposition header values. + * @return string|null Filename if available, or null if not found. + */ + protected static function get_filename_from_disposition( $disposition_header ) { + // Get the filename. + $filename = null; + + foreach ( $disposition_header as $value ) { + $value = trim( $value ); + + if ( strpos( $value, ';' ) === false ) { + continue; + } + + list( $type, $attr_parts ) = explode( ';', $value, 2 ); + + $attr_parts = explode( ';', $attr_parts ); + $attributes = array(); + + foreach ( $attr_parts as $part ) { + if ( strpos( $part, '=' ) === false ) { + continue; + } + + list( $key, $value ) = explode( '=', $part, 2 ); + + $attributes[ trim( $key ) ] = trim( $value ); + } + + if ( empty( $attributes['filename'] ) ) { + continue; + } + + $filename = trim( $attributes['filename'] ); + + // Unquote quoted filename, but after trimming. + if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) { + $filename = substr( $filename, 1, -1 ); + } + } + + return $filename; + } + + /** + * Retrieves file extension by mime type. + * + * @since 0.7.0 + * + * @param string $mime_type Mime type to search extension for. + * @return string|null File extension if available, or null if not found. + */ + protected static function get_file_extension_by_mime_type( $mime_type ) { + static $map = null; + + if ( is_array( $map ) ) { + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } + + $mime_types = wp_get_mime_types(); + $map = array_flip( $mime_types ); + + // Some types have multiple extensions, use only the first one. + foreach ( $map as $type => $extensions ) { + $map[ $type ] = strtok( $extensions, '|' ); + } + + return isset( $map[ $mime_type ] ) ? $map[ $mime_type ] : null; + } +} +has_gzip = is_callable( 'gzopen' ); + } + + function parse( $file ) { + $wxr_version = false; + $in_multiline = false; + + $multiline_content = ''; + + $multiline_tags = array( + 'item' => array( 'posts', array( $this, 'process_post' ) ), + 'wp:category' => array( 'categories', array( $this, 'process_category' ) ), + 'wp:tag' => array( 'tags', array( $this, 'process_tag' ) ), + 'wp:term' => array( 'terms', array( $this, 'process_term' ) ), + ); + + $fp = $this->fopen( $file, 'r' ); + if ( $fp ) { + while ( ! $this->feof( $fp ) ) { + $is_tag_line = false; + $importline = rtrim( $this->fgets( $fp ) ); + + if ( ! $wxr_version && preg_match( '|(\d+\.\d+)|', $importline, $version ) ) { + $wxr_version = $version[1]; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $url ); + $this->base_url = $url[1]; + continue; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $blog_url ); + $this->base_blog_url = $blog_url[1]; + continue; + } elseif ( empty( $this->base_blog_url ) ) { + $this->base_blog_url = $this->base_url; + } + + if ( false !== strpos( $importline, '' ) ) { + preg_match( '|(.*?)|is', $importline, $author ); + $a = $this->process_author( $author[1] ); + $this->authors[ $a['author_login'] ] = $a; + continue; + } + + foreach ( $multiline_tags as $tag => $handler ) { + // Handle multi-line tags on a singular line + $pos = strpos( $importline, "<$tag>" ); + $pos_closing = strpos( $importline, "" ); + if ( preg_match( '|<' . $tag . '>(.*?)|is', $importline, $matches ) ) { + $this->{$handler[0]}[] = call_user_func( $handler[1], $matches[1] ); + + } elseif ( false !== $pos ) { + // Take note of any content after the opening tag + $multiline_content = trim( substr( $importline, $pos + strlen( $tag ) + 2 ) ); + + // We don't want to have this line added to `$is_multiline` below. + $in_multiline = $tag; + $is_tag_line = true; + + } elseif ( false !== $pos_closing ) { + $in_multiline = false; + $multiline_content .= trim( substr( $importline, 0, $pos_closing ) ); + + $this->{$handler[0]}[] = call_user_func( $handler[1], $multiline_content ); + } + } + + if ( $in_multiline && ! $is_tag_line ) { + $multiline_content .= $importline . "\n"; + } + } + + $this->fclose( $fp ); + } + + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->categories, + 'tags' => $this->tags, + 'terms' => $this->terms, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $wxr_version, + ); + } + + function get_tag( $string, $tag ) { + preg_match( "|<$tag.*?>(.*?)|is", $string, $return ); + if ( isset( $return[1] ) ) { + if ( substr( $return[1], 0, 9 ) == '' ) !== false ) { + preg_match_all( '||s', $return[1], $matches ); + $return = ''; + foreach ( $matches[1] as $match ) { + $return .= $match; + } + } else { + $return = preg_replace( '|^$|s', '$1', $return[1] ); + } + } else { + $return = $return[1]; + } + } else { + $return = ''; + } + return $return; + } + + function process_category( $c ) { + $term = array( + 'term_id' => $this->get_tag( $c, 'wp:term_id' ), + 'cat_name' => $this->get_tag( $c, 'wp:cat_name' ), + 'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ), + 'category_parent' => $this->get_tag( $c, 'wp:category_parent' ), + 'category_description' => $this->get_tag( $c, 'wp:category_description' ), + ); + + $term_meta = $this->process_meta( $c, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_tag( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'tag_name' => $this->get_tag( $t, 'wp:tag_name' ), + 'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ), + 'tag_description' => $this->get_tag( $t, 'wp:tag_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_term( $t ) { + $term = array( + 'term_id' => $this->get_tag( $t, 'wp:term_id' ), + 'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ), + 'slug' => $this->get_tag( $t, 'wp:term_slug' ), + 'term_parent' => $this->get_tag( $t, 'wp:term_parent' ), + 'term_name' => $this->get_tag( $t, 'wp:term_name' ), + 'term_description' => $this->get_tag( $t, 'wp:term_description' ), + ); + + $term_meta = $this->process_meta( $t, 'wp:termmeta' ); + if ( ! empty( $term_meta ) ) { + $term['termmeta'] = $term_meta; + } + + return $term; + } + + function process_meta( $string, $tag ) { + $parsed_meta = array(); + + preg_match_all( "|<$tag>(.+?)|is", $string, $meta ); + + if ( ! isset( $meta[1] ) ) { + return $parsed_meta; + } + + foreach ( $meta[1] as $m ) { + $parsed_meta[] = array( + 'key' => $this->get_tag( $m, 'wp:meta_key' ), + 'value' => $this->get_tag( $m, 'wp:meta_value' ), + ); + } + + return $parsed_meta; + } + + function process_author( $a ) { + return array( + 'author_id' => $this->get_tag( $a, 'wp:author_id' ), + 'author_login' => $this->get_tag( $a, 'wp:author_login' ), + 'author_email' => $this->get_tag( $a, 'wp:author_email' ), + 'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ), + 'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ), + 'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ), + ); + } + + function process_post( $post ) { + $post_id = $this->get_tag( $post, 'wp:post_id' ); + $post_title = $this->get_tag( $post, 'title' ); + $post_date = $this->get_tag( $post, 'wp:post_date' ); + $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); + $comment_status = $this->get_tag( $post, 'wp:comment_status' ); + $ping_status = $this->get_tag( $post, 'wp:ping_status' ); + $status = $this->get_tag( $post, 'wp:status' ); + $post_name = $this->get_tag( $post, 'wp:post_name' ); + $post_parent = $this->get_tag( $post, 'wp:post_parent' ); + $menu_order = $this->get_tag( $post, 'wp:menu_order' ); + $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); + $is_sticky = $this->get_tag( $post, 'wp:is_sticky' ); + $guid = $this->get_tag( $post, 'guid' ); + $post_author = $this->get_tag( $post, 'dc:creator' ); + + $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); + $post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + $post_excerpt = str_replace( '
', '
', $post_excerpt ); + + $post_content = $this->get_tag( $post, 'content:encoded' ); + $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + $post_content = str_replace( '
', '
', $post_content ); + + $postdata = compact( + 'post_id', + 'post_author', + 'post_date', + 'post_date_gmt', + 'post_content', + 'post_excerpt', + 'post_title', + 'status', + 'post_name', + 'comment_status', + 'ping_status', + 'guid', + 'post_parent', + 'menu_order', + 'post_type', + 'post_password', + 'is_sticky' + ); + + $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( $attachment_url ) { + $postdata['attachment_url'] = $attachment_url; + } + + preg_match_all( '|(.+?)|is', $post, $terms, PREG_SET_ORDER ); + foreach ( $terms as $t ) { + $post_terms[] = array( + 'slug' => $t[2], + 'domain' => $t[1], + 'name' => str_replace( array( '' ), '', $t[3] ), + ); + } + if ( ! empty( $post_terms ) ) { + $postdata['terms'] = $post_terms; + } + + preg_match_all( '|(.+?)|is', $post, $comments ); + $comments = $comments[1]; + if ( $comments ) { + foreach ( $comments as $comment ) { + $post_comments[] = array( + 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), + 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), + 'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ), + 'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ), + 'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ), + 'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ), + 'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ), + 'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ), + 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), + 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), + 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), + 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), + 'commentmeta' => $this->process_meta( $comment, 'wp:commentmeta' ), + ); + } + } + if ( ! empty( $post_comments ) ) { + $postdata['comments'] = $post_comments; + } + + $post_meta = $this->process_meta( $post, 'wp:postmeta' ); + if ( ! empty( $post_meta ) ) { + $postdata['postmeta'] = $post_meta; + } + + return $postdata; + } + + function _normalize_tag( $matches ) { + return '<' . strtolower( $matches[1] ); + } + + function fopen( $filename, $mode = 'r' ) { + if ( $this->has_gzip ) { + return gzopen( $filename, $mode ); + } + return fopen( $filename, $mode ); + } + + function feof( $fp ) { + if ( $this->has_gzip ) { + return gzeof( $fp ); + } + return feof( $fp ); + } + + function fgets( $fp, $len = 8192 ) { + if ( $this->has_gzip ) { + return gzgets( $fp, $len ); + } + return fgets( $fp, $len ); + } + + function fclose( $fp ) { + if ( $this->has_gzip ) { + return gzclose( $fp ); + } + return fclose( $fp ); + } +} +loadXML( file_get_contents( $file ) ); + if ( ! is_null( $old_value ) ) { + libxml_disable_entity_loader( $old_value ); + } + + if ( ! $success || isset( $dom->doctype ) ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $xml = simplexml_import_dom( $dom ); + unset( $dom ); + + // halt if loading produces an error + if ( ! $xml ) { + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); + } + + $wxr_version = $xml->xpath( '/rss/channel/wp:wxr_version' ); + if ( ! $wxr_version ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $wxr_version = (string) trim( $wxr_version[0] ); + // confirm that we are dealing with the correct file format + if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + $base_url = $xml->xpath( '/rss/channel/wp:base_site_url' ); + $base_url = (string) trim( isset( $base_url[0] ) ? $base_url[0] : '' ); + + $base_blog_url = $xml->xpath( '/rss/channel/wp:base_blog_url' ); + if ( $base_blog_url ) { + $base_blog_url = (string) trim( $base_blog_url[0] ); + } else { + $base_blog_url = $base_url; + } + + $namespaces = $xml->getDocNamespaces(); + if ( ! isset( $namespaces['wp'] ) ) { + $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; + } + if ( ! isset( $namespaces['excerpt'] ) ) { + $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; + } + + // grab authors + foreach ( $xml->xpath( '/rss/channel/wp:author' ) as $author_arr ) { + $a = $author_arr->children( $namespaces['wp'] ); + $login = (string) $a->author_login; + $authors[ $login ] = array( + 'author_id' => (int) $a->author_id, + 'author_login' => $login, + 'author_email' => (string) $a->author_email, + 'author_display_name' => (string) $a->author_display_name, + 'author_first_name' => (string) $a->author_first_name, + 'author_last_name' => (string) $a->author_last_name, + ); + } + + // grab cats, tags and terms + foreach ( $xml->xpath( '/rss/channel/wp:category' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $category = array( + 'term_id' => (int) $t->term_id, + 'category_nicename' => (string) $t->category_nicename, + 'category_parent' => (string) $t->category_parent, + 'cat_name' => (string) $t->cat_name, + 'category_description' => (string) $t->category_description, + ); + + foreach ( $t->termmeta as $meta ) { + $category['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $categories[] = $category; + } + + foreach ( $xml->xpath( '/rss/channel/wp:tag' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $tag = array( + 'term_id' => (int) $t->term_id, + 'tag_slug' => (string) $t->tag_slug, + 'tag_name' => (string) $t->tag_name, + 'tag_description' => (string) $t->tag_description, + ); + + foreach ( $t->termmeta as $meta ) { + $tag['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $tags[] = $tag; + } + + foreach ( $xml->xpath( '/rss/channel/wp:term' ) as $term_arr ) { + $t = $term_arr->children( $namespaces['wp'] ); + $term = array( + 'term_id' => (int) $t->term_id, + 'term_taxonomy' => (string) $t->term_taxonomy, + 'slug' => (string) $t->term_slug, + 'term_parent' => (string) $t->term_parent, + 'term_name' => (string) $t->term_name, + 'term_description' => (string) $t->term_description, + ); + + foreach ( $t->termmeta as $meta ) { + $term['termmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + $terms[] = $term; + } + + // grab posts + foreach ( $xml->channel->item as $item ) { + $post = array( + 'post_title' => (string) $item->title, + 'guid' => (string) $item->guid, + ); + + $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); + $post['post_author'] = (string) $dc->creator; + + $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' ); + $excerpt = $item->children( $namespaces['excerpt'] ); + $post['post_content'] = (string) $content->encoded; + $post['post_excerpt'] = (string) $excerpt->encoded; + + $wp = $item->children( $namespaces['wp'] ); + $post['post_id'] = (int) $wp->post_id; + $post['post_date'] = (string) $wp->post_date; + $post['post_date_gmt'] = (string) $wp->post_date_gmt; + $post['comment_status'] = (string) $wp->comment_status; + $post['ping_status'] = (string) $wp->ping_status; + $post['post_name'] = (string) $wp->post_name; + $post['status'] = (string) $wp->status; + $post['post_parent'] = (int) $wp->post_parent; + $post['menu_order'] = (int) $wp->menu_order; + $post['post_type'] = (string) $wp->post_type; + $post['post_password'] = (string) $wp->post_password; + $post['is_sticky'] = (int) $wp->is_sticky; + + if ( isset( $wp->attachment_url ) ) { + $post['attachment_url'] = (string) $wp->attachment_url; + } + + foreach ( $item->category as $c ) { + $att = $c->attributes(); + if ( isset( $att['nicename'] ) ) { + $post['terms'][] = array( + 'name' => (string) $c, + 'slug' => (string) $att['nicename'], + 'domain' => (string) $att['domain'], + ); + } + } + + foreach ( $wp->postmeta as $meta ) { + $post['postmeta'][] = array( + 'key' => (string) $meta->meta_key, + 'value' => (string) $meta->meta_value, + ); + } + + foreach ( $wp->comment as $comment ) { + $meta = array(); + if ( isset( $comment->commentmeta ) ) { + foreach ( $comment->commentmeta as $m ) { + $meta[] = array( + 'key' => (string) $m->meta_key, + 'value' => (string) $m->meta_value, + ); + } + } + + $post['comments'][] = array( + 'comment_id' => (int) $comment->comment_id, + 'comment_author' => (string) $comment->comment_author, + 'comment_author_email' => (string) $comment->comment_author_email, + 'comment_author_IP' => (string) $comment->comment_author_IP, + 'comment_author_url' => (string) $comment->comment_author_url, + 'comment_date' => (string) $comment->comment_date, + 'comment_date_gmt' => (string) $comment->comment_date_gmt, + 'comment_content' => (string) $comment->comment_content, + 'comment_approved' => (string) $comment->comment_approved, + 'comment_type' => (string) $comment->comment_type, + 'comment_parent' => (string) $comment->comment_parent, + 'comment_user_id' => (int) $comment->comment_user_id, + 'commentmeta' => $meta, + ); + } + + $posts[] = $post; + } + + return array( + 'authors' => $authors, + 'posts' => $posts, + 'categories' => $categories, + 'tags' => $tags, + 'terms' => $terms, + 'base_url' => $base_url, + 'base_blog_url' => $base_blog_url, + 'version' => $wxr_version, + ); + } +} +wxr_version = false; + $this->in_post = false; + $this->cdata = false; + $this->data = false; + $this->sub_data = false; + $this->in_tag = false; + $this->in_sub_tag = false; + $this->authors = array(); + $this->posts = array(); + $this->term = array(); + $this->category = array(); + $this->tag = array(); + + $xml = xml_parser_create( 'UTF-8' ); + xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 ); + xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 ); + xml_set_object( $xml, $this ); + xml_set_character_data_handler( $xml, 'cdata' ); + xml_set_element_handler( $xml, 'tag_open', 'tag_close' ); + + if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) { + $current_line = xml_get_current_line_number( $xml ); + $current_column = xml_get_current_column_number( $xml ); + $error_code = xml_get_error_code( $xml ); + $error_string = xml_error_string( $error_code ); + return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) ); + } + xml_parser_free( $xml ); + + if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) { + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); + } + + return array( + 'authors' => $this->authors, + 'posts' => $this->posts, + 'categories' => $this->category, + 'tags' => $this->tag, + 'terms' => $this->term, + 'base_url' => $this->base_url, + 'base_blog_url' => $this->base_blog_url, + 'version' => $this->wxr_version, + ); + } + + function tag_open( $parse, $tag, $attr ) { + if ( in_array( $tag, $this->wp_tags, true ) ) { + $this->in_tag = substr( $tag, 3 ); + return; + } + + if ( in_array( $tag, $this->wp_sub_tags, true ) ) { + $this->in_sub_tag = substr( $tag, 3 ); + return; + } + + switch ( $tag ) { + case 'category': + if ( isset( $attr['domain'], $attr['nicename'] ) ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data['domain'] = $attr['domain']; + $this->sub_data['slug'] = $attr['nicename']; + } + break; + case 'item': + $this->in_post = true; + break; + case 'title': + if ( $this->in_post ) { + $this->in_tag = 'post_title'; + } + break; + case 'guid': + $this->in_tag = 'guid'; + break; + case 'dc:creator': + $this->in_tag = 'post_author'; + break; + case 'content:encoded': + $this->in_tag = 'post_content'; + break; + case 'excerpt:encoded': + $this->in_tag = 'post_excerpt'; + break; + + case 'wp:term_slug': + $this->in_tag = 'slug'; + break; + case 'wp:meta_key': + $this->in_sub_tag = 'key'; + break; + case 'wp:meta_value': + $this->in_sub_tag = 'value'; + break; + } + } + + function cdata( $parser, $cdata ) { + if ( ! trim( $cdata ) ) { + return; + } + + if ( false !== $this->in_tag || false !== $this->in_sub_tag ) { + $this->cdata .= $cdata; + } else { + $this->cdata .= trim( $cdata ); + } + } + + function tag_close( $parser, $tag ) { + switch ( $tag ) { + case 'wp:comment': + unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data + if ( ! empty( $this->sub_data ) ) { + $this->data['comments'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:commentmeta': + $this->sub_data['commentmeta'][] = array( + 'key' => $this->sub_data['key'], + 'value' => $this->sub_data['value'], + ); + break; + case 'category': + if ( ! empty( $this->sub_data ) ) { + $this->sub_data['name'] = $this->cdata; + $this->data['terms'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:postmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['postmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'item': + $this->posts[] = $this->data; + $this->data = false; + break; + case 'wp:category': + case 'wp:tag': + case 'wp:term': + $n = substr( $tag, 3 ); + array_push( $this->$n, $this->data ); + $this->data = false; + break; + case 'wp:termmeta': + if ( ! empty( $this->sub_data ) ) { + $this->data['termmeta'][] = $this->sub_data; + } + $this->sub_data = false; + break; + case 'wp:author': + if ( ! empty( $this->data['author_login'] ) ) { + $this->authors[ $this->data['author_login'] ] = $this->data; + } + $this->data = false; + break; + case 'wp:base_site_url': + $this->base_url = $this->cdata; + if ( ! isset( $this->base_blog_url ) ) { + $this->base_blog_url = $this->cdata; + } + break; + case 'wp:base_blog_url': + $this->base_blog_url = $this->cdata; + break; + case 'wp:wxr_version': + $this->wxr_version = $this->cdata; + break; + + default: + if ( $this->in_sub_tag ) { + if ( false === $this->sub_data ) { + $this->sub_data = array(); + } + + $this->sub_data[ $this->in_sub_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_sub_tag = false; + } elseif ( $this->in_tag ) { + if ( false === $this->data ) { + $this->data = array(); + } + + $this->data[ $this->in_tag ] = ! empty( $this->cdata ) ? $this->cdata : ''; + $this->in_tag = false; + } + } + + $this->cdata = false; + } +} +parse( $file ); + + // If SimpleXML succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) { + return $result; + } + } elseif ( extension_loaded( 'xml' ) ) { + $parser = new WXR_Parser_XML; + $result = $parser->parse( $file ); + + // If XMLParser succeeds or this is an invalid WXR file then return the results + if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) { + return $result; + } + } + + // We have a malformed XML file, so display the error and fallthrough to regex + if ( isset( $result ) && defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) { + echo '
';
+			if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
+				foreach ( $result->get_error_data() as $error ) {
+					echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
+				}
+			} elseif ( 'XML_parse_error' == $result->get_error_code() ) {
+				$error = $result->get_error_data();
+				echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
+			}
+			echo '
'; + echo '

' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '
'; + echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '

'; + } + + // use regular expressions if nothing else available or this is bad XML + $parser = new WXR_Parser_Regex; + return $parser->parse( $file ); + } +} +=== WordPress Importer === +Contributors: wordpressdotorg +Donate link: https://wordpressfoundation.org/donate/ +Tags: importer, wordpress +Requires at least: 5.2 +Tested up to: 6.1 +Requires PHP: 5.6 +Stable tag: 0.8 +License: GPLv2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html + +Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. + +== Description == + +The WordPress Importer will import the following content from a WordPress export file: + +* Posts, pages and other custom post types +* Comments and comment meta +* Custom fields and post meta +* Categories, tags and terms from custom taxonomies and term meta +* Authors + +For further information and instructions please see the [documention on Importing Content](https://wordpress.org/support/article/importing-content/#wordpress). + +== Installation == + +The quickest method for installing the importer is: + +1. Visit Tools -> Import in the WordPress dashboard +1. Click on the WordPress link in the list of importers +1. Click "Install Now" +1. Finally click "Activate Plugin & Run Importer" + +If you would prefer to do things manually then follow these instructions: + +1. Upload the `wordpress-importer` folder to the `/wp-content/plugins/` directory +1. Activate the plugin through the 'Plugins' menu in WordPress +1. Go to the Tools -> Import screen, click on WordPress + +== Changelog == + += 0.8 = +* Update minimum WordPress requirement to 5.2. +* Update minimum PHP requirement to 5.6. +* Update compatibility tested-up-to to WordPress 6.1. +* PHP 8.0, 8.1, and 8.2 compatibility fixes. +* Fix a bug causing blank lines in content to be ignored when using the Regex Parser. +* Fix a bug resulting in a PHP fatal error when IMPORT_DEBUG is enabled and a category creation error occurs. +* Improved Unit testing & automated testing. + += 0.7 = +* Update minimum WordPress requirement to 3.7 and ensure compatibility with PHP 7.4. +* Fix bug that caused not importing term meta. +* Fix bug that caused slashes to be stripped from imported meta data. +* Fix bug that prevented import of serialized meta data. +* Fix file size check after download of remote files with HTTP compression enabled. +* Improve accessibility of form fields by adding missing labels. +* Improve imports for remote file URLs without name and/or extension. +* Add support for `wp:base_blog_url` field to allow importing multiple files with WP-CLI. +* Add support for term meta parsing when using the regular expressions or XML parser. +* Developers: All PHP classes have been moved into their own files. +* Developers: Allow to change `IMPORT_DEBUG` via `wp-config.php` and change default value to the value of `WP_DEBUG`. + += 0.6.4 = +* Improve PHP7 compatibility. +* Fix bug that caused slashes to be stripped from imported comments. +* Fix for various deprecation notices including `wp_get_http()` and `screen_icon()`. +* Fix for importing export files with multiline term meta data. + += 0.6.3 = +* Add support for import term metadata. +* Fix bug that caused slashes to be stripped from imported content. +* Fix bug that caused characters to be stripped inside of CDATA in some cases. +* Fix PHP notices. + += 0.6.2 = +* Add `wp_import_existing_post` filter, see [Trac ticket #33721](https://core.trac.wordpress.org/ticket/33721). + += 0.6 = +* Support for WXR 1.2 and multiple CDATA sections +* Post aren't duplicates if their post_type's are different + += 0.5.2 = +* Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when +an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used. + += 0.5 = +* Import comment meta (requires export from WordPress 3.2) +* Minor bugfixes and enhancements + += 0.4 = +* Map comment user_id where possible +* Import attachments from `wp:attachment_url` +* Upload attachments to correct directory +* Remap resized image URLs correctly + += 0.3 = +* Use an XML Parser if possible +* Proper import support for nav menus +* ... and much more, see [Trac ticket #15197](https://core.trac.wordpress.org/ticket/15197) + += 0.1 = +* Initial release + +== Frequently Asked Questions == + += Help! I'm getting out of memory errors or a blank screen. = +If your exported file is very large, the import script may run into your host's configured memory limit for PHP. + +A message like "Fatal error: Allowed memory size of 8388608 bytes exhausted" indicates that the script can't successfully import your XML file under the current PHP memory limit. If you have access to the php.ini file, you can manually increase the limit; if you do not (your WordPress installation is hosted on a shared server, for instance), you might have to break your exported XML file into several smaller pieces and run the import script one at a time. + +For those with shared hosting, the best alternative may be to consult hosting support to determine the safest approach for running the import. A host may be willing to temporarily lift the memory limit and/or run the process directly from their end. + +-- [Support Article: Importing Content](https://wordpress.org/support/article/importing-content/#before-importing) + +== Filters == + +The importer has a couple of filters to allow you to completely enable/block certain features: + +* `import_allow_create_users`: return false if you only want to allow mapping to existing users +* `import_allow_fetch_attachments`: return false if you do not wish to allow importing and downloading of attachments +* `import_attachment_size_limit`: return an integer value for the maximum file size in bytes to save (default is 0, which is unlimited) + +There are also a few actions available to hook into: + +* `import_start`: occurs after the export file has been uploaded and author import settings have been chosen +* `import_end`: called after the last output from the importer +posts, pages, comments, custom fields, categories, and tags from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); +} +add_action( 'admin_init', 'wordpress_importer_init' ); diff --git a/build/wp-6.1.js b/build/wp-6.1.js old mode 100755 new mode 100644 index fc01774555..068e06a771 --- a/build/wp-6.1.js +++ b/build/wp-6.1.js @@ -1,6 +1,6 @@ // The number of bytes to download, which is just the size of the `wp.data` file. // Populated by the Dockerfile. -export const dependenciesTotalSize = 10359321; +export const dependenciesTotalSize = 10448476; // The final wp.data filename – populated by the Dockerfile. export const dependencyFilename = 'wp-6.1.data'; @@ -33,8 +33,8 @@ export default function(PHPModule) { // web worker PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/'); } - var PACKAGE_NAME = '/root/output//wp-6.1.data?'; - var REMOTE_PACKAGE_BASE = '/wp-6.1.data?'; + var PACKAGE_NAME = '/root/output//wp-6.1.data?19a9270d55a25f99158131339cf38d29'; + var REMOTE_PACKAGE_BASE = '/wp-6.1.data?19a9270d55a25f99158131339cf38d29'; if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) { Module['locateFile'] = Module['locateFilePackage']; err('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); @@ -123,6 +123,8 @@ Module['FS_createPath']("/wordpress/wp-content", "database", true, true); Module['FS_createPath']("/wordpress/wp-content", "plugins", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins", "akismet", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins/akismet", "views", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins", "wordpress-importer", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins/wordpress-importer", "parsers", true, true); Module['FS_createPath']("/wordpress/wp-content", "themes", true, true); Module['FS_createPath']("/wordpress/wp-content/themes", "twentytwentythree", true, true); Module['FS_createPath']("/wordpress/wp-content/themes/twentytwentythree", "parts", true, true); @@ -333,10 +335,10 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); var files = metadata['files']; for (var i = 0; i < files.length; ++i) { DataRequest.prototype.requests[files[i].filename].onload(); - } Module['removeRunDependency']('datafile_/root/output//wp-6.1.data?'); + } Module['removeRunDependency']('datafile_/root/output//wp-6.1.data?19a9270d55a25f99158131339cf38d29'); }; - Module['addRunDependency']('datafile_/root/output//wp-6.1.data?'); + Module['addRunDependency']('datafile_/root/output//wp-6.1.data?19a9270d55a25f99158131339cf38d29'); if (!Module.preloadResults) Module.preloadResults = {}; @@ -357,7 +359,7 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); } } - loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4100}, {"filename": "/wordpress/index.php", "start": 4100, "end": 4181}, {"filename": "/wordpress/readme.html", "start": 4181, "end": 11570}, {"filename": "/wordpress/wp-activate.php", "start": 11570, "end": 17592}, {"filename": "/wordpress/wp-admin/about.php", "start": 17592, "end": 48010}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 48010, "end": 51722}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 51722, "end": 52902}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 52902, "end": 53045}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 53045, "end": 58448}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 58448, "end": 59295}, {"filename": "/wordpress/wp-admin/admin.php", "start": 59295, "end": 65249}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 65249, "end": 68915}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 68915, "end": 76447}, {"filename": "/wordpress/wp-admin/comment.php", "start": 76447, "end": 86206}, {"filename": "/wordpress/wp-admin/credits.php", "start": 86206, "end": 89541}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 89541, "end": 89720}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 89720, "end": 89903}, {"filename": "/wordpress/wp-admin/customize.php", "start": 89903, "end": 98773}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 98773, "end": 111323}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 111323, "end": 135214}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 135214, "end": 143056}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 143056, "end": 150229}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 150229, "end": 155743}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 155743, "end": 161726}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 161726, "end": 178157}, {"filename": "/wordpress/wp-admin/edit.php", "start": 178157, "end": 194214}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 194214, "end": 201098}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 201098, "end": 208386}, {"filename": "/wordpress/wp-admin/export.php", "start": 208386, "end": 218204}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 218204, "end": 222147}, {"filename": "/wordpress/wp-admin/import.php", "start": 222147, "end": 228015}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 228015, "end": 234927}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 234927, "end": 237069}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 237069, "end": 348192}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 348192, "end": 354946}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 354946, "end": 356221}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 356221, "end": 357361}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 357361, "end": 358549}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 358549, "end": 362616}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 362616, "end": 371391}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 371391, "end": 389076}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 389076, "end": 426576}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 426576, "end": 428346}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 428346, "end": 432461}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 432461, "end": 439462}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 439462, "end": 462517}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 462517, "end": 463983}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 463983, "end": 472947}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 472947, "end": 562006}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 562006, "end": 570535}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 570535, "end": 572380}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 572380, "end": 584034}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 584034, "end": 593196}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 593196, "end": 595861}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 595861, "end": 610503}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 610503, "end": 612757}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 612757, "end": 616411}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 616411, "end": 626548}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 626548, "end": 628339}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 628339, "end": 632024}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 632024, "end": 660626}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 660626, "end": 682394}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 682394, "end": 689766}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 689766, "end": 733278}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 733278, "end": 740850}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 740850, "end": 747530}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 747530, "end": 757635}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 757635, "end": 764783}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 764783, "end": 774521}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 774521, "end": 779183}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 779183, "end": 781585}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 781585, "end": 786381}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 786381, "end": 787109}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 787109, "end": 813402}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 813402, "end": 830582}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 830582, "end": 843467}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 843467, "end": 861082}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 861082, "end": 870076}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 870076, "end": 886977}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 886977, "end": 915519}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 915519, "end": 916477}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 916477, "end": 957562}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 957562, "end": 961769}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 961769, "end": 965986}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 965986, "end": 989391}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 989391, "end": 997506}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 997506, "end": 1017494}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 1017494, "end": 1025993}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1025993, "end": 1099302}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1099302, "end": 1101925}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1101925, "end": 1114102}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1114102, "end": 1124244}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1124244, "end": 1131999}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1131999, "end": 1135094}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1135094, "end": 1136016}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1136016, "end": 1151683}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1151683, "end": 1163031}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1163031, "end": 1166867}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1166867, "end": 1187173}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1187173, "end": 1190959}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1190959, "end": 1238892}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1238892, "end": 1259109}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1259109, "end": 1260211}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1260211, "end": 1275722}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1275722, "end": 1324390}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1324390, "end": 1353206}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1353206, "end": 1372147}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1372147, "end": 1376401}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1376401, "end": 1378256}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1378256, "end": 1462300}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1462300, "end": 1467645}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1467645, "end": 1515284}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1515284, "end": 1542643}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1542643, "end": 1543663}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1543663, "end": 1545292}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1545292, "end": 1568207}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1568207, "end": 1603503}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1603503, "end": 1625254}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1625254, "end": 1625851}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1625851, "end": 1629551}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1629551, "end": 1651104}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1651104, "end": 1691457}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1691457, "end": 1742963}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1742963, "end": 1762513}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1762513, "end": 1772430}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1772430, "end": 1803314}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1803314, "end": 1806325}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1806325, "end": 1810138}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1810138, "end": 1864924}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1864924, "end": 1870311}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1870311, "end": 1896454}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1896454, "end": 1902346}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1902346, "end": 1950937}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1950937, "end": 1972874}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1972874, "end": 2043645}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 2043645, "end": 2056633}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2056633, "end": 2065333}, {"filename": "/wordpress/wp-admin/index.php", "start": 2065333, "end": 2071906}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2071906, "end": 2073834}, {"filename": "/wordpress/wp-admin/install.php", "start": 2073834, "end": 2087938}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2087938, "end": 2088489}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2088489, "end": 2092146}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2092146, "end": 2093568}, {"filename": "/wordpress/wp-admin/link.php", "start": 2093568, "end": 2095538}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2095538, "end": 2097068}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2097068, "end": 2099325}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2099325, "end": 2105376}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2105376, "end": 2108213}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2108213, "end": 2109733}, {"filename": "/wordpress/wp-admin/media.php", "start": 2109733, "end": 2114813}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2114813, "end": 2121992}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2121992, "end": 2136244}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2136244, "end": 2136381}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2136381, "end": 2136467}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2136467, "end": 2140030}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2140030, "end": 2140116}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2140116, "end": 2140212}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2140212, "end": 2140311}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2140311, "end": 2140411}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2140411, "end": 2140512}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2140512, "end": 2140611}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2140611, "end": 2144112}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2144112, "end": 2183172}, {"filename": "/wordpress/wp-admin/network.php", "start": 2183172, "end": 2188000}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2188000, "end": 2188084}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2188084, "end": 2188669}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2188669, "end": 2188755}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2188755, "end": 2189049}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2189049, "end": 2189136}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2189136, "end": 2191750}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2191750, "end": 2195970}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2195970, "end": 2196062}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2196062, "end": 2196267}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2196267, "end": 2196353}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2196353, "end": 2196439}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2196439, "end": 2196525}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2196525, "end": 2215591}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2215591, "end": 2215677}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2215677, "end": 2221818}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2221818, "end": 2229606}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2229606, "end": 2234240}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2234240, "end": 2239530}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2239530, "end": 2249332}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2249332, "end": 2259974}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2259974, "end": 2260065}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2260065, "end": 2260268}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2260268, "end": 2274495}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2274495, "end": 2274585}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2274585, "end": 2274850}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2274850, "end": 2278633}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2278633, "end": 2278721}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2278721, "end": 2282992}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2282992, "end": 2290719}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2290719, "end": 2304213}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2304213, "end": 2317570}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2317570, "end": 2317784}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2317784, "end": 2323629}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2323629, "end": 2341937}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2341937, "end": 2350398}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2350398, "end": 2358966}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2358966, "end": 2366605}, {"filename": "/wordpress/wp-admin/options.php", "start": 2366605, "end": 2376321}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2376321, "end": 2388605}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2388605, "end": 2393375}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2393375, "end": 2417993}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2417993, "end": 2420065}, {"filename": "/wordpress/wp-admin/post.php", "start": 2420065, "end": 2428335}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2428335, "end": 2430251}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2430251, "end": 2433582}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2433582, "end": 2435723}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2435723, "end": 2435806}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2435806, "end": 2439942}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2439942, "end": 2453726}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2453726, "end": 2458292}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2458292, "end": 2461929}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2461929, "end": 2470329}, {"filename": "/wordpress/wp-admin/term.php", "start": 2470329, "end": 2472263}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2472263, "end": 2486243}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2486243, "end": 2505514}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2505514, "end": 2544809}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2544809, "end": 2547558}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2547558, "end": 2584297}, {"filename": "/wordpress/wp-admin/update.php", "start": 2584297, "end": 2594820}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2594820, "end": 2594967}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2594967, "end": 2599311}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2599311, "end": 2612349}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2612349, "end": 2643631}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2643631, "end": 2664127}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2664127, "end": 2664211}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2664211, "end": 2664753}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2664753, "end": 2664839}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2664839, "end": 2664926}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2664926, "end": 2665010}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2665010, "end": 2665596}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2665596, "end": 2665682}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2665682, "end": 2665768}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2665768, "end": 2665856}, {"filename": "/wordpress/wp-admin/users.php", "start": 2665856, "end": 2684444}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2684444, "end": 2686218}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2686218, "end": 2703264}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2703264, "end": 2704141}, {"filename": "/wordpress/wp-blog-header.php", "start": 2704141, "end": 2704308}, {"filename": "/wordpress/wp-comments-post.php", "start": 2704308, "end": 2705719}, {"filename": "/wordpress/wp-config-sample.php", "start": 2705719, "end": 2706562}, {"filename": "/wordpress/wp-config.php", "start": 2706562, "end": 2707445}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2707445, "end": 2912245}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2912245, "end": 2912258}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2912258, "end": 2912286}, {"filename": "/wordpress/wp-content/db.php", "start": 2912286, "end": 2995676}, {"filename": "/wordpress/wp-content/index.php", "start": 2995676, "end": 2995682}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 2995682, "end": 2996817}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 2996817, "end": 3037190}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 3037190, "end": 3040223}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 3040223, "end": 3048390}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 3048390, "end": 3051221}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 3051221, "end": 3095122}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3095122, "end": 3095128}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3095128, "end": 3095305}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3095305, "end": 3106959}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3106959, "end": 3111457}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3111457, "end": 3112271}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3112271, "end": 3113026}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3113026, "end": 3125908}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3125908, "end": 3126171}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3126171, "end": 3126495}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3126495, "end": 3127302}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3127302, "end": 3128080}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3128080, "end": 3128205}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3128205, "end": 3134504}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3134504, "end": 3136239}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3136239, "end": 3136245}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/comments.html", "start": 3136245, "end": 3136311}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/footer.html", "start": 3136311, "end": 3136376}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/header.html", "start": 3136376, "end": 3136912}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/post-meta.html", "start": 3136912, "end": 3136972}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/call-to-action.php", "start": 3136972, "end": 3138076}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/footer-default.php", "start": 3138076, "end": 3138810}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-404.php", "start": 3138810, "end": 3140142}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-comments.php", "start": 3140142, "end": 3142190}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-no-results.php", "start": 3142190, "end": 3142789}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/post-meta.php", "start": 3142789, "end": 3145300}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/style.css", "start": 3145300, "end": 3146396}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/aubergine.json", "start": 3146396, "end": 3152430}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/block-out.json", "start": 3152430, "end": 3156795}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/canary.json", "start": 3156795, "end": 3161387}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/electric.json", "start": 3161387, "end": 3163259}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/grapes.json", "start": 3163259, "end": 3165010}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/marigold.json", "start": 3165010, "end": 3171224}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pilgrimage.json", "start": 3171224, "end": 3177753}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pitch.json", "start": 3177753, "end": 3182510}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/sherbet.json", "start": 3182510, "end": 3187795}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/whisper.json", "start": 3187795, "end": 3199164}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/404.html", "start": 3199164, "end": 3199482}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/archive.html", "start": 3199482, "end": 3201158}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blank.html", "start": 3201158, "end": 3201218}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blog-alternative.html", "start": 3201218, "end": 3202704}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/home.html", "start": 3202704, "end": 3204770}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/index.html", "start": 3204770, "end": 3206140}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/page.html", "start": 3206140, "end": 3207030}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/search.html", "start": 3207030, "end": 3208848}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/single.html", "start": 3208848, "end": 3209787}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/theme.json", "start": 3209787, "end": 3224624}, {"filename": "/wordpress/wp-cron.php", "start": 3224624, "end": 3227339}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3227339, "end": 3264218}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3264218, "end": 3311479}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3311479, "end": 3396816}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3396816, "end": 3413531}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3413531, "end": 3472482}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3472482, "end": 3584713}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 3584713, "end": 3673062}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 3673062, "end": 3698998}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 3698998, "end": 3706448}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 3706448, "end": 3720510}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 3720510, "end": 3795221}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 3795221, "end": 3829332}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 3829332, "end": 3844056}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 3844056, "end": 3854195}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 3854195, "end": 3944300}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 3944300, "end": 3953083}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 3953083, "end": 3953325}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 3953325, "end": 3956253}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 3956253, "end": 3956879}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 3956879, "end": 3958102}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 3958102, "end": 3958765}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 3958765, "end": 3961883}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 3961883, "end": 3966478}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 3966478, "end": 3967115}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 3967115, "end": 3971415}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 3971415, "end": 3973560}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 3973560, "end": 3973779}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 3973779, "end": 4049393}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4049393, "end": 4066437}, {"filename": "/wordpress/wp-includes/Requests/Auth.php", "start": 4066437, "end": 4066521}, {"filename": "/wordpress/wp-includes/Requests/Auth/Basic.php", "start": 4066521, "end": 4067407}, {"filename": "/wordpress/wp-includes/Requests/Cookie.php", "start": 4067407, "end": 4073262}, {"filename": "/wordpress/wp-includes/Requests/Cookie/Jar.php", "start": 4073262, "end": 4075243}, {"filename": "/wordpress/wp-includes/Requests/Exception.php", "start": 4075243, "end": 4075585}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP.php", "start": 4075585, "end": 4076240}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/304.php", "start": 4076240, "end": 4076376}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/305.php", "start": 4076376, "end": 4076509}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/306.php", "start": 4076509, "end": 4076645}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/400.php", "start": 4076645, "end": 4076780}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/401.php", "start": 4076780, "end": 4076916}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/402.php", "start": 4076916, "end": 4077056}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/403.php", "start": 4077056, "end": 4077189}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/404.php", "start": 4077189, "end": 4077322}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/405.php", "start": 4077322, "end": 4077464}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/406.php", "start": 4077464, "end": 4077602}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/407.php", "start": 4077602, "end": 4077755}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/408.php", "start": 4077755, "end": 4077894}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/409.php", "start": 4077894, "end": 4078026}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/410.php", "start": 4078026, "end": 4078154}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/411.php", "start": 4078154, "end": 4078293}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/412.php", "start": 4078293, "end": 4078436}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/413.php", "start": 4078436, "end": 4078584}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/414.php", "start": 4078584, "end": 4078729}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/415.php", "start": 4078729, "end": 4078875}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/416.php", "start": 4078875, "end": 4079030}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/417.php", "start": 4079030, "end": 4079172}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/418.php", "start": 4079172, "end": 4079308}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/428.php", "start": 4079308, "end": 4079453}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/429.php", "start": 4079453, "end": 4079594}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/431.php", "start": 4079594, "end": 4079749}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/500.php", "start": 4079749, "end": 4079894}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/501.php", "start": 4079894, "end": 4080033}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/502.php", "start": 4080033, "end": 4080168}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/503.php", "start": 4080168, "end": 4080311}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/504.php", "start": 4080311, "end": 4080450}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/505.php", "start": 4080450, "end": 4080600}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/511.php", "start": 4080600, "end": 4080755}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/Unknown.php", "start": 4080755, "end": 4081065}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport.php", "start": 4081065, "end": 4081138}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport/cURL.php", "start": 4081138, "end": 4081779}, {"filename": "/wordpress/wp-includes/Requests/Hooker.php", "start": 4081779, "end": 4081931}, {"filename": "/wordpress/wp-includes/Requests/Hooks.php", "start": 4081931, "end": 4082579}, {"filename": "/wordpress/wp-includes/Requests/IDNAEncoder.php", "start": 4082579, "end": 4087840}, {"filename": "/wordpress/wp-includes/Requests/IPv6.php", "start": 4087840, "end": 4090130}, {"filename": "/wordpress/wp-includes/Requests/IRI.php", "start": 4090130, "end": 4105858}, {"filename": "/wordpress/wp-includes/Requests/Proxy.php", "start": 4105858, "end": 4105943}, {"filename": "/wordpress/wp-includes/Requests/Proxy/HTTP.php", "start": 4105943, "end": 4107581}, {"filename": "/wordpress/wp-includes/Requests/Response.php", "start": 4107581, "end": 4108486}, {"filename": "/wordpress/wp-includes/Requests/Response/Headers.php", "start": 4108486, "end": 4109360}, {"filename": "/wordpress/wp-includes/Requests/SSL.php", "start": 4109360, "end": 4110703}, {"filename": "/wordpress/wp-includes/Requests/Session.php", "start": 4110703, "end": 4113715}, {"filename": "/wordpress/wp-includes/Requests/Transport.php", "start": 4113715, "end": 4113929}, {"filename": "/wordpress/wp-includes/Requests/Transport/cURL.php", "start": 4113929, "end": 4124334}, {"filename": "/wordpress/wp-includes/Requests/Transport/fsockopen.php", "start": 4124334, "end": 4132844}, {"filename": "/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php", "start": 4132844, "end": 4133730}, {"filename": "/wordpress/wp-includes/Requests/Utility/FilteredIterator.php", "start": 4133730, "end": 4134237}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4134237, "end": 4134793}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4134793, "end": 4135919}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4135919, "end": 4136195}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4136195, "end": 4138261}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4138261, "end": 4139299}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4139299, "end": 4140667}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4140667, "end": 4142070}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4142070, "end": 4150427}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4150427, "end": 4152078}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4152078, "end": 4152968}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4152968, "end": 4153597}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4153597, "end": 4158041}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4158041, "end": 4158459}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4158459, "end": 4158508}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4158508, "end": 4159071}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4159071, "end": 4170991}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4170991, "end": 4184587}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4184587, "end": 4184641}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4184641, "end": 4191042}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4191042, "end": 4197385}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4197385, "end": 4213516}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4213516, "end": 4286513}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4286513, "end": 4296268}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4296268, "end": 4337585}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4337585, "end": 4339951}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4339951, "end": 4353085}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4353085, "end": 4375479}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4375479, "end": 4375909}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4375909, "end": 4378164}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4378164, "end": 4378781}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4378781, "end": 4390926}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4390926, "end": 4407527}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4407527, "end": 4410955}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4410955, "end": 4414023}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4414023, "end": 4419571}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4419571, "end": 4426144}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4426144, "end": 4428435}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4428435, "end": 4432434}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4432434, "end": 4433166}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4433166, "end": 4436238}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4436238, "end": 4438952}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4438952, "end": 4462189}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.min.php", "start": 4462189, "end": 4473324}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4473324, "end": 4484243}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.min.php", "start": 4484243, "end": 4484353}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.php", "start": 4484353, "end": 4484463}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.min.php", "start": 4484463, "end": 4484547}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.php", "start": 4484547, "end": 4484631}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4484631, "end": 4492172}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4492172, "end": 4499353}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4499353, "end": 4514317}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4514317, "end": 4514633}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4514633, "end": 4521784}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4521784, "end": 4522695}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4522695, "end": 4524614}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4524614, "end": 4525597}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4525597, "end": 4527538}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4527538, "end": 4528636}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4528636, "end": 4529379}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4529379, "end": 4530116}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4530116, "end": 4531127}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4531127, "end": 4535168}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4535168, "end": 4539324}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4539324, "end": 4540368}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4540368, "end": 4541242}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4541242, "end": 4550928}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 4550928, "end": 4553129}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 4553129, "end": 4553914}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 4553914, "end": 4567298}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 4567298, "end": 4569060}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 4569060, "end": 4583401}, {"filename": "/wordpress/wp-includes/block-supports/utils.php", "start": 4583401, "end": 4583850}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 4583850, "end": 4610003}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 4610003, "end": 4615622}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 4615622, "end": 4641844}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 4641844, "end": 4644117}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 4644117, "end": 4645150}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 4645150, "end": 4645190}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 4645190, "end": 4645238}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 4645238, "end": 4646402}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 4646402, "end": 4646615}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 4646615, "end": 4646763}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 4646763, "end": 4646933}, {"filename": "/wordpress/wp-includes/blocks/avatar.php", "start": 4646933, "end": 4650954}, {"filename": "/wordpress/wp-includes/blocks/avatar/block.json", "start": 4650954, "end": 4651960}, {"filename": "/wordpress/wp-includes/blocks/avatar/editor.min.css", "start": 4651960, "end": 4652079}, {"filename": "/wordpress/wp-includes/blocks/avatar/style.min.css", "start": 4652079, "end": 4652165}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 4652165, "end": 4653234}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 4653234, "end": 4653721}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 4653721, "end": 4654083}, {"filename": "/wordpress/wp-includes/blocks/blocks-json.php", "start": 4654083, "end": 4761667}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 4761667, "end": 4763930}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 4763930, "end": 4765111}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 4765111, "end": 4767243}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 4767243, "end": 4768346}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 4768346, "end": 4769455}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 4769455, "end": 4770758}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 4770758, "end": 4773365}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 4773365, "end": 4774114}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 4774114, "end": 4774523}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 4774523, "end": 4776563}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 4776563, "end": 4777714}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 4777714, "end": 4777799}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 4777799, "end": 4777938}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 4777938, "end": 4779130}, {"filename": "/wordpress/wp-includes/blocks/code/editor.min.css", "start": 4779130, "end": 4779166}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 4779166, "end": 4779303}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 4779303, "end": 4779419}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 4779419, "end": 4780862}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 4780862, "end": 4782569}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 4782569, "end": 4782708}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 4782708, "end": 4784182}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name.php", "start": 4784182, "end": 4785604}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name/block.json", "start": 4785604, "end": 4786742}, {"filename": "/wordpress/wp-includes/blocks/comment-content.php", "start": 4786742, "end": 4788413}, {"filename": "/wordpress/wp-includes/blocks/comment-content/block.json", "start": 4788413, "end": 4789456}, {"filename": "/wordpress/wp-includes/blocks/comment-content/style.min.css", "start": 4789456, "end": 4789532}, {"filename": "/wordpress/wp-includes/blocks/comment-date.php", "start": 4789532, "end": 4790544}, {"filename": "/wordpress/wp-includes/blocks/comment-date/block.json", "start": 4790544, "end": 4791602}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link.php", "start": 4791602, "end": 4792652}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link/block.json", "start": 4792652, "end": 4793811}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link.php", "start": 4793811, "end": 4795064}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link/block.json", "start": 4795064, "end": 4796065}, {"filename": "/wordpress/wp-includes/blocks/comment-template.php", "start": 4796065, "end": 4798224}, {"filename": "/wordpress/wp-includes/blocks/comment-template/block.json", "start": 4798224, "end": 4799070}, {"filename": "/wordpress/wp-includes/blocks/comment-template/style.min.css", "start": 4799070, "end": 4799503}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next.php", "start": 4799503, "end": 4800728}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next/block.json", "start": 4800728, "end": 4801685}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers.php", "start": 4801685, "end": 4802640}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/block.json", "start": 4802640, "end": 4803411}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/editor.min.css", "start": 4803411, "end": 4803624}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous.php", "start": 4803624, "end": 4804707}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous/block.json", "start": 4804707, "end": 4805676}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination.php", "start": 4805676, "end": 4806198}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/block.json", "start": 4806198, "end": 4807511}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/editor.min.css", "start": 4807511, "end": 4808231}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/style.min.css", "start": 4808231, "end": 4809238}, {"filename": "/wordpress/wp-includes/blocks/comments-title.php", "start": 4809238, "end": 4811215}, {"filename": "/wordpress/wp-includes/blocks/comments-title/block.json", "start": 4811215, "end": 4812627}, {"filename": "/wordpress/wp-includes/blocks/comments-title/editor.min.css", "start": 4812627, "end": 4812683}, {"filename": "/wordpress/wp-includes/blocks/comments.php", "start": 4812683, "end": 4816345}, {"filename": "/wordpress/wp-includes/blocks/comments/block.json", "start": 4816345, "end": 4817445}, {"filename": "/wordpress/wp-includes/blocks/comments/editor.min.css", "start": 4817445, "end": 4821719}, {"filename": "/wordpress/wp-includes/blocks/comments/style.min.css", "start": 4821719, "end": 4823999}, {"filename": "/wordpress/wp-includes/blocks/cover.php", "start": 4823999, "end": 4825730}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 4825730, "end": 4827953}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 4827953, "end": 4829600}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 4829600, "end": 4846259}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 4846259, "end": 4847063}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 4847063, "end": 4847685}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 4847685, "end": 4849273}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 4849273, "end": 4849443}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 4849443, "end": 4850402}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 4850402, "end": 4851691}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 4851691, "end": 4852325}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 4852325, "end": 4852901}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 4852901, "end": 4852985}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 4852985, "end": 4853069}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 4853069, "end": 4853613}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 4853613, "end": 4854050}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 4854050, "end": 4863104}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 4863104, "end": 4865707}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 4865707, "end": 4868375}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 4868375, "end": 4871720}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 4871720, "end": 4885833}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 4885833, "end": 4885966}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 4885966, "end": 4887624}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 4887624, "end": 4888773}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 4888773, "end": 4888811}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 4888811, "end": 4888873}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 4888873, "end": 4890438}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 4890438, "end": 4890569}, {"filename": "/wordpress/wp-includes/blocks/home-link.php", "start": 4890569, "end": 4893673}, {"filename": "/wordpress/wp-includes/blocks/home-link/block.json", "start": 4893673, "end": 4894749}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 4894749, "end": 4895222}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 4895222, "end": 4895957}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 4895957, "end": 4896508}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 4896508, "end": 4898884}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 4898884, "end": 4901744}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 4901744, "end": 4904228}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 4904228, "end": 4904398}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 4904398, "end": 4904885}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 4904885, "end": 4908130}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 4908130, "end": 4908879}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 4908879, "end": 4909798}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 4909798, "end": 4915352}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 4915352, "end": 4917413}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 4917413, "end": 4917842}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 4917842, "end": 4919457}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 4919457, "end": 4922547}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 4922547, "end": 4923048}, {"filename": "/wordpress/wp-includes/blocks/list-item/block.json", "start": 4923048, "end": 4923562}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 4923562, "end": 4925136}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 4925136, "end": 4925223}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 4925223, "end": 4926120}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 4926120, "end": 4926630}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 4926630, "end": 4929191}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 4929191, "end": 4929749}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 4929749, "end": 4932000}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 4932000, "end": 4932564}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 4932564, "end": 4933128}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 4933128, "end": 4933859}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 4933859, "end": 4941971}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 4941971, "end": 4943548}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 4943548, "end": 4945702}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 4945702, "end": 4945872}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 4945872, "end": 4953122}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 4953122, "end": 4954308}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 4954308, "end": 4955412}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 4955412, "end": 4973448}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 4973448, "end": 4976512}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 4976512, "end": 4987228}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 4987228, "end": 5002570}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.asset.php", "start": 5002570, "end": 5002654}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.asset.php", "start": 5002654, "end": 5002738}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.js", "start": 5002738, "end": 5010517}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5010517, "end": 5010601}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5010601, "end": 5010685}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5010685, "end": 5011829}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5011829, "end": 5012284}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5012284, "end": 5012876}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5012876, "end": 5022596}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5022596, "end": 5023319}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5023319, "end": 5024378}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5024378, "end": 5024740}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5024740, "end": 5026147}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5026147, "end": 5026513}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5026513, "end": 5026949}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5026949, "end": 5027507}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5027507, "end": 5027831}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography.php", "start": 5027831, "end": 5028771}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography/block.json", "start": 5028771, "end": 5029693}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5029693, "end": 5031356}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5031356, "end": 5032674}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5032674, "end": 5033010}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form.php", "start": 5033010, "end": 5034453}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/block.json", "start": 5034453, "end": 5035405}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/editor.min.css", "start": 5035405, "end": 5035529}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/style.min.css", "start": 5035529, "end": 5037402}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5037402, "end": 5038570}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5038570, "end": 5039371}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5039371, "end": 5040723}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5040723, "end": 5041838}, {"filename": "/wordpress/wp-includes/blocks/post-date/style.min.css", "start": 5041838, "end": 5041880}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5041880, "end": 5043401}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5043401, "end": 5044550}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5044550, "end": 5044636}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5044636, "end": 5044691}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5044691, "end": 5049830}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5049830, "end": 5051573}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5051573, "end": 5055719}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5055719, "end": 5057465}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5057465, "end": 5059555}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5059555, "end": 5060587}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5060587, "end": 5062964}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5062964, "end": 5064012}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5064012, "end": 5064106}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5064106, "end": 5064959}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5064959, "end": 5067175}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5067175, "end": 5068288}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5068288, "end": 5068341}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5068341, "end": 5069530}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5069530, "end": 5070895}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5070895, "end": 5071004}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5071004, "end": 5072028}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5072028, "end": 5072133}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5072133, "end": 5073742}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5073742, "end": 5073984}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5073984, "end": 5074910}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5074910, "end": 5075177}, {"filename": "/wordpress/wp-includes/blocks/query-no-results.php", "start": 5075177, "end": 5076214}, {"filename": "/wordpress/wp-includes/blocks/query-no-results/block.json", "start": 5076214, "end": 5077059}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5077059, "end": 5078989}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5078989, "end": 5079928}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5079928, "end": 5081799}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5081799, "end": 5082730}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5082730, "end": 5082934}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5082934, "end": 5084432}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5084432, "end": 5085383}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5085383, "end": 5085935}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5085935, "end": 5087255}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5087255, "end": 5087930}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5087930, "end": 5089145}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5089145, "end": 5090689}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5090689, "end": 5091896}, {"filename": "/wordpress/wp-includes/blocks/query-title/style.min.css", "start": 5091896, "end": 5091940}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5091940, "end": 5092096}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5092096, "end": 5093352}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5093352, "end": 5094687}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5094687, "end": 5096167}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5096167, "end": 5096767}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5096767, "end": 5097235}, {"filename": "/wordpress/wp-includes/blocks/read-more.php", "start": 5097235, "end": 5098119}, {"filename": "/wordpress/wp-includes/blocks/read-more/block.json", "start": 5098119, "end": 5099329}, {"filename": "/wordpress/wp-includes/blocks/read-more/style.min.css", "start": 5099329, "end": 5099588}, {"filename": "/wordpress/wp-includes/blocks/require-dynamic-blocks.php", "start": 5099588, "end": 5103126}, {"filename": "/wordpress/wp-includes/blocks/require-static-blocks.php", "start": 5103126, "end": 5103457}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5103457, "end": 5106811}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5106811, "end": 5107716}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5107716, "end": 5108152}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5108152, "end": 5108851}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5108851, "end": 5123704}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5123704, "end": 5125629}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5125629, "end": 5125886}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5125886, "end": 5127107}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5127107, "end": 5127233}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5127233, "end": 5128237}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5128237, "end": 5128465}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5128465, "end": 5128817}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5128817, "end": 5129254}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5129254, "end": 5129578}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5129578, "end": 5130043}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5130043, "end": 5131067}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5131067, "end": 5134816}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5134816, "end": 5136157}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5136157, "end": 5137669}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5137669, "end": 5138094}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5138094, "end": 5138750}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5138750, "end": 5139874}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5139874, "end": 5139942}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5139942, "end": 5141200}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5141200, "end": 5142642}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5142642, "end": 5142708}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5142708, "end": 5201223}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5201223, "end": 5201859}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5201859, "end": 5202232}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5202232, "end": 5204156}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5204156, "end": 5206143}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5206143, "end": 5215932}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5215932, "end": 5216555}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5216555, "end": 5217379}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5217379, "end": 5217407}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5217407, "end": 5220951}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5220951, "end": 5222931}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5222931, "end": 5226717}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5226717, "end": 5227036}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5227036, "end": 5228201}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5228201, "end": 5229102}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5229102, "end": 5229600}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5229600, "end": 5235303}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5235303, "end": 5235900}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5235900, "end": 5236432}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5236432, "end": 5236523}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5236523, "end": 5237290}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5237290, "end": 5238307}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5238307, "end": 5239037}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5239037, "end": 5239123}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5239123, "end": 5239575}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5239575, "end": 5240794}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5240794, "end": 5240868}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5240868, "end": 5242683}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5242683, "end": 5244946}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5244946, "end": 5245195}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5245195, "end": 5245365}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5245365, "end": 5246741}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5246741, "end": 5247060}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5247060, "end": 5252546}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5252546, "end": 5260946}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5260946, "end": 5262818}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5262818, "end": 5265679}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5265679, "end": 5289190}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5289190, "end": 5309204}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5309204, "end": 5329997}, {"filename": "/wordpress/wp-includes/category.php", "start": 5329997, "end": 5334468}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5334468, "end": 5567699}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5567699, "end": 5568325}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5568325, "end": 5568765}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5568765, "end": 5568906}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5568906, "end": 5582918}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5582918, "end": 5583063}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5583063, "end": 5586809}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5586809, "end": 5587325}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5587325, "end": 5597902}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5597902, "end": 5612473}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5612473, "end": 5668673}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5668673, "end": 5668993}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5668993, "end": 5690432}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5690432, "end": 5691388}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5691388, "end": 5695012}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5695012, "end": 5702824}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5702824, "end": 5706137}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5706137, "end": 5707003}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5707003, "end": 5710390}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5710390, "end": 5721403}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5721403, "end": 5723730}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5723730, "end": 5729597}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5729597, "end": 5729901}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5729901, "end": 5731255}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5731255, "end": 5737461}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5737461, "end": 5739518}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5739518, "end": 5741842}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5741842, "end": 5743989}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5743989, "end": 5747263}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5747263, "end": 5747594}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5747594, "end": 5749596}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5749596, "end": 5753473}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5753473, "end": 5757490}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5757490, "end": 5779199}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5779199, "end": 5782197}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5782197, "end": 5795290}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5795290, "end": 5919642}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 5919642, "end": 5958590}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 5958590, "end": 5962565}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 5962565, "end": 5966849}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 5966849, "end": 5979433}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 5979433, "end": 6020551}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6020551, "end": 6035704}, {"filename": "/wordpress/wp-includes/class-wp-dependencies.php", "start": 6035704, "end": 6041103}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6041103, "end": 6041806}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6041806, "end": 6084132}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6084132, "end": 6091716}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6091716, "end": 6094515}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6094515, "end": 6097608}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6097608, "end": 6098533}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6098533, "end": 6098918}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6098918, "end": 6105025}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6105025, "end": 6107863}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6107863, "end": 6115468}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6115468, "end": 6118086}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6118086, "end": 6120492}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6120492, "end": 6122429}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6122429, "end": 6122992}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6122992, "end": 6125047}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6125047, "end": 6125927}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6125927, "end": 6136750}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6136750, "end": 6153335}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6153335, "end": 6162540}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6162540, "end": 6177153}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6177153, "end": 6183589}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6183589, "end": 6186613}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6186613, "end": 6188562}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6188562, "end": 6194086}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6194086, "end": 6194824}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6194824, "end": 6208073}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6208073, "end": 6209939}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6209939, "end": 6218918}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6218918, "end": 6223826}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6223826, "end": 6230544}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6230544, "end": 6234263}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6234263, "end": 6248110}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6248110, "end": 6250640}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6250640, "end": 6262385}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6262385, "end": 6265369}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6265369, "end": 6344160}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6344160, "end": 6347799}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6347799, "end": 6353594}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6353594, "end": 6355653}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6355653, "end": 6357228}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6357228, "end": 6363329}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6363329, "end": 6388110}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6388110, "end": 6388768}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6388768, "end": 6392292}, {"filename": "/wordpress/wp-includes/class-wp-scripts.php", "start": 6392292, "end": 6401410}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6401410, "end": 6403918}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6403918, "end": 6405230}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6405230, "end": 6406085}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6406085, "end": 6420190}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6420190, "end": 6422877}, {"filename": "/wordpress/wp-includes/class-wp-styles.php", "start": 6422877, "end": 6428020}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6428020, "end": 6437295}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6437295, "end": 6446455}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6446455, "end": 6464662}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6464662, "end": 6466866}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6466866, "end": 6467203}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6467203, "end": 6475227}, {"filename": "/wordpress/wp-includes/class-wp-textdomain-registry.php", "start": 6475227, "end": 6477030}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-data.php", "start": 6477030, "end": 6477481}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6477481, "end": 6488666}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6488666, "end": 6490495}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6490495, "end": 6549573}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6549573, "end": 6577143}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6577143, "end": 6578605}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6578605, "end": 6597088}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6597088, "end": 6598094}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6598094, "end": 6607309}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6607309, "end": 6612929}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6612929, "end": 6614328}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6614328, "end": 6621769}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6621769, "end": 6748784}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6748784, "end": 6763224}, {"filename": "/wordpress/wp-includes/class-wpdb.php", "start": 6763224, "end": 6813366}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6813366, "end": 6813523}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6813523, "end": 6813670}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6813670, "end": 6813815}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6813815, "end": 6851421}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6851421, "end": 6911800}, {"filename": "/wordpress/wp-includes/compat.php", "start": 6911800, "end": 6917477}, {"filename": "/wordpress/wp-includes/cron.php", "start": 6917477, "end": 6930950}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 6930950, "end": 6931588}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 6931588, "end": 6931800}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 6931800, "end": 6934039}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 6934039, "end": 6935280}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 6935280, "end": 6937007}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 6937007, "end": 6937576}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 6937576, "end": 6939753}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 6939753, "end": 6946224}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 6946224, "end": 6946334}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 6946334, "end": 6952951}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 6952951, "end": 6953884}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 6953884, "end": 6954348}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 6954348, "end": 6961068}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 6961068, "end": 6961679}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 6961679, "end": 6963062}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 6963062, "end": 6968313}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 6968313, "end": 6984709}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 6984709, "end": 6986254}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 6986254, "end": 6988229}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 6988229, "end": 6988857}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 6988857, "end": 6989121}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 6989121, "end": 6998711}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 6998711, "end": 7000559}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7000559, "end": 7001143}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7001143, "end": 7001879}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7001879, "end": 7004565}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7004565, "end": 7010046}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7010046, "end": 7010384}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7010384, "end": 7012692}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7012692, "end": 7021508}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7021508, "end": 7023712}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7023712, "end": 7028361}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7028361, "end": 7028839}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7028839, "end": 7028993}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7028993, "end": 7030093}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7030093, "end": 7031341}, {"filename": "/wordpress/wp-includes/date.php", "start": 7031341, "end": 7031494}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7031494, "end": 7037300}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7037300, "end": 7064893}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7064893, "end": 7066344}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7066344, "end": 7126422}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7126422, "end": 7126568}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7126568, "end": 7145132}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7145132, "end": 7147018}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7147018, "end": 7150943}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7150943, "end": 7153461}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7153461, "end": 7155589}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7155589, "end": 7156520}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7156520, "end": 7159343}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7159343, "end": 7162068}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7162068, "end": 7171654}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7171654, "end": 7381838}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7381838, "end": 7496328}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7496328, "end": 7500866}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7500866, "end": 7502905}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7502905, "end": 7577756}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7577756, "end": 7581936}, {"filename": "/wordpress/wp-includes/http.php", "start": 7581936, "end": 7590256}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7590256, "end": 7593318}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7593318, "end": 7594995}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7594995, "end": 7595740}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7595740, "end": 7597591}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7597591, "end": 7630322}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7630322, "end": 7652090}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7652090, "end": 7712728}, {"filename": "/wordpress/wp-includes/load.php", "start": 7712728, "end": 7736227}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7736227, "end": 7736285}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7736285, "end": 7792367}, {"filename": "/wordpress/wp-includes/media.php", "start": 7792367, "end": 7880118}, {"filename": "/wordpress/wp-includes/meta.php", "start": 7880118, "end": 7902567}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 7902567, "end": 7915920}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 7915920, "end": 7918932}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 7918932, "end": 7924620}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 7924620, "end": 7935988}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 7935988, "end": 7938147}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 7938147, "end": 7979956}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 7979956, "end": 7988709}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 7988709, "end": 7990205}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 7990205, "end": 7992174}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 7992174, "end": 8009987}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8009987, "end": 8024070}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8024070, "end": 8048391}, {"filename": "/wordpress/wp-includes/option.php", "start": 8048391, "end": 8082147}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8082147, "end": 8082334}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8082334, "end": 8084816}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8084816, "end": 8132742}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8132742, "end": 8141633}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8141633, "end": 8143152}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8143152, "end": 8149386}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8149386, "end": 8153614}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8153614, "end": 8163328}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8163328, "end": 8167742}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8167742, "end": 8173458}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8173458, "end": 8177405}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8177405, "end": 8207385}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8207385, "end": 8210388}, {"filename": "/wordpress/wp-includes/post.php", "start": 8210388, "end": 8330315}, {"filename": "/wordpress/wp-includes/query.php", "start": 8330315, "end": 8344069}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8344069, "end": 8346132}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8346132, "end": 8346593}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8346593, "end": 8346843}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8346843, "end": 8349709}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8349709, "end": 8350414}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8350414, "end": 8351744}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8351744, "end": 8352419}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8352419, "end": 8353107}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8353107, "end": 8353610}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8353610, "end": 8354744}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8354744, "end": 8354857}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8354857, "end": 8354970}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8354970, "end": 8410236}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8410236, "end": 8421311}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8421311, "end": 8423772}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8423772, "end": 8449013}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8449013, "end": 8464083}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8464083, "end": 8492935}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8492935, "end": 8501014}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8501014, "end": 8507338}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php", "start": 8507338, "end": 8509829}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php", "start": 8509829, "end": 8514250}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8514250, "end": 8517777}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8517777, "end": 8534188}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8534188, "end": 8535060}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8535060, "end": 8573993}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8573993, "end": 8582938}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8582938, "end": 8584145}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8584145, "end": 8596135}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8596135, "end": 8618995}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8618995, "end": 8624195}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8624195, "end": 8635118}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8635118, "end": 8641667}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8641667, "end": 8660864}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8660864, "end": 8667427}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8667427, "end": 8676299}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8676299, "end": 8740743}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8740743, "end": 8757073}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8757073, "end": 8764427}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8764427, "end": 8768965}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8768965, "end": 8778709}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8778709, "end": 8785043}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8785043, "end": 8794101}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8794101, "end": 8814546}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8814546, "end": 8835568}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8835568, "end": 8848324}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8848324, "end": 8856581}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8856581, "end": 8887983}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 8887983, "end": 8899393}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 8899393, "end": 8915571}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 8915571, "end": 8915821}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 8915821, "end": 8926270}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 8926270, "end": 8926627}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 8926627, "end": 8927019}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 8927019, "end": 8927257}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 8927257, "end": 8929197}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 8929197, "end": 8932172}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 8932172, "end": 8932620}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 8932620, "end": 8935009}, {"filename": "/wordpress/wp-includes/revision.php", "start": 8935009, "end": 8947142}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 8947142, "end": 8955167}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 8955167, "end": 8956483}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 8956483, "end": 8956646}, {"filename": "/wordpress/wp-includes/rss.php", "start": 8956646, "end": 8971088}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 8971088, "end": 9062256}, {"filename": "/wordpress/wp-includes/session.php", "start": 9062256, "end": 9062450}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9062450, "end": 9070350}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9070350, "end": 9071550}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9071550, "end": 9072327}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9072327, "end": 9073990}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9073990, "end": 9074610}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9074610, "end": 9078166}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9078166, "end": 9085111}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9085111, "end": 9088354}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9088354, "end": 9090845}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9090845, "end": 9093062}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9093062, "end": 9094551}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9094551, "end": 9095411}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9095411, "end": 9095830}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9095830, "end": 9097531}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9097531, "end": 9099139}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9099139, "end": 9103297}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9103297, "end": 9103848}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9103848, "end": 9126285}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9126285, "end": 9130881}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9130881, "end": 9135044}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9135044, "end": 9146262}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9146262, "end": 9147129}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9147129, "end": 9147213}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9147213, "end": 9147309}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9147309, "end": 9147407}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9147407, "end": 9147513}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9147513, "end": 9147627}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9147627, "end": 9147729}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9147729, "end": 9147837}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9147837, "end": 9147959}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9147959, "end": 9148077}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9148077, "end": 9148191}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9148191, "end": 9148305}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9148305, "end": 9148429}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9148429, "end": 9148535}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9148535, "end": 9148631}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9148631, "end": 9148731}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9148731, "end": 9148829}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9148829, "end": 9148927}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9148927, "end": 9149037}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9149037, "end": 9149133}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9149133, "end": 9149229}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9149229, "end": 9149319}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9149319, "end": 9149413}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9149413, "end": 9149513}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9149513, "end": 9149611}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9149611, "end": 9149695}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9149695, "end": 9149775}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9149775, "end": 9232226}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9232226, "end": 9243197}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9243197, "end": 9246157}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9246157, "end": 9249592}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9249592, "end": 9253027}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9253027, "end": 9258227}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9258227, "end": 9260263}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9260263, "end": 9260969}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9260969, "end": 9340186}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9340186, "end": 9341469}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9341469, "end": 9342292}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9342292, "end": 9343033}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9343033, "end": 9343628}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9343628, "end": 9344365}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9344365, "end": 9345054}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9345054, "end": 9434094}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9434094, "end": 9442876}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9442876, "end": 9445442}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9445442, "end": 9447906}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9447906, "end": 9448681}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9448681, "end": 9455527}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9455527, "end": 9468055}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9468055, "end": 9472929}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9472929, "end": 9475034}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9475034, "end": 9478345}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9478345, "end": 9490721}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9490721, "end": 9495436}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9495436, "end": 9497033}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9497033, "end": 9497515}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9497515, "end": 9506896}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9506896, "end": 9512400}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9512400, "end": 9515165}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9515165, "end": 9516019}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9516019, "end": 9599121}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9599121, "end": 9601811}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9601811, "end": 9602654}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9602654, "end": 9603411}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9603411, "end": 9604022}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9604022, "end": 9604779}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9604779, "end": 9605481}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9605481, "end": 9693832}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9693832, "end": 9701603}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9701603, "end": 9704679}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9704679, "end": 9708687}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9708687, "end": 9722128}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9722128, "end": 9739718}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9739718, "end": 9740503}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9740503, "end": 9749117}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9749117, "end": 9755710}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9755710, "end": 9757843}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9757843, "end": 9760612}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9760612, "end": 9760771}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9760771, "end": 9766769}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9766769, "end": 9767910}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9767910, "end": 9768398}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9768398, "end": 9792945}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9792945, "end": 9817801}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9817801, "end": 9847209}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9847209, "end": 9848865}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9848865, "end": 9848965}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9848965, "end": 9849075}, {"filename": "/wordpress/wp-includes/style-engine.php", "start": 9849075, "end": 9850967}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-declarations.php", "start": 9850967, "end": 9852930}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rule.php", "start": 9852930, "end": 9854530}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php", "start": 9854530, "end": 9855643}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-processor.php", "start": 9855643, "end": 9857711}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine.php", "start": 9857711, "end": 9868063}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9868063, "end": 9937669}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 9937669, "end": 9937995}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 9937995, "end": 9939720}, {"filename": "/wordpress/wp-includes/template.php", "start": 9939720, "end": 9946719}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 9946719, "end": 9948347}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 9948347, "end": 9948864}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 9948864, "end": 9950854}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 9950854, "end": 9951068}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 9951068, "end": 9951123}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 9951123, "end": 9951799}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 9951799, "end": 9952129}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 9952129, "end": 9953688}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 9953688, "end": 9956813}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 9956813, "end": 9957964}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 9957964, "end": 9961637}, {"filename": "/wordpress/wp-includes/theme.json", "start": 9961637, "end": 9971045}, {"filename": "/wordpress/wp-includes/theme.php", "start": 9971045, "end": 10040942}, {"filename": "/wordpress/wp-includes/update.php", "start": 10040942, "end": 10061629}, {"filename": "/wordpress/wp-includes/user.php", "start": 10061629, "end": 10134997}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10134997, "end": 10138992}, {"filename": "/wordpress/wp-includes/version.php", "start": 10138992, "end": 10139150}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10139150, "end": 10171895}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10171895, "end": 10175757}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10175757, "end": 10179997}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10179997, "end": 10183202}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10183202, "end": 10184688}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10184688, "end": 10189219}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10189219, "end": 10196361}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10196361, "end": 10201800}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10201800, "end": 10206014}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10206014, "end": 10211154}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10211154, "end": 10219988}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10219988, "end": 10226065}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10226065, "end": 10234192}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10234192, "end": 10236390}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10236390, "end": 10239967}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10239967, "end": 10244077}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10244077, "end": 10247961}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10247961, "end": 10251139}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10251139, "end": 10252531}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10252531, "end": 10256780}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10256780, "end": 10269177}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10269177, "end": 10270222}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10270222, "end": 10270401}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10270401, "end": 10270750}, {"filename": "/wordpress/wp-links-opml.php", "start": 10270750, "end": 10272360}, {"filename": "/wordpress/wp-load.php", "start": 10272360, "end": 10274155}, {"filename": "/wordpress/wp-login.php", "start": 10274155, "end": 10308288}, {"filename": "/wordpress/wp-mail.php", "start": 10308288, "end": 10314239}, {"filename": "/wordpress/wp-settings.php", "start": 10314239, "end": 10331161}, {"filename": "/wordpress/wp-signup.php", "start": 10331161, "end": 10354073}, {"filename": "/wordpress/wp-trackback.php", "start": 10354073, "end": 10357500}, {"filename": "/wordpress/xmlrpc.php", "start": 10357500, "end": 10359321}], "remote_package_size": 10359321}); + loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4100}, {"filename": "/wordpress/index.php", "start": 4100, "end": 4181}, {"filename": "/wordpress/readme.html", "start": 4181, "end": 11570}, {"filename": "/wordpress/wp-activate.php", "start": 11570, "end": 17592}, {"filename": "/wordpress/wp-admin/about.php", "start": 17592, "end": 48010}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 48010, "end": 51722}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 51722, "end": 52902}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 52902, "end": 53045}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 53045, "end": 58448}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 58448, "end": 59295}, {"filename": "/wordpress/wp-admin/admin.php", "start": 59295, "end": 65249}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 65249, "end": 68915}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 68915, "end": 76447}, {"filename": "/wordpress/wp-admin/comment.php", "start": 76447, "end": 86206}, {"filename": "/wordpress/wp-admin/credits.php", "start": 86206, "end": 89541}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 89541, "end": 89720}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 89720, "end": 89903}, {"filename": "/wordpress/wp-admin/customize.php", "start": 89903, "end": 98773}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 98773, "end": 111323}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 111323, "end": 135214}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 135214, "end": 143056}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 143056, "end": 150229}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 150229, "end": 155743}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 155743, "end": 161726}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 161726, "end": 178157}, {"filename": "/wordpress/wp-admin/edit.php", "start": 178157, "end": 194214}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 194214, "end": 201098}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 201098, "end": 208386}, {"filename": "/wordpress/wp-admin/export.php", "start": 208386, "end": 218204}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 218204, "end": 222147}, {"filename": "/wordpress/wp-admin/import.php", "start": 222147, "end": 228015}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 228015, "end": 234927}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 234927, "end": 237069}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 237069, "end": 348192}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 348192, "end": 354946}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 354946, "end": 356221}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 356221, "end": 357361}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 357361, "end": 358549}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 358549, "end": 362616}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 362616, "end": 371391}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 371391, "end": 389076}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 389076, "end": 426576}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 426576, "end": 428346}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 428346, "end": 432461}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 432461, "end": 439462}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 439462, "end": 462517}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 462517, "end": 463983}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 463983, "end": 472947}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 472947, "end": 562006}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 562006, "end": 570535}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 570535, "end": 572380}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 572380, "end": 584034}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 584034, "end": 593196}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 593196, "end": 595861}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 595861, "end": 610503}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 610503, "end": 612757}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 612757, "end": 616411}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 616411, "end": 626548}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 626548, "end": 628339}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 628339, "end": 632024}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 632024, "end": 660626}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 660626, "end": 682394}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 682394, "end": 689766}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 689766, "end": 733278}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 733278, "end": 740850}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 740850, "end": 747530}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 747530, "end": 757635}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 757635, "end": 764783}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 764783, "end": 774521}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 774521, "end": 779183}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 779183, "end": 781585}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 781585, "end": 786381}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 786381, "end": 787109}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 787109, "end": 813402}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 813402, "end": 830582}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 830582, "end": 843467}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 843467, "end": 861082}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 861082, "end": 870076}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 870076, "end": 886977}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 886977, "end": 915519}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 915519, "end": 916477}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 916477, "end": 957562}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 957562, "end": 961769}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 961769, "end": 965986}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 965986, "end": 989391}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 989391, "end": 997506}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 997506, "end": 1017494}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 1017494, "end": 1025993}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1025993, "end": 1099302}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1099302, "end": 1101925}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1101925, "end": 1114102}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1114102, "end": 1124244}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1124244, "end": 1131999}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1131999, "end": 1135094}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1135094, "end": 1136016}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1136016, "end": 1151683}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1151683, "end": 1163031}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1163031, "end": 1166867}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1166867, "end": 1187173}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1187173, "end": 1190959}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1190959, "end": 1238892}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1238892, "end": 1259109}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1259109, "end": 1260211}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1260211, "end": 1275722}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1275722, "end": 1324390}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1324390, "end": 1353206}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1353206, "end": 1372147}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1372147, "end": 1376401}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1376401, "end": 1378256}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1378256, "end": 1462300}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1462300, "end": 1467645}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1467645, "end": 1515284}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1515284, "end": 1542643}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1542643, "end": 1543663}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1543663, "end": 1545292}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1545292, "end": 1568207}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1568207, "end": 1603503}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1603503, "end": 1625254}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1625254, "end": 1625851}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1625851, "end": 1629551}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1629551, "end": 1651104}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1651104, "end": 1691457}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1691457, "end": 1742963}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1742963, "end": 1762513}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1762513, "end": 1772430}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1772430, "end": 1803314}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1803314, "end": 1806325}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1806325, "end": 1810138}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1810138, "end": 1864924}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1864924, "end": 1870311}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1870311, "end": 1896454}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1896454, "end": 1902346}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1902346, "end": 1950937}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1950937, "end": 1972874}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1972874, "end": 2043645}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 2043645, "end": 2056633}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2056633, "end": 2065333}, {"filename": "/wordpress/wp-admin/index.php", "start": 2065333, "end": 2071906}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2071906, "end": 2073834}, {"filename": "/wordpress/wp-admin/install.php", "start": 2073834, "end": 2087938}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2087938, "end": 2088489}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2088489, "end": 2092146}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2092146, "end": 2093568}, {"filename": "/wordpress/wp-admin/link.php", "start": 2093568, "end": 2095538}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2095538, "end": 2097068}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2097068, "end": 2099325}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2099325, "end": 2105376}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2105376, "end": 2108213}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2108213, "end": 2109733}, {"filename": "/wordpress/wp-admin/media.php", "start": 2109733, "end": 2114813}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2114813, "end": 2121992}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2121992, "end": 2136244}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2136244, "end": 2136381}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2136381, "end": 2136467}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2136467, "end": 2140030}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2140030, "end": 2140116}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2140116, "end": 2140212}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2140212, "end": 2140311}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2140311, "end": 2140411}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2140411, "end": 2140512}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2140512, "end": 2140611}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2140611, "end": 2144112}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2144112, "end": 2183172}, {"filename": "/wordpress/wp-admin/network.php", "start": 2183172, "end": 2188000}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2188000, "end": 2188084}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2188084, "end": 2188669}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2188669, "end": 2188755}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2188755, "end": 2189049}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2189049, "end": 2189136}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2189136, "end": 2191750}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2191750, "end": 2195970}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2195970, "end": 2196062}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2196062, "end": 2196267}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2196267, "end": 2196353}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2196353, "end": 2196439}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2196439, "end": 2196525}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2196525, "end": 2215591}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2215591, "end": 2215677}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2215677, "end": 2221818}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2221818, "end": 2229606}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2229606, "end": 2234240}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2234240, "end": 2239530}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2239530, "end": 2249332}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2249332, "end": 2259974}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2259974, "end": 2260065}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2260065, "end": 2260268}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2260268, "end": 2274495}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2274495, "end": 2274585}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2274585, "end": 2274850}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2274850, "end": 2278633}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2278633, "end": 2278721}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2278721, "end": 2282992}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2282992, "end": 2290719}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2290719, "end": 2304213}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2304213, "end": 2317570}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2317570, "end": 2317784}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2317784, "end": 2323629}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2323629, "end": 2341937}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2341937, "end": 2350398}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2350398, "end": 2358966}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2358966, "end": 2366605}, {"filename": "/wordpress/wp-admin/options.php", "start": 2366605, "end": 2376321}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2376321, "end": 2388605}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2388605, "end": 2393375}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2393375, "end": 2417993}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2417993, "end": 2420065}, {"filename": "/wordpress/wp-admin/post.php", "start": 2420065, "end": 2428335}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2428335, "end": 2430251}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2430251, "end": 2433582}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2433582, "end": 2435723}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2435723, "end": 2435806}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2435806, "end": 2439942}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2439942, "end": 2453726}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2453726, "end": 2458292}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2458292, "end": 2461929}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2461929, "end": 2470329}, {"filename": "/wordpress/wp-admin/term.php", "start": 2470329, "end": 2472263}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2472263, "end": 2486243}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2486243, "end": 2505514}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2505514, "end": 2544809}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2544809, "end": 2547558}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2547558, "end": 2584297}, {"filename": "/wordpress/wp-admin/update.php", "start": 2584297, "end": 2594820}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2594820, "end": 2594967}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2594967, "end": 2599311}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2599311, "end": 2612349}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2612349, "end": 2643631}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2643631, "end": 2664127}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2664127, "end": 2664211}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2664211, "end": 2664753}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2664753, "end": 2664839}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2664839, "end": 2664926}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2664926, "end": 2665010}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2665010, "end": 2665596}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2665596, "end": 2665682}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2665682, "end": 2665768}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2665768, "end": 2665856}, {"filename": "/wordpress/wp-admin/users.php", "start": 2665856, "end": 2684444}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2684444, "end": 2686218}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2686218, "end": 2703264}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2703264, "end": 2704141}, {"filename": "/wordpress/wp-blog-header.php", "start": 2704141, "end": 2704308}, {"filename": "/wordpress/wp-comments-post.php", "start": 2704308, "end": 2705719}, {"filename": "/wordpress/wp-config-sample.php", "start": 2705719, "end": 2706562}, {"filename": "/wordpress/wp-config.php", "start": 2706562, "end": 2707445}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2707445, "end": 2912245}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2912245, "end": 2912258}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2912258, "end": 2912266}, {"filename": "/wordpress/wp-content/db.php", "start": 2912266, "end": 2995656}, {"filename": "/wordpress/wp-content/index.php", "start": 2995656, "end": 2995662}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 2995662, "end": 2996797}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 2996797, "end": 3037170}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 3037170, "end": 3040203}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 3040203, "end": 3048370}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 3048370, "end": 3051201}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 3051201, "end": 3095102}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3095102, "end": 3095108}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3095108, "end": 3095285}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3095285, "end": 3106939}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3106939, "end": 3111437}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3111437, "end": 3112251}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3112251, "end": 3113006}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3113006, "end": 3125888}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3125888, "end": 3126151}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3126151, "end": 3126475}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3126475, "end": 3127282}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3127282, "end": 3128060}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3128060, "end": 3128185}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3128185, "end": 3134484}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3134484, "end": 3136219}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3136219, "end": 3136225}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php", "start": 3136225, "end": 3187654}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/compat.php", "start": 3187654, "end": 3188518}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers.php", "start": 3188518, "end": 3189099}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php", "start": 3189099, "end": 3200401}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php", "start": 3200401, "end": 3208580}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-xml.php", "start": 3208580, "end": 3215467}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser.php", "start": 3215467, "end": 3217371}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/readme.txt", "start": 3217371, "end": 3223192}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/wordpress-importer.php", "start": 3223192, "end": 3225400}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/comments.html", "start": 3225400, "end": 3225466}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/footer.html", "start": 3225466, "end": 3225531}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/header.html", "start": 3225531, "end": 3226067}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/post-meta.html", "start": 3226067, "end": 3226127}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/call-to-action.php", "start": 3226127, "end": 3227231}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/footer-default.php", "start": 3227231, "end": 3227965}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-404.php", "start": 3227965, "end": 3229297}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-comments.php", "start": 3229297, "end": 3231345}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-no-results.php", "start": 3231345, "end": 3231944}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/post-meta.php", "start": 3231944, "end": 3234455}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/style.css", "start": 3234455, "end": 3235551}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/aubergine.json", "start": 3235551, "end": 3241585}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/block-out.json", "start": 3241585, "end": 3245950}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/canary.json", "start": 3245950, "end": 3250542}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/electric.json", "start": 3250542, "end": 3252414}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/grapes.json", "start": 3252414, "end": 3254165}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/marigold.json", "start": 3254165, "end": 3260379}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pilgrimage.json", "start": 3260379, "end": 3266908}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pitch.json", "start": 3266908, "end": 3271665}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/sherbet.json", "start": 3271665, "end": 3276950}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/whisper.json", "start": 3276950, "end": 3288319}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/404.html", "start": 3288319, "end": 3288637}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/archive.html", "start": 3288637, "end": 3290313}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blank.html", "start": 3290313, "end": 3290373}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blog-alternative.html", "start": 3290373, "end": 3291859}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/home.html", "start": 3291859, "end": 3293925}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/index.html", "start": 3293925, "end": 3295295}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/page.html", "start": 3295295, "end": 3296185}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/search.html", "start": 3296185, "end": 3298003}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/single.html", "start": 3298003, "end": 3298942}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/theme.json", "start": 3298942, "end": 3313779}, {"filename": "/wordpress/wp-cron.php", "start": 3313779, "end": 3316494}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3316494, "end": 3353373}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3353373, "end": 3400634}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3400634, "end": 3485971}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3485971, "end": 3502686}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3502686, "end": 3561637}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3561637, "end": 3673868}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 3673868, "end": 3762217}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 3762217, "end": 3788153}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 3788153, "end": 3795603}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 3795603, "end": 3809665}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 3809665, "end": 3884376}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 3884376, "end": 3918487}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 3918487, "end": 3933211}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 3933211, "end": 3943350}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 3943350, "end": 4033455}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 4033455, "end": 4042238}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 4042238, "end": 4042480}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 4042480, "end": 4045408}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 4045408, "end": 4046034}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 4046034, "end": 4047257}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 4047257, "end": 4047920}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 4047920, "end": 4051038}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 4051038, "end": 4055633}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 4055633, "end": 4056270}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 4056270, "end": 4060570}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 4060570, "end": 4062715}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 4062715, "end": 4062934}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 4062934, "end": 4138548}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4138548, "end": 4155592}, {"filename": "/wordpress/wp-includes/Requests/Auth.php", "start": 4155592, "end": 4155676}, {"filename": "/wordpress/wp-includes/Requests/Auth/Basic.php", "start": 4155676, "end": 4156562}, {"filename": "/wordpress/wp-includes/Requests/Cookie.php", "start": 4156562, "end": 4162417}, {"filename": "/wordpress/wp-includes/Requests/Cookie/Jar.php", "start": 4162417, "end": 4164398}, {"filename": "/wordpress/wp-includes/Requests/Exception.php", "start": 4164398, "end": 4164740}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP.php", "start": 4164740, "end": 4165395}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/304.php", "start": 4165395, "end": 4165531}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/305.php", "start": 4165531, "end": 4165664}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/306.php", "start": 4165664, "end": 4165800}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/400.php", "start": 4165800, "end": 4165935}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/401.php", "start": 4165935, "end": 4166071}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/402.php", "start": 4166071, "end": 4166211}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/403.php", "start": 4166211, "end": 4166344}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/404.php", "start": 4166344, "end": 4166477}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/405.php", "start": 4166477, "end": 4166619}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/406.php", "start": 4166619, "end": 4166757}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/407.php", "start": 4166757, "end": 4166910}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/408.php", "start": 4166910, "end": 4167049}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/409.php", "start": 4167049, "end": 4167181}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/410.php", "start": 4167181, "end": 4167309}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/411.php", "start": 4167309, "end": 4167448}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/412.php", "start": 4167448, "end": 4167591}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/413.php", "start": 4167591, "end": 4167739}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/414.php", "start": 4167739, "end": 4167884}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/415.php", "start": 4167884, "end": 4168030}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/416.php", "start": 4168030, "end": 4168185}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/417.php", "start": 4168185, "end": 4168327}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/418.php", "start": 4168327, "end": 4168463}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/428.php", "start": 4168463, "end": 4168608}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/429.php", "start": 4168608, "end": 4168749}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/431.php", "start": 4168749, "end": 4168904}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/500.php", "start": 4168904, "end": 4169049}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/501.php", "start": 4169049, "end": 4169188}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/502.php", "start": 4169188, "end": 4169323}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/503.php", "start": 4169323, "end": 4169466}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/504.php", "start": 4169466, "end": 4169605}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/505.php", "start": 4169605, "end": 4169755}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/511.php", "start": 4169755, "end": 4169910}, {"filename": "/wordpress/wp-includes/Requests/Exception/HTTP/Unknown.php", "start": 4169910, "end": 4170220}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport.php", "start": 4170220, "end": 4170293}, {"filename": "/wordpress/wp-includes/Requests/Exception/Transport/cURL.php", "start": 4170293, "end": 4170934}, {"filename": "/wordpress/wp-includes/Requests/Hooker.php", "start": 4170934, "end": 4171086}, {"filename": "/wordpress/wp-includes/Requests/Hooks.php", "start": 4171086, "end": 4171734}, {"filename": "/wordpress/wp-includes/Requests/IDNAEncoder.php", "start": 4171734, "end": 4176995}, {"filename": "/wordpress/wp-includes/Requests/IPv6.php", "start": 4176995, "end": 4179285}, {"filename": "/wordpress/wp-includes/Requests/IRI.php", "start": 4179285, "end": 4195013}, {"filename": "/wordpress/wp-includes/Requests/Proxy.php", "start": 4195013, "end": 4195098}, {"filename": "/wordpress/wp-includes/Requests/Proxy/HTTP.php", "start": 4195098, "end": 4196736}, {"filename": "/wordpress/wp-includes/Requests/Response.php", "start": 4196736, "end": 4197641}, {"filename": "/wordpress/wp-includes/Requests/Response/Headers.php", "start": 4197641, "end": 4198515}, {"filename": "/wordpress/wp-includes/Requests/SSL.php", "start": 4198515, "end": 4199858}, {"filename": "/wordpress/wp-includes/Requests/Session.php", "start": 4199858, "end": 4202870}, {"filename": "/wordpress/wp-includes/Requests/Transport.php", "start": 4202870, "end": 4203084}, {"filename": "/wordpress/wp-includes/Requests/Transport/cURL.php", "start": 4203084, "end": 4213489}, {"filename": "/wordpress/wp-includes/Requests/Transport/fsockopen.php", "start": 4213489, "end": 4221999}, {"filename": "/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php", "start": 4221999, "end": 4222885}, {"filename": "/wordpress/wp-includes/Requests/Utility/FilteredIterator.php", "start": 4222885, "end": 4223392}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4223392, "end": 4223948}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4223948, "end": 4225074}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4225074, "end": 4225350}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4225350, "end": 4227416}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4227416, "end": 4228454}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4228454, "end": 4229822}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4229822, "end": 4231225}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4231225, "end": 4239582}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4239582, "end": 4241233}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4241233, "end": 4242123}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4242123, "end": 4242752}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4242752, "end": 4247196}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4247196, "end": 4247614}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4247614, "end": 4247663}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4247663, "end": 4248226}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4248226, "end": 4260146}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4260146, "end": 4273742}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4273742, "end": 4273796}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4273796, "end": 4280197}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4280197, "end": 4286540}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4286540, "end": 4302671}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4302671, "end": 4375668}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4375668, "end": 4385423}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4385423, "end": 4426740}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4426740, "end": 4429106}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4429106, "end": 4442240}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4442240, "end": 4464634}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4464634, "end": 4465064}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4465064, "end": 4467319}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4467319, "end": 4467936}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4467936, "end": 4480081}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4480081, "end": 4496682}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4496682, "end": 4500110}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4500110, "end": 4503178}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4503178, "end": 4508726}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4508726, "end": 4515299}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4515299, "end": 4517590}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4517590, "end": 4521589}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4521589, "end": 4522321}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4522321, "end": 4525393}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4525393, "end": 4528107}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4528107, "end": 4551344}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.min.php", "start": 4551344, "end": 4562479}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4562479, "end": 4573398}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.min.php", "start": 4573398, "end": 4573508}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.php", "start": 4573508, "end": 4573618}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.min.php", "start": 4573618, "end": 4573702}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.php", "start": 4573702, "end": 4573786}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4573786, "end": 4581327}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4581327, "end": 4588508}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4588508, "end": 4603472}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4603472, "end": 4603788}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4603788, "end": 4610939}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4610939, "end": 4611850}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4611850, "end": 4613769}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4613769, "end": 4614752}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4614752, "end": 4616693}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4616693, "end": 4617791}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4617791, "end": 4618534}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4618534, "end": 4619271}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4619271, "end": 4620282}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4620282, "end": 4624323}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4624323, "end": 4628479}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4628479, "end": 4629523}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4629523, "end": 4630397}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4630397, "end": 4640083}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 4640083, "end": 4642284}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 4642284, "end": 4643069}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 4643069, "end": 4656453}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 4656453, "end": 4658215}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 4658215, "end": 4672556}, {"filename": "/wordpress/wp-includes/block-supports/utils.php", "start": 4672556, "end": 4673005}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 4673005, "end": 4699158}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 4699158, "end": 4704777}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 4704777, "end": 4730999}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 4730999, "end": 4733272}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 4733272, "end": 4734305}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 4734305, "end": 4734345}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 4734345, "end": 4734393}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 4734393, "end": 4735557}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 4735557, "end": 4735770}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 4735770, "end": 4735918}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 4735918, "end": 4736088}, {"filename": "/wordpress/wp-includes/blocks/avatar.php", "start": 4736088, "end": 4740109}, {"filename": "/wordpress/wp-includes/blocks/avatar/block.json", "start": 4740109, "end": 4741115}, {"filename": "/wordpress/wp-includes/blocks/avatar/editor.min.css", "start": 4741115, "end": 4741234}, {"filename": "/wordpress/wp-includes/blocks/avatar/style.min.css", "start": 4741234, "end": 4741320}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 4741320, "end": 4742389}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 4742389, "end": 4742876}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 4742876, "end": 4743238}, {"filename": "/wordpress/wp-includes/blocks/blocks-json.php", "start": 4743238, "end": 4850822}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 4850822, "end": 4853085}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 4853085, "end": 4854266}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 4854266, "end": 4856398}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 4856398, "end": 4857501}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 4857501, "end": 4858610}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 4858610, "end": 4859913}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 4859913, "end": 4862520}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 4862520, "end": 4863269}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 4863269, "end": 4863678}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 4863678, "end": 4865718}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 4865718, "end": 4866869}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 4866869, "end": 4866954}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 4866954, "end": 4867093}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 4867093, "end": 4868285}, {"filename": "/wordpress/wp-includes/blocks/code/editor.min.css", "start": 4868285, "end": 4868321}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 4868321, "end": 4868458}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 4868458, "end": 4868574}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 4868574, "end": 4870017}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 4870017, "end": 4871724}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 4871724, "end": 4871863}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 4871863, "end": 4873337}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name.php", "start": 4873337, "end": 4874759}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name/block.json", "start": 4874759, "end": 4875897}, {"filename": "/wordpress/wp-includes/blocks/comment-content.php", "start": 4875897, "end": 4877568}, {"filename": "/wordpress/wp-includes/blocks/comment-content/block.json", "start": 4877568, "end": 4878611}, {"filename": "/wordpress/wp-includes/blocks/comment-content/style.min.css", "start": 4878611, "end": 4878687}, {"filename": "/wordpress/wp-includes/blocks/comment-date.php", "start": 4878687, "end": 4879699}, {"filename": "/wordpress/wp-includes/blocks/comment-date/block.json", "start": 4879699, "end": 4880757}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link.php", "start": 4880757, "end": 4881807}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link/block.json", "start": 4881807, "end": 4882966}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link.php", "start": 4882966, "end": 4884219}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link/block.json", "start": 4884219, "end": 4885220}, {"filename": "/wordpress/wp-includes/blocks/comment-template.php", "start": 4885220, "end": 4887379}, {"filename": "/wordpress/wp-includes/blocks/comment-template/block.json", "start": 4887379, "end": 4888225}, {"filename": "/wordpress/wp-includes/blocks/comment-template/style.min.css", "start": 4888225, "end": 4888658}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next.php", "start": 4888658, "end": 4889883}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next/block.json", "start": 4889883, "end": 4890840}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers.php", "start": 4890840, "end": 4891795}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/block.json", "start": 4891795, "end": 4892566}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/editor.min.css", "start": 4892566, "end": 4892779}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous.php", "start": 4892779, "end": 4893862}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous/block.json", "start": 4893862, "end": 4894831}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination.php", "start": 4894831, "end": 4895353}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/block.json", "start": 4895353, "end": 4896666}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/editor.min.css", "start": 4896666, "end": 4897386}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/style.min.css", "start": 4897386, "end": 4898393}, {"filename": "/wordpress/wp-includes/blocks/comments-title.php", "start": 4898393, "end": 4900370}, {"filename": "/wordpress/wp-includes/blocks/comments-title/block.json", "start": 4900370, "end": 4901782}, {"filename": "/wordpress/wp-includes/blocks/comments-title/editor.min.css", "start": 4901782, "end": 4901838}, {"filename": "/wordpress/wp-includes/blocks/comments.php", "start": 4901838, "end": 4905500}, {"filename": "/wordpress/wp-includes/blocks/comments/block.json", "start": 4905500, "end": 4906600}, {"filename": "/wordpress/wp-includes/blocks/comments/editor.min.css", "start": 4906600, "end": 4910874}, {"filename": "/wordpress/wp-includes/blocks/comments/style.min.css", "start": 4910874, "end": 4913154}, {"filename": "/wordpress/wp-includes/blocks/cover.php", "start": 4913154, "end": 4914885}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 4914885, "end": 4917108}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 4917108, "end": 4918755}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 4918755, "end": 4935414}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 4935414, "end": 4936218}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 4936218, "end": 4936840}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 4936840, "end": 4938428}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 4938428, "end": 4938598}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 4938598, "end": 4939557}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 4939557, "end": 4940846}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 4940846, "end": 4941480}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 4941480, "end": 4942056}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 4942056, "end": 4942140}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 4942140, "end": 4942224}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 4942224, "end": 4942768}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 4942768, "end": 4943205}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 4943205, "end": 4952259}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 4952259, "end": 4954862}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 4954862, "end": 4957530}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 4957530, "end": 4960875}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 4960875, "end": 4974988}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 4974988, "end": 4975121}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 4975121, "end": 4976779}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 4976779, "end": 4977928}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 4977928, "end": 4977966}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 4977966, "end": 4978028}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 4978028, "end": 4979593}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 4979593, "end": 4979724}, {"filename": "/wordpress/wp-includes/blocks/home-link.php", "start": 4979724, "end": 4982828}, {"filename": "/wordpress/wp-includes/blocks/home-link/block.json", "start": 4982828, "end": 4983904}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 4983904, "end": 4984377}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 4984377, "end": 4985112}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 4985112, "end": 4985663}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 4985663, "end": 4988039}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 4988039, "end": 4990899}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 4990899, "end": 4993383}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 4993383, "end": 4993553}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 4993553, "end": 4994040}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 4994040, "end": 4997285}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 4997285, "end": 4998034}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 4998034, "end": 4998953}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 4998953, "end": 5004507}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 5004507, "end": 5006568}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 5006568, "end": 5006997}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 5006997, "end": 5008612}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 5008612, "end": 5011702}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 5011702, "end": 5012203}, {"filename": "/wordpress/wp-includes/blocks/list-item/block.json", "start": 5012203, "end": 5012717}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 5012717, "end": 5014291}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 5014291, "end": 5014378}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 5014378, "end": 5015275}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 5015275, "end": 5015785}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 5015785, "end": 5018346}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 5018346, "end": 5018904}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 5018904, "end": 5021155}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 5021155, "end": 5021719}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 5021719, "end": 5022283}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 5022283, "end": 5023014}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 5023014, "end": 5031126}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 5031126, "end": 5032703}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 5032703, "end": 5034857}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 5034857, "end": 5035027}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 5035027, "end": 5042277}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 5042277, "end": 5043463}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 5043463, "end": 5044567}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 5044567, "end": 5062603}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 5062603, "end": 5065667}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 5065667, "end": 5076383}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 5076383, "end": 5091725}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.asset.php", "start": 5091725, "end": 5091809}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.asset.php", "start": 5091809, "end": 5091893}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.js", "start": 5091893, "end": 5099672}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5099672, "end": 5099756}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5099756, "end": 5099840}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5099840, "end": 5100984}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5100984, "end": 5101439}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5101439, "end": 5102031}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5102031, "end": 5111751}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5111751, "end": 5112474}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5112474, "end": 5113533}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5113533, "end": 5113895}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5113895, "end": 5115302}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5115302, "end": 5115668}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5115668, "end": 5116104}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5116104, "end": 5116662}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5116662, "end": 5116986}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography.php", "start": 5116986, "end": 5117926}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography/block.json", "start": 5117926, "end": 5118848}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5118848, "end": 5120511}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5120511, "end": 5121829}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5121829, "end": 5122165}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form.php", "start": 5122165, "end": 5123608}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/block.json", "start": 5123608, "end": 5124560}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/editor.min.css", "start": 5124560, "end": 5124684}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/style.min.css", "start": 5124684, "end": 5126557}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5126557, "end": 5127725}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5127725, "end": 5128526}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5128526, "end": 5129878}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5129878, "end": 5130993}, {"filename": "/wordpress/wp-includes/blocks/post-date/style.min.css", "start": 5130993, "end": 5131035}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5131035, "end": 5132556}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5132556, "end": 5133705}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5133705, "end": 5133791}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5133791, "end": 5133846}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5133846, "end": 5138985}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5138985, "end": 5140728}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5140728, "end": 5144874}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5144874, "end": 5146620}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5146620, "end": 5148710}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5148710, "end": 5149742}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5149742, "end": 5152119}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5152119, "end": 5153167}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5153167, "end": 5153261}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5153261, "end": 5154114}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5154114, "end": 5156330}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5156330, "end": 5157443}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5157443, "end": 5157496}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5157496, "end": 5158685}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5158685, "end": 5160050}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5160050, "end": 5160159}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5160159, "end": 5161183}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5161183, "end": 5161288}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5161288, "end": 5162897}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5162897, "end": 5163139}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5163139, "end": 5164065}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5164065, "end": 5164332}, {"filename": "/wordpress/wp-includes/blocks/query-no-results.php", "start": 5164332, "end": 5165369}, {"filename": "/wordpress/wp-includes/blocks/query-no-results/block.json", "start": 5165369, "end": 5166214}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5166214, "end": 5168144}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5168144, "end": 5169083}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5169083, "end": 5170954}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5170954, "end": 5171885}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5171885, "end": 5172089}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5172089, "end": 5173587}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5173587, "end": 5174538}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5174538, "end": 5175090}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5175090, "end": 5176410}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5176410, "end": 5177085}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5177085, "end": 5178300}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5178300, "end": 5179844}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5179844, "end": 5181051}, {"filename": "/wordpress/wp-includes/blocks/query-title/style.min.css", "start": 5181051, "end": 5181095}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5181095, "end": 5181251}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5181251, "end": 5182507}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5182507, "end": 5183842}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5183842, "end": 5185322}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5185322, "end": 5185922}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5185922, "end": 5186390}, {"filename": "/wordpress/wp-includes/blocks/read-more.php", "start": 5186390, "end": 5187274}, {"filename": "/wordpress/wp-includes/blocks/read-more/block.json", "start": 5187274, "end": 5188484}, {"filename": "/wordpress/wp-includes/blocks/read-more/style.min.css", "start": 5188484, "end": 5188743}, {"filename": "/wordpress/wp-includes/blocks/require-dynamic-blocks.php", "start": 5188743, "end": 5192281}, {"filename": "/wordpress/wp-includes/blocks/require-static-blocks.php", "start": 5192281, "end": 5192612}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5192612, "end": 5195966}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5195966, "end": 5196871}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5196871, "end": 5197307}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5197307, "end": 5198006}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5198006, "end": 5212859}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5212859, "end": 5214784}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5214784, "end": 5215041}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5215041, "end": 5216262}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5216262, "end": 5216388}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5216388, "end": 5217392}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5217392, "end": 5217620}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5217620, "end": 5217972}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5217972, "end": 5218409}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5218409, "end": 5218733}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5218733, "end": 5219198}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5219198, "end": 5220222}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5220222, "end": 5223971}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5223971, "end": 5225312}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5225312, "end": 5226824}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5226824, "end": 5227249}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5227249, "end": 5227905}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5227905, "end": 5229029}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5229029, "end": 5229097}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5229097, "end": 5230355}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5230355, "end": 5231797}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5231797, "end": 5231863}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5231863, "end": 5290378}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5290378, "end": 5291014}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5291014, "end": 5291387}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5291387, "end": 5293311}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5293311, "end": 5295298}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5295298, "end": 5305087}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5305087, "end": 5305710}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5305710, "end": 5306534}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5306534, "end": 5306562}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5306562, "end": 5310106}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5310106, "end": 5312086}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5312086, "end": 5315872}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5315872, "end": 5316191}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5316191, "end": 5317356}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5317356, "end": 5318257}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5318257, "end": 5318755}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5318755, "end": 5324458}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5324458, "end": 5325055}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5325055, "end": 5325587}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5325587, "end": 5325678}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5325678, "end": 5326445}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5326445, "end": 5327462}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5327462, "end": 5328192}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5328192, "end": 5328278}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5328278, "end": 5328730}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5328730, "end": 5329949}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5329949, "end": 5330023}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5330023, "end": 5331838}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5331838, "end": 5334101}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5334101, "end": 5334350}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5334350, "end": 5334520}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5334520, "end": 5335896}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5335896, "end": 5336215}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5336215, "end": 5341701}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5341701, "end": 5350101}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5350101, "end": 5351973}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5351973, "end": 5354834}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5354834, "end": 5378345}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5378345, "end": 5398359}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5398359, "end": 5419152}, {"filename": "/wordpress/wp-includes/category.php", "start": 5419152, "end": 5423623}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5423623, "end": 5656854}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5656854, "end": 5657480}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5657480, "end": 5657920}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5657920, "end": 5658061}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5658061, "end": 5672073}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5672073, "end": 5672218}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5672218, "end": 5675964}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5675964, "end": 5676480}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5676480, "end": 5687057}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5687057, "end": 5701628}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5701628, "end": 5757828}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5757828, "end": 5758148}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5758148, "end": 5779587}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5779587, "end": 5780543}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5780543, "end": 5784167}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5784167, "end": 5791979}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5791979, "end": 5795292}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5795292, "end": 5796158}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5796158, "end": 5799545}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5799545, "end": 5810558}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5810558, "end": 5812885}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5812885, "end": 5818752}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5818752, "end": 5819056}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5819056, "end": 5820410}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5820410, "end": 5826616}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5826616, "end": 5828673}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5828673, "end": 5830997}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5830997, "end": 5833144}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5833144, "end": 5836418}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5836418, "end": 5836749}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5836749, "end": 5838751}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5838751, "end": 5842628}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5842628, "end": 5846645}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5846645, "end": 5868354}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5868354, "end": 5871352}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5871352, "end": 5884445}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5884445, "end": 6008797}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 6008797, "end": 6047745}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 6047745, "end": 6051720}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 6051720, "end": 6056004}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 6056004, "end": 6068588}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 6068588, "end": 6109706}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6109706, "end": 6124859}, {"filename": "/wordpress/wp-includes/class-wp-dependencies.php", "start": 6124859, "end": 6130258}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6130258, "end": 6130961}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6130961, "end": 6173287}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6173287, "end": 6180871}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6180871, "end": 6183670}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6183670, "end": 6186763}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6186763, "end": 6187688}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6187688, "end": 6188073}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6188073, "end": 6194180}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6194180, "end": 6197018}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6197018, "end": 6204623}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6204623, "end": 6207241}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6207241, "end": 6209647}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6209647, "end": 6211584}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6211584, "end": 6212147}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6212147, "end": 6214202}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6214202, "end": 6215082}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6215082, "end": 6225905}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6225905, "end": 6242490}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6242490, "end": 6251695}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6251695, "end": 6266308}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6266308, "end": 6272744}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6272744, "end": 6275768}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6275768, "end": 6277717}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6277717, "end": 6283241}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6283241, "end": 6283979}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6283979, "end": 6297228}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6297228, "end": 6299094}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6299094, "end": 6308073}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6308073, "end": 6312981}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6312981, "end": 6319699}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6319699, "end": 6323418}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6323418, "end": 6337265}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6337265, "end": 6339795}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6339795, "end": 6351540}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6351540, "end": 6354524}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6354524, "end": 6433315}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6433315, "end": 6436954}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6436954, "end": 6442749}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6442749, "end": 6444808}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6444808, "end": 6446383}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6446383, "end": 6452484}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6452484, "end": 6477265}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6477265, "end": 6477923}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6477923, "end": 6481447}, {"filename": "/wordpress/wp-includes/class-wp-scripts.php", "start": 6481447, "end": 6490565}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6490565, "end": 6493073}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6493073, "end": 6494385}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6494385, "end": 6495240}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6495240, "end": 6509345}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6509345, "end": 6512032}, {"filename": "/wordpress/wp-includes/class-wp-styles.php", "start": 6512032, "end": 6517175}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6517175, "end": 6526450}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6526450, "end": 6535610}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6535610, "end": 6553817}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6553817, "end": 6556021}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6556021, "end": 6556358}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6556358, "end": 6564382}, {"filename": "/wordpress/wp-includes/class-wp-textdomain-registry.php", "start": 6564382, "end": 6566185}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-data.php", "start": 6566185, "end": 6566636}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6566636, "end": 6577821}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6577821, "end": 6579650}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6579650, "end": 6638728}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6638728, "end": 6666298}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6666298, "end": 6667760}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6667760, "end": 6686243}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6686243, "end": 6687249}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6687249, "end": 6696464}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6696464, "end": 6702084}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6702084, "end": 6703483}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6703483, "end": 6710924}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6710924, "end": 6837939}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6837939, "end": 6852379}, {"filename": "/wordpress/wp-includes/class-wpdb.php", "start": 6852379, "end": 6902521}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6902521, "end": 6902678}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6902678, "end": 6902825}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6902825, "end": 6902970}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6902970, "end": 6940576}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6940576, "end": 7000955}, {"filename": "/wordpress/wp-includes/compat.php", "start": 7000955, "end": 7006632}, {"filename": "/wordpress/wp-includes/cron.php", "start": 7006632, "end": 7020105}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 7020105, "end": 7020743}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 7020743, "end": 7020955}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 7020955, "end": 7023194}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 7023194, "end": 7024435}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 7024435, "end": 7026162}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 7026162, "end": 7026731}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 7026731, "end": 7028908}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 7028908, "end": 7035379}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 7035379, "end": 7035489}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 7035489, "end": 7042106}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 7042106, "end": 7043039}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 7043039, "end": 7043503}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 7043503, "end": 7050223}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 7050223, "end": 7050834}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 7050834, "end": 7052217}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 7052217, "end": 7057468}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 7057468, "end": 7073864}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 7073864, "end": 7075409}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 7075409, "end": 7077384}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 7077384, "end": 7078012}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 7078012, "end": 7078276}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 7078276, "end": 7087866}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 7087866, "end": 7089714}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7089714, "end": 7090298}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7090298, "end": 7091034}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7091034, "end": 7093720}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7093720, "end": 7099201}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7099201, "end": 7099539}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7099539, "end": 7101847}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7101847, "end": 7110663}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7110663, "end": 7112867}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7112867, "end": 7117516}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7117516, "end": 7117994}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7117994, "end": 7118148}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7118148, "end": 7119248}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7119248, "end": 7120496}, {"filename": "/wordpress/wp-includes/date.php", "start": 7120496, "end": 7120649}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7120649, "end": 7126455}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7126455, "end": 7154048}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7154048, "end": 7155499}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7155499, "end": 7215577}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7215577, "end": 7215723}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7215723, "end": 7234287}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7234287, "end": 7236173}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7236173, "end": 7240098}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7240098, "end": 7242616}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7242616, "end": 7244744}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7244744, "end": 7245675}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7245675, "end": 7248498}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7248498, "end": 7251223}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7251223, "end": 7260809}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7260809, "end": 7470993}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7470993, "end": 7585483}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7585483, "end": 7590021}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7590021, "end": 7592060}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7592060, "end": 7666911}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7666911, "end": 7671091}, {"filename": "/wordpress/wp-includes/http.php", "start": 7671091, "end": 7679411}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7679411, "end": 7682473}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7682473, "end": 7684150}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7684150, "end": 7684895}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7684895, "end": 7686746}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7686746, "end": 7719477}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7719477, "end": 7741245}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7741245, "end": 7801883}, {"filename": "/wordpress/wp-includes/load.php", "start": 7801883, "end": 7825382}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7825382, "end": 7825440}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7825440, "end": 7881522}, {"filename": "/wordpress/wp-includes/media.php", "start": 7881522, "end": 7969273}, {"filename": "/wordpress/wp-includes/meta.php", "start": 7969273, "end": 7991722}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 7991722, "end": 8005075}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 8005075, "end": 8008087}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 8008087, "end": 8013775}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 8013775, "end": 8025143}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 8025143, "end": 8027302}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 8027302, "end": 8069111}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 8069111, "end": 8077864}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 8077864, "end": 8079360}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 8079360, "end": 8081329}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 8081329, "end": 8099142}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8099142, "end": 8113225}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8113225, "end": 8137546}, {"filename": "/wordpress/wp-includes/option.php", "start": 8137546, "end": 8171302}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8171302, "end": 8171489}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8171489, "end": 8173971}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8173971, "end": 8221897}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8221897, "end": 8230788}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8230788, "end": 8232307}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8232307, "end": 8238541}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8238541, "end": 8242769}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8242769, "end": 8252483}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8252483, "end": 8256897}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8256897, "end": 8262613}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8262613, "end": 8266560}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8266560, "end": 8296540}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8296540, "end": 8299543}, {"filename": "/wordpress/wp-includes/post.php", "start": 8299543, "end": 8419470}, {"filename": "/wordpress/wp-includes/query.php", "start": 8419470, "end": 8433224}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8433224, "end": 8435287}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8435287, "end": 8435748}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8435748, "end": 8435998}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8435998, "end": 8438864}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8438864, "end": 8439569}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8439569, "end": 8440899}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8440899, "end": 8441574}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8441574, "end": 8442262}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8442262, "end": 8442765}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8442765, "end": 8443899}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8443899, "end": 8444012}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8444012, "end": 8444125}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8444125, "end": 8499391}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8499391, "end": 8510466}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8510466, "end": 8512927}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8512927, "end": 8538168}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8538168, "end": 8553238}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8553238, "end": 8582090}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8582090, "end": 8590169}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8590169, "end": 8596493}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php", "start": 8596493, "end": 8598984}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php", "start": 8598984, "end": 8603405}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8603405, "end": 8606932}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8606932, "end": 8623343}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8623343, "end": 8624215}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8624215, "end": 8663148}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8663148, "end": 8672093}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8672093, "end": 8673300}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8673300, "end": 8685290}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8685290, "end": 8708150}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8708150, "end": 8713350}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8713350, "end": 8724273}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8724273, "end": 8730822}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8730822, "end": 8750019}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8750019, "end": 8756582}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8756582, "end": 8765454}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8765454, "end": 8829898}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8829898, "end": 8846228}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8846228, "end": 8853582}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8853582, "end": 8858120}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8858120, "end": 8867864}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8867864, "end": 8874198}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8874198, "end": 8883256}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8883256, "end": 8903701}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8903701, "end": 8924723}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8924723, "end": 8937479}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8937479, "end": 8945736}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8945736, "end": 8977138}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 8977138, "end": 8988548}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 8988548, "end": 9004726}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 9004726, "end": 9004976}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 9004976, "end": 9015425}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 9015425, "end": 9015782}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 9015782, "end": 9016174}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 9016174, "end": 9016412}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 9016412, "end": 9018352}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 9018352, "end": 9021327}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 9021327, "end": 9021775}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 9021775, "end": 9024164}, {"filename": "/wordpress/wp-includes/revision.php", "start": 9024164, "end": 9036297}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 9036297, "end": 9044322}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 9044322, "end": 9045638}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 9045638, "end": 9045801}, {"filename": "/wordpress/wp-includes/rss.php", "start": 9045801, "end": 9060243}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 9060243, "end": 9151411}, {"filename": "/wordpress/wp-includes/session.php", "start": 9151411, "end": 9151605}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9151605, "end": 9159505}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9159505, "end": 9160705}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9160705, "end": 9161482}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9161482, "end": 9163145}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9163145, "end": 9163765}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9163765, "end": 9167321}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9167321, "end": 9174266}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9174266, "end": 9177509}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9177509, "end": 9180000}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9180000, "end": 9182217}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9182217, "end": 9183706}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9183706, "end": 9184566}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9184566, "end": 9184985}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9184985, "end": 9186686}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9186686, "end": 9188294}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9188294, "end": 9192452}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9192452, "end": 9193003}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9193003, "end": 9215440}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9215440, "end": 9220036}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9220036, "end": 9224199}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9224199, "end": 9235417}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9235417, "end": 9236284}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9236284, "end": 9236368}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9236368, "end": 9236464}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9236464, "end": 9236562}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9236562, "end": 9236668}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9236668, "end": 9236782}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9236782, "end": 9236884}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9236884, "end": 9236992}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9236992, "end": 9237114}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9237114, "end": 9237232}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9237232, "end": 9237346}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9237346, "end": 9237460}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9237460, "end": 9237584}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9237584, "end": 9237690}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9237690, "end": 9237786}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9237786, "end": 9237886}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9237886, "end": 9237984}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9237984, "end": 9238082}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9238082, "end": 9238192}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9238192, "end": 9238288}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9238288, "end": 9238384}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9238384, "end": 9238474}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9238474, "end": 9238568}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9238568, "end": 9238668}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9238668, "end": 9238766}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9238766, "end": 9238850}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9238850, "end": 9238930}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9238930, "end": 9321381}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9321381, "end": 9332352}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9332352, "end": 9335312}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9335312, "end": 9338747}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9338747, "end": 9342182}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9342182, "end": 9347382}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9347382, "end": 9349418}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9349418, "end": 9350124}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9350124, "end": 9429341}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9429341, "end": 9430624}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9430624, "end": 9431447}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9431447, "end": 9432188}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9432188, "end": 9432783}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9432783, "end": 9433520}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9433520, "end": 9434209}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9434209, "end": 9523249}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9523249, "end": 9532031}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9532031, "end": 9534597}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9534597, "end": 9537061}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9537061, "end": 9537836}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9537836, "end": 9544682}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9544682, "end": 9557210}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9557210, "end": 9562084}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9562084, "end": 9564189}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9564189, "end": 9567500}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9567500, "end": 9579876}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9579876, "end": 9584591}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9584591, "end": 9586188}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9586188, "end": 9586670}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9586670, "end": 9596051}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9596051, "end": 9601555}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9601555, "end": 9604320}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9604320, "end": 9605174}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9605174, "end": 9688276}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9688276, "end": 9690966}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9690966, "end": 9691809}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9691809, "end": 9692566}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9692566, "end": 9693177}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9693177, "end": 9693934}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9693934, "end": 9694636}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9694636, "end": 9782987}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9782987, "end": 9790758}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9790758, "end": 9793834}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9793834, "end": 9797842}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9797842, "end": 9811283}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9811283, "end": 9828873}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9828873, "end": 9829658}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9829658, "end": 9838272}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9838272, "end": 9844865}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9844865, "end": 9846998}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9846998, "end": 9849767}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9849767, "end": 9849926}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9849926, "end": 9855924}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9855924, "end": 9857065}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9857065, "end": 9857553}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9857553, "end": 9882100}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9882100, "end": 9906956}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9906956, "end": 9936364}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9936364, "end": 9938020}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9938020, "end": 9938120}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9938120, "end": 9938230}, {"filename": "/wordpress/wp-includes/style-engine.php", "start": 9938230, "end": 9940122}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-declarations.php", "start": 9940122, "end": 9942085}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rule.php", "start": 9942085, "end": 9943685}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php", "start": 9943685, "end": 9944798}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-processor.php", "start": 9944798, "end": 9946866}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine.php", "start": 9946866, "end": 9957218}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9957218, "end": 10026824}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 10026824, "end": 10027150}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 10027150, "end": 10028875}, {"filename": "/wordpress/wp-includes/template.php", "start": 10028875, "end": 10035874}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 10035874, "end": 10037502}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 10037502, "end": 10038019}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 10038019, "end": 10040009}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 10040009, "end": 10040223}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 10040223, "end": 10040278}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 10040278, "end": 10040954}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 10040954, "end": 10041284}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 10041284, "end": 10042843}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 10042843, "end": 10045968}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 10045968, "end": 10047119}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 10047119, "end": 10050792}, {"filename": "/wordpress/wp-includes/theme.json", "start": 10050792, "end": 10060200}, {"filename": "/wordpress/wp-includes/theme.php", "start": 10060200, "end": 10130097}, {"filename": "/wordpress/wp-includes/update.php", "start": 10130097, "end": 10150784}, {"filename": "/wordpress/wp-includes/user.php", "start": 10150784, "end": 10224152}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10224152, "end": 10228147}, {"filename": "/wordpress/wp-includes/version.php", "start": 10228147, "end": 10228305}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10228305, "end": 10261050}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10261050, "end": 10264912}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10264912, "end": 10269152}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10269152, "end": 10272357}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10272357, "end": 10273843}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10273843, "end": 10278374}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10278374, "end": 10285516}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10285516, "end": 10290955}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10290955, "end": 10295169}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10295169, "end": 10300309}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10300309, "end": 10309143}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10309143, "end": 10315220}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10315220, "end": 10323347}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10323347, "end": 10325545}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10325545, "end": 10329122}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10329122, "end": 10333232}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10333232, "end": 10337116}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10337116, "end": 10340294}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10340294, "end": 10341686}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10341686, "end": 10345935}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10345935, "end": 10358332}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10358332, "end": 10359377}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10359377, "end": 10359556}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10359556, "end": 10359905}, {"filename": "/wordpress/wp-links-opml.php", "start": 10359905, "end": 10361515}, {"filename": "/wordpress/wp-load.php", "start": 10361515, "end": 10363310}, {"filename": "/wordpress/wp-login.php", "start": 10363310, "end": 10397443}, {"filename": "/wordpress/wp-mail.php", "start": 10397443, "end": 10403394}, {"filename": "/wordpress/wp-settings.php", "start": 10403394, "end": 10420316}, {"filename": "/wordpress/wp-signup.php", "start": 10420316, "end": 10443228}, {"filename": "/wordpress/wp-trackback.php", "start": 10443228, "end": 10446655}, {"filename": "/wordpress/xmlrpc.php", "start": 10446655, "end": 10448476}], "remote_package_size": 10448476}); })(); // See esm-prefix.js diff --git a/build/wp-nightly.data b/build/wp-nightly.data old mode 100755 new mode 100644 index ddc1d22d56..a8fd6c92c5 --- a/build/wp-nightly.data +++ b/build/wp-nightly.data @@ -5,11 +5,11 @@ WordPress › Installation - - - - - + + + + + @@ -43,6 +43,7 @@ var _zxcvbnSettings = {"src":"http:\/\/127.0.0.1:8000\/wp-includes\/js\/zxcvbn.m /* ]]> */ + @@ -55,20 +56,20 @@ wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); var pwsL10n = {"unknown":"Password strength unknown","short":"Very weak","bad":"Weak","good":"Medium","strong":"Strong","mismatch":"Mismatch"}; /* ]]> */ - + - + - + $post ) ); $current_screen = get_current_screen(); $current_screen->is_block_editor( true ); add_filter( 'admin_body_class', static function( $classes ) { return "$classes is-fullscreen-mode"; } ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); add_filter( 'screen_options_show_screen', '__return_false' ); wp_enqueue_script( 'heartbeat' ); wp_enqueue_script( 'wp-edit-post' ); $rest_path = rest_get_route_for_post( $post ); $preload_paths = array( '/wp/v2/types?context=view', '/wp/v2/taxonomies?context=view', add_query_arg( array( 'context' => 'edit', 'per_page' => -1, ), rest_get_route_for_post_type_items( 'wp_block' ) ), add_query_arg( 'context', 'edit', $rest_path ), sprintf( '/wp/v2/types/%s?context=edit', $post_type ), '/wp/v2/users/me', array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'page' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_block' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_template' ), 'OPTIONS' ), sprintf( '%s/autosaves?context=edit', $rest_path ), '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), ); block_editor_rest_api_preload( $preload_paths, $block_editor_context ); wp_add_inline_script( 'wp-blocks', sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ), 'after' ); $initial_edits = array(); $is_new_post = false; if ( 'auto-draft' === $post->post_status ) { $is_new_post = true; if ( post_type_supports( $post->post_type, 'title' ) ) { $initial_edits['title'] = $post->post_title; } if ( post_type_supports( $post->post_type, 'editor' ) ) { $initial_edits['content'] = $post->post_content; } if ( post_type_supports( $post->post_type, 'excerpt' ) ) { $initial_edits['excerpt'] = $post->post_excerpt; } } wp_add_inline_script( 'wp-blocks', 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' ); $meta_box_url = admin_url( 'post.php' ); $meta_box_url = add_query_arg( array( 'post' => $post->ID, 'action' => 'edit', 'meta-box-loader' => true, 'meta-box-loader-nonce' => wp_create_nonce( 'meta-box-loader' ), ), $meta_box_url ); wp_add_inline_script( 'wp-editor', sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ), 'before' ); $available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) ); $available_templates = ! empty( $available_templates ) ? array_replace( array( '' => apply_filters( 'default_page_template_title', __( 'Default template' ), 'rest-api' ), ), $available_templates ) : $available_templates; $user_id = wp_check_post_lock( $post->ID ); if ( $user_id ) { $locked = false; if ( apply_filters( 'show_post_locked_dialog', true, $post, $user_id ) ) { $locked = true; } $user_details = null; if ( $locked ) { $user = get_userdata( $user_id ); $user_details = array( 'avatar' => get_avatar_url( $user_id, array( 'size' => 128 ) ), 'name' => $user->display_name, ); } $lock_details = array( 'isLocked' => $locked, 'user' => $user_details, ); } else { $active_post_lock = wp_set_post_lock( $post->ID ); if ( $active_post_lock ) { $active_post_lock = esc_attr( implode( ':', $active_post_lock ) ); } $lock_details = array( 'isLocked' => false, 'activePostLock' => $active_post_lock, ); } $body_placeholder = apply_filters( 'write_your_story', __( 'Type / to choose a block' ), $post ); $editor_settings = array( 'availableTemplates' => $available_templates, 'disablePostFormats' => ! current_theme_supports( 'post-formats' ), 'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ), 'bodyPlaceholder' => $body_placeholder, 'autosaveInterval' => AUTOSAVE_INTERVAL, 'richEditingEnabled' => user_can_richedit(), 'postLock' => $lock_details, 'postLockUtils' => array( 'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ), 'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), ), 'supportsLayout' => WP_Theme_JSON_Resolver::theme_has_support(), 'supportsTemplateMode' => current_theme_supports( 'block-templates' ), 'enableCustomFields' => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), ); $editor_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true ); $editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true ); $autosave = wp_get_post_autosave( $post->ID ); if ( $autosave ) { if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { $editor_settings['autosave'] = array( 'editLink' => get_edit_post_link( $autosave->ID ), ); } else { wp_delete_post_revision( $autosave->ID ); } } if ( ! empty( $post_type_object->template ) ) { $editor_settings['template'] = $post_type_object->template; $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false; } if ( $is_new_post && ! isset( $editor_settings['template'] ) && 'post' === $post->post_type ) { $post_format = get_post_format( $post ); if ( in_array( $post_format, array( 'audio', 'gallery', 'image', 'quote', 'video' ), true ) ) { $editor_settings['template'] = array( array( "core/$post_format" ) ); } } if ( wp_is_block_theme() && $editor_settings['supportsTemplateMode'] ) { $editor_settings['defaultTemplatePartAreas'] = get_allowed_block_template_part_areas(); } wp_enqueue_media( array( 'post' => $post->ID, ) ); wp_tinymce_inline_scripts(); wp_enqueue_editor(); wp_enqueue_style( 'wp-edit-post' ); do_action( 'enqueue_block_editor_assets' ); require_once ABSPATH . 'wp-admin/includes/meta-boxes.php'; register_and_do_post_meta_boxes( $post ); $core_meta_boxes = $wp_meta_boxes[ $current_screen->id ]['normal']['core']; if ( ! isset( $core_meta_boxes['postcustom'] ) || ! $core_meta_boxes['postcustom'] ) { unset( $editor_settings['enableCustomFields'] ); } $editor_settings = get_block_editor_settings( $editor_settings, $block_editor_context ); $init_script = << $post ) ); $current_screen = get_current_screen(); $current_screen->is_block_editor( true ); add_filter( 'admin_body_class', static function( $classes ) { return "$classes is-fullscreen-mode"; } ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); add_filter( 'screen_options_show_screen', '__return_false' ); wp_enqueue_script( 'heartbeat' ); wp_enqueue_script( 'wp-edit-post' ); $rest_path = rest_get_route_for_post( $post ); $preload_paths = array( '/wp/v2/types?context=view', '/wp/v2/taxonomies?context=view', add_query_arg( array( 'context' => 'edit', 'per_page' => -1, ), rest_get_route_for_post_type_items( 'wp_block' ) ), add_query_arg( 'context', 'edit', $rest_path ), sprintf( '/wp/v2/types/%s?context=edit', $post_type ), '/wp/v2/users/me', array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'page' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_block' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_template' ), 'OPTIONS' ), sprintf( '%s/autosaves?context=edit', $rest_path ), '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), ); block_editor_rest_api_preload( $preload_paths, $block_editor_context ); wp_add_inline_script( 'wp-blocks', sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ), 'after' ); $initial_edits = array(); $is_new_post = false; if ( 'auto-draft' === $post->post_status ) { $is_new_post = true; if ( post_type_supports( $post->post_type, 'title' ) ) { $initial_edits['title'] = $post->post_title; } if ( post_type_supports( $post->post_type, 'editor' ) ) { $initial_edits['content'] = $post->post_content; } if ( post_type_supports( $post->post_type, 'excerpt' ) ) { $initial_edits['excerpt'] = $post->post_excerpt; } } wp_add_inline_script( 'wp-blocks', 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' ); $meta_box_url = admin_url( 'post.php' ); $meta_box_url = add_query_arg( array( 'post' => $post->ID, 'action' => 'edit', 'meta-box-loader' => true, 'meta-box-loader-nonce' => wp_create_nonce( 'meta-box-loader' ), ), $meta_box_url ); wp_add_inline_script( 'wp-editor', sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ), 'before' ); $available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) ); $available_templates = ! empty( $available_templates ) ? array_replace( array( '' => apply_filters( 'default_page_template_title', __( 'Default template' ), 'rest-api' ), ), $available_templates ) : $available_templates; $user_id = wp_check_post_lock( $post->ID ); if ( $user_id ) { $locked = false; if ( apply_filters( 'show_post_locked_dialog', true, $post, $user_id ) ) { $locked = true; } $user_details = null; if ( $locked ) { $user = get_userdata( $user_id ); $user_details = array( 'avatar' => get_avatar_url( $user_id, array( 'size' => 128 ) ), 'name' => $user->display_name, ); } $lock_details = array( 'isLocked' => $locked, 'user' => $user_details, ); } else { $active_post_lock = wp_set_post_lock( $post->ID ); if ( $active_post_lock ) { $active_post_lock = esc_attr( implode( ':', $active_post_lock ) ); } $lock_details = array( 'isLocked' => false, 'activePostLock' => $active_post_lock, ); } $body_placeholder = apply_filters( 'write_your_story', __( 'Type / to choose a block' ), $post ); $editor_settings = array( 'availableTemplates' => $available_templates, 'disablePostFormats' => ! current_theme_supports( 'post-formats' ), 'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ), 'bodyPlaceholder' => $body_placeholder, 'autosaveInterval' => AUTOSAVE_INTERVAL, 'richEditingEnabled' => user_can_richedit(), 'postLock' => $lock_details, 'postLockUtils' => array( 'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ), 'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), ), 'supportsLayout' => wp_theme_has_theme_json(), 'supportsTemplateMode' => current_theme_supports( 'block-templates' ), 'enableCustomFields' => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), ); $editor_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true ); $editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true ); $autosave = wp_get_post_autosave( $post->ID ); if ( $autosave ) { if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { $editor_settings['autosave'] = array( 'editLink' => get_edit_post_link( $autosave->ID ), ); } else { wp_delete_post_revision( $autosave->ID ); } } if ( ! empty( $post_type_object->template ) ) { $editor_settings['template'] = $post_type_object->template; $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false; } if ( $is_new_post && ! isset( $editor_settings['template'] ) && 'post' === $post->post_type ) { $post_format = get_post_format( $post ); if ( in_array( $post_format, array( 'audio', 'gallery', 'image', 'quote', 'video' ), true ) ) { $editor_settings['template'] = array( array( "core/$post_format" ) ); } } if ( wp_is_block_theme() && $editor_settings['supportsTemplateMode'] ) { $editor_settings['defaultTemplatePartAreas'] = get_allowed_block_template_part_areas(); } wp_enqueue_media( array( 'post' => $post->ID, ) ); wp_tinymce_inline_scripts(); wp_enqueue_editor(); wp_enqueue_style( 'wp-edit-post' ); do_action( 'enqueue_block_editor_assets' ); require_once ABSPATH . 'wp-admin/includes/meta-boxes.php'; register_and_do_post_meta_boxes( $post ); $core_meta_boxes = $wp_meta_boxes[ $current_screen->id ]['normal']['core']; if ( ! isset( $core_meta_boxes['postcustom'] ) || ! $core_meta_boxes['postcustom'] ) { unset( $editor_settings['enableCustomFields'] ); } $editor_settings = get_block_editor_settings( $editor_settings, $block_editor_context ); $init_script = << $ wp_print_request_filesystem_credentials_modal(); wp_print_admin_notice_templates(); require_once ABSPATH . 'wp-admin/admin-footer.php'; $_GET['list_args']['screen']['id'] ) ); if ( ! $wp_list_table ) { wp_die( 0 ); } if ( ! $wp_list_table->ajax_user_can() ) { wp_die( -1 ); } $wp_list_table->ajax_response(); wp_die( 0 ); } function wp_ajax_ajax_tag_search() { if ( ! isset( $_GET['tax'] ) ) { wp_die( 0 ); } $taxonomy = sanitize_key( $_GET['tax'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { wp_die( -1 ); } $search = wp_unslash( $_GET['q'] ); $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $search = str_replace( $comma, ',', $search ); } if ( false !== strpos( $search, ',' ) ) { $search = explode( ',', $search ); $search = $search[ count( $search ) - 1 ]; } $search = trim( $search ); $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $taxonomy_object, $search ); if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { wp_die(); } $results = get_terms( array( 'taxonomy' => $taxonomy, 'name__like' => $search, 'fields' => 'names', 'hide_empty' => false, 'number' => isset( $_GET['number'] ) ? (int) $_GET['number'] : 0, ) ); $results = apply_filters( 'ajax_term_search_results', $results, $taxonomy_object, $search ); echo implode( "\n", $results ); wp_die(); } function wp_ajax_wp_compression_test() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( -1 ); } if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) { update_site_option( 'can_compress_scripts', 0 ); wp_die( 0 ); } if ( isset( $_GET['test'] ) ) { header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); header( 'Content-Type: application/javascript; charset=UTF-8' ); $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ); $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; if ( 1 == $_GET['test'] ) { echo $test_str; wp_die(); } elseif ( 2 == $_GET['test'] ) { if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { wp_die( -1 ); } if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) { header( 'Content-Encoding: deflate' ); $out = gzdeflate( $test_str, 1 ); } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) { header( 'Content-Encoding: gzip' ); $out = gzencode( $test_str, 1 ); } else { wp_die( -1 ); } echo $out; wp_die(); } elseif ( 'no' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 0 ); } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 1 ); } } wp_die( 0 ); } function wp_ajax_imgedit_preview() { $post_id = (int) $_GET['postid']; if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } check_ajax_referer( "image_editor-$post_id" ); include_once ABSPATH . 'wp-admin/includes/image-edit.php'; if ( ! stream_preview_image( $post_id ) ) { wp_die( -1 ); } wp_die(); } function wp_ajax_oembed_cache() { $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); wp_die( 0 ); } function wp_ajax_autocomplete_user() { if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) { wp_die( -1 ); } if ( ! current_user_can( 'manage_network_users' ) && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) { wp_die( -1 ); } $return = array(); if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { $type = $_REQUEST['autocomplete_type']; } else { $type = 'add'; } if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { $field = $_REQUEST['autocomplete_field']; } else { $field = 'user_login'; } if ( isset( $_REQUEST['site_id'] ) ) { $id = absint( $_REQUEST['site_id'] ); } else { $id = get_current_blog_id(); } $include_blog_users = ( 'search' === $type ? get_users( array( 'blog_id' => $id, 'fields' => 'ID', ) ) : array() ); $exclude_blog_users = ( 'add' === $type ? get_users( array( 'blog_id' => $id, 'fields' => 'ID', ) ) : array() ); $users = get_users( array( 'blog_id' => false, 'search' => '*' . $_REQUEST['term'] . '*', 'include' => $include_blog_users, 'exclude' => $exclude_blog_users, 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ), ) ); foreach ( $users as $user ) { $return[] = array( 'label' => sprintf( _x( '%1$s (%2$s)', 'user autocomplete result' ), $user->user_login, $user->user_email ), 'value' => $user->$field, ); } wp_die( wp_json_encode( $return ) ); } function wp_ajax_get_community_events() { require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; check_ajax_referer( 'community_events' ); $search = isset( $_POST['location'] ) ? wp_unslash( $_POST['location'] ) : ''; $timezone = isset( $_POST['timezone'] ) ? wp_unslash( $_POST['timezone'] ) : ''; $user_id = get_current_user_id(); $saved_location = get_user_option( 'community-events-location', $user_id ); $events_client = new WP_Community_Events( $user_id, $saved_location ); $events = $events_client->get_events( $search, $timezone ); $ip_changed = false; if ( is_wp_error( $events ) ) { wp_send_json_error( array( 'error' => $events->get_error_message(), ) ); } else { if ( empty( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) ) { $ip_changed = true; } elseif ( isset( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) && $saved_location['ip'] !== $events['location']['ip'] ) { $ip_changed = true; } if ( $ip_changed || $search ) { update_user_meta( $user_id, 'community-events-location', $events['location'] ); } wp_send_json_success( $events ); } } function wp_ajax_dashboard_widgets() { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; $pagenow = $_GET['pagenow']; if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) { set_current_screen( $pagenow ); } switch ( $_GET['widget'] ) { case 'dashboard_primary': wp_dashboard_primary(); break; } wp_die(); } function wp_ajax_logged_in() { wp_die( 1 ); } function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0; $per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0; $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; $url = isset( $_POST['_url'] ) ? sanitize_url( $_POST['_url'] ) : ''; if ( ! $total || ! $per_page || ! $page || ! $url ) { $time = time(); $comment = get_comment( $comment_id ); $comment_status = ''; $comment_link = ''; if ( $comment ) { $comment_status = $comment->comment_approved; } if ( 1 === (int) $comment_status ) { $comment_link = get_comment_link( $comment ); } $counts = wp_count_comments(); $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $comment_id, 'supplemental' => array( 'status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), 'comment_link' => $comment_link, ), ) ); $x->send(); } $total += $delta; if ( $total < 0 ) { $total = 0; } if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { $post_id = 0; $status = 'all'; $parsed = parse_url( $url ); if ( isset( $parsed['query'] ) ) { parse_str( $parsed['query'], $query_vars ); if ( ! empty( $query_vars['comment_status'] ) ) { $status = $query_vars['comment_status']; } if ( ! empty( $query_vars['p'] ) ) { $post_id = (int) $query_vars['p']; } if ( ! empty( $query_vars['comment_type'] ) ) { $type = $query_vars['comment_type']; } } if ( empty( $type ) ) { $comment_count = wp_count_comments( $post_id ); if ( isset( $comment_count->$status ) ) { $total = $comment_count->$status; } } } $time = time(); $comment = get_comment( $comment_id ); $counts = wp_count_comments(); $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $comment_id, 'supplemental' => array( 'status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 'total_pages' => ceil( $total / $per_page ), 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), 'total' => $total, 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), ), ) ); $x->send(); } function _wp_ajax_add_hierarchical_term() { $action = $_POST['action']; $taxonomy = get_taxonomy( substr( $action, 4 ) ); check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { wp_die( -1 ); } $names = explode( ',', $_POST[ 'new' . $taxonomy->name ] ); $parent = isset( $_POST[ 'new' . $taxonomy->name . '_parent' ] ) ? (int) $_POST[ 'new' . $taxonomy->name . '_parent' ] : 0; if ( 0 > $parent ) { $parent = 0; } if ( 'category' === $taxonomy->name ) { $post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array(); } else { $post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array(); } $checked_categories = array_map( 'absint', (array) $post_category ); $popular_ids = wp_popular_terms_checklist( $taxonomy->name, 0, 10, false ); foreach ( $names as $cat_name ) { $cat_name = trim( $cat_name ); $category_nicename = sanitize_title( $cat_name ); if ( '' === $category_nicename ) { continue; } $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); if ( ! $cat_id || is_wp_error( $cat_id ) ) { continue; } else { $cat_id = $cat_id['term_id']; } $checked_categories[] = $cat_id; if ( $parent ) { continue; } ob_start(); wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids, ) ); $data = ob_get_clean(); $add = array( 'what' => $taxonomy->name, 'id' => $cat_id, 'data' => str_replace( array( "\n", "\t" ), '', $data ), 'position' => -1, ); } if ( $parent ) { $parent = get_term( $parent, $taxonomy->name ); $term_id = $parent->term_id; while ( $parent->parent ) { $parent = get_term( $parent->parent, $taxonomy->name ); if ( is_wp_error( $parent ) ) { break; } $term_id = $parent->term_id; } ob_start(); wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids, ) ); $data = ob_get_clean(); $add = array( 'what' => $taxonomy->name, 'id' => $term_id, 'data' => str_replace( array( "\n", "\t" ), '', $data ), 'position' => -1, ); } ob_start(); wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', ) ); $sup = ob_get_clean(); $add['supplemental'] = array( 'newcat_parent' => $sup ); $x = new WP_Ajax_Response( $add ); $x->send(); } function wp_ajax_delete_comment() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; $comment = get_comment( $id ); if ( ! $comment ) { wp_die( time() ); } if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { wp_die( -1 ); } check_ajax_referer( "delete-comment_$id" ); $status = wp_get_comment_status( $comment ); $delta = -1; if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) { if ( 'trash' === $status ) { wp_die( time() ); } $r = wp_trash_comment( $comment ); } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) { if ( 'trash' !== $status ) { wp_die( time() ); } $r = wp_untrash_comment( $comment ); if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) { $delta = 1; } } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { if ( 'spam' === $status ) { wp_die( time() ); } $r = wp_spam_comment( $comment ); } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) { if ( 'spam' !== $status ) { wp_die( time() ); } $r = wp_unspam_comment( $comment ); if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) { $delta = 1; } } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { $r = wp_delete_comment( $comment ); } else { wp_die( -1 ); } if ( $r ) { _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); } wp_die( 0 ); } function wp_ajax_delete_tag() { $tag_id = (int) $_POST['tag_ID']; check_ajax_referer( "delete-tag_$tag_id" ); if ( ! current_user_can( 'delete_term', $tag_id ) ) { wp_die( -1 ); } $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag'; $tag = get_term( $tag_id, $taxonomy ); if ( ! $tag || is_wp_error( $tag ) ) { wp_die( 1 ); } if ( wp_delete_term( $tag_id, $taxonomy ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_delete_link() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "delete-bookmark_$id" ); if ( ! current_user_can( 'manage_links' ) ) { wp_die( -1 ); } $link = get_bookmark( $id ); if ( ! $link || is_wp_error( $link ) ) { wp_die( 1 ); } if ( wp_delete_link( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_delete_meta() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "delete-meta_$id" ); $meta = get_metadata_by_mid( 'post', $id ); if ( ! $meta ) { wp_die( 1 ); } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) { wp_die( -1 ); } if ( delete_meta( $meta->meta_id ) ) { wp_die( 1 ); } wp_die( 0 ); } function wp_ajax_delete_post( $action ) { if ( empty( $action ) ) { $action = 'delete-post'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_post', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( wp_delete_post( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_trash_post( $action ) { if ( empty( $action ) ) { $action = 'trash-post'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_post', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( 'trash-post' === $action ) { $done = wp_trash_post( $id ); } else { $done = wp_untrash_post( $id ); } if ( $done ) { wp_die( 1 ); } wp_die( 0 ); } function wp_ajax_untrash_post( $action ) { if ( empty( $action ) ) { $action = 'untrash-post'; } wp_ajax_trash_post( $action ); } function wp_ajax_delete_page( $action ) { if ( empty( $action ) ) { $action = 'delete-page'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_page', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( wp_delete_post( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_dim_comment() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; $comment = get_comment( $id ); if ( ! $comment ) { $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => new WP_Error( 'invalid_comment', sprintf( __( 'Comment %d does not exist' ), $id ) ), ) ); $x->send(); } if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) { wp_die( -1 ); } $current = wp_get_comment_status( $comment ); if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) { wp_die( time() ); } check_ajax_referer( "approve-comment_$id" ); if ( in_array( $current, array( 'unapproved', 'spam' ), true ) ) { $result = wp_set_comment_status( $comment, 'approve', true ); } else { $result = wp_set_comment_status( $comment, 'hold', true ); } if ( is_wp_error( $result ) ) { $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $result, ) ); $x->send(); } _wp_ajax_delete_comment_response( $comment->comment_ID ); wp_die( 0 ); } function wp_ajax_add_link_category( $action ) { if ( empty( $action ) ) { $action = 'add-link-category'; } check_ajax_referer( $action ); $taxonomy_object = get_taxonomy( 'link_category' ); if ( ! current_user_can( $taxonomy_object->cap->manage_terms ) ) { wp_die( -1 ); } $names = explode( ',', wp_unslash( $_POST['newcat'] ) ); $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim( $cat_name ); $slug = sanitize_title( $cat_name ); if ( '' === $slug ) { continue; } $cat_id = wp_insert_term( $cat_name, 'link_category' ); if ( ! $cat_id || is_wp_error( $cat_id ) ) { continue; } else { $cat_id = $cat_id['term_id']; } $cat_name = esc_html( $cat_name ); $x->add( array( 'what' => 'link-category', 'id' => $cat_id, 'data' => "", 'position' => -1, ) ); } $x->send(); } function wp_ajax_add_tag() { check_ajax_referer( 'add-tag', '_wpnonce_add-tag' ); $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag'; $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! current_user_can( $taxonomy_object->cap->edit_terms ) ) { wp_die( -1 ); } $x = new WP_Ajax_Response(); $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); if ( $tag && ! is_wp_error( $tag ) ) { $tag = get_term( $tag['term_id'], $taxonomy ); } if ( ! $tag || is_wp_error( $tag ) ) { $message = __( 'An error has occurred. Please reload the page and try again.' ); $error_code = 'error'; if ( is_wp_error( $tag ) && $tag->get_error_message() ) { $message = $tag->get_error_message(); } if ( is_wp_error( $tag ) && $tag->get_error_code() ) { $error_code = $tag->get_error_code(); } $x->add( array( 'what' => 'taxonomy', 'data' => new WP_Error( $error_code, $message ), ) ); $x->send(); } $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); $level = 0; $noparents = ''; if ( is_taxonomy_hierarchical( $taxonomy ) ) { $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); ob_start(); $wp_list_table->single_row( $tag, $level ); $noparents = ob_get_clean(); } ob_start(); $wp_list_table->single_row( $tag ); $parents = ob_get_clean(); require ABSPATH . 'wp-admin/includes/edit-tag-messages.php'; $message = ''; if ( isset( $messages[ $taxonomy_object->name ][1] ) ) { $message = $messages[ $taxonomy_object->name ][1]; } elseif ( isset( $messages['_item'][1] ) ) { $message = $messages['_item'][1]; } $x->add( array( 'what' => 'taxonomy', 'data' => $message, 'supplemental' => array( 'parents' => $parents, 'noparents' => $noparents, 'notice' => $message, ), ) ); $x->add( array( 'what' => 'term', 'position' => $level, 'supplemental' => (array) $tag, ) ); $x->send(); } function wp_ajax_get_tagcloud() { if ( ! isset( $_POST['tax'] ) ) { wp_die( 0 ); } $taxonomy = sanitize_key( $_POST['tax'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { wp_die( -1 ); } $tags = get_terms( array( 'taxonomy' => $taxonomy, 'number' => 45, 'orderby' => 'count', 'order' => 'DESC', ) ); if ( empty( $tags ) ) { wp_die( $taxonomy_object->labels->not_found ); } if ( is_wp_error( $tags ) ) { wp_die( $tags->get_error_message() ); } foreach ( $tags as $key => $tag ) { $tags[ $key ]->link = '#'; $tags[ $key ]->id = $tag->term_id; } $return = wp_generate_tag_cloud( $tags, array( 'filter' => 0, 'format' => 'list', ) ); if ( empty( $return ) ) { wp_die( 0 ); } echo $return; wp_die(); } function wp_ajax_get_comments( $action ) { global $post_id; if ( empty( $action ) ) { $action = 'get-comments'; } check_ajax_referer( $action ); if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) { $id = absint( $_REQUEST['p'] ); if ( ! empty( $id ) ) { $post_id = $id; } } if ( empty( $post_id ) ) { wp_die( -1 ); } $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } $wp_list_table->prepare_items(); if ( ! $wp_list_table->has_items() ) { wp_die( 1 ); } $x = new WP_Ajax_Response(); ob_start(); foreach ( $wp_list_table->items as $comment ) { if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) { continue; } get_comment( $comment ); $wp_list_table->single_row( $comment ); } $comment_list_item = ob_get_clean(); $x->add( array( 'what' => 'comments', 'data' => $comment_list_item, ) ); $x->send(); } function wp_ajax_replyto_comment( $action ) { if ( empty( $action ) ) { $action = 'replyto-comment'; } check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); $comment_post_id = (int) $_POST['comment_post_ID']; $post = get_post( $comment_post_id ); if ( ! $post ) { wp_die( -1 ); } if ( ! current_user_can( 'edit_post', $comment_post_id ) ) { wp_die( -1 ); } if ( empty( $post->post_status ) ) { wp_die( 1 ); } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ), true ) ) { wp_die( __( 'You cannot reply to a comment on a draft post.' ) ); } $user = wp_get_current_user(); if ( $user->exists() ) { $comment_author = wp_slash( $user->display_name ); $comment_author_email = wp_slash( $user->user_email ); $comment_author_url = wp_slash( $user->user_url ); $user_id = $user->ID; if ( current_user_can( 'unfiltered_html' ) ) { if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) { $_POST['_wp_unfiltered_html_comment'] = ''; } if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); kses_init_filters(); remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); add_filter( 'pre_comment_content', 'wp_filter_kses' ); } } } else { wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); } $comment_content = trim( $_POST['content'] ); if ( '' === $comment_content ) { wp_die( __( 'Please type your comment text.' ) ); } $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment'; $comment_parent = 0; if ( isset( $_POST['comment_ID'] ) ) { $comment_parent = absint( $_POST['comment_ID'] ); } $comment_auto_approved = false; $commentdata = array( 'comment_post_ID' => $comment_post_id, ); $commentdata += compact( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_id' ); if ( ! empty( $_POST['approve_parent'] ) ) { $parent = get_comment( $comment_parent ); if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) { if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { wp_die( -1 ); } if ( wp_set_comment_status( $parent, 'approve' ) ) { $comment_auto_approved = true; } } } $comment_id = wp_new_comment( $commentdata ); if ( is_wp_error( $comment_id ) ) { wp_die( $comment_id->get_error_message() ); } $comment = get_comment( $comment_id ); if ( ! $comment ) { wp_die( 1 ); } $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; ob_start(); if ( isset( $_REQUEST['mode'] ) && 'dashboard' === $_REQUEST['mode'] ) { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; _wp_dashboard_recent_comments_row( $comment ); } else { if ( isset( $_REQUEST['mode'] ) && 'single' === $_REQUEST['mode'] ) { $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); } else { $wp_list_table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); } $wp_list_table->single_row( $comment ); } $comment_list_item = ob_get_clean(); $response = array( 'what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position, ); $counts = wp_count_comments(); $response['supplemental'] = array( 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), ); if ( $comment_auto_approved ) { $response['supplemental']['parent_approved'] = $parent->comment_ID; $response['supplemental']['parent_post_id'] = $parent->comment_post_ID; } $x = new WP_Ajax_Response(); $x->add( $response ); $x->send(); } function wp_ajax_edit_comment() { check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); $comment_id = (int) $_POST['comment_ID']; if ( ! current_user_can( 'edit_comment', $comment_id ) ) { wp_die( -1 ); } if ( '' === $_POST['content'] ) { wp_die( __( 'Please type your comment text.' ) ); } if ( isset( $_POST['status'] ) ) { $_POST['comment_status'] = $_POST['status']; } $updated = edit_comment(); if ( is_wp_error( $updated ) ) { wp_die( $updated->get_error_message() ); } $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; $checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0; $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); $comment = get_comment( $comment_id ); if ( empty( $comment->comment_ID ) ) { wp_die( -1 ); } ob_start(); $wp_list_table->single_row( $comment ); $comment_list_item = ob_get_clean(); $x = new WP_Ajax_Response(); $x->add( array( 'what' => 'edit_comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position, ) ); $x->send(); } function wp_ajax_add_menu_item() { check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; $menu_items_data = array(); foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { if ( ! empty( $menu_item_data['menu-item-type'] ) && 'custom' !== $menu_item_data['menu-item-type'] && ! empty( $menu_item_data['menu-item-object-id'] ) ) { switch ( $menu_item_data['menu-item-type'] ) { case 'post_type': $_object = get_post( $menu_item_data['menu-item-object-id'] ); break; case 'post_type_archive': $_object = get_post_type_object( $menu_item_data['menu-item-object'] ); break; case 'taxonomy': $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); break; } $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); $_menu_item = reset( $_menu_items ); $menu_item_data['menu-item-description'] = $_menu_item->description; } $menu_items_data[] = $menu_item_data; } $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); if ( is_wp_error( $item_ids ) ) { wp_die( 0 ); } $menu_items = array(); foreach ( (array) $item_ids as $menu_item_id ) { $menu_obj = get_post( $menu_item_id ); if ( ! empty( $menu_obj->ID ) ) { $menu_obj = wp_setup_nav_menu_item( $menu_obj ); $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title; $menu_obj->label = $menu_obj->title; $menu_items[] = $menu_obj; } } $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); if ( ! class_exists( $walker_class_name ) ) { wp_die( 0 ); } if ( ! empty( $menu_items ) ) { $args = array( 'after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new $walker_class_name(), ); echo walk_nav_menu_tree( $menu_items, 0, (object) $args ); } wp_die(); } function wp_ajax_add_meta() { check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' ); $c = 0; $pid = (int) $_POST['post_id']; $post = get_post( $pid ); if ( isset( $_POST['metakeyselect'] ) || isset( $_POST['metakeyinput'] ) ) { if ( ! current_user_can( 'edit_post', $pid ) ) { wp_die( -1 ); } if ( isset( $_POST['metakeyselect'] ) && '#NONE#' === $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) { wp_die( 1 ); } if ( 'auto-draft' === $post->post_status ) { $post_data = array(); $post_data['action'] = 'draft'; $post_data['post_ID'] = $pid; $post_data['post_type'] = $post->post_type; $post_data['post_status'] = 'draft'; $now = time(); $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); $pid = edit_post( $post_data ); if ( $pid ) { if ( is_wp_error( $pid ) ) { $x = new WP_Ajax_Response( array( 'what' => 'meta', 'data' => $pid, ) ); $x->send(); } $mid = add_meta( $pid ); if ( ! $mid ) { wp_die( __( 'Please provide a custom field value.' ) ); } } else { wp_die( 0 ); } } else { $mid = add_meta( $pid ); if ( ! $mid ) { wp_die( __( 'Please provide a custom field value.' ) ); } } $meta = get_metadata_by_mid( 'post', $mid ); $pid = (int) $meta->post_id; $meta = get_object_vars( $meta ); $x = new WP_Ajax_Response( array( 'what' => 'meta', 'id' => $mid, 'data' => _list_meta_row( $meta, $c ), 'position' => 1, 'supplemental' => array( 'postid' => $pid ), ) ); } else { $mid = (int) key( $_POST['meta'] ); $key = wp_unslash( $_POST['meta'][ $mid ]['key'] ); $value = wp_unslash( $_POST['meta'][ $mid ]['value'] ); if ( '' === trim( $key ) ) { wp_die( __( 'Please provide a custom field name.' ) ); } $meta = get_metadata_by_mid( 'post', $mid ); if ( ! $meta ) { wp_die( 0 ); } if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) || ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) || ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) { wp_die( -1 ); } if ( $meta->meta_value != $value || $meta->meta_key != $key ) { $u = update_metadata_by_mid( 'post', $mid, $value, $key ); if ( ! $u ) { wp_die( 0 ); } } $x = new WP_Ajax_Response( array( 'what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row( array( 'meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid, ), $c ), 'position' => 0, 'supplemental' => array( 'postid' => $meta->post_id ), ) ); } $x->send(); } function wp_ajax_add_user( $action ) { if ( empty( $action ) ) { $action = 'add-user'; } check_ajax_referer( $action ); if ( ! current_user_can( 'create_users' ) ) { wp_die( -1 ); } $user_id = edit_user(); if ( ! $user_id ) { wp_die( 0 ); } elseif ( is_wp_error( $user_id ) ) { $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, ) ); $x->send(); } $user_object = get_userdata( $user_id ); $wp_list_table = _get_list_table( 'WP_Users_List_Table' ); $role = current( $user_object->roles ); $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, 'data' => $wp_list_table->single_row( $user_object, '', $role ), 'supplemental' => array( 'show-link' => sprintf( __( 'User %s added' ), '' . $user_object->user_login . '' ), 'role' => $role, ), ) ); $x->send(); } function wp_ajax_closed_postboxes() { check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed'] ) : array(); $closed = array_filter( $closed ); $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); $hidden = array_filter( $hidden ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } if ( is_array( $closed ) ) { update_user_meta( $user->ID, "closedpostboxes_$page", $closed ); } if ( is_array( $hidden ) ) { $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); update_user_meta( $user->ID, "metaboxhidden_$page", $hidden ); } wp_die( 1 ); } function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); update_user_meta( $user->ID, "manage{$page}columnshidden", $hidden ); wp_die( 1 ); } function wp_ajax_update_welcome_panel() { check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 ); wp_die( 1 ); } function wp_ajax_menu_get_metabox() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; if ( isset( $_POST['item-type'] ) && 'post_type' === $_POST['item-type'] ) { $type = 'posttype'; $callback = 'wp_nav_menu_item_post_type_meta_box'; $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' === $_POST['item-type'] ) { $type = 'taxonomy'; $callback = 'wp_nav_menu_item_taxonomy_meta_box'; $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); } if ( ! empty( $_POST['item-object'] ) && isset( $items[ $_POST['item-object'] ] ) ) { $menus_meta_box_object = $items[ $_POST['item-object'] ]; $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object ); $box_args = array( 'id' => 'add-' . $item->name, 'title' => $item->labels->name, 'callback' => $callback, 'args' => $item, ); ob_start(); $callback( null, $box_args ); $markup = ob_get_clean(); echo wp_json_encode( array( 'replace-id' => $type . '-' . $item->name, 'markup' => $markup, ) ); } wp_die(); } function wp_ajax_wp_link_ajax() { check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' ); $args = array(); if ( isset( $_POST['search'] ) ) { $args['s'] = wp_unslash( $_POST['search'] ); } if ( isset( $_POST['term'] ) ) { $args['s'] = wp_unslash( $_POST['term'] ); } $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; if ( ! class_exists( '_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } $results = _WP_Editors::wp_link_query( $args ); if ( ! isset( $results ) ) { wp_die( 0 ); } echo wp_json_encode( $results ); echo "\n"; wp_die(); } function wp_ajax_menu_locations_save() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); if ( ! isset( $_POST['menu-locations'] ) ) { wp_die( 0 ); } set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) ); wp_die( 1 ); } function wp_ajax_meta_box_order() { check_ajax_referer( 'meta-box-order' ); $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; if ( 'auto' !== $page_columns ) { $page_columns = (int) $page_columns; } $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } if ( $order ) { update_user_meta( $user->ID, "meta-box-order_$page", $order ); } if ( $page_columns ) { update_user_meta( $user->ID, "screen_layout_$page", $page_columns ); } wp_send_json_success(); } function wp_ajax_menu_quick_search() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; _wp_ajax_menu_quick_search( $_POST ); wp_die(); } function wp_ajax_get_permalink() { check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; wp_die( get_preview_post_link( $post_id ) ); } function wp_ajax_sample_permalink() { check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); } function wp_ajax_inline_save() { global $mode; check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); if ( ! isset( $_POST['post_ID'] ) || ! (int) $_POST['post_ID'] ) { wp_die(); } $post_ID = (int) $_POST['post_ID']; if ( 'page' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } } else { if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } } $last = wp_check_post_lock( $post_ID ); if ( $last ) { $last_user = get_userdata( $last ); $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); $msg_template = __( 'Saving is disabled: %s is currently editing this post.' ); if ( 'page' === $_POST['post_type'] ) { $msg_template = __( 'Saving is disabled: %s is currently editing this page.' ); } printf( $msg_template, esc_html( $last_user_name ) ); wp_die(); } $data = &$_POST; $post = get_post( $post_ID, ARRAY_A ); $post = wp_slash( $post ); $data['content'] = $post['post_content']; $data['excerpt'] = $post['post_excerpt']; $data['user_ID'] = get_current_user_id(); if ( isset( $data['post_parent'] ) ) { $data['parent_id'] = $data['post_parent']; } if ( isset( $data['keep_private'] ) && 'private' === $data['keep_private'] ) { $data['visibility'] = 'private'; $data['post_status'] = 'private'; } else { $data['post_status'] = $data['_status']; } if ( empty( $data['comment_status'] ) ) { $data['comment_status'] = 'closed'; } if ( empty( $data['ping_status'] ) ) { $data['ping_status'] = 'closed'; } if ( ! empty( $data['tax_input'] ) ) { foreach ( $data['tax_input'] as $taxonomy => $terms ) { $tax_object = get_taxonomy( $taxonomy ); if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) { unset( $data['tax_input'][ $taxonomy ] ); } } } if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ), true ) ) { $post['post_status'] = 'publish'; $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] ); } edit_post(); $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) ); $mode = 'excerpt' === $_POST['post_view'] ? 'excerpt' : 'list'; $level = 0; if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) { $request_post = array( get_post( $_POST['post_ID'] ) ); $parent = $request_post[0]->post_parent; while ( $parent > 0 ) { $parent_post = get_post( $parent ); $parent = $parent_post->post_parent; $level++; } } $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level ); wp_die(); } function wp_ajax_inline_save_tax() { check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); $taxonomy = sanitize_key( $_POST['taxonomy'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! isset( $_POST['tax_ID'] ) || ! (int) $_POST['tax_ID'] ) { wp_die( -1 ); } $id = (int) $_POST['tax_ID']; if ( ! current_user_can( 'edit_term', $id ) ) { wp_die( -1 ); } $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); $tag = get_term( $id, $taxonomy ); $_POST['description'] = $tag->description; $updated = wp_update_term( $id, $taxonomy, $_POST ); if ( $updated && ! is_wp_error( $updated ) ) { $tag = get_term( $updated['term_id'], $taxonomy ); if ( ! $tag || is_wp_error( $tag ) ) { if ( is_wp_error( $tag ) && $tag->get_error_message() ) { wp_die( $tag->get_error_message() ); } wp_die( __( 'Item not updated.' ) ); } } else { if ( is_wp_error( $updated ) && $updated->get_error_message() ) { wp_die( $updated->get_error_message() ); } wp_die( __( 'Item not updated.' ) ); } $level = 0; $parent = $tag->parent; while ( $parent > 0 ) { $parent_tag = get_term( $parent, $taxonomy ); $parent = $parent_tag->parent; $level++; } $wp_list_table->single_row( $tag, $level ); wp_die(); } function wp_ajax_find_posts() { check_ajax_referer( 'find-posts' ); $post_types = get_post_types( array( 'public' => true ), 'objects' ); unset( $post_types['attachment'] ); $args = array( 'post_type' => array_keys( $post_types ), 'post_status' => 'any', 'posts_per_page' => 50, ); $search = wp_unslash( $_POST['ps'] ); if ( '' !== $search ) { $args['s'] = $search; } $posts = get_posts( $args ); if ( ! $posts ) { wp_send_json_error( __( 'No items found.' ) ); } $html = ''; $alt = ''; foreach ( $posts as $post ) { $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); $alt = ( 'alternate' === $alt ) ? '' : 'alternate'; switch ( $post->post_status ) { case 'publish': case 'private': $stat = __( 'Published' ); break; case 'future': $stat = __( 'Scheduled' ); break; case 'pending': $stat = __( 'Pending Review' ); break; case 'draft': $stat = __( 'Draft' ); break; } if ( '0000-00-00 00:00:00' === $post->post_date ) { $time = ''; } else { $time = mysql2date( __( 'Y/m/d' ), $post->post_date ); } $html .= ''; $html .= '' . "\n\n"; } $html .= '

' . __( 'Title' ) . '' . __( 'Type' ) . '' . __( 'Date' ) . '' . __( 'Status' ) . '
' . esc_html( $post_types[ $post->post_type ]->labels->singular_name ) . '' . esc_html( $time ) . '' . esc_html( $stat ) . '
'; wp_send_json_success( $html ); } function wp_ajax_widgets_order() { check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } unset( $_POST['savewidgets'], $_POST['action'] ); if ( is_array( $_POST['sidebars'] ) ) { $sidebars = array(); foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) { $sb = array(); if ( ! empty( $val ) ) { $val = explode( ',', $val ); foreach ( $val as $k => $v ) { if ( strpos( $v, 'widget-' ) === false ) { continue; } $sb[ $k ] = substr( $v, strpos( $v, '_' ) + 1 ); } } $sidebars[ $key ] = $sb; } wp_set_sidebars_widgets( $sidebars ); wp_die( 1 ); } wp_die( -1 ); } function wp_ajax_save_widget() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) || ! isset( $_POST['id_base'] ) ) { wp_die( -1 ); } unset( $_POST['savewidgets'], $_POST['action'] ); do_action( 'load-widgets.php' ); do_action( 'widgets.php' ); do_action( 'sidebar_admin_setup' ); $id_base = wp_unslash( $_POST['id_base'] ); $widget_id = wp_unslash( $_POST['widget-id'] ); $sidebar_id = $_POST['sidebar']; $multi_number = ! empty( $_POST['multi_number'] ) ? (int) $_POST['multi_number'] : 0; $settings = isset( $_POST[ 'widget-' . $id_base ] ) && is_array( $_POST[ 'widget-' . $id_base ] ) ? $_POST[ 'widget-' . $id_base ] : false; $error = '

' . __( 'An error has occurred. Please reload the page and try again.' ) . '

'; $sidebars = wp_get_sidebars_widgets(); $sidebar = isset( $sidebars[ $sidebar_id ] ) ? $sidebars[ $sidebar_id ] : array(); if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { if ( ! isset( $wp_registered_widgets[ $widget_id ] ) ) { wp_die( $error ); } $sidebar = array_diff( $sidebar, array( $widget_id ) ); $_POST = array( 'sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1', ); do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); } elseif ( $settings && preg_match( '/__i__|%i%/', key( $settings ) ) ) { if ( ! $multi_number ) { wp_die( $error ); } $_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) ); $widget_id = $id_base . '-' . $multi_number; $sidebar[] = $widget_id; } $_POST['widget-id'] = $sidebar; foreach ( (array) $wp_registered_widget_updates as $name => $control ) { if ( $name == $id_base ) { if ( ! is_callable( $control['callback'] ) ) { continue; } ob_start(); call_user_func_array( $control['callback'], $control['params'] ); ob_end_clean(); break; } } if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { $sidebars[ $sidebar_id ] = $sidebar; wp_set_sidebars_widgets( $sidebars ); echo "deleted:$widget_id"; wp_die(); } if ( ! empty( $_POST['add_new'] ) ) { wp_die(); } $form = $wp_registered_widget_controls[ $widget_id ]; if ( $form ) { call_user_func_array( $form['callback'], $form['params'] ); } wp_die(); } function wp_ajax_update_widget() { global $wp_customize; $wp_customize->widgets->wp_ajax_update_widget(); } function wp_ajax_delete_inactive_widgets() { check_ajax_referer( 'remove-inactive-widgets', 'removeinactivewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } unset( $_POST['removeinactivewidgets'], $_POST['action'] ); do_action( 'load-widgets.php' ); do_action( 'widgets.php' ); do_action( 'sidebar_admin_setup' ); $sidebars_widgets = wp_get_sidebars_widgets(); foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) { $pieces = explode( '-', $widget_id ); $multi_number = array_pop( $pieces ); $id_base = implode( '-', $pieces ); $widget = get_option( 'widget_' . $id_base ); unset( $widget[ $multi_number ] ); update_option( 'widget_' . $id_base, $widget ); unset( $sidebars_widgets['wp_inactive_widgets'][ $key ] ); } wp_set_sidebars_widgets( $sidebars_widgets ); wp_die(); } function wp_ajax_media_create_image_subsizes() { check_ajax_referer( 'media-form' ); if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to upload files.' ) ) ); } if ( empty( $_POST['attachment_id'] ) ) { wp_send_json_error( array( 'message' => __( 'Upload failed. Please reload and try again.' ) ) ); } $attachment_id = (int) $_POST['attachment_id']; if ( ! empty( $_POST['_wp_upload_failed_cleanup'] ) ) { if ( wp_attachment_is_image( $attachment_id ) && current_user_can( 'delete_post', $attachment_id ) ) { $attachment = get_post( $attachment_id ); if ( $attachment && ( time() - strtotime( $attachment->post_date_gmt ) < 600 ) ) { wp_delete_attachment( $attachment_id, true ); wp_send_json_success(); } } } if ( ! headers_sent() ) { header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); } wp_update_image_subsizes( $attachment_id ); if ( ! empty( $_POST['_legacy_support'] ) ) { $response = array( 'id' => $attachment_id ); } else { $response = wp_prepare_attachment_for_js( $attachment_id ); if ( ! $response ) { wp_send_json_error( array( 'message' => __( 'Upload failed.' ) ) ); } } wp_send_json_success( $response ); } function wp_ajax_upload_attachment() { check_ajax_referer( 'media-form' ); if ( ! current_user_can( 'upload_files' ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'Sorry, you are not allowed to upload files.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } if ( isset( $_REQUEST['post_id'] ) ) { $post_id = $_REQUEST['post_id']; if ( ! current_user_can( 'edit_post', $post_id ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'Sorry, you are not allowed to attach files to this post.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } } else { $post_id = null; } $post_data = ! empty( $_REQUEST['post_data'] ) ? _wp_get_allowed_postdata( _wp_translate_postdata( false, (array) $_REQUEST['post_data'] ) ) : array(); if ( is_wp_error( $post_data ) ) { wp_die( $post_data->get_error_message() ); } if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ), true ) ) { $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] ); if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } } $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data ); if ( is_wp_error( $attachment_id ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => $attachment_id->get_error_message(), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { if ( 'custom-background' === $post_data['context'] ) { update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); } if ( 'custom-header' === $post_data['context'] ) { update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); } } $attachment = wp_prepare_attachment_for_js( $attachment_id ); if ( ! $attachment ) { wp_die(); } echo wp_json_encode( array( 'success' => true, 'data' => $attachment, ) ); wp_die(); } function wp_ajax_image_editor() { $attachment_id = (int) $_POST['postid']; if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { wp_die( -1 ); } check_ajax_referer( "image_editor-$attachment_id" ); include_once ABSPATH . 'wp-admin/includes/image-edit.php'; $msg = false; switch ( $_POST['do'] ) { case 'save': $msg = wp_save_image( $attachment_id ); if ( ! empty( $msg->error ) ) { wp_send_json_error( $msg ); } wp_send_json_success( $msg ); break; case 'scale': $msg = wp_save_image( $attachment_id ); break; case 'restore': $msg = wp_restore_image( $attachment_id ); break; } ob_start(); wp_image_editor( $attachment_id, $msg ); $html = ob_get_clean(); if ( ! empty( $msg->error ) ) { wp_send_json_error( array( 'message' => $msg, 'html' => $html, ) ); } wp_send_json_success( array( 'message' => $msg, 'html' => $html, ) ); } function wp_ajax_set_post_thumbnail() { $json = ! empty( $_REQUEST['json'] ); $post_ID = (int) $_POST['post_id']; if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( -1 ); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( $json ) { check_ajax_referer( "update-post_$post_ID" ); } else { check_ajax_referer( "set_post_thumbnail-$post_ID" ); } if ( '-1' == $thumbnail_id ) { if ( delete_post_thumbnail( $post_ID ) ) { $return = _wp_post_thumbnail_html( null, $post_ID ); $json ? wp_send_json_success( $return ) : wp_die( $return ); } else { wp_die( 0 ); } } if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) { $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); $json ? wp_send_json_success( $return ) : wp_die( $return ); } wp_die( 0 ); } function wp_ajax_get_post_thumbnail_html() { $post_ID = (int) $_POST['post_id']; check_ajax_referer( "update-post_$post_ID" ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( -1 ); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( -1 === $thumbnail_id ) { $thumbnail_id = null; } $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); wp_send_json_success( $return ); } function wp_ajax_set_attachment_thumbnail() { if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) { wp_send_json_error(); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( empty( $thumbnail_id ) ) { wp_send_json_error(); } $post_ids = array(); foreach ( $_POST['urls'] as $url ) { $post_id = attachment_url_to_postid( $url ); if ( ! empty( $post_id ) ) { $post_ids[] = $post_id; } } if ( empty( $post_ids ) ) { wp_send_json_error(); } $success = 0; foreach ( $post_ids as $post_id ) { if ( ! current_user_can( 'edit_post', $post_id ) ) { continue; } if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) { $success++; } } if ( 0 === $success ) { wp_send_json_error(); } else { wp_send_json_success(); } wp_send_json_error(); } function wp_ajax_date_format() { wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) ); } function wp_ajax_time_format() { wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) ); } function wp_ajax_wp_fullscreen_save_post() { $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; $post = null; if ( $post_id ) { $post = get_post( $post_id ); } check_ajax_referer( 'update-post_' . $post_id, '_wpnonce' ); $post_id = edit_post(); if ( is_wp_error( $post_id ) ) { wp_send_json_error(); } if ( $post ) { $last_date = mysql2date( __( 'F j, Y' ), $post->post_modified ); $last_time = mysql2date( __( 'g:i a' ), $post->post_modified ); } else { $last_date = date_i18n( __( 'F j, Y' ) ); $last_time = date_i18n( __( 'g:i a' ) ); } $last_id = get_post_meta( $post_id, '_edit_last', true ); if ( $last_id ) { $last_user = get_userdata( $last_id ); $last_edited = sprintf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), $last_date, $last_time ); } else { $last_edited = sprintf( __( 'Last edited on %1$s at %2$s' ), $last_date, $last_time ); } wp_send_json_success( array( 'last_edited' => $last_edited ) ); } function wp_ajax_wp_remove_post_lock() { if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) { wp_die( 0 ); } $post_id = (int) $_POST['post_ID']; $post = get_post( $post_id ); if ( ! $post ) { wp_die( 0 ); } check_ajax_referer( 'update-post_' . $post_id ); if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); if ( get_current_user_id() != $active_lock[1] ) { wp_die( 0 ); } $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); wp_die( 1 ); } function wp_ajax_dismiss_wp_pointer() { $pointer = $_POST['pointer']; if ( sanitize_key( $pointer ) != $pointer ) { wp_die( 0 ); } $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); if ( in_array( $pointer, $dismissed, true ) ) { wp_die( 0 ); } $dismissed[] = $pointer; $dismissed = implode( ',', $dismissed ); update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); wp_die( 1 ); } function wp_ajax_get_attachment() { if ( ! isset( $_REQUEST['id'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } $post = get_post( $id ); if ( ! $post ) { wp_send_json_error(); } if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error(); } $attachment = wp_prepare_attachment_for_js( $id ); if ( ! $attachment ) { wp_send_json_error(); } wp_send_json_success( $attachment ); } function wp_ajax_query_attachments() { if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error(); } $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); $keys = array( 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 'post_parent', 'author', 'post__in', 'post__not_in', 'year', 'monthnum', ); foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { $keys[] = $t->query_var; } } $query = array_intersect_key( $query, array_flip( $keys ) ); $query['post_type'] = 'attachment'; if ( MEDIA_TRASH && ! empty( $_REQUEST['query']['post_status'] ) && 'trash' === $_REQUEST['query']['post_status'] ) { $query['post_status'] = 'trash'; } else { $query['post_status'] = 'inherit'; } if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) { $query['post_status'] .= ',private'; } if ( isset( $query['s'] ) ) { add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); } $query = apply_filters( 'ajax_query_attachments_args', $query ); $attachments_query = new WP_Query( $query ); update_post_parent_caches( $attachments_query->posts ); $posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts ); $posts = array_filter( $posts ); $total_posts = $attachments_query->found_posts; if ( $total_posts < 1 ) { unset( $query['paged'] ); $count_query = new WP_Query(); $count_query->query( $query ); $total_posts = $count_query->found_posts; } $posts_per_page = (int) $attachments_query->get( 'posts_per_page' ); $max_pages = $posts_per_page ? ceil( $total_posts / $posts_per_page ) : 0; header( 'X-WP-Total: ' . (int) $total_posts ); header( 'X-WP-TotalPages: ' . (int) $max_pages ); wp_send_json_success( $posts ); } function wp_ajax_save_attachment() { if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } check_ajax_referer( 'update-post_' . $id, 'nonce' ); if ( ! current_user_can( 'edit_post', $id ) ) { wp_send_json_error(); } $changes = $_REQUEST['changes']; $post = get_post( $id, ARRAY_A ); if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } if ( isset( $changes['parent'] ) ) { $post['post_parent'] = $changes['parent']; } if ( isset( $changes['title'] ) ) { $post['post_title'] = $changes['title']; } if ( isset( $changes['caption'] ) ) { $post['post_excerpt'] = $changes['caption']; } if ( isset( $changes['description'] ) ) { $post['post_content'] = $changes['description']; } if ( MEDIA_TRASH && isset( $changes['status'] ) ) { $post['post_status'] = $changes['status']; } if ( isset( $changes['alt'] ) ) { $alt = wp_unslash( $changes['alt'] ); if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) { $alt = wp_strip_all_tags( $alt, true ); update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) ); } } if ( wp_attachment_is( 'audio', $post['ID'] ) ) { $changed = false; $id3data = wp_get_attachment_metadata( $post['ID'] ); if ( ! is_array( $id3data ) ) { $changed = true; $id3data = array(); } foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) { if ( isset( $changes[ $key ] ) ) { $changed = true; $id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) ); } } if ( $changed ) { wp_update_attachment_metadata( $id, $id3data ); } } if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) { wp_delete_post( $id ); } else { wp_update_post( $post ); } wp_send_json_success(); } function wp_ajax_save_attachment_compat() { if ( ! isset( $_REQUEST['id'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) { wp_send_json_error(); } $attachment_data = $_REQUEST['attachments'][ $id ]; check_ajax_referer( 'update-post_' . $id, 'nonce' ); if ( ! current_user_can( 'edit_post', $id ) ) { wp_send_json_error(); } $post = get_post( $id, ARRAY_A ); if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); if ( isset( $post['errors'] ) ) { $errors = $post['errors']; unset( $post['errors'] ); } wp_update_post( $post ); foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { if ( isset( $attachment_data[ $taxonomy ] ) ) { wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); } } $attachment = wp_prepare_attachment_for_js( $id ); if ( ! $attachment ) { wp_send_json_error(); } wp_send_json_success( $attachment ); } function wp_ajax_save_attachment_order() { if ( ! isset( $_REQUEST['post_id'] ) ) { wp_send_json_error(); } $post_id = absint( $_REQUEST['post_id'] ); if ( ! $post_id ) { wp_send_json_error(); } if ( empty( $_REQUEST['attachments'] ) ) { wp_send_json_error(); } check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); $attachments = $_REQUEST['attachments']; if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_send_json_error(); } foreach ( $attachments as $attachment_id => $menu_order ) { if ( ! current_user_can( 'edit_post', $attachment_id ) ) { continue; } $attachment = get_post( $attachment_id ); if ( ! $attachment ) { continue; } if ( 'attachment' !== $attachment->post_type ) { continue; } wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order, ) ); } wp_send_json_success(); } function wp_ajax_send_attachment_to_editor() { check_ajax_referer( 'media-send-to-editor', 'nonce' ); $attachment = wp_unslash( $_POST['attachment'] ); $id = (int) $attachment['id']; $post = get_post( $id ); if ( ! $post ) { wp_send_json_error(); } if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } if ( current_user_can( 'edit_post', $id ) ) { $insert_into_post_id = (int) $_POST['post_id']; if ( 0 == $post->post_parent && $insert_into_post_id ) { wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id, ) ); } } $url = empty( $attachment['url'] ) ? '' : $attachment['url']; $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url ); remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; if ( '' === trim( $caption ) ) { $caption = ''; } $title = ''; $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { $html = stripslashes_deep( $_POST['html'] ); } else { $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; if ( ! empty( $url ) ) { $html = '' . $html . ''; } } $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); wp_send_json_success( $html ); } function wp_ajax_send_link_to_editor() { global $post, $wp_embed; check_ajax_referer( 'media-send-to-editor', 'nonce' ); $src = wp_unslash( $_POST['src'] ); if ( ! $src ) { wp_send_json_error(); } if ( ! strpos( $src, '://' ) ) { $src = 'http://' . $src; } $src = sanitize_url( $src ); if ( ! $src ) { wp_send_json_error(); } $link_text = trim( wp_unslash( $_POST['link_text'] ) ); if ( ! $link_text ) { $link_text = wp_basename( $src ); } $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); $check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' ); $fallback = $wp_embed->maybe_make_link( $src ); if ( $check_embed !== $fallback ) { $html = '[embed]' . $src . '[/embed]'; } elseif ( $link_text ) { $html = '' . $link_text . ''; } else { $html = ''; } $type = 'file'; $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); if ( $ext ) { $ext_type = wp_ext2type( $ext ); if ( 'audio' === $ext_type || 'video' === $ext_type ) { $type = $ext_type; } } $html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text ); wp_send_json_success( $html ); } function wp_ajax_heartbeat() { if ( empty( $_POST['_nonce'] ) ) { wp_send_json_error(); } $response = array(); $data = array(); $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); if ( ! empty( $_POST['screen_id'] ) ) { $screen_id = sanitize_key( $_POST['screen_id'] ); } else { $screen_id = 'front'; } if ( ! empty( $_POST['data'] ) ) { $data = wp_unslash( (array) $_POST['data'] ); } if ( 1 !== $nonce_state ) { $response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id ); if ( false === $nonce_state ) { $response['nonces_expired'] = true; wp_send_json( $response ); } } if ( ! empty( $data ) ) { $response = apply_filters( 'heartbeat_received', $response, $data, $screen_id ); } $response = apply_filters( 'heartbeat_send', $response, $screen_id ); do_action( 'heartbeat_tick', $response, $screen_id ); $response['server_time'] = time(); wp_send_json( $response ); } function wp_ajax_get_revision_diffs() { require ABSPATH . 'wp-admin/includes/revision.php'; $post = get_post( (int) $_REQUEST['post_id'] ); if ( ! $post ) { wp_send_json_error(); } if ( ! current_user_can( 'edit_post', $post->ID ) ) { wp_send_json_error(); } $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ); if ( ! $revisions ) { wp_send_json_error(); } $return = array(); ; foreach ( $_REQUEST['compare'] as $compare_key ) { list( $compare_from, $compare_to ) = explode( ':', $compare_key ); $return[] = array( 'id' => $compare_key, 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ), ); } wp_send_json_success( $return ); } function wp_ajax_save_user_color_scheme() { global $_wp_admin_css_colors; check_ajax_referer( 'save-color-scheme', 'nonce' ); $color_scheme = sanitize_key( $_POST['color_scheme'] ); if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { wp_send_json_error(); } $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); wp_send_json_success( array( 'previousScheme' => 'admin-color-' . $previous_color_scheme, 'currentScheme' => 'admin-color-' . $color_scheme, ) ); } function wp_ajax_query_themes() { global $themes_allowedtags, $theme_field_defaults; if ( ! current_user_can( 'install_themes' ) ) { wp_send_json_error(); } $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array( 'per_page' => 20, 'fields' => array_merge( (array) $theme_field_defaults, array( 'reviews_url' => true, ) ), ) ); if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { $user = get_user_option( 'wporg_favorites' ); if ( $user ) { $args['user'] = $user; } } $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); $api = themes_api( 'query_themes', $args ); if ( is_wp_error( $api ) ) { wp_send_json_error(); } $update_php = network_admin_url( 'update.php?action=install-theme' ); $installed_themes = search_theme_directories(); if ( false === $installed_themes ) { $installed_themes = array(); } foreach ( $installed_themes as $theme_slug => $theme_data ) { if ( str_contains( $theme_slug, '/' ) ) { unset( $installed_themes[ $theme_slug ] ); } } foreach ( $api->themes as &$theme ) { $theme->install_url = add_query_arg( array( 'theme' => $theme->slug, '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ), ), $update_php ); if ( current_user_can( 'switch_themes' ) ) { if ( is_multisite() ) { $theme->activate_url = add_query_arg( array( 'action' => 'enable', '_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ), 'theme' => $theme->slug, ), network_admin_url( 'themes.php' ) ); } else { $theme->activate_url = add_query_arg( array( 'action' => 'activate', '_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ), 'stylesheet' => $theme->slug, ), admin_url( 'themes.php' ) ); } } $is_theme_installed = array_key_exists( $theme->slug, $installed_themes ); $theme->block_theme = $is_theme_installed && wp_get_theme( $theme->slug )->is_block_theme(); if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $customize_url = $theme->block_theme ? admin_url( 'site-editor.php' ) : wp_customize_url( $theme->slug ); $theme->customize_url = add_query_arg( array( 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), ), $customize_url ); } $theme->name = wp_kses( $theme->name, $themes_allowedtags ); $theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags ); $theme->version = wp_kses( $theme->version, $themes_allowedtags ); $theme->description = wp_kses( $theme->description, $themes_allowedtags ); $theme->stars = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false, ) ); $theme->num_ratings = number_format_i18n( $theme->num_ratings ); $theme->preview_url = set_url_scheme( $theme->preview_url ); $theme->compatible_wp = is_wp_version_compatible( $theme->requires ); $theme->compatible_php = is_php_version_compatible( $theme->requires_php ); } wp_send_json_success( $api ); } function wp_ajax_parse_embed() { global $post, $wp_embed, $content_width; if ( empty( $_POST['shortcode'] ) ) { wp_send_json_error(); } $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { wp_send_json_error(); } setup_postdata( $post ); } elseif ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $shortcode = wp_unslash( $_POST['shortcode'] ); preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); $atts = shortcode_parse_atts( $matches[3] ); if ( ! empty( $matches[5] ) ) { $url = $matches[5]; } elseif ( ! empty( $atts['src'] ) ) { $url = $atts['src']; } else { $url = ''; } $parsed = false; $wp_embed->return_false_on_fail = true; if ( 0 === $post_id ) { $wp_embed->usecache = false; } if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); $parsed = $wp_embed->run_shortcode( $ssl_shortcode ); if ( ! $parsed ) { $no_ssl_support = true; } } if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) { if ( ! isset( $content_width ) ) { $content_width = (int) $_POST['maxwidth']; } else { $content_width = min( $content_width, (int) $_POST['maxwidth'] ); } } if ( $url && ! $parsed ) { $parsed = $wp_embed->run_shortcode( $shortcode ); } if ( ! $parsed ) { wp_send_json_error( array( 'type' => 'not-embeddable', 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '' ), ) ); } if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) { $styles = ''; $mce_styles = wpview_media_sandbox_styles(); foreach ( $mce_styles as $style ) { $styles .= sprintf( '', $style ); } $html = do_shortcode( $parsed ); global $wp_scripts; if ( ! empty( $wp_scripts ) ) { $wp_scripts->done = array(); } ob_start(); wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); $scripts = ob_get_clean(); $parsed = $styles . $html . $scripts; } if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || preg_match( '%]*href="http://%', $parsed ) ) ) ) { wp_send_json_error( array( 'type' => 'not-ssl', 'message' => __( 'This preview is unavailable in the editor.' ), ) ); } $return = array( 'body' => $parsed, 'attr' => $wp_embed->last_attr, ); if ( strpos( $parsed, 'class="wp-embedded-content' ) ) { if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { $script_src = includes_url( 'js/wp-embed.js' ); } else { $script_src = includes_url( 'js/wp-embed.min.js' ); } $return['head'] = ''; $return['sandbox'] = true; } wp_send_json_success( $return ); } function wp_ajax_parse_media_shortcode() { global $post, $wp_scripts; if ( empty( $_POST['shortcode'] ) ) { wp_send_json_error(); } $shortcode = wp_unslash( $_POST['shortcode'] ); if ( ! empty( $_POST['post_ID'] ) ) { $post = get_post( (int) $_POST['post_ID'] ); } if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { if ( 'embed' === $shortcode ) { wp_send_json_error(); } } else { setup_postdata( $post ); } $parsed = do_shortcode( $shortcode ); if ( empty( $parsed ) ) { wp_send_json_error( array( 'type' => 'no-items', 'message' => __( 'No items found.' ), ) ); } $head = ''; $styles = wpview_media_sandbox_styles(); foreach ( $styles as $style ) { $head .= ''; } if ( ! empty( $wp_scripts ) ) { $wp_scripts->done = array(); } ob_start(); echo $parsed; if ( 'playlist' === $_REQUEST['type'] ) { wp_underscore_playlist_templates(); wp_print_scripts( 'wp-playlist' ); } else { wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); } wp_send_json_success( array( 'head' => $head, 'body' => ob_get_clean(), ) ); } function wp_ajax_destroy_sessions() { $user = get_userdata( (int) $_POST['user_id'] ); if ( $user ) { if ( ! current_user_can( 'edit_user', $user->ID ) ) { $user = false; } elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) { $user = false; } } if ( ! $user ) { wp_send_json_error( array( 'message' => __( 'Could not log out user sessions. Please try again.' ), ) ); } $sessions = WP_Session_Tokens::get_instance( $user->ID ); if ( get_current_user_id() === $user->ID ) { $sessions->destroy_others( wp_get_session_token() ); $message = __( 'You are now logged out everywhere else.' ); } else { $sessions->destroy_all(); $message = sprintf( __( '%s has been logged out.' ), $user->display_name ); } wp_send_json_success( array( 'message' => $message ) ); } function wp_ajax_crop_image() { $attachment_id = absint( $_POST['id'] ); check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' ); if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { wp_send_json_error(); } $context = str_replace( '_', '-', $_POST['context'] ); $data = array_map( 'absint', $_POST['cropDetails'] ); $cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] ); if ( ! $cropped || is_wp_error( $cropped ) ) { wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) ); } switch ( $context ) { case 'site-icon': require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php'; $wp_site_icon = new WP_Site_Icon(); if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { wp_delete_file( $cropped ); add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); break; } $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); $attachment = $wp_site_icon->create_attachment_object( $cropped, $attachment_id ); unset( $attachment['ID'] ); add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); $attachment_id = $wp_site_icon->insert_attachment( $attachment, $cropped ); remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); break; default: do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped ); $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); $parent_url = wp_get_attachment_url( $attachment_id ); $parent_basename = wp_basename( $parent_url ); $url = str_replace( $parent_basename, wp_basename( $cropped ), $parent_url ); $size = wp_getimagesize( $cropped ); $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; $original_attachment = get_post( $attachment_id ); $sanitized_post_title = sanitize_file_name( $original_attachment->post_title ); $use_original_title = ( ( '' !== trim( $original_attachment->post_title ) ) && ( $parent_basename !== $sanitized_post_title ) && ( pathinfo( $parent_basename, PATHINFO_FILENAME ) !== $sanitized_post_title ) ); $use_original_description = ( '' !== trim( $original_attachment->post_content ) ); $attachment = array( 'post_title' => $use_original_title ? $original_attachment->post_title : wp_basename( $cropped ), 'post_content' => $use_original_description ? $original_attachment->post_content : $url, 'post_mime_type' => $image_type, 'guid' => $url, 'context' => $context, ); if ( '' !== trim( $original_attachment->post_excerpt ) ) { $attachment['post_excerpt'] = $original_attachment->post_excerpt; } if ( '' !== trim( $original_attachment->_wp_attachment_image_alt ) ) { $attachment['meta_input'] = array( '_wp_attachment_image_alt' => wp_slash( $original_attachment->_wp_attachment_image_alt ), ); } $attachment_id = wp_insert_attachment( $attachment, $cropped ); $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); $metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata ); wp_update_attachment_metadata( $attachment_id, $metadata ); $attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context ); } wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) ); } function wp_ajax_generate_password() { wp_send_json_success( wp_generate_password( 24 ) ); } function wp_ajax_nopriv_generate_password() { wp_send_json_success( wp_generate_password( 24 ) ); } function wp_ajax_save_wporg_username() { if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { wp_send_json_error(); } check_ajax_referer( 'save_wporg_username_' . get_current_user_id() ); $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; if ( ! $username ) { wp_send_json_error(); } wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); } function wp_ajax_install_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $slug = sanitize_key( wp_unslash( $_POST['slug'] ) ); $status = array( 'install' => 'theme', 'slug' => $slug, ); if ( ! current_user_can( 'install_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to install themes on this site.' ); wp_send_json_error( $status ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/theme.php'; $api = themes_api( 'theme_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ), ) ); if ( is_wp_error( $api ) ) { $status['errorMessage'] = $api->get_error_message(); wp_send_json_error( $status ); } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Theme_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $result ) ) { $status['errorCode'] = $result->get_error_code(); $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_null( $result ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['themeName'] = wp_get_theme( $slug )->get( 'Name' ); if ( current_user_can( 'switch_themes' ) ) { if ( is_multisite() ) { $status['activateUrl'] = add_query_arg( array( 'action' => 'enable', '_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ), 'theme' => $slug, ), network_admin_url( 'themes.php' ) ); } else { $status['activateUrl'] = add_query_arg( array( 'action' => 'activate', '_wpnonce' => wp_create_nonce( 'switch-theme_' . $slug ), 'stylesheet' => $slug, ), admin_url( 'themes.php' ) ); } } $theme = wp_get_theme( $slug ); $status['blockTheme'] = $theme->is_block_theme(); if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $status['customizeUrl'] = add_query_arg( array( 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), ), wp_customize_url( $slug ) ); } wp_send_json_success( $status ); } function wp_ajax_update_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); $status = array( 'update' => 'theme', 'slug' => $stylesheet, 'oldVersion' => '', 'newVersion' => '', ); if ( ! current_user_can( 'update_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to update themes for this site.' ); wp_send_json_error( $status ); } $theme = wp_get_theme( $stylesheet ); if ( $theme->exists() ) { $status['oldVersion'] = $theme->get( 'Version' ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $current = get_site_transient( 'update_themes' ); if ( empty( $current ) ) { wp_update_themes(); } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Theme_Upgrader( $skin ); $result = $upgrader->bulk_upgrade( array( $stylesheet ) ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) { if ( true === $result[ $stylesheet ] ) { $status['errorMessage'] = $upgrader->strings['up_to_date']; wp_send_json_error( $status ); } $theme = wp_get_theme( $stylesheet ); if ( $theme->exists() ) { $status['newVersion'] = $theme->get( 'Version' ); } wp_send_json_success( $status ); } elseif ( false === $result ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['errorMessage'] = __( 'Theme update failed.' ); wp_send_json_error( $status ); } function wp_ajax_delete_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); $status = array( 'delete' => 'theme', 'slug' => $stylesheet, ); if ( ! current_user_can( 'delete_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to delete themes on this site.' ); wp_send_json_error( $status ); } if ( ! wp_get_theme( $stylesheet )->exists() ) { $status['errorMessage'] = __( 'The requested theme does not exist.' ); wp_send_json_error( $status ); } $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ); ob_start(); $credentials = request_filesystem_credentials( $url ); ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } include_once ABSPATH . 'wp-admin/includes/theme.php'; $result = delete_theme( $stylesheet ); if ( is_wp_error( $result ) ) { $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( false === $result ) { $status['errorMessage'] = __( 'Theme could not be deleted.' ); wp_send_json_error( $status ); } wp_send_json_success( $status ); } function wp_ajax_install_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $status = array( 'install' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), ); if ( ! current_user_can( 'install_plugins' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.' ); wp_send_json_error( $status ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 'fields' => array( 'sections' => false, ), ) ); if ( is_wp_error( $api ) ) { $status['errorMessage'] = $api->get_error_message(); wp_send_json_error( $status ); } $status['pluginName'] = $api->name; $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $result ) ) { $status['errorCode'] = $result->get_error_code(); $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_null( $result ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $install_status = install_plugin_install_status( $api ); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; $plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' ); if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) { $status['activateUrl'] = add_query_arg( array( '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ), 'action' => 'activate', 'plugin' => $install_status['file'], ), $plugins_url ); } if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) { $status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] ); } wp_send_json_success( $status ); } function wp_ajax_update_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); $status = array( 'update' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 'oldVersion' => '', 'newVersion' => '', ); if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' ); wp_send_json_error( $status ); } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $status['plugin'] = $plugin; $status['pluginName'] = $plugin_data['Name']; if ( $plugin_data['Version'] ) { $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; wp_update_plugins(); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->bulk_upgrade( array( $plugin ) ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) { if ( true === $result[ $plugin ] ) { $status['errorMessage'] = $upgrader->strings['up_to_date']; wp_send_json_error( $status ); } $plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] ); $plugin_data = reset( $plugin_data ); if ( $plugin_data['Version'] ) { $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); } wp_send_json_success( $status ); } elseif ( false === $result ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['errorMessage'] = __( 'Plugin update failed.' ); wp_send_json_error( $status ); } function wp_ajax_delete_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); $status = array( 'delete' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), ); if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' ); wp_send_json_error( $status ); } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $status['plugin'] = $plugin; $status['pluginName'] = $plugin_data['Name']; if ( is_plugin_active( $plugin ) ) { $status['errorMessage'] = __( 'You cannot delete a plugin while it is active on the main site.' ); wp_send_json_error( $status ); } $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' ); ob_start(); $credentials = request_filesystem_credentials( $url ); ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $result = delete_plugins( array( $plugin ) ); if ( is_wp_error( $result ) ) { $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( false === $result ) { $status['errorMessage'] = __( 'Plugin could not be deleted.' ); wp_send_json_error( $status ); } wp_send_json_success( $status ); } function wp_ajax_search_plugins() { check_ajax_referer( 'updates' ); wp_plugin_update_rows(); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) { set_current_screen( $pagenow ); } $wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array( 'screen' => get_current_screen(), ) ); $status = array(); if ( ! $wp_list_table->ajax_user_can() ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); wp_send_json_error( $status ); } $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( '_ajax_nonce' => null, 'action' => null, ) ), network_admin_url( 'plugins.php', 'relative' ) ); $GLOBALS['s'] = wp_unslash( $_POST['s'] ); $wp_list_table->prepare_items(); ob_start(); $wp_list_table->display(); $status['count'] = count( $wp_list_table->items ); $status['items'] = ob_get_clean(); wp_send_json_success( $status ); } function wp_ajax_search_install_plugins() { check_ajax_referer( 'updates' ); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; if ( 'plugin-install-network' === $pagenow || 'plugin-install' === $pagenow ) { set_current_screen( $pagenow ); } $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array( 'screen' => get_current_screen(), ) ); $status = array(); if ( ! $wp_list_table->ajax_user_can() ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); wp_send_json_error( $status ); } $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( '_ajax_nonce' => null, 'action' => null, ) ), network_admin_url( 'plugin-install.php', 'relative' ) ); $wp_list_table->prepare_items(); ob_start(); $wp_list_table->display(); $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' ); $status['items'] = ob_get_clean(); wp_send_json_success( $status ); } function wp_ajax_edit_theme_plugin_file() { $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); if ( is_wp_error( $r ) ) { wp_send_json_error( array_merge( array( 'code' => $r->get_error_code(), 'message' => $r->get_error_message(), ), (array) $r->get_error_data() ) ); } else { wp_send_json_success( array( 'message' => __( 'File edited successfully.' ), ) ); } } function wp_ajax_wp_privacy_export_personal_data() { if ( empty( $_POST['id'] ) ) { wp_send_json_error( __( 'Missing request ID.' ) ); } $request_id = (int) $_POST['id']; if ( $request_id < 1 ) { wp_send_json_error( __( 'Invalid request ID.' ) ); } if ( ! current_user_can( 'export_others_personal_data' ) ) { wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) ); } check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); } $email_address = $request->email; if ( ! is_email( $email_address ) ) { wp_send_json_error( __( 'A valid email address must be given.' ) ); } if ( ! isset( $_POST['exporter'] ) ) { wp_send_json_error( __( 'Missing exporter index.' ) ); } $exporter_index = (int) $_POST['exporter']; if ( ! isset( $_POST['page'] ) ) { wp_send_json_error( __( 'Missing page index.' ) ); } $page = (int) $_POST['page']; $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( 'true' === $_POST['sendAsEmail'] ) : false; $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); if ( ! is_array( $exporters ) ) { wp_send_json_error( __( 'An exporter has improperly used the registration filter.' ) ); } if ( 0 < count( $exporters ) ) { if ( $exporter_index < 1 ) { wp_send_json_error( __( 'Exporter index cannot be negative.' ) ); } if ( $exporter_index > count( $exporters ) ) { wp_send_json_error( __( 'Exporter index is out of range.' ) ); } if ( $page < 1 ) { wp_send_json_error( __( 'Page index cannot be less than one.' ) ); } $exporter_keys = array_keys( $exporters ); $exporter_key = $exporter_keys[ $exporter_index - 1 ]; $exporter = $exporters[ $exporter_key ]; if ( ! is_array( $exporter ) ) { wp_send_json_error( sprintf( __( 'Expected an array describing the exporter at index %s.' ), $exporter_key ) ); } if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { wp_send_json_error( sprintf( __( 'Exporter array at index %s does not include a friendly name.' ), $exporter_key ) ); } $exporter_friendly_name = $exporter['exporter_friendly_name']; if ( ! array_key_exists( 'callback', $exporter ) ) { wp_send_json_error( sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! is_callable( $exporter['callback'] ) ) { wp_send_json_error( sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } $callback = $exporter['callback']; $response = call_user_func( $callback, $email_address, $page ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } if ( ! is_array( $response ) ) { wp_send_json_error( sprintf( __( 'Expected response as an array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! array_key_exists( 'data', $response ) ) { wp_send_json_error( sprintf( __( 'Expected data in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! is_array( $response['data'] ) ) { wp_send_json_error( sprintf( __( 'Expected data array in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! array_key_exists( 'done', $response ) ) { wp_send_json_error( sprintf( __( 'Expected done (boolean) in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } } else { $exporter_key = ''; $response = array( 'data' => array(), 'done' => true, ); } $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } wp_send_json_success( $response ); } function wp_ajax_wp_privacy_erase_personal_data() { if ( empty( $_POST['id'] ) ) { wp_send_json_error( __( 'Missing request ID.' ) ); } $request_id = (int) $_POST['id']; if ( $request_id < 1 ) { wp_send_json_error( __( 'Invalid request ID.' ) ); } if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) { wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) ); } check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); $request = wp_get_user_request( $request_id ); if ( ! $request || 'remove_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); } $email_address = $request->email; if ( ! is_email( $email_address ) ) { wp_send_json_error( __( 'Invalid email address in request.' ) ); } if ( ! isset( $_POST['eraser'] ) ) { wp_send_json_error( __( 'Missing eraser index.' ) ); } $eraser_index = (int) $_POST['eraser']; if ( ! isset( $_POST['page'] ) ) { wp_send_json_error( __( 'Missing page index.' ) ); } $page = (int) $_POST['page']; $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); if ( 0 < count( $erasers ) ) { if ( $eraser_index < 1 ) { wp_send_json_error( __( 'Eraser index cannot be less than one.' ) ); } if ( $eraser_index > count( $erasers ) ) { wp_send_json_error( __( 'Eraser index is out of range.' ) ); } if ( $page < 1 ) { wp_send_json_error( __( 'Page index cannot be less than one.' ) ); } $eraser_keys = array_keys( $erasers ); $eraser_key = $eraser_keys[ $eraser_index - 1 ]; $eraser = $erasers[ $eraser_key ]; if ( ! is_array( $eraser ) ) { wp_send_json_error( sprintf( __( 'Expected an array describing the eraser at index %d.' ), $eraser_index ) ); } if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) { wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a friendly name.' ), $eraser_index ) ); } $eraser_friendly_name = $eraser['eraser_friendly_name']; if ( ! array_key_exists( 'callback', $eraser ) ) { wp_send_json_error( sprintf( __( 'Eraser does not include a callback: %s.' ), esc_html( $eraser_friendly_name ) ) ); } if ( ! is_callable( $eraser['callback'] ) ) { wp_send_json_error( sprintf( __( 'Eraser callback is not valid: %s.' ), esc_html( $eraser_friendly_name ) ) ); } $callback = $eraser['callback']; $response = call_user_func( $callback, $email_address, $page ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } if ( ! is_array( $response ) ) { wp_send_json_error( sprintf( __( 'Did not receive array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'items_removed', $response ) ) { wp_send_json_error( sprintf( __( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'items_retained', $response ) ) { wp_send_json_error( sprintf( __( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'messages', $response ) ) { wp_send_json_error( sprintf( __( 'Expected messages key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! is_array( $response['messages'] ) ) { wp_send_json_error( sprintf( __( 'Expected messages key to reference an array in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'done', $response ) ) { wp_send_json_error( sprintf( __( 'Expected done flag in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } } else { $eraser_key = ''; $response = array( 'items_removed' => false, 'items_retained' => false, 'messages' => array(), 'done' => true, ); } $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id, $eraser_key ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } wp_send_json_success( $response ); } function wp_ajax_health_check_dotorg_communication() { _doing_it_wrong( 'wp_ajax_health_check_dotorg_communication', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_dotorg_communication', 'WP_REST_Site_Health_Controller::test_dotorg_communication' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_dotorg_communication() ); } function wp_ajax_health_check_background_updates() { _doing_it_wrong( 'wp_ajax_health_check_background_updates', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_background_updates', 'WP_REST_Site_Health_Controller::test_background_updates' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_background_updates() ); } function wp_ajax_health_check_loopback_requests() { _doing_it_wrong( 'wp_ajax_health_check_loopback_requests', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_loopback_requests', 'WP_REST_Site_Health_Controller::test_loopback_requests' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_loopback_requests() ); } function wp_ajax_health_check_site_status_result() { check_ajax_referer( 'health-check-site-status-result' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) ); wp_send_json_success(); } function wp_ajax_health_check_get_sizes() { _doing_it_wrong( 'wp_ajax_health_check_get_sizes', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_get_sizes', 'WP_REST_Site_Health_Controller::get_directory_sizes' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status-result' ); if ( ! current_user_can( 'view_site_health_checks' ) || is_multisite() ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Debug_Data' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php'; } $sizes_data = WP_Debug_Data::get_sizes(); $all_sizes = array( 'raw' => 0 ); foreach ( $sizes_data as $name => $value ) { $name = sanitize_text_field( $name ); $data = array(); if ( isset( $value['size'] ) ) { if ( is_string( $value['size'] ) ) { $data['size'] = sanitize_text_field( $value['size'] ); } else { $data['size'] = (int) $value['size']; } } if ( isset( $value['debug'] ) ) { if ( is_string( $value['debug'] ) ) { $data['debug'] = sanitize_text_field( $value['debug'] ); } else { $data['debug'] = (int) $value['debug']; } } if ( ! empty( $value['raw'] ) ) { $data['raw'] = (int) $value['raw']; } $all_sizes[ $name ] = $data; } if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) { wp_send_json_error( $all_sizes ); } wp_send_json_success( $all_sizes ); } function wp_ajax_rest_nonce() { exit( wp_create_nonce( 'wp_rest' ) ); } function wp_ajax_toggle_auto_updates() { check_ajax_referer( 'updates' ); if ( empty( $_POST['type'] ) || empty( $_POST['asset'] ) || empty( $_POST['state'] ) ) { wp_send_json_error( array( 'error' => __( 'Invalid data. No selected item.' ) ) ); } $asset = sanitize_text_field( urldecode( $_POST['asset'] ) ); if ( 'enable' !== $_POST['state'] && 'disable' !== $_POST['state'] ) { wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown state.' ) ) ); } $state = $_POST['state']; if ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) { wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown type.' ) ) ); } $type = $_POST['type']; switch ( $type ) { case 'plugin': if ( ! current_user_can( 'update_plugins' ) ) { $error_message = __( 'Sorry, you are not allowed to modify plugins.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $option = 'auto_update_plugins'; $all_items = apply_filters( 'all_plugins', get_plugins() ); break; case 'theme': if ( ! current_user_can( 'update_themes' ) ) { $error_message = __( 'Sorry, you are not allowed to modify themes.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $option = 'auto_update_themes'; $all_items = wp_get_themes(); break; default: wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown type.' ) ) ); } if ( ! array_key_exists( $asset, $all_items ) ) { $error_message = __( 'Invalid data. The item does not exist.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $auto_updates = (array) get_site_option( $option, array() ); if ( 'disable' === $state ) { $auto_updates = array_diff( $auto_updates, array( $asset ) ); } else { $auto_updates[] = $asset; $auto_updates = array_unique( $auto_updates ); } $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); update_site_option( $option, $auto_updates ); wp_send_json_success(); } function wp_ajax_send_password_reset() { $user_id = isset( $_POST['user_id'] ) ? (int) $_POST['user_id'] : 0; check_ajax_referer( 'reset-password-for-' . $user_id, 'nonce' ); if ( ! current_user_can( 'edit_user', $user_id ) ) { wp_send_json_error( __( 'Cannot send password reset, permission denied.' ) ); } $user = get_userdata( $user_id ); $results = retrieve_password( $user->user_login ); if ( true === $results ) { wp_send_json_success( sprintf( __( 'A password reset link was emailed to %s.' ), $user->display_name ) ); } else { wp_send_json_error( $results->get_error_message() ); } } $_GET['list_args']['screen']['id'] ) ); if ( ! $wp_list_table ) { wp_die( 0 ); } if ( ! $wp_list_table->ajax_user_can() ) { wp_die( -1 ); } $wp_list_table->ajax_response(); wp_die( 0 ); } function wp_ajax_ajax_tag_search() { if ( ! isset( $_GET['tax'] ) ) { wp_die( 0 ); } $taxonomy = sanitize_key( $_GET['tax'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { wp_die( -1 ); } $search = wp_unslash( $_GET['q'] ); $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $search = str_replace( $comma, ',', $search ); } if ( false !== strpos( $search, ',' ) ) { $search = explode( ',', $search ); $search = $search[ count( $search ) - 1 ]; } $search = trim( $search ); $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $taxonomy_object, $search ); if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { wp_die(); } $results = get_terms( array( 'taxonomy' => $taxonomy, 'name__like' => $search, 'fields' => 'names', 'hide_empty' => false, 'number' => isset( $_GET['number'] ) ? (int) $_GET['number'] : 0, ) ); $results = apply_filters( 'ajax_term_search_results', $results, $taxonomy_object, $search ); echo implode( "\n", $results ); wp_die(); } function wp_ajax_wp_compression_test() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( -1 ); } if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) { update_site_option( 'can_compress_scripts', 0 ); wp_die( 0 ); } if ( isset( $_GET['test'] ) ) { header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); header( 'Content-Type: application/javascript; charset=UTF-8' ); $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ); $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; if ( 1 == $_GET['test'] ) { echo $test_str; wp_die(); } elseif ( 2 == $_GET['test'] ) { if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { wp_die( -1 ); } if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) { header( 'Content-Encoding: deflate' ); $out = gzdeflate( $test_str, 1 ); } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) { header( 'Content-Encoding: gzip' ); $out = gzencode( $test_str, 1 ); } else { wp_die( -1 ); } echo $out; wp_die(); } elseif ( 'no' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 0 ); } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); update_site_option( 'can_compress_scripts', 1 ); } } wp_die( 0 ); } function wp_ajax_imgedit_preview() { $post_id = (int) $_GET['postid']; if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } check_ajax_referer( "image_editor-$post_id" ); include_once ABSPATH . 'wp-admin/includes/image-edit.php'; if ( ! stream_preview_image( $post_id ) ) { wp_die( -1 ); } wp_die(); } function wp_ajax_oembed_cache() { $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); wp_die( 0 ); } function wp_ajax_autocomplete_user() { if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) { wp_die( -1 ); } if ( ! current_user_can( 'manage_network_users' ) && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) { wp_die( -1 ); } $return = array(); if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { $type = $_REQUEST['autocomplete_type']; } else { $type = 'add'; } if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { $field = $_REQUEST['autocomplete_field']; } else { $field = 'user_login'; } if ( isset( $_REQUEST['site_id'] ) ) { $id = absint( $_REQUEST['site_id'] ); } else { $id = get_current_blog_id(); } $include_blog_users = ( 'search' === $type ? get_users( array( 'blog_id' => $id, 'fields' => 'ID', ) ) : array() ); $exclude_blog_users = ( 'add' === $type ? get_users( array( 'blog_id' => $id, 'fields' => 'ID', ) ) : array() ); $users = get_users( array( 'blog_id' => false, 'search' => '*' . $_REQUEST['term'] . '*', 'include' => $include_blog_users, 'exclude' => $exclude_blog_users, 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ), ) ); foreach ( $users as $user ) { $return[] = array( 'label' => sprintf( _x( '%1$s (%2$s)', 'user autocomplete result' ), $user->user_login, $user->user_email ), 'value' => $user->$field, ); } wp_die( wp_json_encode( $return ) ); } function wp_ajax_get_community_events() { require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; check_ajax_referer( 'community_events' ); $search = isset( $_POST['location'] ) ? wp_unslash( $_POST['location'] ) : ''; $timezone = isset( $_POST['timezone'] ) ? wp_unslash( $_POST['timezone'] ) : ''; $user_id = get_current_user_id(); $saved_location = get_user_option( 'community-events-location', $user_id ); $events_client = new WP_Community_Events( $user_id, $saved_location ); $events = $events_client->get_events( $search, $timezone ); $ip_changed = false; if ( is_wp_error( $events ) ) { wp_send_json_error( array( 'error' => $events->get_error_message(), ) ); } else { if ( empty( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) ) { $ip_changed = true; } elseif ( isset( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) && $saved_location['ip'] !== $events['location']['ip'] ) { $ip_changed = true; } if ( $ip_changed || $search ) { update_user_meta( $user_id, 'community-events-location', $events['location'] ); } wp_send_json_success( $events ); } } function wp_ajax_dashboard_widgets() { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; $pagenow = $_GET['pagenow']; if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) { set_current_screen( $pagenow ); } switch ( $_GET['widget'] ) { case 'dashboard_primary': wp_dashboard_primary(); break; } wp_die(); } function wp_ajax_logged_in() { wp_die( 1 ); } function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0; $per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0; $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; $url = isset( $_POST['_url'] ) ? sanitize_url( $_POST['_url'] ) : ''; if ( ! $total || ! $per_page || ! $page || ! $url ) { $time = time(); $comment = get_comment( $comment_id ); $comment_status = ''; $comment_link = ''; if ( $comment ) { $comment_status = $comment->comment_approved; } if ( 1 === (int) $comment_status ) { $comment_link = get_comment_link( $comment ); } $counts = wp_count_comments(); $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $comment_id, 'supplemental' => array( 'status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), 'comment_link' => $comment_link, ), ) ); $x->send(); } $total += $delta; if ( $total < 0 ) { $total = 0; } if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { $post_id = 0; $status = 'all'; $parsed = parse_url( $url ); if ( isset( $parsed['query'] ) ) { parse_str( $parsed['query'], $query_vars ); if ( ! empty( $query_vars['comment_status'] ) ) { $status = $query_vars['comment_status']; } if ( ! empty( $query_vars['p'] ) ) { $post_id = (int) $query_vars['p']; } if ( ! empty( $query_vars['comment_type'] ) ) { $type = $query_vars['comment_type']; } } if ( empty( $type ) ) { $comment_count = wp_count_comments( $post_id ); if ( isset( $comment_count->$status ) ) { $total = $comment_count->$status; } } } $time = time(); $comment = get_comment( $comment_id ); $counts = wp_count_comments(); $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $comment_id, 'supplemental' => array( 'status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 'total_pages' => ceil( $total / $per_page ), 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), 'total' => $total, 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), ), ) ); $x->send(); } function _wp_ajax_add_hierarchical_term() { $action = $_POST['action']; $taxonomy = get_taxonomy( substr( $action, 4 ) ); check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { wp_die( -1 ); } $names = explode( ',', $_POST[ 'new' . $taxonomy->name ] ); $parent = isset( $_POST[ 'new' . $taxonomy->name . '_parent' ] ) ? (int) $_POST[ 'new' . $taxonomy->name . '_parent' ] : 0; if ( 0 > $parent ) { $parent = 0; } if ( 'category' === $taxonomy->name ) { $post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array(); } else { $post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array(); } $checked_categories = array_map( 'absint', (array) $post_category ); $popular_ids = wp_popular_terms_checklist( $taxonomy->name, 0, 10, false ); foreach ( $names as $cat_name ) { $cat_name = trim( $cat_name ); $category_nicename = sanitize_title( $cat_name ); if ( '' === $category_nicename ) { continue; } $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); if ( ! $cat_id || is_wp_error( $cat_id ) ) { continue; } else { $cat_id = $cat_id['term_id']; } $checked_categories[] = $cat_id; if ( $parent ) { continue; } ob_start(); wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids, ) ); $data = ob_get_clean(); $add = array( 'what' => $taxonomy->name, 'id' => $cat_id, 'data' => str_replace( array( "\n", "\t" ), '', $data ), 'position' => -1, ); } if ( $parent ) { $parent = get_term( $parent, $taxonomy->name ); $term_id = $parent->term_id; while ( $parent->parent ) { $parent = get_term( $parent->parent, $taxonomy->name ); if ( is_wp_error( $parent ) ) { break; } $term_id = $parent->term_id; } ob_start(); wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids, ) ); $data = ob_get_clean(); $add = array( 'what' => $taxonomy->name, 'id' => $term_id, 'data' => str_replace( array( "\n", "\t" ), '', $data ), 'position' => -1, ); } ob_start(); wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', ) ); $sup = ob_get_clean(); $add['supplemental'] = array( 'newcat_parent' => $sup ); $x = new WP_Ajax_Response( $add ); $x->send(); } function wp_ajax_delete_comment() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; $comment = get_comment( $id ); if ( ! $comment ) { wp_die( time() ); } if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { wp_die( -1 ); } check_ajax_referer( "delete-comment_$id" ); $status = wp_get_comment_status( $comment ); $delta = -1; if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) { if ( 'trash' === $status ) { wp_die( time() ); } $r = wp_trash_comment( $comment ); } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) { if ( 'trash' !== $status ) { wp_die( time() ); } $r = wp_untrash_comment( $comment ); if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) { $delta = 1; } } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { if ( 'spam' === $status ) { wp_die( time() ); } $r = wp_spam_comment( $comment ); } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) { if ( 'spam' !== $status ) { wp_die( time() ); } $r = wp_unspam_comment( $comment ); if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) { $delta = 1; } } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { $r = wp_delete_comment( $comment ); } else { wp_die( -1 ); } if ( $r ) { _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); } wp_die( 0 ); } function wp_ajax_delete_tag() { $tag_id = (int) $_POST['tag_ID']; check_ajax_referer( "delete-tag_$tag_id" ); if ( ! current_user_can( 'delete_term', $tag_id ) ) { wp_die( -1 ); } $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag'; $tag = get_term( $tag_id, $taxonomy ); if ( ! $tag || is_wp_error( $tag ) ) { wp_die( 1 ); } if ( wp_delete_term( $tag_id, $taxonomy ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_delete_link() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "delete-bookmark_$id" ); if ( ! current_user_can( 'manage_links' ) ) { wp_die( -1 ); } $link = get_bookmark( $id ); if ( ! $link || is_wp_error( $link ) ) { wp_die( 1 ); } if ( wp_delete_link( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_delete_meta() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "delete-meta_$id" ); $meta = get_metadata_by_mid( 'post', $id ); if ( ! $meta ) { wp_die( 1 ); } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) { wp_die( -1 ); } if ( delete_meta( $meta->meta_id ) ) { wp_die( 1 ); } wp_die( 0 ); } function wp_ajax_delete_post( $action ) { if ( empty( $action ) ) { $action = 'delete-post'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_post', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( wp_delete_post( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_trash_post( $action ) { if ( empty( $action ) ) { $action = 'trash-post'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_post', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( 'trash-post' === $action ) { $done = wp_trash_post( $id ); } else { $done = wp_untrash_post( $id ); } if ( $done ) { wp_die( 1 ); } wp_die( 0 ); } function wp_ajax_untrash_post( $action ) { if ( empty( $action ) ) { $action = 'untrash-post'; } wp_ajax_trash_post( $action ); } function wp_ajax_delete_page( $action ) { if ( empty( $action ) ) { $action = 'delete-page'; } $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; check_ajax_referer( "{$action}_$id" ); if ( ! current_user_can( 'delete_page', $id ) ) { wp_die( -1 ); } if ( ! get_post( $id ) ) { wp_die( 1 ); } if ( wp_delete_post( $id ) ) { wp_die( 1 ); } else { wp_die( 0 ); } } function wp_ajax_dim_comment() { $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; $comment = get_comment( $id ); if ( ! $comment ) { $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => new WP_Error( 'invalid_comment', sprintf( __( 'Comment %d does not exist' ), $id ) ), ) ); $x->send(); } if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) { wp_die( -1 ); } $current = wp_get_comment_status( $comment ); if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) { wp_die( time() ); } check_ajax_referer( "approve-comment_$id" ); if ( in_array( $current, array( 'unapproved', 'spam' ), true ) ) { $result = wp_set_comment_status( $comment, 'approve', true ); } else { $result = wp_set_comment_status( $comment, 'hold', true ); } if ( is_wp_error( $result ) ) { $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $result, ) ); $x->send(); } _wp_ajax_delete_comment_response( $comment->comment_ID ); wp_die( 0 ); } function wp_ajax_add_link_category( $action ) { if ( empty( $action ) ) { $action = 'add-link-category'; } check_ajax_referer( $action ); $taxonomy_object = get_taxonomy( 'link_category' ); if ( ! current_user_can( $taxonomy_object->cap->manage_terms ) ) { wp_die( -1 ); } $names = explode( ',', wp_unslash( $_POST['newcat'] ) ); $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim( $cat_name ); $slug = sanitize_title( $cat_name ); if ( '' === $slug ) { continue; } $cat_id = wp_insert_term( $cat_name, 'link_category' ); if ( ! $cat_id || is_wp_error( $cat_id ) ) { continue; } else { $cat_id = $cat_id['term_id']; } $cat_name = esc_html( $cat_name ); $x->add( array( 'what' => 'link-category', 'id' => $cat_id, 'data' => "", 'position' => -1, ) ); } $x->send(); } function wp_ajax_add_tag() { check_ajax_referer( 'add-tag', '_wpnonce_add-tag' ); $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag'; $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! current_user_can( $taxonomy_object->cap->edit_terms ) ) { wp_die( -1 ); } $x = new WP_Ajax_Response(); $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); if ( $tag && ! is_wp_error( $tag ) ) { $tag = get_term( $tag['term_id'], $taxonomy ); } if ( ! $tag || is_wp_error( $tag ) ) { $message = __( 'An error has occurred. Please reload the page and try again.' ); $error_code = 'error'; if ( is_wp_error( $tag ) && $tag->get_error_message() ) { $message = $tag->get_error_message(); } if ( is_wp_error( $tag ) && $tag->get_error_code() ) { $error_code = $tag->get_error_code(); } $x->add( array( 'what' => 'taxonomy', 'data' => new WP_Error( $error_code, $message ), ) ); $x->send(); } $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); $level = 0; $noparents = ''; if ( is_taxonomy_hierarchical( $taxonomy ) ) { $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); ob_start(); $wp_list_table->single_row( $tag, $level ); $noparents = ob_get_clean(); } ob_start(); $wp_list_table->single_row( $tag ); $parents = ob_get_clean(); require ABSPATH . 'wp-admin/includes/edit-tag-messages.php'; $message = ''; if ( isset( $messages[ $taxonomy_object->name ][1] ) ) { $message = $messages[ $taxonomy_object->name ][1]; } elseif ( isset( $messages['_item'][1] ) ) { $message = $messages['_item'][1]; } $x->add( array( 'what' => 'taxonomy', 'data' => $message, 'supplemental' => array( 'parents' => $parents, 'noparents' => $noparents, 'notice' => $message, ), ) ); $x->add( array( 'what' => 'term', 'position' => $level, 'supplemental' => (array) $tag, ) ); $x->send(); } function wp_ajax_get_tagcloud() { if ( ! isset( $_POST['tax'] ) ) { wp_die( 0 ); } $taxonomy = sanitize_key( $_POST['tax'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { wp_die( -1 ); } $tags = get_terms( array( 'taxonomy' => $taxonomy, 'number' => 45, 'orderby' => 'count', 'order' => 'DESC', ) ); if ( empty( $tags ) ) { wp_die( $taxonomy_object->labels->not_found ); } if ( is_wp_error( $tags ) ) { wp_die( $tags->get_error_message() ); } foreach ( $tags as $key => $tag ) { $tags[ $key ]->link = '#'; $tags[ $key ]->id = $tag->term_id; } $return = wp_generate_tag_cloud( $tags, array( 'filter' => 0, 'format' => 'list', ) ); if ( empty( $return ) ) { wp_die( 0 ); } echo $return; wp_die(); } function wp_ajax_get_comments( $action ) { global $post_id; if ( empty( $action ) ) { $action = 'get-comments'; } check_ajax_referer( $action ); if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) { $id = absint( $_REQUEST['p'] ); if ( ! empty( $id ) ) { $post_id = $id; } } if ( empty( $post_id ) ) { wp_die( -1 ); } $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } $wp_list_table->prepare_items(); if ( ! $wp_list_table->has_items() ) { wp_die( 1 ); } $x = new WP_Ajax_Response(); ob_start(); foreach ( $wp_list_table->items as $comment ) { if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) { continue; } get_comment( $comment ); $wp_list_table->single_row( $comment ); } $comment_list_item = ob_get_clean(); $x->add( array( 'what' => 'comments', 'data' => $comment_list_item, ) ); $x->send(); } function wp_ajax_replyto_comment( $action ) { if ( empty( $action ) ) { $action = 'replyto-comment'; } check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); $comment_post_id = (int) $_POST['comment_post_ID']; $post = get_post( $comment_post_id ); if ( ! $post ) { wp_die( -1 ); } if ( ! current_user_can( 'edit_post', $comment_post_id ) ) { wp_die( -1 ); } if ( empty( $post->post_status ) ) { wp_die( 1 ); } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ), true ) ) { wp_die( __( 'You cannot reply to a comment on a draft post.' ) ); } $user = wp_get_current_user(); if ( $user->exists() ) { $comment_author = wp_slash( $user->display_name ); $comment_author_email = wp_slash( $user->user_email ); $comment_author_url = wp_slash( $user->user_url ); $user_id = $user->ID; if ( current_user_can( 'unfiltered_html' ) ) { if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) { $_POST['_wp_unfiltered_html_comment'] = ''; } if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); kses_init_filters(); remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); add_filter( 'pre_comment_content', 'wp_filter_kses' ); } } } else { wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); } $comment_content = trim( $_POST['content'] ); if ( '' === $comment_content ) { wp_die( __( 'Please type your comment text.' ) ); } $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : 'comment'; $comment_parent = 0; if ( isset( $_POST['comment_ID'] ) ) { $comment_parent = absint( $_POST['comment_ID'] ); } $comment_auto_approved = false; $commentdata = array( 'comment_post_ID' => $comment_post_id, ); $commentdata += compact( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_id' ); if ( ! empty( $_POST['approve_parent'] ) ) { $parent = get_comment( $comment_parent ); if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) { if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { wp_die( -1 ); } if ( wp_set_comment_status( $parent, 'approve' ) ) { $comment_auto_approved = true; } } } $comment_id = wp_new_comment( $commentdata ); if ( is_wp_error( $comment_id ) ) { wp_die( $comment_id->get_error_message() ); } $comment = get_comment( $comment_id ); if ( ! $comment ) { wp_die( 1 ); } $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; ob_start(); if ( isset( $_REQUEST['mode'] ) && 'dashboard' === $_REQUEST['mode'] ) { require_once ABSPATH . 'wp-admin/includes/dashboard.php'; _wp_dashboard_recent_comments_row( $comment ); } else { if ( isset( $_REQUEST['mode'] ) && 'single' === $_REQUEST['mode'] ) { $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); } else { $wp_list_table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); } $wp_list_table->single_row( $comment ); } $comment_list_item = ob_get_clean(); $response = array( 'what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position, ); $counts = wp_count_comments(); $response['supplemental'] = array( 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ), number_format_i18n( $counts->moderated ) ), ); if ( $comment_auto_approved ) { $response['supplemental']['parent_approved'] = $parent->comment_ID; $response['supplemental']['parent_post_id'] = $parent->comment_post_ID; } $x = new WP_Ajax_Response(); $x->add( $response ); $x->send(); } function wp_ajax_edit_comment() { check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); $comment_id = (int) $_POST['comment_ID']; if ( ! current_user_can( 'edit_comment', $comment_id ) ) { wp_die( -1 ); } if ( '' === $_POST['content'] ) { wp_die( __( 'Please type your comment text.' ) ); } if ( isset( $_POST['status'] ) ) { $_POST['comment_status'] = $_POST['status']; } $updated = edit_comment(); if ( is_wp_error( $updated ) ) { wp_die( $updated->get_error_message() ); } $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; $checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0; $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); $comment = get_comment( $comment_id ); if ( empty( $comment->comment_ID ) ) { wp_die( -1 ); } ob_start(); $wp_list_table->single_row( $comment ); $comment_list_item = ob_get_clean(); $x = new WP_Ajax_Response(); $x->add( array( 'what' => 'edit_comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position, ) ); $x->send(); } function wp_ajax_add_menu_item() { check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; $menu_items_data = array(); foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { if ( ! empty( $menu_item_data['menu-item-type'] ) && 'custom' !== $menu_item_data['menu-item-type'] && ! empty( $menu_item_data['menu-item-object-id'] ) ) { switch ( $menu_item_data['menu-item-type'] ) { case 'post_type': $_object = get_post( $menu_item_data['menu-item-object-id'] ); break; case 'post_type_archive': $_object = get_post_type_object( $menu_item_data['menu-item-object'] ); break; case 'taxonomy': $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); break; } $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); $_menu_item = reset( $_menu_items ); $menu_item_data['menu-item-description'] = $_menu_item->description; } $menu_items_data[] = $menu_item_data; } $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); if ( is_wp_error( $item_ids ) ) { wp_die( 0 ); } $menu_items = array(); foreach ( (array) $item_ids as $menu_item_id ) { $menu_obj = get_post( $menu_item_id ); if ( ! empty( $menu_obj->ID ) ) { $menu_obj = wp_setup_nav_menu_item( $menu_obj ); $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title; $menu_obj->label = $menu_obj->title; $menu_items[] = $menu_obj; } } $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); if ( ! class_exists( $walker_class_name ) ) { wp_die( 0 ); } if ( ! empty( $menu_items ) ) { $args = array( 'after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new $walker_class_name(), ); echo walk_nav_menu_tree( $menu_items, 0, (object) $args ); } wp_die(); } function wp_ajax_add_meta() { check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' ); $c = 0; $pid = (int) $_POST['post_id']; $post = get_post( $pid ); if ( isset( $_POST['metakeyselect'] ) || isset( $_POST['metakeyinput'] ) ) { if ( ! current_user_can( 'edit_post', $pid ) ) { wp_die( -1 ); } if ( isset( $_POST['metakeyselect'] ) && '#NONE#' === $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) { wp_die( 1 ); } if ( 'auto-draft' === $post->post_status ) { $post_data = array(); $post_data['action'] = 'draft'; $post_data['post_ID'] = $pid; $post_data['post_type'] = $post->post_type; $post_data['post_status'] = 'draft'; $now = time(); $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) ); $pid = edit_post( $post_data ); if ( $pid ) { if ( is_wp_error( $pid ) ) { $x = new WP_Ajax_Response( array( 'what' => 'meta', 'data' => $pid, ) ); $x->send(); } $mid = add_meta( $pid ); if ( ! $mid ) { wp_die( __( 'Please provide a custom field value.' ) ); } } else { wp_die( 0 ); } } else { $mid = add_meta( $pid ); if ( ! $mid ) { wp_die( __( 'Please provide a custom field value.' ) ); } } $meta = get_metadata_by_mid( 'post', $mid ); $pid = (int) $meta->post_id; $meta = get_object_vars( $meta ); $x = new WP_Ajax_Response( array( 'what' => 'meta', 'id' => $mid, 'data' => _list_meta_row( $meta, $c ), 'position' => 1, 'supplemental' => array( 'postid' => $pid ), ) ); } else { $mid = (int) key( $_POST['meta'] ); $key = wp_unslash( $_POST['meta'][ $mid ]['key'] ); $value = wp_unslash( $_POST['meta'][ $mid ]['value'] ); if ( '' === trim( $key ) ) { wp_die( __( 'Please provide a custom field name.' ) ); } $meta = get_metadata_by_mid( 'post', $mid ); if ( ! $meta ) { wp_die( 0 ); } if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) || ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) || ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) { wp_die( -1 ); } if ( $meta->meta_value != $value || $meta->meta_key != $key ) { $u = update_metadata_by_mid( 'post', $mid, $value, $key ); if ( ! $u ) { wp_die( 0 ); } } $x = new WP_Ajax_Response( array( 'what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row( array( 'meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid, ), $c ), 'position' => 0, 'supplemental' => array( 'postid' => $meta->post_id ), ) ); } $x->send(); } function wp_ajax_add_user( $action ) { if ( empty( $action ) ) { $action = 'add-user'; } check_ajax_referer( $action ); if ( ! current_user_can( 'create_users' ) ) { wp_die( -1 ); } $user_id = edit_user(); if ( ! $user_id ) { wp_die( 0 ); } elseif ( is_wp_error( $user_id ) ) { $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, ) ); $x->send(); } $user_object = get_userdata( $user_id ); $wp_list_table = _get_list_table( 'WP_Users_List_Table' ); $role = current( $user_object->roles ); $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, 'data' => $wp_list_table->single_row( $user_object, '', $role ), 'supplemental' => array( 'show-link' => sprintf( __( 'User %s added' ), '' . $user_object->user_login . '' ), 'role' => $role, ), ) ); $x->send(); } function wp_ajax_closed_postboxes() { check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed'] ) : array(); $closed = array_filter( $closed ); $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); $hidden = array_filter( $hidden ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } if ( is_array( $closed ) ) { update_user_meta( $user->ID, "closedpostboxes_$page", $closed ); } if ( is_array( $hidden ) ) { $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); update_user_meta( $user->ID, "metaboxhidden_$page", $hidden ); } wp_die( 1 ); } function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); update_user_meta( $user->ID, "manage{$page}columnshidden", $hidden ); wp_die( 1 ); } function wp_ajax_update_welcome_panel() { check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 ); wp_die( 1 ); } function wp_ajax_menu_get_metabox() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; if ( isset( $_POST['item-type'] ) && 'post_type' === $_POST['item-type'] ) { $type = 'posttype'; $callback = 'wp_nav_menu_item_post_type_meta_box'; $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' === $_POST['item-type'] ) { $type = 'taxonomy'; $callback = 'wp_nav_menu_item_taxonomy_meta_box'; $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); } if ( ! empty( $_POST['item-object'] ) && isset( $items[ $_POST['item-object'] ] ) ) { $menus_meta_box_object = $items[ $_POST['item-object'] ]; $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object ); $box_args = array( 'id' => 'add-' . $item->name, 'title' => $item->labels->name, 'callback' => $callback, 'args' => $item, ); ob_start(); $callback( null, $box_args ); $markup = ob_get_clean(); echo wp_json_encode( array( 'replace-id' => $type . '-' . $item->name, 'markup' => $markup, ) ); } wp_die(); } function wp_ajax_wp_link_ajax() { check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' ); $args = array(); if ( isset( $_POST['search'] ) ) { $args['s'] = wp_unslash( $_POST['search'] ); } if ( isset( $_POST['term'] ) ) { $args['s'] = wp_unslash( $_POST['term'] ); } $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; if ( ! class_exists( '_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } $results = _WP_Editors::wp_link_query( $args ); if ( ! isset( $results ) ) { wp_die( 0 ); } echo wp_json_encode( $results ); echo "\n"; wp_die(); } function wp_ajax_menu_locations_save() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); if ( ! isset( $_POST['menu-locations'] ) ) { wp_die( 0 ); } set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) ); wp_die( 1 ); } function wp_ajax_meta_box_order() { check_ajax_referer( 'meta-box-order' ); $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; if ( 'auto' !== $page_columns ) { $page_columns = (int) $page_columns; } $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); } $user = wp_get_current_user(); if ( ! $user ) { wp_die( -1 ); } if ( $order ) { update_user_meta( $user->ID, "meta-box-order_$page", $order ); } if ( $page_columns ) { update_user_meta( $user->ID, "screen_layout_$page", $page_columns ); } wp_send_json_success(); } function wp_ajax_menu_quick_search() { if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; _wp_ajax_menu_quick_search( $_POST ); wp_die(); } function wp_ajax_get_permalink() { check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; wp_die( get_preview_post_link( $post_id ) ); } function wp_ajax_sample_permalink() { check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); } function wp_ajax_inline_save() { global $mode; check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); if ( ! isset( $_POST['post_ID'] ) || ! (int) $_POST['post_ID'] ) { wp_die(); } $post_ID = (int) $_POST['post_ID']; if ( 'page' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } } else { if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } } $last = wp_check_post_lock( $post_ID ); if ( $last ) { $last_user = get_userdata( $last ); $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); $msg_template = __( 'Saving is disabled: %s is currently editing this post.' ); if ( 'page' === $_POST['post_type'] ) { $msg_template = __( 'Saving is disabled: %s is currently editing this page.' ); } printf( $msg_template, esc_html( $last_user_name ) ); wp_die(); } $data = &$_POST; $post = get_post( $post_ID, ARRAY_A ); $post = wp_slash( $post ); $data['content'] = $post['post_content']; $data['excerpt'] = $post['post_excerpt']; $data['user_ID'] = get_current_user_id(); if ( isset( $data['post_parent'] ) ) { $data['parent_id'] = $data['post_parent']; } if ( isset( $data['keep_private'] ) && 'private' === $data['keep_private'] ) { $data['visibility'] = 'private'; $data['post_status'] = 'private'; } else { $data['post_status'] = $data['_status']; } if ( empty( $data['comment_status'] ) ) { $data['comment_status'] = 'closed'; } if ( empty( $data['ping_status'] ) ) { $data['ping_status'] = 'closed'; } if ( ! empty( $data['tax_input'] ) ) { foreach ( $data['tax_input'] as $taxonomy => $terms ) { $tax_object = get_taxonomy( $taxonomy ); if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) { unset( $data['tax_input'][ $taxonomy ] ); } } } if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ), true ) ) { $post['post_status'] = 'publish'; $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] ); } edit_post(); $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) ); $mode = 'excerpt' === $_POST['post_view'] ? 'excerpt' : 'list'; $level = 0; if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) { $request_post = array( get_post( $_POST['post_ID'] ) ); $parent = $request_post[0]->post_parent; while ( $parent > 0 ) { $parent_post = get_post( $parent ); $parent = $parent_post->post_parent; $level++; } } $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level ); wp_die(); } function wp_ajax_inline_save_tax() { check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); $taxonomy = sanitize_key( $_POST['taxonomy'] ); $taxonomy_object = get_taxonomy( $taxonomy ); if ( ! $taxonomy_object ) { wp_die( 0 ); } if ( ! isset( $_POST['tax_ID'] ) || ! (int) $_POST['tax_ID'] ) { wp_die( -1 ); } $id = (int) $_POST['tax_ID']; if ( ! current_user_can( 'edit_term', $id ) ) { wp_die( -1 ); } $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); $tag = get_term( $id, $taxonomy ); $_POST['description'] = $tag->description; $updated = wp_update_term( $id, $taxonomy, $_POST ); if ( $updated && ! is_wp_error( $updated ) ) { $tag = get_term( $updated['term_id'], $taxonomy ); if ( ! $tag || is_wp_error( $tag ) ) { if ( is_wp_error( $tag ) && $tag->get_error_message() ) { wp_die( $tag->get_error_message() ); } wp_die( __( 'Item not updated.' ) ); } } else { if ( is_wp_error( $updated ) && $updated->get_error_message() ) { wp_die( $updated->get_error_message() ); } wp_die( __( 'Item not updated.' ) ); } $level = 0; $parent = $tag->parent; while ( $parent > 0 ) { $parent_tag = get_term( $parent, $taxonomy ); $parent = $parent_tag->parent; $level++; } $wp_list_table->single_row( $tag, $level ); wp_die(); } function wp_ajax_find_posts() { check_ajax_referer( 'find-posts' ); $post_types = get_post_types( array( 'public' => true ), 'objects' ); unset( $post_types['attachment'] ); $args = array( 'post_type' => array_keys( $post_types ), 'post_status' => 'any', 'posts_per_page' => 50, ); $search = wp_unslash( $_POST['ps'] ); if ( '' !== $search ) { $args['s'] = $search; } $posts = get_posts( $args ); if ( ! $posts ) { wp_send_json_error( __( 'No items found.' ) ); } $html = ''; $alt = ''; foreach ( $posts as $post ) { $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); $alt = ( 'alternate' === $alt ) ? '' : 'alternate'; switch ( $post->post_status ) { case 'publish': case 'private': $stat = __( 'Published' ); break; case 'future': $stat = __( 'Scheduled' ); break; case 'pending': $stat = __( 'Pending Review' ); break; case 'draft': $stat = __( 'Draft' ); break; } if ( '0000-00-00 00:00:00' === $post->post_date ) { $time = ''; } else { $time = mysql2date( __( 'Y/m/d' ), $post->post_date ); } $html .= ''; $html .= '' . "\n\n"; } $html .= '

' . __( 'Title' ) . '' . __( 'Type' ) . '' . __( 'Date' ) . '' . __( 'Status' ) . '
' . esc_html( $post_types[ $post->post_type ]->labels->singular_name ) . '' . esc_html( $time ) . '' . esc_html( $stat ) . '
'; wp_send_json_success( $html ); } function wp_ajax_widgets_order() { check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } unset( $_POST['savewidgets'], $_POST['action'] ); if ( is_array( $_POST['sidebars'] ) ) { $sidebars = array(); foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) { $sb = array(); if ( ! empty( $val ) ) { $val = explode( ',', $val ); foreach ( $val as $k => $v ) { if ( strpos( $v, 'widget-' ) === false ) { continue; } $sb[ $k ] = substr( $v, strpos( $v, '_' ) + 1 ); } } $sidebars[ $key ] = $sb; } wp_set_sidebars_widgets( $sidebars ); wp_die( 1 ); } wp_die( -1 ); } function wp_ajax_save_widget() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) || ! isset( $_POST['id_base'] ) ) { wp_die( -1 ); } unset( $_POST['savewidgets'], $_POST['action'] ); do_action( 'load-widgets.php' ); do_action( 'widgets.php' ); do_action( 'sidebar_admin_setup' ); $id_base = wp_unslash( $_POST['id_base'] ); $widget_id = wp_unslash( $_POST['widget-id'] ); $sidebar_id = $_POST['sidebar']; $multi_number = ! empty( $_POST['multi_number'] ) ? (int) $_POST['multi_number'] : 0; $settings = isset( $_POST[ 'widget-' . $id_base ] ) && is_array( $_POST[ 'widget-' . $id_base ] ) ? $_POST[ 'widget-' . $id_base ] : false; $error = '

' . __( 'An error has occurred. Please reload the page and try again.' ) . '

'; $sidebars = wp_get_sidebars_widgets(); $sidebar = isset( $sidebars[ $sidebar_id ] ) ? $sidebars[ $sidebar_id ] : array(); if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { if ( ! isset( $wp_registered_widgets[ $widget_id ] ) ) { wp_die( $error ); } $sidebar = array_diff( $sidebar, array( $widget_id ) ); $_POST = array( 'sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1', ); do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); } elseif ( $settings && preg_match( '/__i__|%i%/', key( $settings ) ) ) { if ( ! $multi_number ) { wp_die( $error ); } $_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) ); $widget_id = $id_base . '-' . $multi_number; $sidebar[] = $widget_id; } $_POST['widget-id'] = $sidebar; foreach ( (array) $wp_registered_widget_updates as $name => $control ) { if ( $name == $id_base ) { if ( ! is_callable( $control['callback'] ) ) { continue; } ob_start(); call_user_func_array( $control['callback'], $control['params'] ); ob_end_clean(); break; } } if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { $sidebars[ $sidebar_id ] = $sidebar; wp_set_sidebars_widgets( $sidebars ); echo "deleted:$widget_id"; wp_die(); } if ( ! empty( $_POST['add_new'] ) ) { wp_die(); } $form = $wp_registered_widget_controls[ $widget_id ]; if ( $form ) { call_user_func_array( $form['callback'], $form['params'] ); } wp_die(); } function wp_ajax_update_widget() { global $wp_customize; $wp_customize->widgets->wp_ajax_update_widget(); } function wp_ajax_delete_inactive_widgets() { check_ajax_referer( 'remove-inactive-widgets', 'removeinactivewidgets' ); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( -1 ); } unset( $_POST['removeinactivewidgets'], $_POST['action'] ); do_action( 'load-widgets.php' ); do_action( 'widgets.php' ); do_action( 'sidebar_admin_setup' ); $sidebars_widgets = wp_get_sidebars_widgets(); foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) { $pieces = explode( '-', $widget_id ); $multi_number = array_pop( $pieces ); $id_base = implode( '-', $pieces ); $widget = get_option( 'widget_' . $id_base ); unset( $widget[ $multi_number ] ); update_option( 'widget_' . $id_base, $widget ); unset( $sidebars_widgets['wp_inactive_widgets'][ $key ] ); } wp_set_sidebars_widgets( $sidebars_widgets ); wp_die(); } function wp_ajax_media_create_image_subsizes() { check_ajax_referer( 'media-form' ); if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to upload files.' ) ) ); } if ( empty( $_POST['attachment_id'] ) ) { wp_send_json_error( array( 'message' => __( 'Upload failed. Please reload and try again.' ) ) ); } $attachment_id = (int) $_POST['attachment_id']; if ( ! empty( $_POST['_wp_upload_failed_cleanup'] ) ) { if ( wp_attachment_is_image( $attachment_id ) && current_user_can( 'delete_post', $attachment_id ) ) { $attachment = get_post( $attachment_id ); if ( $attachment && ( time() - strtotime( $attachment->post_date_gmt ) < 600 ) ) { wp_delete_attachment( $attachment_id, true ); wp_send_json_success(); } } } if ( ! headers_sent() ) { header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); } wp_update_image_subsizes( $attachment_id ); if ( ! empty( $_POST['_legacy_support'] ) ) { $response = array( 'id' => $attachment_id ); } else { $response = wp_prepare_attachment_for_js( $attachment_id ); if ( ! $response ) { wp_send_json_error( array( 'message' => __( 'Upload failed.' ) ) ); } } wp_send_json_success( $response ); } function wp_ajax_upload_attachment() { check_ajax_referer( 'media-form' ); if ( ! current_user_can( 'upload_files' ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'Sorry, you are not allowed to upload files.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } if ( isset( $_REQUEST['post_id'] ) ) { $post_id = $_REQUEST['post_id']; if ( ! current_user_can( 'edit_post', $post_id ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'Sorry, you are not allowed to attach files to this post.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } } else { $post_id = null; } $post_data = ! empty( $_REQUEST['post_data'] ) ? _wp_get_allowed_postdata( _wp_translate_postdata( false, (array) $_REQUEST['post_data'] ) ) : array(); if ( is_wp_error( $post_data ) ) { wp_die( $post_data->get_error_message() ); } if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ), true ) ) { $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] ); if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } } $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data ); if ( is_wp_error( $attachment_id ) ) { echo wp_json_encode( array( 'success' => false, 'data' => array( 'message' => $attachment_id->get_error_message(), 'filename' => esc_html( $_FILES['async-upload']['name'] ), ), ) ); wp_die(); } if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { if ( 'custom-background' === $post_data['context'] ) { update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); } if ( 'custom-header' === $post_data['context'] ) { update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); } } $attachment = wp_prepare_attachment_for_js( $attachment_id ); if ( ! $attachment ) { wp_die(); } echo wp_json_encode( array( 'success' => true, 'data' => $attachment, ) ); wp_die(); } function wp_ajax_image_editor() { $attachment_id = (int) $_POST['postid']; if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { wp_die( -1 ); } check_ajax_referer( "image_editor-$attachment_id" ); include_once ABSPATH . 'wp-admin/includes/image-edit.php'; $msg = false; switch ( $_POST['do'] ) { case 'save': $msg = wp_save_image( $attachment_id ); if ( ! empty( $msg->error ) ) { wp_send_json_error( $msg ); } wp_send_json_success( $msg ); break; case 'scale': $msg = wp_save_image( $attachment_id ); break; case 'restore': $msg = wp_restore_image( $attachment_id ); break; } ob_start(); wp_image_editor( $attachment_id, $msg ); $html = ob_get_clean(); if ( ! empty( $msg->error ) ) { wp_send_json_error( array( 'message' => $msg, 'html' => $html, ) ); } wp_send_json_success( array( 'message' => $msg, 'html' => $html, ) ); } function wp_ajax_set_post_thumbnail() { $json = ! empty( $_REQUEST['json'] ); $post_ID = (int) $_POST['post_id']; if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( -1 ); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( $json ) { check_ajax_referer( "update-post_$post_ID" ); } else { check_ajax_referer( "set_post_thumbnail-$post_ID" ); } if ( '-1' == $thumbnail_id ) { if ( delete_post_thumbnail( $post_ID ) ) { $return = _wp_post_thumbnail_html( null, $post_ID ); $json ? wp_send_json_success( $return ) : wp_die( $return ); } else { wp_die( 0 ); } } if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) { $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); $json ? wp_send_json_success( $return ) : wp_die( $return ); } wp_die( 0 ); } function wp_ajax_get_post_thumbnail_html() { $post_ID = (int) $_POST['post_id']; check_ajax_referer( "update-post_$post_ID" ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { wp_die( -1 ); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( -1 === $thumbnail_id ) { $thumbnail_id = null; } $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); wp_send_json_success( $return ); } function wp_ajax_set_attachment_thumbnail() { if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) { wp_send_json_error(); } $thumbnail_id = (int) $_POST['thumbnail_id']; if ( empty( $thumbnail_id ) ) { wp_send_json_error(); } $post_ids = array(); foreach ( $_POST['urls'] as $url ) { $post_id = attachment_url_to_postid( $url ); if ( ! empty( $post_id ) ) { $post_ids[] = $post_id; } } if ( empty( $post_ids ) ) { wp_send_json_error(); } $success = 0; foreach ( $post_ids as $post_id ) { if ( ! current_user_can( 'edit_post', $post_id ) ) { continue; } if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) { $success++; } } if ( 0 === $success ) { wp_send_json_error(); } else { wp_send_json_success(); } wp_send_json_error(); } function wp_ajax_date_format() { wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) ); } function wp_ajax_time_format() { wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) ); } function wp_ajax_wp_fullscreen_save_post() { $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; $post = null; if ( $post_id ) { $post = get_post( $post_id ); } check_ajax_referer( 'update-post_' . $post_id, '_wpnonce' ); $post_id = edit_post(); if ( is_wp_error( $post_id ) ) { wp_send_json_error(); } if ( $post ) { $last_date = mysql2date( __( 'F j, Y' ), $post->post_modified ); $last_time = mysql2date( __( 'g:i a' ), $post->post_modified ); } else { $last_date = date_i18n( __( 'F j, Y' ) ); $last_time = date_i18n( __( 'g:i a' ) ); } $last_id = get_post_meta( $post_id, '_edit_last', true ); if ( $last_id ) { $last_user = get_userdata( $last_id ); $last_edited = sprintf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), $last_date, $last_time ); } else { $last_edited = sprintf( __( 'Last edited on %1$s at %2$s' ), $last_date, $last_time ); } wp_send_json_success( array( 'last_edited' => $last_edited ) ); } function wp_ajax_wp_remove_post_lock() { if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) { wp_die( 0 ); } $post_id = (int) $_POST['post_ID']; $post = get_post( $post_id ); if ( ! $post ) { wp_die( 0 ); } check_ajax_referer( 'update-post_' . $post_id ); if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); if ( get_current_user_id() != $active_lock[1] ) { wp_die( 0 ); } $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); wp_die( 1 ); } function wp_ajax_dismiss_wp_pointer() { $pointer = $_POST['pointer']; if ( sanitize_key( $pointer ) != $pointer ) { wp_die( 0 ); } $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); if ( in_array( $pointer, $dismissed, true ) ) { wp_die( 0 ); } $dismissed[] = $pointer; $dismissed = implode( ',', $dismissed ); update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); wp_die( 1 ); } function wp_ajax_get_attachment() { if ( ! isset( $_REQUEST['id'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } $post = get_post( $id ); if ( ! $post ) { wp_send_json_error(); } if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error(); } $attachment = wp_prepare_attachment_for_js( $id ); if ( ! $attachment ) { wp_send_json_error(); } wp_send_json_success( $attachment ); } function wp_ajax_query_attachments() { if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error(); } $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); $keys = array( 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 'post_parent', 'author', 'post__in', 'post__not_in', 'year', 'monthnum', ); foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { $keys[] = $t->query_var; } } $query = array_intersect_key( $query, array_flip( $keys ) ); $query['post_type'] = 'attachment'; if ( MEDIA_TRASH && ! empty( $_REQUEST['query']['post_status'] ) && 'trash' === $_REQUEST['query']['post_status'] ) { $query['post_status'] = 'trash'; } else { $query['post_status'] = 'inherit'; } if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) { $query['post_status'] .= ',private'; } if ( isset( $query['s'] ) ) { add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); } $query = apply_filters( 'ajax_query_attachments_args', $query ); $attachments_query = new WP_Query( $query ); update_post_parent_caches( $attachments_query->posts ); $posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts ); $posts = array_filter( $posts ); $total_posts = $attachments_query->found_posts; if ( $total_posts < 1 ) { unset( $query['paged'] ); $count_query = new WP_Query(); $count_query->query( $query ); $total_posts = $count_query->found_posts; } $posts_per_page = (int) $attachments_query->get( 'posts_per_page' ); $max_pages = $posts_per_page ? ceil( $total_posts / $posts_per_page ) : 0; header( 'X-WP-Total: ' . (int) $total_posts ); header( 'X-WP-TotalPages: ' . (int) $max_pages ); wp_send_json_success( $posts ); } function wp_ajax_save_attachment() { if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } check_ajax_referer( 'update-post_' . $id, 'nonce' ); if ( ! current_user_can( 'edit_post', $id ) ) { wp_send_json_error(); } $changes = $_REQUEST['changes']; $post = get_post( $id, ARRAY_A ); if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } if ( isset( $changes['parent'] ) ) { $post['post_parent'] = $changes['parent']; } if ( isset( $changes['title'] ) ) { $post['post_title'] = $changes['title']; } if ( isset( $changes['caption'] ) ) { $post['post_excerpt'] = $changes['caption']; } if ( isset( $changes['description'] ) ) { $post['post_content'] = $changes['description']; } if ( MEDIA_TRASH && isset( $changes['status'] ) ) { $post['post_status'] = $changes['status']; } if ( isset( $changes['alt'] ) ) { $alt = wp_unslash( $changes['alt'] ); if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) { $alt = wp_strip_all_tags( $alt, true ); update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) ); } } if ( wp_attachment_is( 'audio', $post['ID'] ) ) { $changed = false; $id3data = wp_get_attachment_metadata( $post['ID'] ); if ( ! is_array( $id3data ) ) { $changed = true; $id3data = array(); } foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) { if ( isset( $changes[ $key ] ) ) { $changed = true; $id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) ); } } if ( $changed ) { wp_update_attachment_metadata( $id, $id3data ); } } if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) { wp_delete_post( $id ); } else { wp_update_post( $post ); do_action( 'wp_ajax_save_attachment', $post, $changes ); } wp_send_json_success(); } function wp_ajax_save_attachment_compat() { if ( ! isset( $_REQUEST['id'] ) ) { wp_send_json_error(); } $id = absint( $_REQUEST['id'] ); if ( ! $id ) { wp_send_json_error(); } if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) { wp_send_json_error(); } $attachment_data = $_REQUEST['attachments'][ $id ]; check_ajax_referer( 'update-post_' . $id, 'nonce' ); if ( ! current_user_can( 'edit_post', $id ) ) { wp_send_json_error(); } $post = get_post( $id, ARRAY_A ); if ( 'attachment' !== $post['post_type'] ) { wp_send_json_error(); } $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); if ( isset( $post['errors'] ) ) { $errors = $post['errors']; unset( $post['errors'] ); } wp_update_post( $post ); foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { if ( isset( $attachment_data[ $taxonomy ] ) ) { wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); } } $attachment = wp_prepare_attachment_for_js( $id ); if ( ! $attachment ) { wp_send_json_error(); } wp_send_json_success( $attachment ); } function wp_ajax_save_attachment_order() { if ( ! isset( $_REQUEST['post_id'] ) ) { wp_send_json_error(); } $post_id = absint( $_REQUEST['post_id'] ); if ( ! $post_id ) { wp_send_json_error(); } if ( empty( $_REQUEST['attachments'] ) ) { wp_send_json_error(); } check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); $attachments = $_REQUEST['attachments']; if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_send_json_error(); } foreach ( $attachments as $attachment_id => $menu_order ) { if ( ! current_user_can( 'edit_post', $attachment_id ) ) { continue; } $attachment = get_post( $attachment_id ); if ( ! $attachment ) { continue; } if ( 'attachment' !== $attachment->post_type ) { continue; } wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order, ) ); } wp_send_json_success(); } function wp_ajax_send_attachment_to_editor() { check_ajax_referer( 'media-send-to-editor', 'nonce' ); $attachment = wp_unslash( $_POST['attachment'] ); $id = (int) $attachment['id']; $post = get_post( $id ); if ( ! $post ) { wp_send_json_error(); } if ( 'attachment' !== $post->post_type ) { wp_send_json_error(); } if ( current_user_can( 'edit_post', $id ) ) { $insert_into_post_id = (int) $_POST['post_id']; if ( 0 == $post->post_parent && $insert_into_post_id ) { wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id, ) ); } } $url = empty( $attachment['url'] ) ? '' : $attachment['url']; $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url ); remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; if ( '' === trim( $caption ) ) { $caption = ''; } $title = ''; $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { $html = stripslashes_deep( $_POST['html'] ); } else { $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; if ( ! empty( $url ) ) { $html = '' . $html . ''; } } $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); wp_send_json_success( $html ); } function wp_ajax_send_link_to_editor() { global $post, $wp_embed; check_ajax_referer( 'media-send-to-editor', 'nonce' ); $src = wp_unslash( $_POST['src'] ); if ( ! $src ) { wp_send_json_error(); } if ( ! strpos( $src, '://' ) ) { $src = 'http://' . $src; } $src = sanitize_url( $src ); if ( ! $src ) { wp_send_json_error(); } $link_text = trim( wp_unslash( $_POST['link_text'] ) ); if ( ! $link_text ) { $link_text = wp_basename( $src ); } $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); $check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' ); $fallback = $wp_embed->maybe_make_link( $src ); if ( $check_embed !== $fallback ) { $html = '[embed]' . $src . '[/embed]'; } elseif ( $link_text ) { $html = '' . $link_text . ''; } else { $html = ''; } $type = 'file'; $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); if ( $ext ) { $ext_type = wp_ext2type( $ext ); if ( 'audio' === $ext_type || 'video' === $ext_type ) { $type = $ext_type; } } $html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text ); wp_send_json_success( $html ); } function wp_ajax_heartbeat() { if ( empty( $_POST['_nonce'] ) ) { wp_send_json_error(); } $response = array(); $data = array(); $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); if ( ! empty( $_POST['screen_id'] ) ) { $screen_id = sanitize_key( $_POST['screen_id'] ); } else { $screen_id = 'front'; } if ( ! empty( $_POST['data'] ) ) { $data = wp_unslash( (array) $_POST['data'] ); } if ( 1 !== $nonce_state ) { $response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id ); if ( false === $nonce_state ) { $response['nonces_expired'] = true; wp_send_json( $response ); } } if ( ! empty( $data ) ) { $response = apply_filters( 'heartbeat_received', $response, $data, $screen_id ); } $response = apply_filters( 'heartbeat_send', $response, $screen_id ); do_action( 'heartbeat_tick', $response, $screen_id ); $response['server_time'] = time(); wp_send_json( $response ); } function wp_ajax_get_revision_diffs() { require ABSPATH . 'wp-admin/includes/revision.php'; $post = get_post( (int) $_REQUEST['post_id'] ); if ( ! $post ) { wp_send_json_error(); } if ( ! current_user_can( 'edit_post', $post->ID ) ) { wp_send_json_error(); } $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ); if ( ! $revisions ) { wp_send_json_error(); } $return = array(); ; foreach ( $_REQUEST['compare'] as $compare_key ) { list( $compare_from, $compare_to ) = explode( ':', $compare_key ); $return[] = array( 'id' => $compare_key, 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ), ); } wp_send_json_success( $return ); } function wp_ajax_save_user_color_scheme() { global $_wp_admin_css_colors; check_ajax_referer( 'save-color-scheme', 'nonce' ); $color_scheme = sanitize_key( $_POST['color_scheme'] ); if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { wp_send_json_error(); } $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); wp_send_json_success( array( 'previousScheme' => 'admin-color-' . $previous_color_scheme, 'currentScheme' => 'admin-color-' . $color_scheme, ) ); } function wp_ajax_query_themes() { global $themes_allowedtags, $theme_field_defaults; if ( ! current_user_can( 'install_themes' ) ) { wp_send_json_error(); } $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array( 'per_page' => 20, 'fields' => array_merge( (array) $theme_field_defaults, array( 'reviews_url' => true, ) ), ) ); if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { $user = get_user_option( 'wporg_favorites' ); if ( $user ) { $args['user'] = $user; } } $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); $api = themes_api( 'query_themes', $args ); if ( is_wp_error( $api ) ) { wp_send_json_error(); } $update_php = network_admin_url( 'update.php?action=install-theme' ); $installed_themes = search_theme_directories(); if ( false === $installed_themes ) { $installed_themes = array(); } foreach ( $installed_themes as $theme_slug => $theme_data ) { if ( str_contains( $theme_slug, '/' ) ) { unset( $installed_themes[ $theme_slug ] ); } } foreach ( $api->themes as &$theme ) { $theme->install_url = add_query_arg( array( 'theme' => $theme->slug, '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ), ), $update_php ); if ( current_user_can( 'switch_themes' ) ) { if ( is_multisite() ) { $theme->activate_url = add_query_arg( array( 'action' => 'enable', '_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ), 'theme' => $theme->slug, ), network_admin_url( 'themes.php' ) ); } else { $theme->activate_url = add_query_arg( array( 'action' => 'activate', '_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ), 'stylesheet' => $theme->slug, ), admin_url( 'themes.php' ) ); } } $is_theme_installed = array_key_exists( $theme->slug, $installed_themes ); $theme->block_theme = $is_theme_installed && wp_get_theme( $theme->slug )->is_block_theme(); if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $customize_url = $theme->block_theme ? admin_url( 'site-editor.php' ) : wp_customize_url( $theme->slug ); $theme->customize_url = add_query_arg( array( 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), ), $customize_url ); } $theme->name = wp_kses( $theme->name, $themes_allowedtags ); $theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags ); $theme->version = wp_kses( $theme->version, $themes_allowedtags ); $theme->description = wp_kses( $theme->description, $themes_allowedtags ); $theme->stars = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false, ) ); $theme->num_ratings = number_format_i18n( $theme->num_ratings ); $theme->preview_url = set_url_scheme( $theme->preview_url ); $theme->compatible_wp = is_wp_version_compatible( $theme->requires ); $theme->compatible_php = is_php_version_compatible( $theme->requires_php ); } wp_send_json_success( $api ); } function wp_ajax_parse_embed() { global $post, $wp_embed, $content_width; if ( empty( $_POST['shortcode'] ) ) { wp_send_json_error(); } $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { wp_send_json_error(); } setup_postdata( $post ); } elseif ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $shortcode = wp_unslash( $_POST['shortcode'] ); preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); $atts = shortcode_parse_atts( $matches[3] ); if ( ! empty( $matches[5] ) ) { $url = $matches[5]; } elseif ( ! empty( $atts['src'] ) ) { $url = $atts['src']; } else { $url = ''; } $parsed = false; $wp_embed->return_false_on_fail = true; if ( 0 === $post_id ) { $wp_embed->usecache = false; } if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); $parsed = $wp_embed->run_shortcode( $ssl_shortcode ); if ( ! $parsed ) { $no_ssl_support = true; } } if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) { if ( ! isset( $content_width ) ) { $content_width = (int) $_POST['maxwidth']; } else { $content_width = min( $content_width, (int) $_POST['maxwidth'] ); } } if ( $url && ! $parsed ) { $parsed = $wp_embed->run_shortcode( $shortcode ); } if ( ! $parsed ) { wp_send_json_error( array( 'type' => 'not-embeddable', 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '' ), ) ); } if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) { $styles = ''; $mce_styles = wpview_media_sandbox_styles(); foreach ( $mce_styles as $style ) { $styles .= sprintf( '', $style ); } $html = do_shortcode( $parsed ); global $wp_scripts; if ( ! empty( $wp_scripts ) ) { $wp_scripts->done = array(); } ob_start(); wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); $scripts = ob_get_clean(); $parsed = $styles . $html . $scripts; } if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || preg_match( '%]*href="http://%', $parsed ) ) ) ) { wp_send_json_error( array( 'type' => 'not-ssl', 'message' => __( 'This preview is unavailable in the editor.' ), ) ); } $return = array( 'body' => $parsed, 'attr' => $wp_embed->last_attr, ); if ( strpos( $parsed, 'class="wp-embedded-content' ) ) { if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { $script_src = includes_url( 'js/wp-embed.js' ); } else { $script_src = includes_url( 'js/wp-embed.min.js' ); } $return['head'] = ''; $return['sandbox'] = true; } wp_send_json_success( $return ); } function wp_ajax_parse_media_shortcode() { global $post, $wp_scripts; if ( empty( $_POST['shortcode'] ) ) { wp_send_json_error(); } $shortcode = wp_unslash( $_POST['shortcode'] ); if ( ! empty( $_POST['post_ID'] ) ) { $post = get_post( (int) $_POST['post_ID'] ); } if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { if ( 'embed' === $shortcode ) { wp_send_json_error(); } } else { setup_postdata( $post ); } $parsed = do_shortcode( $shortcode ); if ( empty( $parsed ) ) { wp_send_json_error( array( 'type' => 'no-items', 'message' => __( 'No items found.' ), ) ); } $head = ''; $styles = wpview_media_sandbox_styles(); foreach ( $styles as $style ) { $head .= ''; } if ( ! empty( $wp_scripts ) ) { $wp_scripts->done = array(); } ob_start(); echo $parsed; if ( 'playlist' === $_REQUEST['type'] ) { wp_underscore_playlist_templates(); wp_print_scripts( 'wp-playlist' ); } else { wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); } wp_send_json_success( array( 'head' => $head, 'body' => ob_get_clean(), ) ); } function wp_ajax_destroy_sessions() { $user = get_userdata( (int) $_POST['user_id'] ); if ( $user ) { if ( ! current_user_can( 'edit_user', $user->ID ) ) { $user = false; } elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) { $user = false; } } if ( ! $user ) { wp_send_json_error( array( 'message' => __( 'Could not log out user sessions. Please try again.' ), ) ); } $sessions = WP_Session_Tokens::get_instance( $user->ID ); if ( get_current_user_id() === $user->ID ) { $sessions->destroy_others( wp_get_session_token() ); $message = __( 'You are now logged out everywhere else.' ); } else { $sessions->destroy_all(); $message = sprintf( __( '%s has been logged out.' ), $user->display_name ); } wp_send_json_success( array( 'message' => $message ) ); } function wp_ajax_crop_image() { $attachment_id = absint( $_POST['id'] ); check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' ); if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { wp_send_json_error(); } $context = str_replace( '_', '-', $_POST['context'] ); $data = array_map( 'absint', $_POST['cropDetails'] ); $cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] ); if ( ! $cropped || is_wp_error( $cropped ) ) { wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) ); } switch ( $context ) { case 'site-icon': require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php'; $wp_site_icon = new WP_Site_Icon(); if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { wp_delete_file( $cropped ); add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); break; } $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); $attachment = $wp_site_icon->create_attachment_object( $cropped, $attachment_id ); unset( $attachment['ID'] ); add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); $attachment_id = $wp_site_icon->insert_attachment( $attachment, $cropped ); remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); break; default: do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped ); $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); $parent_url = wp_get_attachment_url( $attachment_id ); $parent_basename = wp_basename( $parent_url ); $url = str_replace( $parent_basename, wp_basename( $cropped ), $parent_url ); $size = wp_getimagesize( $cropped ); $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; $original_attachment = get_post( $attachment_id ); $sanitized_post_title = sanitize_file_name( $original_attachment->post_title ); $use_original_title = ( ( '' !== trim( $original_attachment->post_title ) ) && ( $parent_basename !== $sanitized_post_title ) && ( pathinfo( $parent_basename, PATHINFO_FILENAME ) !== $sanitized_post_title ) ); $use_original_description = ( '' !== trim( $original_attachment->post_content ) ); $attachment = array( 'post_title' => $use_original_title ? $original_attachment->post_title : wp_basename( $cropped ), 'post_content' => $use_original_description ? $original_attachment->post_content : $url, 'post_mime_type' => $image_type, 'guid' => $url, 'context' => $context, ); if ( '' !== trim( $original_attachment->post_excerpt ) ) { $attachment['post_excerpt'] = $original_attachment->post_excerpt; } if ( '' !== trim( $original_attachment->_wp_attachment_image_alt ) ) { $attachment['meta_input'] = array( '_wp_attachment_image_alt' => wp_slash( $original_attachment->_wp_attachment_image_alt ), ); } $attachment_id = wp_insert_attachment( $attachment, $cropped ); $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); $metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata ); wp_update_attachment_metadata( $attachment_id, $metadata ); $attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context ); } wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) ); } function wp_ajax_generate_password() { wp_send_json_success( wp_generate_password( 24 ) ); } function wp_ajax_nopriv_generate_password() { wp_send_json_success( wp_generate_password( 24 ) ); } function wp_ajax_save_wporg_username() { if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { wp_send_json_error(); } check_ajax_referer( 'save_wporg_username_' . get_current_user_id() ); $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; if ( ! $username ) { wp_send_json_error(); } wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); } function wp_ajax_install_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $slug = sanitize_key( wp_unslash( $_POST['slug'] ) ); $status = array( 'install' => 'theme', 'slug' => $slug, ); if ( ! current_user_can( 'install_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to install themes on this site.' ); wp_send_json_error( $status ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/theme.php'; $api = themes_api( 'theme_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ), ) ); if ( is_wp_error( $api ) ) { $status['errorMessage'] = $api->get_error_message(); wp_send_json_error( $status ); } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Theme_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $result ) ) { $status['errorCode'] = $result->get_error_code(); $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_null( $result ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['themeName'] = wp_get_theme( $slug )->get( 'Name' ); if ( current_user_can( 'switch_themes' ) ) { if ( is_multisite() ) { $status['activateUrl'] = add_query_arg( array( 'action' => 'enable', '_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ), 'theme' => $slug, ), network_admin_url( 'themes.php' ) ); } else { $status['activateUrl'] = add_query_arg( array( 'action' => 'activate', '_wpnonce' => wp_create_nonce( 'switch-theme_' . $slug ), 'stylesheet' => $slug, ), admin_url( 'themes.php' ) ); } } $theme = wp_get_theme( $slug ); $status['blockTheme'] = $theme->is_block_theme(); if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $status['customizeUrl'] = add_query_arg( array( 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), ), wp_customize_url( $slug ) ); } wp_send_json_success( $status ); } function wp_ajax_update_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); $status = array( 'update' => 'theme', 'slug' => $stylesheet, 'oldVersion' => '', 'newVersion' => '', ); if ( ! current_user_can( 'update_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to update themes for this site.' ); wp_send_json_error( $status ); } $theme = wp_get_theme( $stylesheet ); if ( $theme->exists() ) { $status['oldVersion'] = $theme->get( 'Version' ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $current = get_site_transient( 'update_themes' ); if ( empty( $current ) ) { wp_update_themes(); } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Theme_Upgrader( $skin ); $result = $upgrader->bulk_upgrade( array( $stylesheet ) ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) { if ( true === $result[ $stylesheet ] ) { $status['errorMessage'] = $upgrader->strings['up_to_date']; wp_send_json_error( $status ); } $theme = wp_get_theme( $stylesheet ); if ( $theme->exists() ) { $status['newVersion'] = $theme->get( 'Version' ); } wp_send_json_success( $status ); } elseif ( false === $result ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['errorMessage'] = __( 'Theme update failed.' ); wp_send_json_error( $status ); } function wp_ajax_delete_theme() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __( 'No theme specified.' ), ) ); } $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); $status = array( 'delete' => 'theme', 'slug' => $stylesheet, ); if ( ! current_user_can( 'delete_themes' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to delete themes on this site.' ); wp_send_json_error( $status ); } if ( ! wp_get_theme( $stylesheet )->exists() ) { $status['errorMessage'] = __( 'The requested theme does not exist.' ); wp_send_json_error( $status ); } $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ); ob_start(); $credentials = request_filesystem_credentials( $url ); ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } include_once ABSPATH . 'wp-admin/includes/theme.php'; $result = delete_theme( $stylesheet ); if ( is_wp_error( $result ) ) { $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( false === $result ) { $status['errorMessage'] = __( 'Theme could not be deleted.' ); wp_send_json_error( $status ); } wp_send_json_success( $status ); } function wp_ajax_install_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $status = array( 'install' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), ); if ( ! current_user_can( 'install_plugins' ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.' ); wp_send_json_error( $status ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 'fields' => array( 'sections' => false, ), ) ); if ( is_wp_error( $api ) ) { $status['errorMessage'] = $api->get_error_message(); wp_send_json_error( $status ); } $status['pluginName'] = $api->name; $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $result ) ) { $status['errorCode'] = $result->get_error_code(); $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_null( $result ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $install_status = install_plugin_install_status( $api ); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; $plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' ); if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) { $status['activateUrl'] = add_query_arg( array( '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ), 'action' => 'activate', 'plugin' => $install_status['file'], ), $plugins_url ); } if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) { $status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] ); } wp_send_json_success( $status ); } function wp_ajax_update_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); $status = array( 'update' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 'oldVersion' => '', 'newVersion' => '', ); if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' ); wp_send_json_error( $status ); } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $status['plugin'] = $plugin; $status['pluginName'] = $plugin_data['Name']; if ( $plugin_data['Version'] ) { $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; wp_update_plugins(); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->bulk_upgrade( array( $plugin ) ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $status['debug'] = $skin->get_upgrade_messages(); } if ( is_wp_error( $skin->result ) ) { $status['errorCode'] = $skin->result->get_error_code(); $status['errorMessage'] = $skin->result->get_error_message(); wp_send_json_error( $status ); } elseif ( $skin->get_errors()->has_errors() ) { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) { if ( true === $result[ $plugin ] ) { $status['errorMessage'] = $upgrader->strings['up_to_date']; wp_send_json_error( $status ); } $plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] ); $plugin_data = reset( $plugin_data ); if ( $plugin_data['Version'] ) { $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); } wp_send_json_success( $status ); } elseif ( false === $result ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $status['errorMessage'] = __( 'Plugin update failed.' ); wp_send_json_error( $status ); } function wp_ajax_delete_plugin() { check_ajax_referer( 'updates' ); if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) { wp_send_json_error( array( 'slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __( 'No plugin specified.' ), ) ); } $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); $status = array( 'delete' => 'plugin', 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), ); if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' ); wp_send_json_error( $status ); } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $status['plugin'] = $plugin; $status['pluginName'] = $plugin_data['Name']; if ( is_plugin_active( $plugin ) ) { $status['errorMessage'] = __( 'You cannot delete a plugin while it is active on the main site.' ); wp_send_json_error( $status ); } $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' ); ob_start(); $credentials = request_filesystem_credentials( $url ); ob_end_clean(); if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { global $wp_filesystem; $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); } wp_send_json_error( $status ); } $result = delete_plugins( array( $plugin ) ); if ( is_wp_error( $result ) ) { $status['errorMessage'] = $result->get_error_message(); wp_send_json_error( $status ); } elseif ( false === $result ) { $status['errorMessage'] = __( 'Plugin could not be deleted.' ); wp_send_json_error( $status ); } wp_send_json_success( $status ); } function wp_ajax_search_plugins() { check_ajax_referer( 'updates' ); wp_plugin_update_rows(); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) { set_current_screen( $pagenow ); } $wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array( 'screen' => get_current_screen(), ) ); $status = array(); if ( ! $wp_list_table->ajax_user_can() ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); wp_send_json_error( $status ); } $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( '_ajax_nonce' => null, 'action' => null, ) ), network_admin_url( 'plugins.php', 'relative' ) ); $GLOBALS['s'] = wp_unslash( $_POST['s'] ); $wp_list_table->prepare_items(); ob_start(); $wp_list_table->display(); $status['count'] = count( $wp_list_table->items ); $status['items'] = ob_get_clean(); wp_send_json_success( $status ); } function wp_ajax_search_install_plugins() { check_ajax_referer( 'updates' ); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; if ( 'plugin-install-network' === $pagenow || 'plugin-install' === $pagenow ) { set_current_screen( $pagenow ); } $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array( 'screen' => get_current_screen(), ) ); $status = array(); if ( ! $wp_list_table->ajax_user_can() ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); wp_send_json_error( $status ); } $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( '_ajax_nonce' => null, 'action' => null, ) ), network_admin_url( 'plugin-install.php', 'relative' ) ); $wp_list_table->prepare_items(); ob_start(); $wp_list_table->display(); $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' ); $status['items'] = ob_get_clean(); wp_send_json_success( $status ); } function wp_ajax_edit_theme_plugin_file() { $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); if ( is_wp_error( $r ) ) { wp_send_json_error( array_merge( array( 'code' => $r->get_error_code(), 'message' => $r->get_error_message(), ), (array) $r->get_error_data() ) ); } else { wp_send_json_success( array( 'message' => __( 'File edited successfully.' ), ) ); } } function wp_ajax_wp_privacy_export_personal_data() { if ( empty( $_POST['id'] ) ) { wp_send_json_error( __( 'Missing request ID.' ) ); } $request_id = (int) $_POST['id']; if ( $request_id < 1 ) { wp_send_json_error( __( 'Invalid request ID.' ) ); } if ( ! current_user_can( 'export_others_personal_data' ) ) { wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) ); } check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); } $email_address = $request->email; if ( ! is_email( $email_address ) ) { wp_send_json_error( __( 'A valid email address must be given.' ) ); } if ( ! isset( $_POST['exporter'] ) ) { wp_send_json_error( __( 'Missing exporter index.' ) ); } $exporter_index = (int) $_POST['exporter']; if ( ! isset( $_POST['page'] ) ) { wp_send_json_error( __( 'Missing page index.' ) ); } $page = (int) $_POST['page']; $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( 'true' === $_POST['sendAsEmail'] ) : false; $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); if ( ! is_array( $exporters ) ) { wp_send_json_error( __( 'An exporter has improperly used the registration filter.' ) ); } if ( 0 < count( $exporters ) ) { if ( $exporter_index < 1 ) { wp_send_json_error( __( 'Exporter index cannot be negative.' ) ); } if ( $exporter_index > count( $exporters ) ) { wp_send_json_error( __( 'Exporter index is out of range.' ) ); } if ( $page < 1 ) { wp_send_json_error( __( 'Page index cannot be less than one.' ) ); } $exporter_keys = array_keys( $exporters ); $exporter_key = $exporter_keys[ $exporter_index - 1 ]; $exporter = $exporters[ $exporter_key ]; if ( ! is_array( $exporter ) ) { wp_send_json_error( sprintf( __( 'Expected an array describing the exporter at index %s.' ), $exporter_key ) ); } if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { wp_send_json_error( sprintf( __( 'Exporter array at index %s does not include a friendly name.' ), $exporter_key ) ); } $exporter_friendly_name = $exporter['exporter_friendly_name']; if ( ! array_key_exists( 'callback', $exporter ) ) { wp_send_json_error( sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! is_callable( $exporter['callback'] ) ) { wp_send_json_error( sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter_friendly_name ) ) ); } $callback = $exporter['callback']; $response = call_user_func( $callback, $email_address, $page ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } if ( ! is_array( $response ) ) { wp_send_json_error( sprintf( __( 'Expected response as an array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! array_key_exists( 'data', $response ) ) { wp_send_json_error( sprintf( __( 'Expected data in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! is_array( $response['data'] ) ) { wp_send_json_error( sprintf( __( 'Expected data array in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } if ( ! array_key_exists( 'done', $response ) ) { wp_send_json_error( sprintf( __( 'Expected done (boolean) in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) ); } } else { $exporter_key = ''; $response = array( 'data' => array(), 'done' => true, ); } $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } wp_send_json_success( $response ); } function wp_ajax_wp_privacy_erase_personal_data() { if ( empty( $_POST['id'] ) ) { wp_send_json_error( __( 'Missing request ID.' ) ); } $request_id = (int) $_POST['id']; if ( $request_id < 1 ) { wp_send_json_error( __( 'Invalid request ID.' ) ); } if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) { wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) ); } check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); $request = wp_get_user_request( $request_id ); if ( ! $request || 'remove_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); } $email_address = $request->email; if ( ! is_email( $email_address ) ) { wp_send_json_error( __( 'Invalid email address in request.' ) ); } if ( ! isset( $_POST['eraser'] ) ) { wp_send_json_error( __( 'Missing eraser index.' ) ); } $eraser_index = (int) $_POST['eraser']; if ( ! isset( $_POST['page'] ) ) { wp_send_json_error( __( 'Missing page index.' ) ); } $page = (int) $_POST['page']; $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); if ( 0 < count( $erasers ) ) { if ( $eraser_index < 1 ) { wp_send_json_error( __( 'Eraser index cannot be less than one.' ) ); } if ( $eraser_index > count( $erasers ) ) { wp_send_json_error( __( 'Eraser index is out of range.' ) ); } if ( $page < 1 ) { wp_send_json_error( __( 'Page index cannot be less than one.' ) ); } $eraser_keys = array_keys( $erasers ); $eraser_key = $eraser_keys[ $eraser_index - 1 ]; $eraser = $erasers[ $eraser_key ]; if ( ! is_array( $eraser ) ) { wp_send_json_error( sprintf( __( 'Expected an array describing the eraser at index %d.' ), $eraser_index ) ); } if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) { wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a friendly name.' ), $eraser_index ) ); } $eraser_friendly_name = $eraser['eraser_friendly_name']; if ( ! array_key_exists( 'callback', $eraser ) ) { wp_send_json_error( sprintf( __( 'Eraser does not include a callback: %s.' ), esc_html( $eraser_friendly_name ) ) ); } if ( ! is_callable( $eraser['callback'] ) ) { wp_send_json_error( sprintf( __( 'Eraser callback is not valid: %s.' ), esc_html( $eraser_friendly_name ) ) ); } $callback = $eraser['callback']; $response = call_user_func( $callback, $email_address, $page ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } if ( ! is_array( $response ) ) { wp_send_json_error( sprintf( __( 'Did not receive array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'items_removed', $response ) ) { wp_send_json_error( sprintf( __( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'items_retained', $response ) ) { wp_send_json_error( sprintf( __( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'messages', $response ) ) { wp_send_json_error( sprintf( __( 'Expected messages key in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! is_array( $response['messages'] ) ) { wp_send_json_error( sprintf( __( 'Expected messages key to reference an array in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } if ( ! array_key_exists( 'done', $response ) ) { wp_send_json_error( sprintf( __( 'Expected done flag in response array from %1$s eraser (index %2$d).' ), esc_html( $eraser_friendly_name ), $eraser_index ) ); } } else { $eraser_key = ''; $response = array( 'items_removed' => false, 'items_retained' => false, 'messages' => array(), 'done' => true, ); } $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id, $eraser_key ); if ( is_wp_error( $response ) ) { wp_send_json_error( $response ); } wp_send_json_success( $response ); } function wp_ajax_health_check_dotorg_communication() { _doing_it_wrong( 'wp_ajax_health_check_dotorg_communication', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_dotorg_communication', 'WP_REST_Site_Health_Controller::test_dotorg_communication' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_dotorg_communication() ); } function wp_ajax_health_check_background_updates() { _doing_it_wrong( 'wp_ajax_health_check_background_updates', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_background_updates', 'WP_REST_Site_Health_Controller::test_background_updates' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_background_updates() ); } function wp_ajax_health_check_loopback_requests() { _doing_it_wrong( 'wp_ajax_health_check_loopback_requests', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_loopback_requests', 'WP_REST_Site_Health_Controller::test_loopback_requests' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } $site_health = WP_Site_Health::get_instance(); wp_send_json_success( $site_health->get_test_loopback_requests() ); } function wp_ajax_health_check_site_status_result() { check_ajax_referer( 'health-check-site-status-result' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { wp_send_json_error(); } set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) ); wp_send_json_success(); } function wp_ajax_health_check_get_sizes() { _doing_it_wrong( 'wp_ajax_health_check_get_sizes', sprintf( __( 'The Site Health check for %1$s has been replaced with %2$s.' ), 'wp_ajax_health_check_get_sizes', 'WP_REST_Site_Health_Controller::get_directory_sizes' ), '5.6.0' ); check_ajax_referer( 'health-check-site-status-result' ); if ( ! current_user_can( 'view_site_health_checks' ) || is_multisite() ) { wp_send_json_error(); } if ( ! class_exists( 'WP_Debug_Data' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php'; } $sizes_data = WP_Debug_Data::get_sizes(); $all_sizes = array( 'raw' => 0 ); foreach ( $sizes_data as $name => $value ) { $name = sanitize_text_field( $name ); $data = array(); if ( isset( $value['size'] ) ) { if ( is_string( $value['size'] ) ) { $data['size'] = sanitize_text_field( $value['size'] ); } else { $data['size'] = (int) $value['size']; } } if ( isset( $value['debug'] ) ) { if ( is_string( $value['debug'] ) ) { $data['debug'] = sanitize_text_field( $value['debug'] ); } else { $data['debug'] = (int) $value['debug']; } } if ( ! empty( $value['raw'] ) ) { $data['raw'] = (int) $value['raw']; } $all_sizes[ $name ] = $data; } if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) { wp_send_json_error( $all_sizes ); } wp_send_json_success( $all_sizes ); } function wp_ajax_rest_nonce() { exit( wp_create_nonce( 'wp_rest' ) ); } function wp_ajax_toggle_auto_updates() { check_ajax_referer( 'updates' ); if ( empty( $_POST['type'] ) || empty( $_POST['asset'] ) || empty( $_POST['state'] ) ) { wp_send_json_error( array( 'error' => __( 'Invalid data. No selected item.' ) ) ); } $asset = sanitize_text_field( urldecode( $_POST['asset'] ) ); if ( 'enable' !== $_POST['state'] && 'disable' !== $_POST['state'] ) { wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown state.' ) ) ); } $state = $_POST['state']; if ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) { wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown type.' ) ) ); } $type = $_POST['type']; switch ( $type ) { case 'plugin': if ( ! current_user_can( 'update_plugins' ) ) { $error_message = __( 'Sorry, you are not allowed to modify plugins.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $option = 'auto_update_plugins'; $all_items = apply_filters( 'all_plugins', get_plugins() ); break; case 'theme': if ( ! current_user_can( 'update_themes' ) ) { $error_message = __( 'Sorry, you are not allowed to modify themes.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $option = 'auto_update_themes'; $all_items = wp_get_themes(); break; default: wp_send_json_error( array( 'error' => __( 'Invalid data. Unknown type.' ) ) ); } if ( ! array_key_exists( $asset, $all_items ) ) { $error_message = __( 'Invalid data. The item does not exist.' ); wp_send_json_error( array( 'error' => $error_message ) ); } $auto_updates = (array) get_site_option( $option, array() ); if ( 'disable' === $state ) { $auto_updates = array_diff( $auto_updates, array( $asset ) ); } else { $auto_updates[] = $asset; $auto_updates = array_unique( $auto_updates ); } $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); update_site_option( $option, $auto_updates ); wp_send_json_success(); } function wp_ajax_send_password_reset() { $user_id = isset( $_POST['user_id'] ) ? (int) $_POST['user_id'] : 0; check_ajax_referer( 'reset-password-for-' . $user_id, 'nonce' ); if ( ! current_user_can( 'edit_user', $user_id ) ) { wp_send_json_error( __( 'Cannot send password reset, permission denied.' ) ); } $user = get_userdata( $user_id ); $results = retrieve_password( $user->user_login ); if ( true === $results ) { wp_send_json_success( sprintf( __( 'A password reset link was emailed to %s.' ), $user->display_name ) ); } else { wp_send_json_error( $results->get_error_message() ); } } ' . __( 'You need a higher level of permission.' ) . '' . '

' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '

', 403 ); } $_POST['link_url'] = esc_html( $_POST['link_url'] ); $_POST['link_url'] = esc_url( $_POST['link_url'] ); $_POST['link_name'] = esc_html( $_POST['link_name'] ); $_POST['link_image'] = esc_html( $_POST['link_image'] ); $_POST['link_rss'] = esc_url( $_POST['link_rss'] ); if ( ! isset( $_POST['link_visible'] ) || 'N' !== $_POST['link_visible'] ) { $_POST['link_visible'] = 'Y'; } if ( ! empty( $link_id ) ) { $_POST['link_id'] = $link_id; return wp_update_link( $_POST ); } else { return wp_insert_link( $_POST ); } } function get_default_link_to_edit() { $link = new stdClass(); if ( isset( $_GET['linkurl'] ) ) { $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) ); } else { $link->link_url = ''; } if ( isset( $_GET['name'] ) ) { $link->link_name = esc_attr( wp_unslash( $_GET['name'] ) ); } else { $link->link_name = ''; } $link->link_visible = 'Y'; return $link; } function wp_delete_link( $link_id ) { global $wpdb; do_action( 'delete_link', $link_id ); wp_delete_object_term_relationships( $link_id, 'link_category' ); $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); do_action( 'deleted_link', $link_id ); clean_bookmark_cache( $link_id ); return true; } function wp_get_link_cats( $link_id = 0 ) { $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) ); return array_unique( $cats ); } function get_link_to_edit( $link ) { return get_bookmark( $link, OBJECT, 'edit' ); } function wp_insert_link( $linkdata, $wp_error = false ) { global $wpdb; $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0, ); $parsed_args = wp_parse_args( $linkdata, $defaults ); $parsed_args = wp_unslash( sanitize_bookmark( $parsed_args, 'db' ) ); $link_id = $parsed_args['link_id']; $link_name = $parsed_args['link_name']; $link_url = $parsed_args['link_url']; $update = false; if ( ! empty( $link_id ) ) { $update = true; } if ( '' === trim( $link_name ) ) { if ( '' !== trim( $link_url ) ) { $link_name = $link_url; } else { return 0; } } if ( '' === trim( $link_url ) ) { return 0; } $link_rating = ( ! empty( $parsed_args['link_rating'] ) ) ? $parsed_args['link_rating'] : 0; $link_image = ( ! empty( $parsed_args['link_image'] ) ) ? $parsed_args['link_image'] : ''; $link_target = ( ! empty( $parsed_args['link_target'] ) ) ? $parsed_args['link_target'] : ''; $link_visible = ( ! empty( $parsed_args['link_visible'] ) ) ? $parsed_args['link_visible'] : 'Y'; $link_owner = ( ! empty( $parsed_args['link_owner'] ) ) ? $parsed_args['link_owner'] : get_current_user_id(); $link_notes = ( ! empty( $parsed_args['link_notes'] ) ) ? $parsed_args['link_notes'] : ''; $link_description = ( ! empty( $parsed_args['link_description'] ) ) ? $parsed_args['link_description'] : ''; $link_rss = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : ''; $link_rel = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : ''; $link_category = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array(); if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) { $link_category = array( get_option( 'default_link_category' ) ); } if ( $update ) { if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) { if ( $wp_error ) { return new WP_Error( 'db_update_error', __( 'Could not update link in the database.' ), $wpdb->last_error ); } else { return 0; } } } else { if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) { if ( $wp_error ) { return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database.' ), $wpdb->last_error ); } else { return 0; } } $link_id = (int) $wpdb->insert_id; } wp_set_link_cats( $link_id, $link_category ); if ( $update ) { do_action( 'edit_link', $link_id ); } else { do_action( 'add_link', $link_id ); } clean_bookmark_cache( $link_id ); return $link_id; } function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) { $link_categories = array( get_option( 'default_link_category' ) ); } $link_categories = array_map( 'intval', $link_categories ); $link_categories = array_unique( $link_categories ); wp_set_object_terms( $link_id, $link_categories, 'link_category' ); clean_bookmark_cache( $link_id ); } function wp_update_link( $linkdata ) { $link_id = (int) $linkdata['link_id']; $link = get_bookmark( $link_id, ARRAY_A ); $link = wp_slash( $link ); if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && count( $linkdata['link_category'] ) > 0 ) { $link_cats = $linkdata['link_category']; } else { $link_cats = $link['link_category']; } $linkdata = array_merge( $link, $linkdata ); $linkdata['link_category'] = $link_cats; return wp_insert_link( $linkdata ); } function wp_link_manager_disabled_message() { global $pagenow; if ( ! in_array( $pagenow, array( 'link-manager.php', 'link-add.php', 'link.php' ), true ) ) { return; } add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); $really_can_manage_links = current_user_can( 'manage_links' ); remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); if ( $really_can_manage_links ) { $plugins = get_plugins(); if ( empty( $plugins['link-manager/link-manager.php'] ) ) { if ( current_user_can( 'install_plugins' ) ) { $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=link-manager' ), 'install-plugin_link-manager' ); wp_die( sprintf( __( 'If you are looking to use the link manager, please install the Link Manager plugin.' ), esc_url( $install_url ) ) ); } } elseif ( is_plugin_inactive( 'link-manager/link-manager.php' ) ) { if ( current_user_can( 'activate_plugins' ) ) { $activate_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=link-manager/link-manager.php' ), 'activate-plugin_link-manager/link-manager.php' ); wp_die( sprintf( __( 'Please activate the Link Manager plugin to use the link manager.' ), esc_url( $activate_url ) ) ); } } } wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); } options['context'] = $context; } ob_start(); $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); ob_end_clean(); return $result; } public function get_upgrade_messages() { return $this->messages; } public function feedback( $feedback, ...$args ) { if ( is_wp_error( $feedback ) ) { $string = $feedback->get_error_message(); } elseif ( is_array( $feedback ) ) { return; } else { $string = $feedback; } if ( ! empty( $this->upgrader->strings[ $string ] ) ) { $string = $this->upgrader->strings[ $string ]; } if ( strpos( $string, '%' ) !== false ) { if ( ! empty( $args ) ) { $string = vsprintf( $string, $args ); } } $string = trim( $string ); $string = wp_kses( $string, array( 'a' => array( 'href' => true, ), 'br' => true, 'em' => true, 'strong' => true, ) ); if ( empty( $string ) ) { return; } $this->messages[] = $string; } public function header() { ob_start(); } public function footer() { $output = ob_get_clean(); if ( ! empty( $output ) ) { $this->feedback( $output ); } } } upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' ); } public function before( $title = '' ) { parent::before( $this->plugin_info['Title'] ); } public function after( $title = '' ) { parent::after( $this->plugin_info['Title'] ); $this->decrement_update_count( 'plugin' ); } public function bulk_footer() { parent::bulk_footer(); $update_actions = array( 'plugins_page' => sprintf( '%s', self_admin_url( 'plugins.php' ), __( 'Go to Plugins page' ) ), 'updates_page' => sprintf( '%s', self_admin_url( 'update-core.php' ), __( 'Go to WordPress Updates page' ) ), ); if ( ! current_user_can( 'activate_plugins' ) ) { unset( $update_actions['plugins_page'] ); } $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); if ( ! empty( $update_actions ) ) { $this->feedback( implode( ' | ', (array) $update_actions ) ); } } } ↓', wp_nonce_url( add_query_arg( array( 'action' => 'move-down-menu-item', 'menu-item' => $item_id, ), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) ), 'move-menu_item' ), esc_attr__( 'Move down' ) ); ?> $item_id, ), remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) ); } printf( '%s', $item_id, $edit_url, esc_attr__( 'Edit menu item' ), __( 'Edit' ) ); ?> + if ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) { $edit_url = admin_url( 'nav-menus.php' ); } else { $edit_url = add_query_arg( array( 'edit-menu-item' => $item_id, ), remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) ); } printf( '%s', $item_id, esc_url( $edit_url ), esc_attr__( 'Edit menu item' ), __( 'Edit' ) ); ?> @@ -2988,7 +2989,7 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s] $file = get_attached_file( $post->ID ); echo esc_html( wp_basename( $file ) ); ?>

%s', esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), get_the_author() ); } public function column_desc( $post ) { echo has_excerpt() ? $post->post_excerpt : ''; } public function column_date( $post ) { if ( '0000-00-00 00:00:00' === $post->post_date ) { $h_time = __( 'Unpublished' ); } else { $time = get_post_timestamp( $post ); $time_diff = time() - $time; if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { $h_time = get_the_time( __( 'Y/m/d' ), $post ); } } echo apply_filters( 'media_date_column_time', $h_time, $post, 'date' ); } public function column_parent( $post ) { $user_can_edit = current_user_can( 'edit_post', $post->ID ); if ( $post->post_parent > 0 ) { $parent = get_post( $post->post_parent ); } else { $parent = false; } if ( $parent ) { $title = _draft_or_post_title( $post->post_parent ); $parent_type = get_post_type_object( $parent->post_type ); if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { printf( '%s', get_edit_post_link( $post->post_parent ), $title ); } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { printf( '%s', $title ); } else { _e( '(Private post)' ); } if ( $user_can_edit ) : $detach_url = add_query_arg( array( 'parent_post_id' => $post->post_parent, 'media[]' => $post->ID, '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), ), 'upload.php' ); printf( '
%s', $detach_url, esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), __( 'Detach' ) ); endif; } else { _e( '(Unattached)' ); ?> + } public function column_author( $post ) { printf( '%s', esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), get_the_author() ); } public function column_desc( $post ) { _deprecated_function( __METHOD__, '6.2.0' ); } public function column_date( $post ) { if ( '0000-00-00 00:00:00' === $post->post_date ) { $h_time = __( 'Unpublished' ); } else { $time = get_post_timestamp( $post ); $time_diff = time() - $time; if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { $h_time = get_the_time( __( 'Y/m/d' ), $post ); } } echo apply_filters( 'media_date_column_time', $h_time, $post, 'date' ); } public function column_parent( $post ) { $user_can_edit = current_user_can( 'edit_post', $post->ID ); if ( $post->post_parent > 0 ) { $parent = get_post( $post->post_parent ); } else { $parent = false; } if ( $parent ) { $title = _draft_or_post_title( $post->post_parent ); $parent_type = get_post_type_object( $parent->post_type ); if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { printf( '%s', get_edit_post_link( $post->post_parent ), $title ); } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { printf( '%s', $title ); } else { _e( '(Private post)' ); } if ( $user_can_edit ) : $detach_url = add_query_arg( array( 'parent_post_id' => $post->post_parent, 'media[]' => $post->ID, '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), ), 'upload.php' ); printf( '
%s', $detach_url, esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), __( 'Detach' ) ); endif; } else { _e( '(Unattached)' ); ?> post_parent ); printf( '
%s', $post->ID, esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), __( 'Attach' ) ); } } } public function column_comments( $post ) { echo '
'; if ( isset( $this->comment_pending_count[ $post->ID ] ) ) { $pending_comments = $this->comment_pending_count[ $post->ID ]; } else { $pending_comments = get_pending_comments_num( $post->ID ); } $this->comments_bubble( $post->ID, $pending_comments ); echo '
'; } public function column_default( $item, $column_name ) { $post = $item; if ( 'categories' === $column_name ) { $taxonomy = 'category'; } elseif ( 'tags' === $column_name ) { $taxonomy = 'post_tag'; } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { $taxonomy = substr( $column_name, 9 ); } else { $taxonomy = false; } if ( $taxonomy ) { $terms = get_the_terms( $post->ID, $taxonomy ); if ( is_array( $terms ) ) { $output = array(); foreach ( $terms as $t ) { $posts_in_term_qv = array(); $posts_in_term_qv['taxonomy'] = $taxonomy; $posts_in_term_qv['term'] = $t->slug; $output[] = sprintf( '%s', esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) ); } echo implode( wp_get_list_item_separator(), $output ); } else { echo '' . get_taxonomy( $taxonomy )->labels->no_terms . ''; } return; } do_action( 'manage_media_custom_column', $column_name, $post->ID ); } public function display_rows() { global $post, $wp_query; $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); reset( $wp_query->posts ); $this->comment_pending_count = get_pending_comments_num( $post_ids ); add_filter( 'the_title', 'esc_html' ); while ( have_posts() ) : the_post(); if ( $this->is_trash && 'trash' !== $post->post_status || ! $this->is_trash && 'trash' === $post->post_status ) { continue; } $post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other'; ?> @@ -3926,7 +3927,7 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s] })( window.wp ); '; } } public function bulk_header() {} public function bulk_footer() {} public function hide_process_failed( $wp_error ) { return false; } } skin = new WP_Upgrader_Skin(); } else { $this->skin = $skin; } } public function init() { $this->skin->set_upgrader( $this ); $this->generic_strings(); } public function generic_strings() { $this->strings['bad_request'] = __( 'Invalid data provided.' ); $this->strings['fs_unavailable'] = __( 'Could not access filesystem.' ); $this->strings['fs_error'] = __( 'Filesystem error.' ); $this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' ); $this->strings['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' ); $this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' ); $this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' ); $this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' ); $this->strings['download_failed'] = __( 'Download failed.' ); $this->strings['installing_package'] = __( 'Installing the latest version…' ); $this->strings['no_files'] = __( 'The package contains no files.' ); $this->strings['folder_exists'] = __( 'Destination folder already exists.' ); $this->strings['mkdir_failed'] = __( 'Could not create directory.' ); $this->strings['incompatible_archive'] = __( 'The package could not be installed.' ); $this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ); $this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' ); $this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' ); } public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) { global $wp_filesystem; $credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership ); if ( false === $credentials ) { return false; } if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) { $error = true; if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) { $error = $wp_filesystem->errors; } $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership ); return false; } if ( ! is_object( $wp_filesystem ) ) { return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] ); } if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors ); } foreach ( (array) $directories as $dir ) { switch ( $dir ) { case ABSPATH: if ( ! $wp_filesystem->abspath() ) { return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] ); } break; case WP_CONTENT_DIR: if ( ! $wp_filesystem->wp_content_dir() ) { return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] ); } break; case WP_PLUGIN_DIR: if ( ! $wp_filesystem->wp_plugins_dir() ) { return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] ); } break; case get_theme_root(): if ( ! $wp_filesystem->wp_themes_dir() ) { return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] ); } break; default: if ( ! $wp_filesystem->find_folder( $dir ) ) { return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) ); } break; } } return true; } public function download_package( $package, $check_signatures = false, $hook_extra = array() ) { $reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra ); if ( false !== $reply ) { return $reply; } if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { return $package; } if ( empty( $package ) ) { return new WP_Error( 'no_package', $this->strings['no_package'] ); } $this->skin->feedback( 'downloading_package', $package ); $download_file = download_url( $package, 300, $check_signatures ); if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) { return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() ); } return $download_file; } public function unpack_package( $package, $delete_package = true ) { global $wp_filesystem; $this->skin->feedback( 'unpack_package' ); $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/'; $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder ); if ( ! empty( $upgrade_files ) ) { foreach ( $upgrade_files as $file ) { $wp_filesystem->delete( $upgrade_folder . $file['name'], true ); } } $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' ); if ( $wp_filesystem->is_dir( $working_dir ) ) { $wp_filesystem->delete( $working_dir, true ); } $result = unzip_file( $package, $working_dir ); if ( $delete_package ) { unlink( $package ); } if ( is_wp_error( $result ) ) { $wp_filesystem->delete( $working_dir, true ); if ( 'incompatible_archive' === $result->get_error_code() ) { return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() ); } return $result; } return $working_dir; } protected function flatten_dirlist( $nested_files, $path = '' ) { $files = array(); foreach ( $nested_files as $name => $details ) { $files[ $path . $name ] = $details; if ( ! empty( $details['files'] ) ) { $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); $files = $files + $children; } } return $files; } public function clear_destination( $remote_destination ) { global $wp_filesystem; $files = $wp_filesystem->dirlist( $remote_destination, true, true ); if ( false === $files ) { return true; } $files = $this->flatten_dirlist( $files ); $unwritable_files = array(); foreach ( $files as $filename => $file_details ) { if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) ); if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { $unwritable_files[] = $filename; } } } if ( ! empty( $unwritable_files ) ) { return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) ); } if ( ! $wp_filesystem->delete( $remote_destination, true ) ) { return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] ); } return true; } public function install_package( $args = array() ) { global $wp_filesystem, $wp_theme_directories; $defaults = array( 'source' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => false, 'abort_if_destination_exists' => true, 'hook_extra' => array(), ); $args = wp_parse_args( $args, $defaults ); $source = $args['source']; $destination = $args['destination']; $clear_destination = $args['clear_destination']; ; if ( empty( $source ) || empty( $destination ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); } $this->skin->feedback( 'installing_package' ); $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] ); if ( is_wp_error( $res ) ) { return $res; } $remote_source = $args['source']; $local_destination = $destination; $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); $remote_destination = $wp_filesystem->find_folder( $local_destination ); if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); } elseif ( 0 === count( $source_files ) ) { return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); } else { $source = trailingslashit( $args['source'] ); } $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] ); if ( is_wp_error( $source ) ) { return $source; } if ( $source !== $remote_source ) { $source_files = array_keys( $wp_filesystem->dirlist( $source ) ); } $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' ); if ( is_array( $wp_theme_directories ) ) { $protected_directories = array_merge( $protected_directories, $wp_theme_directories ); } if ( in_array( $destination, $protected_directories, true ) ) { $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) ); $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) ); } if ( $clear_destination ) { $this->skin->feedback( 'remove_old' ); $removed = $this->clear_destination( $remote_destination ); $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] ); if ( is_wp_error( $removed ) ) { return $removed; } } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) { $_files = $wp_filesystem->dirlist( $remote_destination ); if ( ! empty( $_files ) ) { $wp_filesystem->delete( $remote_source, true ); return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination ); } } if ( ! $wp_filesystem->exists( $remote_destination ) ) { if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination ); } } if ( class_exists( 'Rollback_Update_Failure\WP_Upgrader' ) && function_exists( '\Rollback_Update_Failure\move_dir' ) ) { $result = \Rollback_Update_Failure\move_dir( $source, $remote_destination ); } else { $result = copy_dir( $source, $remote_destination ); } if ( is_wp_error( $result ) ) { if ( $args['clear_working'] ) { $wp_filesystem->delete( $remote_source, true ); } return $result; } if ( $args['clear_working'] ) { $wp_filesystem->delete( $remote_source, true ); } $destination_name = basename( str_replace( $local_destination, '', $destination ) ); if ( '.' === $destination_name ) { $destination_name = ''; } $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' ); $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result ); if ( is_wp_error( $res ) ) { $this->result = $res; return $res; } return $this->result; } public function run( $options ) { $defaults = array( 'package' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => true, 'abort_if_destination_exists' => true, 'is_multi' => false, 'hook_extra' => array(), ); $options = wp_parse_args( $options, $defaults ); $options = apply_filters( 'upgrader_package_options', $options ); if ( ! $options['is_multi'] ) { $this->skin->header(); } $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); if ( ! $res ) { if ( ! $options['is_multi'] ) { $this->skin->footer(); } return false; } $this->skin->before(); if ( is_wp_error( $res ) ) { $this->skin->error( $res ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $res; } $download = $this->download_package( $options['package'], true, $options['hook_extra'] ); if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) { if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) { $this->skin->feedback( $download->get_error_message() ); wp_version_check( array( 'signature_failure_code' => $download->get_error_code(), 'signature_failure_data' => $download->get_error_data(), ) ); } $download = $download->get_error_data( 'softfail-filename' ); } if ( is_wp_error( $download ) ) { $this->skin->error( $download ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $download; } $delete_package = ( $download !== $options['package'] ); $working_dir = $this->unpack_package( $download, $delete_package ); if ( is_wp_error( $working_dir ) ) { $this->skin->error( $working_dir ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $working_dir; } $result = $this->install_package( array( 'source' => $working_dir, 'destination' => $options['destination'], 'clear_destination' => $options['clear_destination'], 'abort_if_destination_exists' => $options['abort_if_destination_exists'], 'clear_working' => $options['clear_working'], 'hook_extra' => $options['hook_extra'], ) ); $result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] ); $this->skin->set_result( $result ); if ( is_wp_error( $result ) ) { $this->skin->error( $result ); if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) { $this->skin->feedback( 'process_failed' ); } } else { $this->skin->feedback( 'process_success' ); } $this->skin->after(); if ( ! $options['is_multi'] ) { do_action( 'upgrader_process_complete', $this, $options['hook_extra'] ); $this->skin->footer(); } return $result; } public function maintenance_mode( $enable = false ) { global $wp_filesystem; $file = $wp_filesystem->abspath() . '.maintenance'; if ( $enable ) { $this->skin->feedback( 'maintenance_start' ); $maintenance_string = ''; $wp_filesystem->delete( $file ); $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) { $this->skin->feedback( 'maintenance_end' ); $wp_filesystem->delete( $file ); } } public static function create_lock( $lock_name, $release_timeout = null ) { global $wpdb; if ( ! $release_timeout ) { $release_timeout = HOUR_IN_SECONDS; } $lock_option = $lock_name . '.lock'; $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) ); if ( ! $lock_result ) { $lock_result = get_option( $lock_option ); if ( ! $lock_result ) { return false; } if ( $lock_result > ( time() - $release_timeout ) ) { return false; } WP_Upgrader::release_lock( $lock_name ); return WP_Upgrader::create_lock( $lock_name, $release_timeout ); } update_option( $lock_option, time() ); return true; } public static function release_lock( $lock_name ) { return delete_option( $lock_name . '.lock' ); } } require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-theme-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-language-pack-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-core-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-file-upload-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; skin = new WP_Upgrader_Skin(); } else { $this->skin = $skin; } } public function init() { $this->skin->set_upgrader( $this ); $this->generic_strings(); } public function generic_strings() { $this->strings['bad_request'] = __( 'Invalid data provided.' ); $this->strings['fs_unavailable'] = __( 'Could not access filesystem.' ); $this->strings['fs_error'] = __( 'Filesystem error.' ); $this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' ); $this->strings['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' ); $this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' ); $this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' ); $this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' ); $this->strings['download_failed'] = __( 'Download failed.' ); $this->strings['installing_package'] = __( 'Installing the latest version…' ); $this->strings['no_files'] = __( 'The package contains no files.' ); $this->strings['folder_exists'] = __( 'Destination folder already exists.' ); $this->strings['mkdir_failed'] = __( 'Could not create directory.' ); $this->strings['incompatible_archive'] = __( 'The package could not be installed.' ); $this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ); $this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' ); $this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' ); } public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) { global $wp_filesystem; $credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership ); if ( false === $credentials ) { return false; } if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) { $error = true; if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) { $error = $wp_filesystem->errors; } $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership ); return false; } if ( ! is_object( $wp_filesystem ) ) { return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] ); } if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors ); } foreach ( (array) $directories as $dir ) { switch ( $dir ) { case ABSPATH: if ( ! $wp_filesystem->abspath() ) { return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] ); } break; case WP_CONTENT_DIR: if ( ! $wp_filesystem->wp_content_dir() ) { return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] ); } break; case WP_PLUGIN_DIR: if ( ! $wp_filesystem->wp_plugins_dir() ) { return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] ); } break; case get_theme_root(): if ( ! $wp_filesystem->wp_themes_dir() ) { return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] ); } break; default: if ( ! $wp_filesystem->find_folder( $dir ) ) { return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) ); } break; } } return true; } public function download_package( $package, $check_signatures = false, $hook_extra = array() ) { $reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra ); if ( false !== $reply ) { return $reply; } if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { return $package; } if ( empty( $package ) ) { return new WP_Error( 'no_package', $this->strings['no_package'] ); } $this->skin->feedback( 'downloading_package', $package ); $download_file = download_url( $package, 300, $check_signatures ); if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) { return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() ); } return $download_file; } public function unpack_package( $package, $delete_package = true ) { global $wp_filesystem; $this->skin->feedback( 'unpack_package' ); $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/'; $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder ); if ( ! empty( $upgrade_files ) ) { foreach ( $upgrade_files as $file ) { $wp_filesystem->delete( $upgrade_folder . $file['name'], true ); } } $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' ); if ( $wp_filesystem->is_dir( $working_dir ) ) { $wp_filesystem->delete( $working_dir, true ); } $result = unzip_file( $package, $working_dir ); if ( $delete_package ) { unlink( $package ); } if ( is_wp_error( $result ) ) { $wp_filesystem->delete( $working_dir, true ); if ( 'incompatible_archive' === $result->get_error_code() ) { return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() ); } return $result; } return $working_dir; } protected function flatten_dirlist( $nested_files, $path = '' ) { $files = array(); foreach ( $nested_files as $name => $details ) { $files[ $path . $name ] = $details; if ( ! empty( $details['files'] ) ) { $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); $files = $files + $children; } } return $files; } public function clear_destination( $remote_destination ) { global $wp_filesystem; $files = $wp_filesystem->dirlist( $remote_destination, true, true ); if ( false === $files ) { return true; } $files = $this->flatten_dirlist( $files ); $unwritable_files = array(); foreach ( $files as $filename => $file_details ) { if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) ); if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { $unwritable_files[] = $filename; } } } if ( ! empty( $unwritable_files ) ) { return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) ); } if ( ! $wp_filesystem->delete( $remote_destination, true ) ) { return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] ); } return true; } public function install_package( $args = array() ) { global $wp_filesystem, $wp_theme_directories; $defaults = array( 'source' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => false, 'abort_if_destination_exists' => true, 'hook_extra' => array(), ); $args = wp_parse_args( $args, $defaults ); $source = $args['source']; $destination = $args['destination']; $clear_destination = $args['clear_destination']; ; if ( empty( $source ) || empty( $destination ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); } $this->skin->feedback( 'installing_package' ); $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] ); if ( is_wp_error( $res ) ) { return $res; } $remote_source = $args['source']; $local_destination = $destination; $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); $remote_destination = $wp_filesystem->find_folder( $local_destination ); if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); } elseif ( 0 === count( $source_files ) ) { return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); } else { $source = trailingslashit( $args['source'] ); } $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] ); if ( is_wp_error( $source ) ) { return $source; } if ( $source !== $remote_source ) { $source_files = array_keys( $wp_filesystem->dirlist( $source ) ); } $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' ); if ( is_array( $wp_theme_directories ) ) { $protected_directories = array_merge( $protected_directories, $wp_theme_directories ); } if ( in_array( $destination, $protected_directories, true ) ) { $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) ); $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) ); } if ( $clear_destination ) { $this->skin->feedback( 'remove_old' ); $removed = $this->clear_destination( $remote_destination ); $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] ); if ( is_wp_error( $removed ) ) { return $removed; } } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) { $_files = $wp_filesystem->dirlist( $remote_destination ); if ( ! empty( $_files ) ) { $wp_filesystem->delete( $remote_source, true ); return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination ); } } if ( ! $wp_filesystem->exists( $remote_destination ) ) { if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination ); } } $result = copy_dir( $source, $remote_destination ); if ( $args['clear_working'] ) { $wp_filesystem->delete( $remote_source, true ); } if ( is_wp_error( $result ) ) { return $result; } $destination_name = basename( str_replace( $local_destination, '', $destination ) ); if ( '.' === $destination_name ) { $destination_name = ''; } $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' ); $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result ); if ( is_wp_error( $res ) ) { $this->result = $res; return $res; } return $this->result; } public function run( $options ) { $defaults = array( 'package' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => true, 'abort_if_destination_exists' => true, 'is_multi' => false, 'hook_extra' => array(), ); $options = wp_parse_args( $options, $defaults ); $options = apply_filters( 'upgrader_package_options', $options ); if ( ! $options['is_multi'] ) { $this->skin->header(); } $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); if ( ! $res ) { if ( ! $options['is_multi'] ) { $this->skin->footer(); } return false; } $this->skin->before(); if ( is_wp_error( $res ) ) { $this->skin->error( $res ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $res; } $download = $this->download_package( $options['package'], true, $options['hook_extra'] ); if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) { if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) { $this->skin->feedback( $download->get_error_message() ); wp_version_check( array( 'signature_failure_code' => $download->get_error_code(), 'signature_failure_data' => $download->get_error_data(), ) ); } $download = $download->get_error_data( 'softfail-filename' ); } if ( is_wp_error( $download ) ) { $this->skin->error( $download ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $download; } $delete_package = ( $download !== $options['package'] ); $working_dir = $this->unpack_package( $download, $delete_package ); if ( is_wp_error( $working_dir ) ) { $this->skin->error( $working_dir ); $this->skin->after(); if ( ! $options['is_multi'] ) { $this->skin->footer(); } return $working_dir; } $result = $this->install_package( array( 'source' => $working_dir, 'destination' => $options['destination'], 'clear_destination' => $options['clear_destination'], 'abort_if_destination_exists' => $options['abort_if_destination_exists'], 'clear_working' => $options['clear_working'], 'hook_extra' => $options['hook_extra'], ) ); $result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] ); $this->skin->set_result( $result ); if ( is_wp_error( $result ) ) { $this->skin->error( $result ); if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) { $this->skin->feedback( 'process_failed' ); } } else { $this->skin->feedback( 'process_success' ); } $this->skin->after(); if ( ! $options['is_multi'] ) { do_action( 'upgrader_process_complete', $this, $options['hook_extra'] ); $this->skin->footer(); } return $result; } public function maintenance_mode( $enable = false ) { global $wp_filesystem; $file = $wp_filesystem->abspath() . '.maintenance'; if ( $enable ) { $this->skin->feedback( 'maintenance_start' ); $maintenance_string = ''; $wp_filesystem->delete( $file ); $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) { $this->skin->feedback( 'maintenance_end' ); $wp_filesystem->delete( $file ); } } public static function create_lock( $lock_name, $release_timeout = null ) { global $wpdb; if ( ! $release_timeout ) { $release_timeout = HOUR_IN_SECONDS; } $lock_option = $lock_name . '.lock'; $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) ); if ( ! $lock_result ) { $lock_result = get_option( $lock_option ); if ( ! $lock_result ) { return false; } if ( $lock_result > ( time() - $release_timeout ) ) { return false; } WP_Upgrader::release_lock( $lock_name ); return WP_Upgrader::create_lock( $lock_name, $release_timeout ); } update_option( $lock_option, time() ); return true; } public static function release_lock( $lock_name ) { return delete_option( $lock_name . '.lock' ); } } require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-theme-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-language-pack-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-core-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-file-upload-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; 'user', 'plural' => 'users', 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); $this->is_site_users = 'site-users-network' === $this->screen->id; if ( $this->is_site_users ) { $this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0; } } public function ajax_user_can() { if ( $this->is_site_users ) { return current_user_can( 'manage_sites' ); } else { return current_user_can( 'list_users' ); } } public function prepare_items() { global $role, $usersearch; $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page'; $users_per_page = $this->get_items_per_page( $per_page ); $paged = $this->get_pagenum(); if ( 'none' === $role ) { $args = array( 'number' => $users_per_page, 'offset' => ( $paged - 1 ) * $users_per_page, 'include' => wp_get_users_with_no_role( $this->site_id ), 'search' => $usersearch, 'fields' => 'all_with_meta', ); } else { $args = array( 'number' => $users_per_page, 'offset' => ( $paged - 1 ) * $users_per_page, 'role' => $role, 'search' => $usersearch, 'fields' => 'all_with_meta', ); } if ( '' !== $args['search'] ) { $args['search'] = '*' . $args['search'] . '*'; } if ( $this->is_site_users ) { $args['blog_id'] = $this->site_id; } if ( isset( $_REQUEST['orderby'] ) ) { $args['orderby'] = $_REQUEST['orderby']; } if ( isset( $_REQUEST['order'] ) ) { $args['order'] = $_REQUEST['order']; } $args = apply_filters( 'users_list_table_query_args', $args ); $wp_user_search = new WP_User_Query( $args ); $this->items = $wp_user_search->get_results(); $this->set_pagination_args( array( 'total_items' => $wp_user_search->get_total(), 'per_page' => $users_per_page, ) ); } public function no_items() { _e( 'No users found.' ); } protected function get_views() { global $role; $wp_roles = wp_roles(); $count_users = ! wp_is_large_user_count(); if ( $this->is_site_users ) { $url = 'site-users.php?id=' . $this->site_id; } else { $url = 'users.php'; } $role_links = array(); $avail_roles = array(); $all_text = __( 'All' ); if ( $count_users ) { if ( $this->is_site_users ) { switch_to_blog( $this->site_id ); $users_of_blog = count_users( 'time', $this->site_id ); restore_current_blog(); } else { $users_of_blog = count_users(); } $total_users = $users_of_blog['total_users']; $avail_roles =& $users_of_blog['avail_roles']; unset( $users_of_blog ); $all_text = sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ); } $role_links['all'] = array( 'url' => $url, 'label' => $all_text, 'current' => empty( $role ), ); foreach ( $wp_roles->get_names() as $this_role => $name ) { if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) { continue; } $name = translate_user_role( $name ); if ( $count_users ) { $name = sprintf( __( '%1$s (%2$s)' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) ); } $role_links[ $this_role ] = array( 'url' => esc_url( add_query_arg( 'role', $this_role, $url ) ), 'label' => $name, 'current' => $this_role === $role, ); } if ( ! empty( $avail_roles['none'] ) ) { $name = __( 'No role' ); $name = sprintf( __( '%1$s (%2$s)' ), $name, number_format_i18n( $avail_roles['none'] ) ); $role_links['none'] = array( 'url' => esc_url( add_query_arg( 'role', 'none', $url ) ), 'label' => $name, 'current' => 'none' === $role, ); } return $this->get_views_links( $role_links ); } protected function get_bulk_actions() { $actions = array(); if ( is_multisite() ) { if ( current_user_can( 'remove_users' ) ) { $actions['remove'] = __( 'Remove' ); } } else { if ( current_user_can( 'delete_users' ) ) { $actions['delete'] = __( 'Delete' ); } } if ( current_user_can( 'edit_users' ) ) { $actions['resetpassword'] = __( 'Send password reset' ); } return $actions; } protected function extra_tablenav( $which ) { $id = 'bottom' === $which ? 'new_role2' : 'new_role'; $button_id = 'bottom' === $which ? 'changeit2' : 'changeit'; ?>
has_items() ) : ?> @@ -4559,7 +4560,7 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s]
@@ -5414,6 +5415,9 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s]
+
+ +
@@ -5796,7 +5800,7 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s]
@@ -5812,7 +5816,7 @@ Thanks! -- The WordPress Team" ) ); $body[] = ''; $subject = sprintf( __( '[%s]

post_name, $post ); ?> - + post_type ); ?> @@ -6937,7 +6941,7 @@ echo '
  • '; printf( __( 'Add the fol requires_php ) ? $api->requires_php : null; $requires_wp = isset( $api->requires ) ? $api->requires : null; $compatible_php = is_php_version_compatible( $requires_php ); $compatible_wp = is_wp_version_compatible( $requires_wp ); $tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) ); if ( ! $compatible_php ) { echo '

    '; _e( 'Error: This plugin requires a newer version of PHP.' ); if ( current_user_can( 'update_php' ) ) { printf( ' ' . __( 'Click here to learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); wp_update_php_annotation( '

    ', '' ); } else { echo '

    '; } echo '
    '; } if ( ! $tested_wp ) { echo '

    '; _e( 'Warning: This plugin has not been tested with your current version of WordPress.' ); echo '

    '; } elseif ( ! $compatible_wp ) { echo '

    '; _e( 'Error: This plugin requires a newer version of WordPress.' ); if ( current_user_can( 'update_core' ) ) { printf( ' ' . __( 'Click here to update WordPress.' ), esc_url( self_admin_url( 'update-core.php' ) ) ); } echo '

    '; } foreach ( (array) $api->sections as $section_name => $content ) { $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); $content = links_add_target( $content, '_blank' ); $san_section = esc_attr( $section_name ); $display = ( $section_name === $section ) ? 'block' : 'none'; echo "\t
    \n"; echo $content; echo "\t
    \n"; } echo "
  • \n"; echo "\n"; echo "\n"; echo "\n"; iframe_footer(); exit; } 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', 'RequiresWP' => 'Requires at least', 'RequiresPHP' => 'Requires PHP', 'UpdateURI' => 'Update URI', '_sitewide' => 'Site Wide Only', ); $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), 'Site Wide Only: true', 'Network: true' ) ); $plugin_data['Network'] = $plugin_data['_sitewide']; } $plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) ); unset( $plugin_data['_sitewide'] ); if ( ! $plugin_data['TextDomain'] ) { $plugin_slug = dirname( plugin_basename( $plugin_file ) ); if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) { $plugin_data['TextDomain'] = $plugin_slug; } } if ( $markup || $translate ) { $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); } else { $plugin_data['Title'] = $plugin_data['Name']; $plugin_data['AuthorName'] = $plugin_data['Author']; } return $plugin_data; } function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { $plugin_file = plugin_basename( $plugin_file ); if ( $translate ) { $textdomain = $plugin_data['TextDomain']; if ( $textdomain ) { if ( ! is_textdomain_loaded( $textdomain ) ) { if ( $plugin_data['DomainPath'] ) { load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); } else { load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); } } } elseif ( 'hello.php' === basename( $plugin_file ) ) { $textdomain = 'default'; } if ( $textdomain ) { foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) { if ( ! empty( $plugin_data[ $field ] ) ) { $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); } } } } $allowed_tags_in_links = array( 'abbr' => array( 'title' => true ), 'acronym' => array( 'title' => true ), 'code' => true, 'em' => true, 'strong' => true, ); $allowed_tags = $allowed_tags_in_links; $allowed_tags['a'] = array( 'href' => true, 'title' => true, ); $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); $plugin_data['Title'] = $plugin_data['Name']; $plugin_data['AuthorName'] = $plugin_data['Author']; if ( $markup ) { if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) { $plugin_data['Title'] = '' . $plugin_data['Name'] . ''; } if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) { $plugin_data['Author'] = '' . $plugin_data['Author'] . ''; } $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); if ( $plugin_data['Author'] ) { $plugin_data['Description'] .= sprintf( ' ' . __( 'By %s.' ) . '', $plugin_data['Author'] ); } } return $plugin_data; } function get_plugin_files( $plugin ) { $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; $dir = dirname( $plugin_file ); $plugin_files = array( plugin_basename( $plugin_file ) ); if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) { $exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); $list_files = list_files( $dir, 100, $exclusions ); $list_files = array_map( 'plugin_basename', $list_files ); $plugin_files = array_merge( $plugin_files, $list_files ); $plugin_files = array_values( array_unique( $plugin_files ) ); } return $plugin_files; } function get_plugins( $plugin_folder = '' ) { $cache_plugins = wp_cache_get( 'plugins', 'plugins' ); if ( ! $cache_plugins ) { $cache_plugins = array(); } if ( isset( $cache_plugins[ $plugin_folder ] ) ) { return $cache_plugins[ $plugin_folder ]; } $wp_plugins = array(); $plugin_root = WP_PLUGIN_DIR; if ( ! empty( $plugin_folder ) ) { $plugin_root .= $plugin_folder; } $plugins_dir = @opendir( $plugin_root ); $plugin_files = array(); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { if ( '.' === substr( $file, 0, 1 ) ) { continue; } if ( is_dir( $plugin_root . '/' . $file ) ) { $plugins_subdir = @opendir( $plugin_root . '/' . $file ); if ( $plugins_subdir ) { while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) { if ( '.' === substr( $subfile, 0, 1 ) ) { continue; } if ( '.php' === substr( $subfile, -4 ) ) { $plugin_files[] = "$file/$subfile"; } } closedir( $plugins_subdir ); } } else { if ( '.php' === substr( $file, -4 ) ) { $plugin_files[] = $file; } } } closedir( $plugins_dir ); } if ( empty( $plugin_files ) ) { return $wp_plugins; } foreach ( $plugin_files as $plugin_file ) { if ( ! is_readable( "$plugin_root/$plugin_file" ) ) { continue; } $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); if ( empty( $plugin_data['Name'] ) ) { continue; } $wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data; } uasort( $wp_plugins, '_sort_uname_callback' ); $cache_plugins[ $plugin_folder ] = $wp_plugins; wp_cache_set( 'plugins', $cache_plugins, 'plugins' ); return $wp_plugins; } function get_mu_plugins() { $wp_plugins = array(); $plugin_files = array(); if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { return $wp_plugins; } $plugins_dir = @opendir( WPMU_PLUGIN_DIR ); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { if ( '.php' === substr( $file, -4 ) ) { $plugin_files[] = $file; } } } else { return $wp_plugins; } closedir( $plugins_dir ); if ( empty( $plugin_files ) ) { return $wp_plugins; } foreach ( $plugin_files as $plugin_file ) { if ( ! is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) { continue; } $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); if ( empty( $plugin_data['Name'] ) ) { $plugin_data['Name'] = $plugin_file; } $wp_plugins[ $plugin_file ] = $plugin_data; } if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) { unset( $wp_plugins['index.php'] ); } uasort( $wp_plugins, '_sort_uname_callback' ); return $wp_plugins; } function _sort_uname_callback( $a, $b ) { return strnatcasecmp( $a['Name'], $b['Name'] ); } function get_dropins() { $dropins = array(); $plugin_files = array(); $_dropins = _get_dropins(); $plugins_dir = @opendir( WP_CONTENT_DIR ); if ( $plugins_dir ) { while ( ( $file = readdir( $plugins_dir ) ) !== false ) { if ( isset( $_dropins[ $file ] ) ) { $plugin_files[] = $file; } } } else { return $dropins; } closedir( $plugins_dir ); if ( empty( $plugin_files ) ) { return $dropins; } foreach ( $plugin_files as $plugin_file ) { if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) { continue; } $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); if ( empty( $plugin_data['Name'] ) ) { $plugin_data['Name'] = $plugin_file; } $dropins[ $plugin_file ] = $plugin_data; } uksort( $dropins, 'strnatcasecmp' ); return $dropins; } function _get_dropins() { $dropins = array( 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), 'db.php' => array( __( 'Custom database class.' ), true ), 'db-error.php' => array( __( 'Custom database error message.' ), true ), 'install.php' => array( __( 'Custom installation script.' ), true ), 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), 'object-cache.php' => array( __( 'External object cache.' ), true ), 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), 'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), ); if ( is_multisite() ) { $dropins['sunrise.php'] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); $dropins['blog-deleted.php'] = array( __( 'Custom site deleted message.' ), true ); $dropins['blog-inactive.php'] = array( __( 'Custom site inactive message.' ), true ); $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); } return $dropins; } function is_plugin_active( $plugin ) { return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin ); } function is_plugin_inactive( $plugin ) { return ! is_plugin_active( $plugin ); } 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; } function is_network_only_plugin( $plugin ) { $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); if ( $plugin_data ) { return $plugin_data['Network']; } return false; } function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { $plugin = plugin_basename( trim( $plugin ) ); if ( is_multisite() && ( $network_wide || is_network_only_plugin( $plugin ) ) ) { $network_wide = true; $current = get_site_option( 'active_sitewide_plugins', array() ); $_GET['networkwide'] = 1; } else { $current = get_option( 'active_plugins', array() ); } $valid = validate_plugin( $plugin ); if ( is_wp_error( $valid ) ) { return $valid; } $requirements = validate_plugin_requirements( $plugin ); if ( is_wp_error( $requirements ) ) { return $requirements; } if ( $network_wide && ! isset( $current[ $plugin ] ) || ! $network_wide && ! in_array( $plugin, $current, true ) ) { if ( ! empty( $redirect ) ) { wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); } ob_start(); plugin_sandbox_scrape( $plugin ); if ( ! $silent ) { do_action( 'activate_plugin', $plugin, $network_wide ); do_action( "activate_{$plugin}", $network_wide ); } if ( $network_wide ) { $current = get_site_option( 'active_sitewide_plugins', array() ); $current[ $plugin ] = time(); update_site_option( 'active_sitewide_plugins', $current ); } else { $current = get_option( 'active_plugins', array() ); $current[] = $plugin; sort( $current ); update_option( 'active_plugins', $current ); } if ( ! $silent ) { do_action( 'activated_plugin', $plugin, $network_wide ); } if ( ob_get_length() > 0 ) { $output = ob_get_clean(); return new WP_Error( 'unexpected_output', __( 'The plugin generated unexpected output.' ), $output ); } ob_end_clean(); } return null; } function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { if ( is_multisite() ) { $network_current = get_site_option( 'active_sitewide_plugins', array() ); } $current = get_option( 'active_plugins', array() ); $do_blog = false; $do_network = false; foreach ( (array) $plugins as $plugin ) { $plugin = plugin_basename( trim( $plugin ) ); if ( ! is_plugin_active( $plugin ) ) { continue; } $network_deactivating = ( false !== $network_wide ) && is_plugin_active_for_network( $plugin ); if ( ! $silent ) { do_action( 'deactivate_plugin', $plugin, $network_deactivating ); } if ( false !== $network_wide ) { if ( is_plugin_active_for_network( $plugin ) ) { $do_network = true; unset( $network_current[ $plugin ] ); } elseif ( $network_wide ) { continue; } } if ( true !== $network_wide ) { $key = array_search( $plugin, $current, true ); if ( false !== $key ) { $do_blog = true; unset( $current[ $key ] ); } } if ( $do_blog && wp_is_recovery_mode() ) { list( $extension ) = explode( '/', $plugin ); wp_paused_plugins()->delete( $extension ); } if ( ! $silent ) { do_action( "deactivate_{$plugin}", $network_deactivating ); do_action( 'deactivated_plugin', $plugin, $network_deactivating ); } } if ( $do_blog ) { update_option( 'active_plugins', $current ); } if ( $do_network ) { update_site_option( 'active_sitewide_plugins', $network_current ); } } function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { if ( ! is_array( $plugins ) ) { $plugins = array( $plugins ); } $errors = array(); foreach ( $plugins as $plugin ) { if ( ! empty( $redirect ) ) { $redirect = add_query_arg( 'plugin', $plugin, $redirect ); } $result = activate_plugin( $plugin, $redirect, $network_wide, $silent ); if ( is_wp_error( $result ) ) { $errors[ $plugin ] = $result; } } if ( ! empty( $errors ) ) { return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors ); } return true; } function delete_plugins( $plugins, $deprecated = '' ) { global $wp_filesystem; if ( empty( $plugins ) ) { return false; } $checked = array(); foreach ( $plugins as $plugin ) { $checked[] = 'checked[]=' . $plugin; } $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&' . implode( '&', $checked ), 'bulk-plugins' ); ob_start(); $credentials = request_filesystem_credentials( $url ); $data = ob_get_clean(); if ( false === $credentials ) { if ( ! empty( $data ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; echo $data; require_once ABSPATH . 'wp-admin/admin-footer.php'; exit; } return; } if ( ! WP_Filesystem( $credentials ) ) { ob_start(); request_filesystem_credentials( $url, '', true ); $data = ob_get_clean(); if ( ! empty( $data ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; echo $data; require_once ABSPATH . 'wp-admin/admin-footer.php'; exit; } return; } if ( ! is_object( $wp_filesystem ) ) { return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) ); } if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors ); } $plugins_dir = $wp_filesystem->wp_plugins_dir(); if ( empty( $plugins_dir ) ) { return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) ); } $plugins_dir = trailingslashit( $plugins_dir ); $plugin_translations = wp_get_installed_translations( 'plugins' ); $errors = array(); foreach ( $plugins as $plugin_file ) { if ( is_uninstallable_plugin( $plugin_file ) ) { uninstall_plugin( $plugin_file ); } do_action( 'delete_plugin', $plugin_file ); $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); if ( strpos( $plugin_file, '/' ) && $this_plugin_dir !== $plugins_dir ) { $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); } else { $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); } do_action( 'deleted_plugin', $plugin_file, $deleted ); if ( ! $deleted ) { $errors[] = $plugin_file; continue; } $plugin_slug = dirname( $plugin_file ); if ( 'hello.php' === $plugin_file ) { $plugin_slug = 'hello-dolly'; } if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) { $translations = $plugin_translations[ $plugin_slug ]; foreach ( $translations as $translation => $data ) { $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' ); $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' ); $json_translation_files = glob( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '-*.json' ); if ( $json_translation_files ) { array_map( array( $wp_filesystem, 'delete' ), $json_translation_files ); } } } } $current = get_site_transient( 'update_plugins' ); if ( $current ) { $deleted = array_diff( $plugins, $errors ); foreach ( $deleted as $plugin_file ) { unset( $current->response[ $plugin_file ] ); } set_site_transient( 'update_plugins', $current ); } if ( ! empty( $errors ) ) { if ( 1 === count( $errors ) ) { $message = __( 'Could not fully remove the plugin %s.' ); } else { $message = __( 'Could not fully remove the plugins %s.' ); } return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); } return true; } function validate_active_plugins() { $plugins = get_option( 'active_plugins', array() ); if ( ! is_array( $plugins ) ) { update_option( 'active_plugins', array() ); $plugins = array(); } if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); $plugins = array_merge( $plugins, array_keys( $network_plugins ) ); } if ( empty( $plugins ) ) { return array(); } $invalid = array(); foreach ( $plugins as $plugin ) { $result = validate_plugin( $plugin ); if ( is_wp_error( $result ) ) { $invalid[ $plugin ] = $result; deactivate_plugins( $plugin, true ); } } return $invalid; } function validate_plugin( $plugin ) { if ( validate_file( $plugin ) ) { return new WP_Error( 'plugin_invalid', __( 'Invalid plugin path.' ) ); } if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) { return new WP_Error( 'plugin_not_found', __( 'Plugin file does not exist.' ) ); } $installed_plugins = get_plugins(); if ( ! isset( $installed_plugins[ $plugin ] ) ) { return new WP_Error( 'no_plugin_header', __( 'The plugin does not have a valid header.' ) ); } return 0; } function validate_plugin_requirements( $plugin ) { $plugin_headers = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $requirements = array( 'requires' => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '', 'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '', ); $compatible_wp = is_wp_version_compatible( $requirements['requires'] ); $compatible_php = is_php_version_compatible( $requirements['requires_php'] ); $php_update_message = '

    ' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); $annotation = wp_get_update_php_annotation(); if ( $annotation ) { $php_update_message .= '

    ' . $annotation . ''; } if ( ! $compatible_wp && ! $compatible_php ) { return new WP_Error( 'plugin_wp_php_incompatible', '

    ' . sprintf( _x( 'Error: Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ), get_bloginfo( 'version' ), PHP_VERSION, $plugin_headers['Name'], $requirements['requires'], $requirements['requires_php'] ) . $php_update_message . '

    ' ); } elseif ( ! $compatible_php ) { return new WP_Error( 'plugin_php_incompatible', '

    ' . sprintf( _x( 'Error: Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ), PHP_VERSION, $plugin_headers['Name'], $requirements['requires_php'] ) . $php_update_message . '

    ' ); } elseif ( ! $compatible_wp ) { return new WP_Error( 'plugin_wp_incompatible', '

    ' . sprintf( _x( 'Error: Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ), get_bloginfo( 'version' ), $plugin_headers['Name'], $requirements['requires'] ) . '

    ' ); } return true; } function is_uninstallable_plugin( $plugin ) { $file = plugin_basename( $plugin ); $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) { return true; } return false; } function uninstall_plugin( $plugin ) { $file = plugin_basename( $plugin ); $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins ); if ( file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) { if ( isset( $uninstallable_plugins[ $file ] ) ) { unset( $uninstallable_plugins[ $file ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); } unset( $uninstallable_plugins ); define( 'WP_UNINSTALL_PLUGIN', $file ); wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); include_once WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php'; return true; } if ( isset( $uninstallable_plugins[ $file ] ) ) { $callable = $uninstallable_plugins[ $file ]; unset( $uninstallable_plugins[ $file ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); unset( $uninstallable_plugins ); wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); include_once WP_PLUGIN_DIR . '/' . $file; add_action( "uninstall_{$file}", $callable ); do_action( "uninstall_{$file}" ); } } function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) { global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; $menu_slug = plugin_basename( $menu_slug ); $admin_page_hooks[ $menu_slug ] = sanitize_title( $menu_title ); $hookname = get_plugin_page_hookname( $menu_slug, '' ); if ( ! empty( $callback ) && ! empty( $hookname ) && current_user_can( $capability ) ) { add_action( $hookname, $callback ); } if ( empty( $icon_url ) ) { $icon_url = 'dashicons-admin-generic'; $icon_class = 'menu-icon-generic '; } else { $icon_url = set_url_scheme( $icon_url ); $icon_class = ''; } $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); if ( null !== $position && ! is_numeric( $position ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The seventh parameter passed to %s should be numeric representing menu position.' ), 'add_menu_page()' ), '6.0.0' ); $position = null; } if ( null === $position || ! is_numeric( $position ) ) { $menu[] = $new_menu; } elseif ( isset( $menu[ (string) $position ] ) ) { $collision_avoider = base_convert( substr( md5( $menu_slug . $menu_title ), -4 ), 16, 10 ) * 0.00001; $position = (string) ( $position + $collision_avoider ); $menu[ $position ] = $new_menu; } else { $position = (string) $position; $menu[ $position ] = $new_menu; } $_registered_pages[ $hookname ] = true; $_parent_pages[ $menu_slug ] = false; return $hookname; } function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, $_registered_pages, $_parent_pages; $menu_slug = plugin_basename( $menu_slug ); $parent_slug = plugin_basename( $parent_slug ); if ( isset( $_wp_real_parent_file[ $parent_slug ] ) ) { $parent_slug = $_wp_real_parent_file[ $parent_slug ]; } if ( ! current_user_can( $capability ) ) { $_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] = true; return false; } if ( ! isset( $submenu[ $parent_slug ] ) && $menu_slug !== $parent_slug ) { foreach ( (array) $menu as $parent_menu ) { if ( $parent_menu[2] === $parent_slug && current_user_can( $parent_menu[1] ) ) { $submenu[ $parent_slug ][] = array_slice( $parent_menu, 0, 4 ); } } } $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); if ( null !== $position && ! is_numeric( $position ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The seventh parameter passed to %s should be numeric representing menu position.' ), 'add_submenu_page()' ), '5.3.0' ); $position = null; } if ( null === $position || ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) ) ) { $submenu[ $parent_slug ][] = $new_sub_menu; } else { $position = max( $position, 0 ); if ( 0 === $position ) { array_unshift( $submenu[ $parent_slug ], $new_sub_menu ); } else { $position = absint( $position ); $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true ); $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true ); $before_items[] = $new_sub_menu; $submenu[ $parent_slug ] = array_merge( $before_items, $after_items ); } } ksort( $submenu[ $parent_slug ] ); $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); if ( ! empty( $callback ) && ! empty( $hookname ) ) { add_action( $hookname, $callback ); } $_registered_pages[ $hookname ] = true; if ( 'tools.php' === $parent_slug ) { $_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true; } $_parent_pages[ $menu_slug ] = $parent_slug; return $hookname; } function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { if ( current_user_can( 'edit_users' ) ) { $parent = 'users.php'; } else { $parent = 'profile.php'; } return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); } function remove_menu_page( $menu_slug ) { global $menu; foreach ( $menu as $i => $item ) { if ( $menu_slug === $item[2] ) { unset( $menu[ $i ] ); return $item; } } return false; } function remove_submenu_page( $menu_slug, $submenu_slug ) { global $submenu; if ( ! isset( $submenu[ $menu_slug ] ) ) { return false; } foreach ( $submenu[ $menu_slug ] as $i => $item ) { if ( $submenu_slug === $item[2] ) { unset( $submenu[ $menu_slug ][ $i ] ); return $item; } } return false; } function menu_page_url( $menu_slug, $display = true ) { global $_parent_pages; if ( isset( $_parent_pages[ $menu_slug ] ) ) { $parent_slug = $_parent_pages[ $menu_slug ]; if ( $parent_slug && ! isset( $_parent_pages[ $parent_slug ] ) ) { $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); } else { $url = admin_url( 'admin.php?page=' . $menu_slug ); } } else { $url = ''; } $url = esc_url( $url ); if ( $display ) { echo $url; } return $url; } function get_admin_page_parent( $parent_page = '' ) { global $parent_file, $menu, $submenu, $pagenow, $typenow, $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) { if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) { $parent_page = $_wp_real_parent_file[ $parent_page ]; } return $parent_page; } if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) { foreach ( (array) $menu as $parent_menu ) { if ( $parent_menu[2] === $plugin_page ) { $parent_file = $plugin_page; if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { $parent_file = $_wp_real_parent_file[ $parent_file ]; } return $parent_file; } } if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { $parent_file = $plugin_page; if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { $parent_file = $_wp_real_parent_file[ $parent_file ]; } return $parent_file; } } if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) { $parent_file = $pagenow; if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { $parent_file = $_wp_real_parent_file[ $parent_file ]; } return $parent_file; } foreach ( array_keys( (array) $submenu ) as $parent_page ) { foreach ( $submenu[ $parent_page ] as $submenu_array ) { if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) { $parent_page = $_wp_real_parent_file[ $parent_page ]; } if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) { $parent_file = $parent_page; return $parent_page; } elseif ( empty( $typenow ) && $pagenow === $submenu_array[2] && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) ) ) { $parent_file = $parent_page; return $parent_page; } elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) { $parent_file = $parent_page; return $parent_page; } } } if ( empty( $parent_file ) ) { $parent_file = ''; } return ''; } function get_admin_page_title() { global $title, $menu, $submenu, $pagenow, $typenow, $plugin_page; if ( ! empty( $title ) ) { return $title; } $hook = get_plugin_page_hook( $plugin_page, $pagenow ); $parent = get_admin_page_parent(); $parent1 = $parent; if ( empty( $parent ) ) { foreach ( (array) $menu as $menu_array ) { if ( isset( $menu_array[3] ) ) { if ( $menu_array[2] === $pagenow ) { $title = $menu_array[3]; return $menu_array[3]; } elseif ( isset( $plugin_page ) && $plugin_page === $menu_array[2] && $hook === $menu_array[5] ) { $title = $menu_array[3]; return $menu_array[3]; } } else { $title = $menu_array[0]; return $title; } } } else { foreach ( array_keys( $submenu ) as $parent ) { foreach ( $submenu[ $parent ] as $submenu_array ) { if ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] && ( $pagenow === $parent || $plugin_page === $parent || $plugin_page === $hook || 'admin.php' === $pagenow && $parent1 !== $submenu_array[2] || ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $parent ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } if ( $submenu_array[2] !== $pagenow || isset( $_GET['page'] ) ) { continue; } if ( isset( $submenu_array[3] ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } else { $title = $submenu_array[0]; return $title; } } } if ( empty( $title ) ) { foreach ( $menu as $menu_array ) { if ( isset( $plugin_page ) && $plugin_page === $menu_array[2] && 'admin.php' === $pagenow && $parent1 === $menu_array[2] ) { $title = $menu_array[3]; return $menu_array[3]; } } } } return $title; } function get_plugin_page_hook( $plugin_page, $parent_page ) { $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); if ( has_action( $hook ) ) { return $hook; } else { return null; } } function get_plugin_page_hookname( $plugin_page, $parent_page ) { global $admin_page_hooks; $parent = get_admin_page_parent( $parent_page ); $page_type = 'admin'; if ( empty( $parent_page ) || 'admin.php' === $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) { if ( isset( $admin_page_hooks[ $plugin_page ] ) ) { $page_type = 'toplevel'; } elseif ( isset( $admin_page_hooks[ $parent ] ) ) { $page_type = $admin_page_hooks[ $parent ]; } } elseif ( isset( $admin_page_hooks[ $parent ] ) ) { $page_type = $admin_page_hooks[ $parent ]; } $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); return $page_type . '_page_' . $plugin_name; } function user_can_access_admin_page() { global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv, $plugin_page, $_registered_pages; $parent = get_admin_page_parent(); if ( ! isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) ) { return false; } if ( isset( $plugin_page ) ) { if ( isset( $_wp_submenu_nopriv[ $parent ][ $plugin_page ] ) ) { return false; } $hookname = get_plugin_page_hookname( $plugin_page, $parent ); if ( ! isset( $_registered_pages[ $hookname ] ) ) { return false; } } if ( empty( $parent ) ) { if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) { return false; } if ( isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) ) { return false; } if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) { return false; } if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { return false; } foreach ( array_keys( $_wp_submenu_nopriv ) as $key ) { if ( isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) ) { return false; } if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) { return false; } } return true; } if ( isset( $plugin_page ) && $plugin_page === $parent && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { return false; } if ( isset( $submenu[ $parent ] ) ) { foreach ( $submenu[ $parent ] as $submenu_array ) { if ( isset( $plugin_page ) && $submenu_array[2] === $plugin_page ) { return current_user_can( $submenu_array[1] ); } elseif ( $submenu_array[2] === $pagenow ) { return current_user_can( $submenu_array[1] ); } } } foreach ( $menu as $menu_array ) { if ( $menu_array[2] === $parent ) { return current_user_can( $menu_array[1] ); } } return true; } function option_update_filter( $options ) { global $new_allowed_options; if ( is_array( $new_allowed_options ) ) { $options = add_allowed_options( $new_allowed_options, $options ); } return $options; } function add_allowed_options( $new_options, $options = '' ) { if ( '' === $options ) { global $allowed_options; } else { $allowed_options = $options; } foreach ( $new_options as $page => $keys ) { foreach ( $keys as $key ) { if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) { $allowed_options[ $page ] = array(); $allowed_options[ $page ][] = $key; } else { $pos = array_search( $key, $allowed_options[ $page ], true ); if ( false === $pos ) { $allowed_options[ $page ][] = $key; } } } } return $allowed_options; } function remove_allowed_options( $del_options, $options = '' ) { if ( '' === $options ) { global $allowed_options; } else { $allowed_options = $options; } foreach ( $del_options as $page => $keys ) { foreach ( $keys as $key ) { if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) { $pos = array_search( $key, $allowed_options[ $page ], true ); if ( false !== $pos ) { unset( $allowed_options[ $page ][ $pos ] ); } } } } return $allowed_options; } function settings_fields( $option_group ) { echo ""; echo ''; wp_nonce_field( "$option_group-options" ); } function wp_clean_plugins_cache( $clear_update_cache = true ) { if ( $clear_update_cache ) { delete_site_transient( 'update_plugins' ); } wp_cache_delete( 'plugins', 'plugins' ); } function plugin_sandbox_scrape( $plugin ) { if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { define( 'WP_SANDBOX_SCRAPING', true ); } wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); include_once WP_PLUGIN_DIR . '/' . $plugin; } function wp_add_privacy_policy_content( $plugin_name, $policy_text ) { if ( ! is_admin() ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.' ), 'admin_init' ), '4.9.7' ); return; } elseif ( ! doing_action( 'admin_init' ) && ! did_action( 'admin_init' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.' ), 'admin_init' ), '4.9.7' ); return; } if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php'; } WP_Privacy_Policy_Content::add( $plugin_name, $policy_text ); } function is_plugin_paused( $plugin ) { if ( ! isset( $GLOBALS['_paused_plugins'] ) ) { return false; } if ( ! is_plugin_active( $plugin ) ) { return false; } list( $plugin ) = explode( '/', $plugin ); return array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ); } function wp_get_plugin_error( $plugin ) { if ( ! isset( $GLOBALS['_paused_plugins'] ) ) { return false; } list( $plugin ) = explode( '/', $plugin ); if ( ! array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ) ) { return false; } return $GLOBALS['_paused_plugins'][ $plugin ]; } function resume_plugin( $plugin, $redirect = '' ) { if ( ! empty( $redirect ) ) { wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-resume-error_' . $plugin ), $redirect ) ); ob_start(); plugin_sandbox_scrape( $plugin ); ob_clean(); } list( $extension ) = explode( '/', $plugin ); $result = wp_paused_plugins()->delete( $extension ); if ( ! $result ) { return new WP_Error( 'could_not_resume_plugin', __( 'Could not resume the plugin.' ) ); } return true; } function paused_plugins_notice() { if ( 'plugins.php' === $GLOBALS['pagenow'] ) { return; } if ( ! current_user_can( 'resume_plugins' ) ) { return; } if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) { return; } printf( '

    %s
    %s

    %s

    ', __( 'One or more plugins failed to load properly.' ), __( 'You can find more details and make changes on the Plugins screen.' ), esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ), __( 'Go to the Plugins screen' ) ); } function deactivated_plugins_notice() { if ( 'plugins.php' === $GLOBALS['pagenow'] ) { return; } if ( ! current_user_can( 'activate_plugins' ) ) { return; } $blog_deactivated_plugins = get_option( 'wp_force_deactivated_plugins' ); $site_deactivated_plugins = array(); if ( false === $blog_deactivated_plugins ) { update_option( 'wp_force_deactivated_plugins', array() ); } if ( is_multisite() ) { $site_deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins' ); if ( false === $site_deactivated_plugins ) { update_site_option( 'wp_force_deactivated_plugins', array() ); } } if ( empty( $blog_deactivated_plugins ) && empty( $site_deactivated_plugins ) ) { return; } $deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins ); foreach ( $deactivated_plugins as $plugin ) { if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) { $explanation = sprintf( __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ), $plugin['plugin_name'], $plugin['version_deactivated'], $GLOBALS['wp_version'], $plugin['version_compatible'] ); } else { $explanation = sprintf( __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ), $plugin['plugin_name'], ! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '', $GLOBALS['wp_version'], $plugin['version_compatible'] ); } printf( '

    %s
    %s

    %s

    ', sprintf( __( '%s plugin deactivated during WordPress upgrade.' ), $plugin['plugin_name'] ), $explanation, esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ), __( 'Go to the Plugins screen' ) ); } update_option( 'wp_force_deactivated_plugins', array() ); if ( is_multisite() ) { update_site_option( 'wp_force_deactivated_plugins', array() ); } } cap->create_posts ) ) { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); } } if ( isset( $post_data['content'] ) ) { $post_data['post_content'] = $post_data['content']; } if ( isset( $post_data['excerpt'] ) ) { $post_data['post_excerpt'] = $post_data['excerpt']; } if ( isset( $post_data['parent_id'] ) ) { $post_data['post_parent'] = (int) $post_data['parent_id']; } if ( isset( $post_data['trackback_url'] ) ) { $post_data['to_ping'] = $post_data['trackback_url']; } $post_data['user_ID'] = get_current_user_id(); if ( ! empty( $post_data['post_author_override'] ) ) { $post_data['post_author'] = (int) $post_data['post_author_override']; } else { if ( ! empty( $post_data['post_author'] ) ) { $post_data['post_author'] = (int) $post_data['post_author']; } else { $post_data['post_author'] = (int) $post_data['user_ID']; } } if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) && ! current_user_can( $ptype->cap->edit_others_posts ) ) { if ( $update ) { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); } } else { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); } } } if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'auto-draft' === $post_data['post_status'] ) { $post_data['post_status'] = 'draft'; } if ( ! get_post_status_object( $post_data['post_status'] ) ) { unset( $post_data['post_status'] ); } } if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) { $post_data['post_status'] = 'draft'; } if ( isset( $post_data['saveasprivate'] ) && '' !== $post_data['saveasprivate'] ) { $post_data['post_status'] = 'private'; } if ( isset( $post_data['publish'] ) && ( '' !== $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) ) { $post_data['post_status'] = 'publish'; } if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) { $post_data['post_status'] = 'draft'; } if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) { $post_data['post_status'] = 'pending'; } if ( isset( $post_data['ID'] ) ) { $post_id = $post_data['ID']; } else { $post_id = false; } $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; } $published_statuses = array( 'publish', 'future' ); if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses, true ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) { if ( ! in_array( $previous_status, $published_statuses, true ) || ! current_user_can( 'edit_post', $post_id ) ) { $post_data['post_status'] = 'pending'; } } if ( ! isset( $post_data['post_status'] ) ) { $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; } if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { unset( $post_data['post_password'] ); } if ( ! isset( $post_data['comment_status'] ) ) { $post_data['comment_status'] = 'closed'; } if ( ! isset( $post_data['ping_status'] ) ) { $post_data['ping_status'] = 'closed'; } foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) { if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) { $post_data['edit_date'] = '1'; break; } } if ( ! empty( $post_data['edit_date'] ) ) { $aa = $post_data['aa']; $mm = $post_data['mm']; $jj = $post_data['jj']; $hh = $post_data['hh']; $mn = $post_data['mn']; $ss = $post_data['ss']; $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; $jj = ( $jj > 31 ) ? 31 : $jj; $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; $hh = ( $hh > 23 ) ? $hh - 24 : $hh; $mn = ( $mn > 59 ) ? $mn - 60 : $mn; $ss = ( $ss > 59 ) ? $ss - 60 : $ss; $post_data['post_date'] = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss ); $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); if ( ! $valid_date ) { return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); } $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); } if ( isset( $post_data['post_category'] ) ) { $category_object = get_taxonomy( 'category' ); if ( ! current_user_can( $category_object->cap->assign_terms ) ) { unset( $post_data['post_category'] ); } } return $post_data; } function _wp_get_allowed_postdata( $post_data = null ) { if ( empty( $post_data ) ) { $post_data = $_POST; } if ( is_wp_error( $post_data ) ) { return $post_data; } return array_diff_key( $post_data, array_flip( array( 'meta_input', 'file', 'guid' ) ) ); } function edit_post( $post_data = null ) { global $wpdb; if ( empty( $post_data ) ) { $post_data = &$_POST; } unset( $post_data['filter'] ); $post_ID = (int) $post_data['post_ID']; $post = get_post( $post_ID ); $post_data['post_type'] = $post->post_type; $post_data['post_mime_type'] = $post->post_mime_type; if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } $ptype = get_post_type_object( $post_data['post_type'] ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { if ( 'page' === $post_data['post_type'] ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } } if ( post_type_supports( $ptype->name, 'revisions' ) ) { $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1, ) ); $revision = current( $revisions ); if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); } } if ( isset( $post_data['visibility'] ) ) { switch ( $post_data['visibility'] ) { case 'public': $post_data['post_password'] = ''; break; case 'password': unset( $post_data['sticky'] ); break; case 'private': $post_data['post_status'] = 'private'; $post_data['post_password'] = ''; unset( $post_data['sticky'] ); break; } } $post_data = _wp_translate_postdata( true, $post_data ); if ( is_wp_error( $post_data ) ) { wp_die( $post_data->get_error_message() ); } $translated = _wp_get_allowed_postdata( $post_data ); if ( isset( $post_data['post_format'] ) ) { set_post_format( $post_ID, $post_data['post_format'] ); } $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); foreach ( $format_meta_urls as $format_meta_url ) { $keyed = '_format_' . $format_meta_url; if ( isset( $post_data[ $keyed ] ) ) { update_post_meta( $post_ID, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) ); } } $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); foreach ( $format_keys as $key ) { $keyed = '_format_' . $key; if ( isset( $post_data[ $keyed ] ) ) { if ( current_user_can( 'unfiltered_html' ) ) { update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); } else { update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); } } } if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { $id3data = wp_get_attachment_metadata( $post_ID ); if ( ! is_array( $id3data ) ) { $id3data = array(); } foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { if ( isset( $post_data[ 'id3_' . $key ] ) ) { $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); } } wp_update_attachment_metadata( $post_ID, $id3data ); } if ( isset( $post_data['meta'] ) && $post_data['meta'] ) { foreach ( $post_data['meta'] as $key => $value ) { $meta = get_post_meta_by_id( $key ); if ( ! $meta ) { continue; } if ( $meta->post_id != $post_ID ) { continue; } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) { continue; } if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { continue; } update_meta( $key, $value['key'], $value['value'] ); } } if ( isset( $post_data['deletemeta'] ) && $post_data['deletemeta'] ) { foreach ( $post_data['deletemeta'] as $key => $value ) { $meta = get_post_meta_by_id( $key ); if ( ! $meta ) { continue; } if ( $meta->post_id != $post_ID ) { continue; } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { continue; } delete_meta( $key ); } } if ( 'attachment' === $post_data['post_type'] ) { if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) { $image_alt = wp_strip_all_tags( $image_alt, true ); update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); } } $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); $translated = apply_filters( 'attachment_fields_to_save', $translated, $attachment_data ); } if ( isset( $post_data['tax_input'] ) ) { foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { $tax_object = get_taxonomy( $taxonomy ); if ( $tax_object && isset( $tax_object->meta_box_sanitize_cb ) ) { $translated['tax_input'][ $taxonomy ] = call_user_func_array( $tax_object->meta_box_sanitize_cb, array( $taxonomy, $terms ) ); } } } add_meta( $post_ID ); update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); $success = wp_update_post( $translated ); if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { $fields = array( 'post_title', 'post_content', 'post_excerpt' ); foreach ( $fields as $field ) { if ( isset( $translated[ $field ] ) ) { $translated[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $translated[ $field ] ); } } wp_update_post( $translated ); } _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { if ( ! empty( $post_data['sticky'] ) ) { stick_post( $post_ID ); } else { unstick_post( $post_ID ); } } return $post_ID; } function bulk_edit_posts( $post_data = null ) { global $wpdb; if ( empty( $post_data ) ) { $post_data = &$_POST; } if ( isset( $post_data['post_type'] ) ) { $ptype = get_post_type_object( $post_data['post_type'] ); } else { $ptype = get_post_type_object( 'post' ); } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { if ( 'page' === $ptype->name ) { wp_die( __( 'Sorry, you are not allowed to edit pages.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit posts.' ) ); } } if ( -1 == $post_data['_status'] ) { $post_data['post_status'] = null; unset( $post_data['post_status'] ); } else { $post_data['post_status'] = $post_data['_status']; } unset( $post_data['_status'] ); if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } $post_IDs = array_map( 'intval', (array) $post_data['post'] ); $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky', 'post_format', ); foreach ( $reset as $field ) { if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { unset( $post_data[ $field ] ); } } if ( isset( $post_data['post_category'] ) ) { if ( is_array( $post_data['post_category'] ) && ! empty( $post_data['post_category'] ) ) { $new_cats = array_map( 'absint', $post_data['post_category'] ); } else { unset( $post_data['post_category'] ); } } $tax_input = array(); if ( isset( $post_data['tax_input'] ) ) { foreach ( $post_data['tax_input'] as $tax_name => $terms ) { if ( empty( $terms ) ) { continue; } if ( is_taxonomy_hierarchical( $tax_name ) ) { $tax_input[ $tax_name ] = array_map( 'absint', $terms ); } else { $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $terms = str_replace( $comma, ',', $terms ); } $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); } } } if ( isset( $post_data['post_parent'] ) && (int) $post_data['post_parent'] ) { $parent = (int) $post_data['post_parent']; $pages = $wpdb->get_results( "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'" ); $children = array(); for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { $children[] = $parent; foreach ( $pages as $page ) { if ( (int) $page->ID === $parent ) { $parent = (int) $page->post_parent; break; } } } } $updated = array(); $skipped = array(); $locked = array(); $shared_post_data = $post_data; foreach ( $post_IDs as $post_ID ) { $post_data = $shared_post_data; $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); if ( ! isset( $post_type_object ) || ( isset( $children ) && in_array( $post_ID, $children, true ) ) || ! current_user_can( 'edit_post', $post_ID ) ) { $skipped[] = $post_ID; continue; } if ( wp_check_post_lock( $post_ID ) ) { $locked[] = $post_ID; continue; } $post = get_post( $post_ID ); $tax_names = get_object_taxonomies( $post ); foreach ( $tax_names as $tax_name ) { $taxonomy_obj = get_taxonomy( $tax_name ); if ( ! $taxonomy_obj->show_in_quick_edit ) { continue; } if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { $new_terms = $tax_input[ $tax_name ]; } else { $new_terms = array(); } if ( $taxonomy_obj->hierarchical ) { $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) ); } else { $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) ); } $post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms ); } if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) { $cats = (array) wp_get_post_categories( $post_ID ); $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) ); unset( $post_data['tax_input']['category'] ); } $post_data['post_ID'] = $post_ID; $post_data['post_type'] = $post->post_type; $post_data['post_mime_type'] = $post->post_mime_type; foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { if ( ! isset( $post_data[ $field ] ) ) { $post_data[ $field ] = $post->$field; } } $post_data = _wp_translate_postdata( true, $post_data ); if ( is_wp_error( $post_data ) ) { $skipped[] = $post_ID; continue; } $post_data = _wp_get_allowed_postdata( $post_data ); if ( isset( $shared_post_data['post_format'] ) ) { set_post_format( $post_ID, $shared_post_data['post_format'] ); } unset( $post_data['tax_input']['post_format'] ); $post_id = wp_update_post( $post_data ); update_post_meta( $post_id, '_edit_last', get_current_user_id() ); $updated[] = $post_id; if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { if ( 'sticky' === $post_data['sticky'] ) { stick_post( $post_ID ); } else { unstick_post( $post_ID ); } } } return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked, ); } function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { $post_title = ''; if ( ! empty( $_REQUEST['post_title'] ) ) { $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ) ); } $post_content = ''; if ( ! empty( $_REQUEST['content'] ) ) { $post_content = esc_html( wp_unslash( $_REQUEST['content'] ) ); } $post_excerpt = ''; if ( ! empty( $_REQUEST['excerpt'] ) ) { $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ) ); } if ( $create_in_db ) { $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft', ), false, false ); $post = get_post( $post_id ); if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { set_post_format( $post, get_option( 'default_post_format' ) ); } wp_after_insert_post( $post, false, null ); if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) { wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); } } else { $post = new stdClass(); $post->ID = 0; $post->post_author = ''; $post->post_date = ''; $post->post_date_gmt = ''; $post->post_password = ''; $post->post_name = ''; $post->post_type = $post_type; $post->post_status = 'draft'; $post->to_ping = ''; $post->pinged = ''; $post->comment_status = get_default_comment_status( $post_type ); $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); $post->post_pingback = get_option( 'default_pingback_flag' ); $post->post_category = get_option( 'default_category' ); $post->page_template = 'default'; $post->post_parent = 0; $post->menu_order = 0; $post = new WP_Post( $post ); } $post->post_content = (string) apply_filters( 'default_content', $post_content, $post ); $post->post_title = (string) apply_filters( 'default_title', $post_title, $post ); $post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post ); return $post; } function post_exists( $title, $content = '', $date = '', $type = '', $status = '' ) { global $wpdb; $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); $post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) ); $post_status = wp_unslash( sanitize_post_field( 'post_status', $status, 0, 'db' ) ); $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; $args = array(); if ( ! empty( $date ) ) { $query .= ' AND post_date = %s'; $args[] = $post_date; } if ( ! empty( $title ) ) { $query .= ' AND post_title = %s'; $args[] = $post_title; } if ( ! empty( $content ) ) { $query .= ' AND post_content = %s'; $args[] = $post_content; } if ( ! empty( $type ) ) { $query .= ' AND post_type = %s'; $args[] = $post_type; } if ( ! empty( $status ) ) { $query .= ' AND post_status = %s'; $args[] = $post_status; } if ( ! empty( $args ) ) { return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) ); } return 0; } function wp_write_post() { if ( isset( $_POST['post_type'] ) ) { $ptype = get_post_type_object( $_POST['post_type'] ); } else { $ptype = get_post_type_object( 'post' ); } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { if ( 'page' === $ptype->name ) { return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); } else { return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); } } $_POST['post_mime_type'] = ''; unset( $_POST['filter'] ); if ( isset( $_POST['post_ID'] ) ) { return edit_post(); } if ( isset( $_POST['visibility'] ) ) { switch ( $_POST['visibility'] ) { case 'public': $_POST['post_password'] = ''; break; case 'password': unset( $_POST['sticky'] ); break; case 'private': $_POST['post_status'] = 'private'; $_POST['post_password'] = ''; unset( $_POST['sticky'] ); break; } } $translated = _wp_translate_postdata( false ); if ( is_wp_error( $translated ) ) { return $translated; } $translated = _wp_get_allowed_postdata( $translated ); $post_ID = wp_insert_post( $translated ); if ( is_wp_error( $post_ID ) ) { return $post_ID; } if ( empty( $post_ID ) ) { return 0; } add_meta( $post_ID ); add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); return $post_ID; } function write_post() { $result = wp_write_post(); if ( is_wp_error( $result ) ) { wp_die( $result->get_error_message() ); } else { return $result; } } function add_meta( $post_ID ) { $post_ID = (int) $post_ID; $metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; $metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; $metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : ''; if ( is_string( $metavalue ) ) { $metavalue = trim( $metavalue ); } if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { if ( '#NONE#' !== $metakeyselect ) { $metakey = $metakeyselect; } if ( $metakeyinput ) { $metakey = $metakeyinput; } if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { return false; } $metakey = wp_slash( $metakey ); return add_post_meta( $post_ID, $metakey, $metavalue ); } return false; } function delete_meta( $mid ) { return delete_metadata_by_mid( 'post', $mid ); } function get_meta_keys() { global $wpdb; $keys = $wpdb->get_col( " + function _wp_translate_postdata( $update = false, $post_data = null ) { if ( empty( $post_data ) ) { $post_data = &$_POST; } if ( $update ) { $post_data['ID'] = (int) $post_data['post_ID']; } $ptype = get_post_type_object( $post_data['post_type'] ); if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); } } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); } } if ( isset( $post_data['content'] ) ) { $post_data['post_content'] = $post_data['content']; } if ( isset( $post_data['excerpt'] ) ) { $post_data['post_excerpt'] = $post_data['excerpt']; } if ( isset( $post_data['parent_id'] ) ) { $post_data['post_parent'] = (int) $post_data['parent_id']; } if ( isset( $post_data['trackback_url'] ) ) { $post_data['to_ping'] = $post_data['trackback_url']; } $post_data['user_ID'] = get_current_user_id(); if ( ! empty( $post_data['post_author_override'] ) ) { $post_data['post_author'] = (int) $post_data['post_author_override']; } else { if ( ! empty( $post_data['post_author'] ) ) { $post_data['post_author'] = (int) $post_data['post_author']; } else { $post_data['post_author'] = (int) $post_data['user_ID']; } } if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) && ! current_user_can( $ptype->cap->edit_others_posts ) ) { if ( $update ) { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); } } else { if ( 'page' === $post_data['post_type'] ) { return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); } else { return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); } } } if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'auto-draft' === $post_data['post_status'] ) { $post_data['post_status'] = 'draft'; } if ( ! get_post_status_object( $post_data['post_status'] ) ) { unset( $post_data['post_status'] ); } } if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) { $post_data['post_status'] = 'draft'; } if ( isset( $post_data['saveasprivate'] ) && '' !== $post_data['saveasprivate'] ) { $post_data['post_status'] = 'private'; } if ( isset( $post_data['publish'] ) && ( '' !== $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) ) { $post_data['post_status'] = 'publish'; } if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) { $post_data['post_status'] = 'draft'; } if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) { $post_data['post_status'] = 'pending'; } if ( isset( $post_data['ID'] ) ) { $post_id = $post_data['ID']; } else { $post_id = false; } $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; } $published_statuses = array( 'publish', 'future' ); if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses, true ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) { if ( ! in_array( $previous_status, $published_statuses, true ) || ! current_user_can( 'edit_post', $post_id ) ) { $post_data['post_status'] = 'pending'; } } if ( ! isset( $post_data['post_status'] ) ) { $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; } if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { unset( $post_data['post_password'] ); } if ( ! isset( $post_data['comment_status'] ) ) { $post_data['comment_status'] = 'closed'; } if ( ! isset( $post_data['ping_status'] ) ) { $post_data['ping_status'] = 'closed'; } foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) { if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) { $post_data['edit_date'] = '1'; break; } } if ( ! empty( $post_data['edit_date'] ) ) { $aa = $post_data['aa']; $mm = $post_data['mm']; $jj = $post_data['jj']; $hh = $post_data['hh']; $mn = $post_data['mn']; $ss = $post_data['ss']; $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; $jj = ( $jj > 31 ) ? 31 : $jj; $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; $hh = ( $hh > 23 ) ? $hh - 24 : $hh; $mn = ( $mn > 59 ) ? $mn - 60 : $mn; $ss = ( $ss > 59 ) ? $ss - 60 : $ss; $post_data['post_date'] = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss ); $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); if ( ! $valid_date ) { return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); } $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); } if ( isset( $post_data['post_category'] ) ) { $category_object = get_taxonomy( 'category' ); if ( ! current_user_can( $category_object->cap->assign_terms ) ) { unset( $post_data['post_category'] ); } } return $post_data; } function _wp_get_allowed_postdata( $post_data = null ) { if ( empty( $post_data ) ) { $post_data = $_POST; } if ( is_wp_error( $post_data ) ) { return $post_data; } return array_diff_key( $post_data, array_flip( array( 'meta_input', 'file', 'guid' ) ) ); } function edit_post( $post_data = null ) { global $wpdb; if ( empty( $post_data ) ) { $post_data = &$_POST; } unset( $post_data['filter'] ); $post_ID = (int) $post_data['post_ID']; $post = get_post( $post_ID ); $post_data['post_type'] = $post->post_type; $post_data['post_mime_type'] = $post->post_mime_type; if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } $ptype = get_post_type_object( $post_data['post_type'] ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { if ( 'page' === $post_data['post_type'] ) { wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } } if ( post_type_supports( $ptype->name, 'revisions' ) ) { $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1, ) ); $revision = current( $revisions ); if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); } } if ( isset( $post_data['visibility'] ) ) { switch ( $post_data['visibility'] ) { case 'public': $post_data['post_password'] = ''; break; case 'password': unset( $post_data['sticky'] ); break; case 'private': $post_data['post_status'] = 'private'; $post_data['post_password'] = ''; unset( $post_data['sticky'] ); break; } } $post_data = _wp_translate_postdata( true, $post_data ); if ( is_wp_error( $post_data ) ) { wp_die( $post_data->get_error_message() ); } $translated = _wp_get_allowed_postdata( $post_data ); if ( isset( $post_data['post_format'] ) ) { set_post_format( $post_ID, $post_data['post_format'] ); } $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); foreach ( $format_meta_urls as $format_meta_url ) { $keyed = '_format_' . $format_meta_url; if ( isset( $post_data[ $keyed ] ) ) { update_post_meta( $post_ID, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) ); } } $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); foreach ( $format_keys as $key ) { $keyed = '_format_' . $key; if ( isset( $post_data[ $keyed ] ) ) { if ( current_user_can( 'unfiltered_html' ) ) { update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); } else { update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); } } } if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { $id3data = wp_get_attachment_metadata( $post_ID ); if ( ! is_array( $id3data ) ) { $id3data = array(); } foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { if ( isset( $post_data[ 'id3_' . $key ] ) ) { $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); } } wp_update_attachment_metadata( $post_ID, $id3data ); } if ( isset( $post_data['meta'] ) && $post_data['meta'] ) { foreach ( $post_data['meta'] as $key => $value ) { $meta = get_post_meta_by_id( $key ); if ( ! $meta ) { continue; } if ( $meta->post_id != $post_ID ) { continue; } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) { continue; } if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { continue; } update_meta( $key, $value['key'], $value['value'] ); } } if ( isset( $post_data['deletemeta'] ) && $post_data['deletemeta'] ) { foreach ( $post_data['deletemeta'] as $key => $value ) { $meta = get_post_meta_by_id( $key ); if ( ! $meta ) { continue; } if ( $meta->post_id != $post_ID ) { continue; } if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { continue; } delete_meta( $key ); } } if ( 'attachment' === $post_data['post_type'] ) { if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) { $image_alt = wp_strip_all_tags( $image_alt, true ); update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); } } $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); $translated = apply_filters( 'attachment_fields_to_save', $translated, $attachment_data ); } if ( isset( $post_data['tax_input'] ) ) { foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { $tax_object = get_taxonomy( $taxonomy ); if ( $tax_object && isset( $tax_object->meta_box_sanitize_cb ) ) { $translated['tax_input'][ $taxonomy ] = call_user_func_array( $tax_object->meta_box_sanitize_cb, array( $taxonomy, $terms ) ); } } } add_meta( $post_ID ); update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); $success = wp_update_post( $translated ); if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { $fields = array( 'post_title', 'post_content', 'post_excerpt' ); foreach ( $fields as $field ) { if ( isset( $translated[ $field ] ) ) { $translated[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $translated[ $field ] ); } } wp_update_post( $translated ); } _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { if ( ! empty( $post_data['sticky'] ) ) { stick_post( $post_ID ); } else { unstick_post( $post_ID ); } } return $post_ID; } function bulk_edit_posts( $post_data = null ) { global $wpdb; if ( empty( $post_data ) ) { $post_data = &$_POST; } if ( isset( $post_data['post_type'] ) ) { $ptype = get_post_type_object( $post_data['post_type'] ); } else { $ptype = get_post_type_object( 'post' ); } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { if ( 'page' === $ptype->name ) { wp_die( __( 'Sorry, you are not allowed to edit pages.' ) ); } else { wp_die( __( 'Sorry, you are not allowed to edit posts.' ) ); } } if ( -1 == $post_data['_status'] ) { $post_data['post_status'] = null; unset( $post_data['post_status'] ); } else { $post_data['post_status'] = $post_data['_status']; } unset( $post_data['_status'] ); if ( ! empty( $post_data['post_status'] ) ) { $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); if ( 'inherit' === $post_data['post_status'] ) { unset( $post_data['post_status'] ); } } $post_IDs = array_map( 'intval', (array) $post_data['post'] ); $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky', 'post_format', ); foreach ( $reset as $field ) { if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { unset( $post_data[ $field ] ); } } if ( isset( $post_data['post_category'] ) ) { if ( is_array( $post_data['post_category'] ) && ! empty( $post_data['post_category'] ) ) { $new_cats = array_map( 'absint', $post_data['post_category'] ); } else { unset( $post_data['post_category'] ); } } $tax_input = array(); if ( isset( $post_data['tax_input'] ) ) { foreach ( $post_data['tax_input'] as $tax_name => $terms ) { if ( empty( $terms ) ) { continue; } if ( is_taxonomy_hierarchical( $tax_name ) ) { $tax_input[ $tax_name ] = array_map( 'absint', $terms ); } else { $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $terms = str_replace( $comma, ',', $terms ); } $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); } } } if ( isset( $post_data['post_parent'] ) && (int) $post_data['post_parent'] ) { $parent = (int) $post_data['post_parent']; $pages = $wpdb->get_results( "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'" ); $children = array(); for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { $children[] = $parent; foreach ( $pages as $page ) { if ( (int) $page->ID === $parent ) { $parent = (int) $page->post_parent; break; } } } } $updated = array(); $skipped = array(); $locked = array(); $shared_post_data = $post_data; foreach ( $post_IDs as $post_ID ) { $post_data = $shared_post_data; $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); if ( ! isset( $post_type_object ) || ( isset( $children ) && in_array( $post_ID, $children, true ) ) || ! current_user_can( 'edit_post', $post_ID ) ) { $skipped[] = $post_ID; continue; } if ( wp_check_post_lock( $post_ID ) ) { $locked[] = $post_ID; continue; } $post = get_post( $post_ID ); $tax_names = get_object_taxonomies( $post ); foreach ( $tax_names as $tax_name ) { $taxonomy_obj = get_taxonomy( $tax_name ); if ( ! $taxonomy_obj->show_in_quick_edit ) { continue; } if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { $new_terms = $tax_input[ $tax_name ]; } else { $new_terms = array(); } if ( $taxonomy_obj->hierarchical ) { $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) ); } else { $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) ); } $post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms ); } if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) { $cats = (array) wp_get_post_categories( $post_ID ); $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) ); unset( $post_data['tax_input']['category'] ); } $post_data['post_ID'] = $post_ID; $post_data['post_type'] = $post->post_type; $post_data['post_mime_type'] = $post->post_mime_type; foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { if ( ! isset( $post_data[ $field ] ) ) { $post_data[ $field ] = $post->$field; } } $post_data = _wp_translate_postdata( true, $post_data ); if ( is_wp_error( $post_data ) ) { $skipped[] = $post_ID; continue; } $post_data = _wp_get_allowed_postdata( $post_data ); if ( isset( $shared_post_data['post_format'] ) ) { set_post_format( $post_ID, $shared_post_data['post_format'] ); } unset( $post_data['tax_input']['post_format'] ); $post_id = wp_update_post( $post_data ); update_post_meta( $post_id, '_edit_last', get_current_user_id() ); $updated[] = $post_id; if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { if ( 'sticky' === $post_data['sticky'] ) { stick_post( $post_ID ); } else { unstick_post( $post_ID ); } } } do_action( 'bulk_edit_posts', $post_data ); return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked, ); } function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { $post_title = ''; if ( ! empty( $_REQUEST['post_title'] ) ) { $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ) ); } $post_content = ''; if ( ! empty( $_REQUEST['content'] ) ) { $post_content = esc_html( wp_unslash( $_REQUEST['content'] ) ); } $post_excerpt = ''; if ( ! empty( $_REQUEST['excerpt'] ) ) { $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ) ); } if ( $create_in_db ) { $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft', ), false, false ); $post = get_post( $post_id ); if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { set_post_format( $post, get_option( 'default_post_format' ) ); } wp_after_insert_post( $post, false, null ); if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) { wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); } } else { $post = new stdClass(); $post->ID = 0; $post->post_author = ''; $post->post_date = ''; $post->post_date_gmt = ''; $post->post_password = ''; $post->post_name = ''; $post->post_type = $post_type; $post->post_status = 'draft'; $post->to_ping = ''; $post->pinged = ''; $post->comment_status = get_default_comment_status( $post_type ); $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); $post->post_pingback = get_option( 'default_pingback_flag' ); $post->post_category = get_option( 'default_category' ); $post->page_template = 'default'; $post->post_parent = 0; $post->menu_order = 0; $post = new WP_Post( $post ); } $post->post_content = (string) apply_filters( 'default_content', $post_content, $post ); $post->post_title = (string) apply_filters( 'default_title', $post_title, $post ); $post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post ); return $post; } function post_exists( $title, $content = '', $date = '', $type = '', $status = '' ) { global $wpdb; $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); $post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) ); $post_status = wp_unslash( sanitize_post_field( 'post_status', $status, 0, 'db' ) ); $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; $args = array(); if ( ! empty( $date ) ) { $query .= ' AND post_date = %s'; $args[] = $post_date; } if ( ! empty( $title ) ) { $query .= ' AND post_title = %s'; $args[] = $post_title; } if ( ! empty( $content ) ) { $query .= ' AND post_content = %s'; $args[] = $post_content; } if ( ! empty( $type ) ) { $query .= ' AND post_type = %s'; $args[] = $post_type; } if ( ! empty( $status ) ) { $query .= ' AND post_status = %s'; $args[] = $post_status; } if ( ! empty( $args ) ) { return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) ); } return 0; } function wp_write_post() { if ( isset( $_POST['post_type'] ) ) { $ptype = get_post_type_object( $_POST['post_type'] ); } else { $ptype = get_post_type_object( 'post' ); } if ( ! current_user_can( $ptype->cap->edit_posts ) ) { if ( 'page' === $ptype->name ) { return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); } else { return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); } } $_POST['post_mime_type'] = ''; unset( $_POST['filter'] ); if ( isset( $_POST['post_ID'] ) ) { return edit_post(); } if ( isset( $_POST['visibility'] ) ) { switch ( $_POST['visibility'] ) { case 'public': $_POST['post_password'] = ''; break; case 'password': unset( $_POST['sticky'] ); break; case 'private': $_POST['post_status'] = 'private'; $_POST['post_password'] = ''; unset( $_POST['sticky'] ); break; } } $translated = _wp_translate_postdata( false ); if ( is_wp_error( $translated ) ) { return $translated; } $translated = _wp_get_allowed_postdata( $translated ); $post_ID = wp_insert_post( $translated ); if ( is_wp_error( $post_ID ) ) { return $post_ID; } if ( empty( $post_ID ) ) { return 0; } add_meta( $post_ID ); add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); _fix_attachment_links( $post_ID ); wp_set_post_lock( $post_ID ); return $post_ID; } function write_post() { $result = wp_write_post(); if ( is_wp_error( $result ) ) { wp_die( $result->get_error_message() ); } else { return $result; } } function add_meta( $post_ID ) { $post_ID = (int) $post_ID; $metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; $metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; $metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : ''; if ( is_string( $metavalue ) ) { $metavalue = trim( $metavalue ); } if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { if ( '#NONE#' !== $metakeyselect ) { $metakey = $metakeyselect; } if ( $metakeyinput ) { $metakey = $metakeyinput; } if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { return false; } $metakey = wp_slash( $metakey ); return add_post_meta( $post_ID, $metakey, $metavalue ); } return false; } function delete_meta( $mid ) { return delete_metadata_by_mid( 'post', $mid ); } function get_meta_keys() { global $wpdb; $keys = $wpdb->get_col( " SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key @@ -7853,7 +7857,7 @@ document.body.className = c; prepare_items(); $wp_list_table->single_row( $theme ); } function display_themes() { global $wp_list_table; if ( ! isset( $wp_list_table ) ) { $wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); } $wp_list_table->prepare_items(); $wp_list_table->display(); } function install_theme_information() { global $wp_list_table; $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) ); if ( is_wp_error( $theme ) ) { wp_die( $theme ); } iframe_header( __( 'Theme Installation' ) ); if ( ! isset( $wp_list_table ) ) { $wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); } $wp_list_table->theme_installer_single( $theme ); iframe_footer(); exit; } errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors ); } $themes_dir = $wp_filesystem->wp_themes_dir(); if ( empty( $themes_dir ) ) { return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); } do_action( 'delete_theme', $stylesheet ); $themes_dir = trailingslashit( $themes_dir ); $theme_dir = trailingslashit( $themes_dir . $stylesheet ); $deleted = $wp_filesystem->delete( $theme_dir, true ); do_action( 'deleted_theme', $stylesheet, $deleted ); if ( ! $deleted ) { return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) ); } $theme_translations = wp_get_installed_translations( 'themes' ); if ( ! empty( $theme_translations[ $stylesheet ] ) ) { $translations = $theme_translations[ $stylesheet ]; foreach ( $translations as $translation => $data ) { $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' ); $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' ); $json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' ); if ( $json_translation_files ) { array_map( array( $wp_filesystem, 'delete' ), $json_translation_files ); } } } if ( is_multisite() ) { WP_Theme::network_disable_theme( $stylesheet ); } delete_site_transient( 'update_themes' ); return true; } function get_page_templates( $post = null, $post_type = 'page' ) { return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); } function _get_template_edit_filename( $fullpath, $containingfolder ) { return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath ); } function theme_update_available( $theme ) { echo get_theme_update_available( $theme ); } function get_theme_update_available( $theme ) { static $themes_update = null; if ( ! current_user_can( 'update_themes' ) ) { return false; } if ( ! isset( $themes_update ) ) { $themes_update = get_site_transient( 'update_themes' ); } if ( ! ( $theme instanceof WP_Theme ) ) { return false; } $stylesheet = $theme->get_stylesheet(); $html = ''; if ( isset( $themes_update->response[ $stylesheet ] ) ) { $update = $themes_update->response[ $stylesheet ]; $theme_name = $theme->display( 'Name' ); $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800, ), $update['url'] ); $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); if ( ! is_multisite() ) { if ( ! current_user_can( 'update_themes' ) ) { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'] ); } elseif ( empty( $update['package'] ) ) { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this theme.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'] ); } else { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details or update now.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'], $update_url, sprintf( 'aria-label="%s" id="update-theme" data-slug="%s"', esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme_name ) ), $stylesheet ) ); } } } return $html; } function get_theme_feature_list( $api = true ) { $features = array( __( 'Subject' ) => array( 'blog' => __( 'Blog' ), 'e-commerce' => __( 'E-Commerce' ), 'education' => __( 'Education' ), 'entertainment' => __( 'Entertainment' ), 'food-and-drink' => __( 'Food & Drink' ), 'holiday' => __( 'Holiday' ), 'news' => __( 'News' ), 'photography' => __( 'Photography' ), 'portfolio' => __( 'Portfolio' ), ), __( 'Features' ) => array( 'accessibility-ready' => __( 'Accessibility Ready' ), 'block-patterns' => __( 'Block Editor Patterns' ), 'block-styles' => __( 'Block Editor Styles' ), 'custom-background' => __( 'Custom Background' ), 'custom-colors' => __( 'Custom Colors' ), 'custom-header' => __( 'Custom Header' ), 'custom-logo' => __( 'Custom Logo' ), 'editor-style' => __( 'Editor Style' ), 'featured-image-header' => __( 'Featured Image Header' ), 'featured-images' => __( 'Featured Images' ), 'footer-widgets' => __( 'Footer Widgets' ), 'full-site-editing' => __( 'Site Editor' ), 'full-width-template' => __( 'Full Width Template' ), 'post-formats' => __( 'Post Formats' ), 'sticky-post' => __( 'Sticky Post' ), 'template-editing' => __( 'Template Editing' ), 'theme-options' => __( 'Theme Options' ), ), __( 'Layout' ) => array( 'grid-layout' => __( 'Grid Layout' ), 'one-column' => __( 'One Column' ), 'two-columns' => __( 'Two Columns' ), 'three-columns' => __( 'Three Columns' ), 'four-columns' => __( 'Four Columns' ), 'left-sidebar' => __( 'Left Sidebar' ), 'right-sidebar' => __( 'Right Sidebar' ), 'wide-blocks' => __( 'Wide Blocks' ), ), ); if ( ! $api || ! current_user_can( 'install_themes' ) ) { return $features; } $feature_list = get_site_transient( 'wporg_theme_feature_list' ); if ( ! $feature_list ) { set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); } if ( ! $feature_list ) { $feature_list = themes_api( 'feature_list', array() ); if ( is_wp_error( $feature_list ) ) { return $features; } } if ( ! $feature_list ) { return $features; } set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); $category_translations = array( 'Layout' => __( 'Layout' ), 'Features' => __( 'Features' ), 'Subject' => __( 'Subject' ), ); $wporg_features = array(); foreach ( (array) $feature_list as $feature_category => $feature_items ) { if ( isset( $category_translations[ $feature_category ] ) ) { $feature_category = $category_translations[ $feature_category ]; } $wporg_features[ $feature_category ] = array(); foreach ( $feature_items as $feature ) { if ( isset( $features[ $feature_category ][ $feature ] ) ) { $wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ]; } else { $wporg_features[ $feature_category ][ $feature ] = $feature; } } } return $wporg_features; } function themes_api( $action, $args = array() ) { require ABSPATH . WPINC . '/version.php'; if ( is_array( $args ) ) { $args = (object) $args; } if ( 'query_themes' === $action ) { if ( ! isset( $args->per_page ) ) { $args->per_page = 24; } } if ( ! isset( $args->locale ) ) { $args->locale = get_user_locale(); } if ( ! isset( $args->wp_version ) ) { $args->wp_version = substr( $wp_version, 0, 3 ); } $args = apply_filters( 'themes_api_args', $args, $action ); $res = apply_filters( 'themes_api', false, $action, $args ); if ( ! $res ) { $url = 'http://api.wordpress.org/themes/info/1.2/'; $url = add_query_arg( array( 'action' => $action, 'request' => $args, ), $url ); $http_url = $url; $ssl = wp_http_supports( array( 'ssl' ) ); if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } $http_args = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), ); $request = wp_remote_get( $url, $http_args ); if ( $ssl && is_wp_error( $request ) ) { if ( ! wp_doing_ajax() ) { trigger_error( sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); } $request = wp_remote_get( $http_url, $http_args ); } if ( is_wp_error( $request ) ) { $res = new WP_Error( 'themes_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ), $request->get_error_message() ); } else { $res = json_decode( wp_remote_retrieve_body( $request ), true ); if ( is_array( $res ) ) { $res = (object) $res; } elseif ( null === $res ) { $res = new WP_Error( 'themes_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ), wp_remote_retrieve_body( $request ) ); } if ( isset( $res->error ) ) { $res = new WP_Error( 'themes_api_failed', $res->error ); } } if ( ! is_wp_error( $res ) ) { if ( 'query_themes' === $action ) { foreach ( $res->themes as $i => $theme ) { $res->themes[ $i ] = (object) $theme; } } if ( 'feature_list' === $action ) { $res = (array) $res; } } } return apply_filters( 'themes_api_result', $res, $action, $args ); } function wp_prepare_themes_for_js( $themes = null ) { $current_theme = get_stylesheet(); $prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme ); if ( ! empty( $prepared_themes ) ) { return $prepared_themes; } $prepared_themes[ $current_theme ] = array(); if ( null === $themes ) { $themes = wp_get_themes( array( 'allowed' => true ) ); if ( ! isset( $themes[ $current_theme ] ) ) { $themes[ $current_theme ] = wp_get_theme(); } } $updates = array(); $no_updates = array(); if ( ! is_multisite() && current_user_can( 'update_themes' ) ) { $updates_transient = get_site_transient( 'update_themes' ); if ( isset( $updates_transient->response ) ) { $updates = $updates_transient->response; } if ( isset( $updates_transient->no_update ) ) { $no_updates = $updates_transient->no_update; } } WP_Theme::sort_by_name( $themes ); $parents = array(); $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); foreach ( $themes as $theme ) { $slug = $theme->get_stylesheet(); $encoded_slug = urlencode( $slug ); $parent = false; if ( $theme->parent() ) { $parent = $theme->parent(); $parents[ $slug ] = $parent->get_stylesheet(); $parent = $parent->display( 'Name' ); } $customize_action = null; $can_edit_theme_options = current_user_can( 'edit_theme_options' ); $can_customize = current_user_can( 'customize' ); $is_block_theme = $theme->is_block_theme(); if ( $is_block_theme && $can_edit_theme_options ) { $customize_action = esc_url( admin_url( 'site-editor.php' ) ); } elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) { $customize_action = esc_url( add_query_arg( array( 'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ), ), wp_customize_url( $slug ) ) ); } $update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null; $update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null; $auto_update = in_array( $slug, $auto_updates, true ); $auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update'; if ( isset( $updates[ $slug ] ) ) { $auto_update_supported = true; $auto_update_filter_payload = (object) $updates[ $slug ]; } elseif ( isset( $no_updates[ $slug ] ) ) { $auto_update_supported = true; $auto_update_filter_payload = (object) $no_updates[ $slug ]; } else { $auto_update_supported = false; $auto_update_filter_payload = (object) array( 'theme' => $slug, 'new_version' => $theme->get( 'Version' ), 'url' => '', 'package' => '', 'requires' => $theme->get( 'RequiresWP' ), 'requires_php' => $theme->get( 'RequiresPHP' ), ); } $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload ); $prepared_themes[ $slug ] = array( 'id' => $slug, 'name' => $theme->display( 'Name' ), 'screenshot' => array( $theme->get_screenshot() ), 'description' => $theme->display( 'Description' ), 'author' => $theme->display( 'Author', false, true ), 'authorAndUri' => $theme->display( 'Author' ), 'tags' => $theme->display( 'Tags' ), 'version' => $theme->get( 'Version' ), 'compatibleWP' => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ), 'compatiblePHP' => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ), 'updateResponse' => array( 'compatibleWP' => is_wp_version_compatible( $update_requires_wp ), 'compatiblePHP' => is_php_version_compatible( $update_requires_php ), ), 'parent' => $parent, 'active' => $slug === $current_theme, 'hasUpdate' => isset( $updates[ $slug ] ), 'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ), 'update' => get_theme_update_available( $theme ), 'autoupdate' => array( 'enabled' => $auto_update || $auto_update_forced, 'supported' => $auto_update_supported, 'forced' => $auto_update_forced, ), 'actions' => array( 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, 'customize' => $customize_action, 'delete' => ( ! is_multisite() && current_user_can( 'delete_themes' ) ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, 'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&stylesheet=' . $encoded_slug ), 'updates' ) : null, ), 'blockTheme' => $theme->is_block_theme(), ); } if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); } $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes ); $prepared_themes = array_values( $prepared_themes ); return array_filter( $prepared_themes ); } function customize_themes_print_templates() { ?> + function delete_theme( $stylesheet, $redirect = '' ) { global $wp_filesystem; if ( empty( $stylesheet ) ) { return false; } if ( empty( $redirect ) ) { $redirect = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ); } ob_start(); $credentials = request_filesystem_credentials( $redirect ); $data = ob_get_clean(); if ( false === $credentials ) { if ( ! empty( $data ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; echo $data; require_once ABSPATH . 'wp-admin/admin-footer.php'; exit; } return; } if ( ! WP_Filesystem( $credentials ) ) { ob_start(); request_filesystem_credentials( $redirect, '', true ); $data = ob_get_clean(); if ( ! empty( $data ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; echo $data; require_once ABSPATH . 'wp-admin/admin-footer.php'; exit; } return; } if ( ! is_object( $wp_filesystem ) ) { return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) ); } if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors ); } $themes_dir = $wp_filesystem->wp_themes_dir(); if ( empty( $themes_dir ) ) { return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); } do_action( 'delete_theme', $stylesheet ); $themes_dir = trailingslashit( $themes_dir ); $theme_dir = trailingslashit( $themes_dir . $stylesheet ); $deleted = $wp_filesystem->delete( $theme_dir, true ); do_action( 'deleted_theme', $stylesheet, $deleted ); if ( ! $deleted ) { return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) ); } $theme_translations = wp_get_installed_translations( 'themes' ); if ( ! empty( $theme_translations[ $stylesheet ] ) ) { $translations = $theme_translations[ $stylesheet ]; foreach ( $translations as $translation => $data ) { $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' ); $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' ); $json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' ); if ( $json_translation_files ) { array_map( array( $wp_filesystem, 'delete' ), $json_translation_files ); } } } if ( is_multisite() ) { WP_Theme::network_disable_theme( $stylesheet ); } delete_site_transient( 'update_themes' ); return true; } function get_page_templates( $post = null, $post_type = 'page' ) { return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); } function _get_template_edit_filename( $fullpath, $containingfolder ) { return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath ); } function theme_update_available( $theme ) { echo get_theme_update_available( $theme ); } function get_theme_update_available( $theme ) { static $themes_update = null; if ( ! current_user_can( 'update_themes' ) ) { return false; } if ( ! isset( $themes_update ) ) { $themes_update = get_site_transient( 'update_themes' ); } if ( ! ( $theme instanceof WP_Theme ) ) { return false; } $stylesheet = $theme->get_stylesheet(); $html = ''; if ( isset( $themes_update->response[ $stylesheet ] ) ) { $update = $themes_update->response[ $stylesheet ]; $theme_name = $theme->display( 'Name' ); $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800, ), $update['url'] ); $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); if ( ! is_multisite() ) { if ( ! current_user_can( 'update_themes' ) ) { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'] ); } elseif ( empty( $update['package'] ) ) { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this theme.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'] ); } else { $html = sprintf( '

    ' . __( 'There is a new version of %1$s available. View version %4$s details or update now.' ) . '

    ', $theme_name, esc_url( $details_url ), sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) ), $update['new_version'], $update_url, sprintf( 'aria-label="%s" id="update-theme" data-slug="%s"', esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme_name ) ), $stylesheet ) ); } } } return $html; } function get_theme_feature_list( $api = true ) { $features = array( __( 'Subject' ) => array( 'blog' => __( 'Blog' ), 'e-commerce' => __( 'E-Commerce' ), 'education' => __( 'Education' ), 'entertainment' => __( 'Entertainment' ), 'food-and-drink' => __( 'Food & Drink' ), 'holiday' => __( 'Holiday' ), 'news' => __( 'News' ), 'photography' => __( 'Photography' ), 'portfolio' => __( 'Portfolio' ), ), __( 'Features' ) => array( 'accessibility-ready' => __( 'Accessibility Ready' ), 'block-patterns' => __( 'Block Editor Patterns' ), 'block-styles' => __( 'Block Editor Styles' ), 'custom-background' => __( 'Custom Background' ), 'custom-colors' => __( 'Custom Colors' ), 'custom-header' => __( 'Custom Header' ), 'custom-logo' => __( 'Custom Logo' ), 'editor-style' => __( 'Editor Style' ), 'featured-image-header' => __( 'Featured Image Header' ), 'featured-images' => __( 'Featured Images' ), 'footer-widgets' => __( 'Footer Widgets' ), 'full-site-editing' => __( 'Site Editor' ), 'full-width-template' => __( 'Full Width Template' ), 'post-formats' => __( 'Post Formats' ), 'sticky-post' => __( 'Sticky Post' ), 'style-variations' => __( 'Style Variations' ), 'template-editing' => __( 'Template Editing' ), 'theme-options' => __( 'Theme Options' ), ), __( 'Layout' ) => array( 'grid-layout' => __( 'Grid Layout' ), 'one-column' => __( 'One Column' ), 'two-columns' => __( 'Two Columns' ), 'three-columns' => __( 'Three Columns' ), 'four-columns' => __( 'Four Columns' ), 'left-sidebar' => __( 'Left Sidebar' ), 'right-sidebar' => __( 'Right Sidebar' ), 'wide-blocks' => __( 'Wide Blocks' ), ), ); if ( ! $api || ! current_user_can( 'install_themes' ) ) { return $features; } $feature_list = get_site_transient( 'wporg_theme_feature_list' ); if ( ! $feature_list ) { set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); } if ( ! $feature_list ) { $feature_list = themes_api( 'feature_list', array() ); if ( is_wp_error( $feature_list ) ) { return $features; } } if ( ! $feature_list ) { return $features; } set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); $category_translations = array( 'Layout' => __( 'Layout' ), 'Features' => __( 'Features' ), 'Subject' => __( 'Subject' ), ); $wporg_features = array(); foreach ( (array) $feature_list as $feature_category => $feature_items ) { if ( isset( $category_translations[ $feature_category ] ) ) { $feature_category = $category_translations[ $feature_category ]; } $wporg_features[ $feature_category ] = array(); foreach ( $feature_items as $feature ) { if ( isset( $features[ $feature_category ][ $feature ] ) ) { $wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ]; } else { $wporg_features[ $feature_category ][ $feature ] = $feature; } } } return $wporg_features; } function themes_api( $action, $args = array() ) { require ABSPATH . WPINC . '/version.php'; if ( is_array( $args ) ) { $args = (object) $args; } if ( 'query_themes' === $action ) { if ( ! isset( $args->per_page ) ) { $args->per_page = 24; } } if ( ! isset( $args->locale ) ) { $args->locale = get_user_locale(); } if ( ! isset( $args->wp_version ) ) { $args->wp_version = substr( $wp_version, 0, 3 ); } $args = apply_filters( 'themes_api_args', $args, $action ); $res = apply_filters( 'themes_api', false, $action, $args ); if ( ! $res ) { $url = 'http://api.wordpress.org/themes/info/1.2/'; $url = add_query_arg( array( 'action' => $action, 'request' => $args, ), $url ); $http_url = $url; $ssl = wp_http_supports( array( 'ssl' ) ); if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } $http_args = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), ); $request = wp_remote_get( $url, $http_args ); if ( $ssl && is_wp_error( $request ) ) { if ( ! wp_doing_ajax() ) { trigger_error( sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); } $request = wp_remote_get( $http_url, $http_args ); } if ( is_wp_error( $request ) ) { $res = new WP_Error( 'themes_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ), $request->get_error_message() ); } else { $res = json_decode( wp_remote_retrieve_body( $request ), true ); if ( is_array( $res ) ) { $res = (object) $res; } elseif ( null === $res ) { $res = new WP_Error( 'themes_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), __( 'https://wordpress.org/support/forums/' ) ), wp_remote_retrieve_body( $request ) ); } if ( isset( $res->error ) ) { $res = new WP_Error( 'themes_api_failed', $res->error ); } } if ( ! is_wp_error( $res ) ) { if ( 'query_themes' === $action ) { foreach ( $res->themes as $i => $theme ) { $res->themes[ $i ] = (object) $theme; } } if ( 'feature_list' === $action ) { $res = (array) $res; } } } return apply_filters( 'themes_api_result', $res, $action, $args ); } function wp_prepare_themes_for_js( $themes = null ) { $current_theme = get_stylesheet(); $prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme ); if ( ! empty( $prepared_themes ) ) { return $prepared_themes; } $prepared_themes[ $current_theme ] = array(); if ( null === $themes ) { $themes = wp_get_themes( array( 'allowed' => true ) ); if ( ! isset( $themes[ $current_theme ] ) ) { $themes[ $current_theme ] = wp_get_theme(); } } $updates = array(); $no_updates = array(); if ( ! is_multisite() && current_user_can( 'update_themes' ) ) { $updates_transient = get_site_transient( 'update_themes' ); if ( isset( $updates_transient->response ) ) { $updates = $updates_transient->response; } if ( isset( $updates_transient->no_update ) ) { $no_updates = $updates_transient->no_update; } } WP_Theme::sort_by_name( $themes ); $parents = array(); $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); foreach ( $themes as $theme ) { $slug = $theme->get_stylesheet(); $encoded_slug = urlencode( $slug ); $parent = false; if ( $theme->parent() ) { $parent = $theme->parent(); $parents[ $slug ] = $parent->get_stylesheet(); $parent = $parent->display( 'Name' ); } $customize_action = null; $can_edit_theme_options = current_user_can( 'edit_theme_options' ); $can_customize = current_user_can( 'customize' ); $is_block_theme = $theme->is_block_theme(); if ( $is_block_theme && $can_edit_theme_options ) { $customize_action = esc_url( admin_url( 'site-editor.php' ) ); } elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) { $customize_action = esc_url( add_query_arg( array( 'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ), ), wp_customize_url( $slug ) ) ); } $update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null; $update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null; $auto_update = in_array( $slug, $auto_updates, true ); $auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update'; if ( isset( $updates[ $slug ] ) ) { $auto_update_supported = true; $auto_update_filter_payload = (object) $updates[ $slug ]; } elseif ( isset( $no_updates[ $slug ] ) ) { $auto_update_supported = true; $auto_update_filter_payload = (object) $no_updates[ $slug ]; } else { $auto_update_supported = false; $auto_update_filter_payload = (object) array( 'theme' => $slug, 'new_version' => $theme->get( 'Version' ), 'url' => '', 'package' => '', 'requires' => $theme->get( 'RequiresWP' ), 'requires_php' => $theme->get( 'RequiresPHP' ), ); } $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload ); $prepared_themes[ $slug ] = array( 'id' => $slug, 'name' => $theme->display( 'Name' ), 'screenshot' => array( $theme->get_screenshot() ), 'description' => $theme->display( 'Description' ), 'author' => $theme->display( 'Author', false, true ), 'authorAndUri' => $theme->display( 'Author' ), 'tags' => $theme->display( 'Tags' ), 'version' => $theme->get( 'Version' ), 'compatibleWP' => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ), 'compatiblePHP' => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ), 'updateResponse' => array( 'compatibleWP' => is_wp_version_compatible( $update_requires_wp ), 'compatiblePHP' => is_php_version_compatible( $update_requires_php ), ), 'parent' => $parent, 'active' => $slug === $current_theme, 'hasUpdate' => isset( $updates[ $slug ] ), 'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ), 'update' => get_theme_update_available( $theme ), 'autoupdate' => array( 'enabled' => $auto_update || $auto_update_forced, 'supported' => $auto_update_supported, 'forced' => $auto_update_forced, ), 'actions' => array( 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, 'customize' => $customize_action, 'delete' => ( ! is_multisite() && current_user_can( 'delete_themes' ) ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, 'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&stylesheet=' . $encoded_slug ), 'updates' ) : null, ), 'blockTheme' => $theme->is_block_theme(), ); } if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); } $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes ); $prepared_themes = array_values( $prepared_themes ); return array_filter( $prepared_themes ); } function customize_themes_print_templates() { ?> + + ', wp_json_encode( $selector ) ); } } ); } return preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . $filter_id . ' ', $block_content, 1 ); } WP_Block_Supports::get_instance()->register( 'duotone', array( 'register_attribute' => 'wp_register_duotone_support', ) ); add_filter( 'render_block', 'wp_render_duotone_support', 10, 2 ); <', '><', $svg ); $svg = trim( $svg ); } return $svg; } function wp_register_duotone_support( $block_type ) { $has_duotone_support = false; if ( property_exists( $block_type, 'supports' ) ) { $has_duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false ); } if ( $has_duotone_support ) { if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } } } function wp_render_duotone_support( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $duotone_support = false; if ( $block_type && property_exists( $block_type, 'supports' ) ) { $duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false ); } $has_duotone_attribute = isset( $block['attrs']['style']['color']['duotone'] ); if ( ! $duotone_support || ! $has_duotone_attribute ) { return $block_content; } $colors = $block['attrs']['style']['color']['duotone']; $filter_key = is_array( $colors ) ? implode( '-', $colors ) : $colors; $filter_preset = array( 'slug' => wp_unique_id( sanitize_key( $filter_key . '-' ) ), 'colors' => $colors, ); $filter_property = wp_get_duotone_filter_property( $filter_preset ); $filter_id = wp_get_duotone_filter_id( $filter_preset ); $scope = '.' . $filter_id; $selectors = explode( ',', $duotone_support ); $scoped = array(); foreach ( $selectors as $sel ) { $scoped[] = $scope . ' ' . trim( $sel ); } $selector = implode( ', ', $scoped ); $filter_style = SCRIPT_DEBUG ? $selector . " {\n\tfilter: " . $filter_property . " !important;\n}\n" : $selector . '{filter:' . $filter_property . ' !important;}'; wp_register_style( $filter_id, false, array(), true, true ); wp_add_inline_style( $filter_id, $filter_style ); wp_enqueue_style( $filter_id ); if ( 'unset' !== $colors ) { $filter_svg = wp_get_duotone_filter_svg( $filter_preset ); add_action( 'wp_footer', static function () use ( $filter_svg, $selector ) { echo $filter_svg; global $is_safari; if ( $is_safari ) { printf( '', wp_json_encode( $selector ) ); } } ); } return preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . $filter_id . ' ', $block_content, 1 ); } WP_Block_Supports::get_instance()->register( 'duotone', array( 'register_attribute' => 'wp_register_duotone_support', ) ); add_filter( 'render_block', 'wp_render_duotone_support', 10, 2 ); get_registered( $block['blockName'] ); $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); if ( $skip_link_color_serialization ) { return $block_content; } $link_color = null; if ( ! empty( $block['attrs'] ) ) { $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null ); } if ( null === $link_color ) { return $block_content; } $class_name = wp_get_elements_class_name( $block ); $html_element_matches = array(); preg_match( '/<[^>]+>/', $block_content, $html_element_matches, PREG_OFFSET_CAPTURE ); $first_element = $html_element_matches[0][0]; if ( strpos( $first_element, 'class="' ) !== false ) { $content = preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . $class_name . ' ', $block_content, 1 ); } else { $first_element_offset = $html_element_matches[0][1]; $content = substr_replace( $block_content, ' class="' . $class_name . '"', $first_element_offset + strlen( $first_element ) - 1, 0 ); } return $content; } function wp_render_elements_support_styles( $pre_render, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null; $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); if ( $skip_link_color_serialization ) { return null; } $class_name = wp_get_elements_class_name( $block ); $link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null; wp_style_engine_get_styles( $link_block_styles, array( 'selector' => ".$class_name a", 'context' => 'block-supports', ) ); return null; } add_filter( 'render_block', 'wp_render_elements_support', 10, 2 ); add_filter( 'pre_render_block', 'wp_render_elements_support_styles', 10, 2 ); name ); if ( $block_classname ) { $attributes['class'] = $block_classname; } } return $attributes; } WP_Block_Supports::get_instance()->register( 'generated-classname', array( 'apply' => 'wp_apply_generated_classname_support', ) ); attributes ) { $block_type->attributes = array(); } if ( ! array_key_exists( 'layout', $block_type->attributes ) ) { $block_type->attributes['layout'] = array( 'type' => 'object', ); } } } function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em', $block_spacing = null ) { $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default'; $layout_styles = array(); if ( 'default' === $layout_type ) { if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $gap_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); $gap_value = "var(--wp--preset--spacing--$slug)"; } array_push( $layout_styles, array( 'selector' => "$selector > *", 'declarations' => array( 'margin-block-start' => '0', 'margin-block-end' => '0', ), ), array( 'selector' => "$selector$selector > * + *", 'declarations' => array( 'margin-block-start' => $gap_value, 'margin-block-end' => '0', ), ) ); } } } elseif ( 'constrained' === $layout_type ) { $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : ''; $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : ''; $justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center'; $all_max_width_value = $content_size ? $content_size : $wide_size; $wide_max_width_value = $wide_size ? $wide_size : $content_size; $all_max_width_value = safecss_filter_attr( explode( ';', $all_max_width_value )[0] ); $wide_max_width_value = safecss_filter_attr( explode( ';', $wide_max_width_value )[0] ); $margin_left = 'left' === $justify_content ? '0 !important' : 'auto !important'; $margin_right = 'right' === $justify_content ? '0 !important' : 'auto !important'; if ( $content_size || $wide_size ) { array_push( $layout_styles, array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'max-width' => $all_max_width_value, 'margin-left' => $margin_left, 'margin-right' => $margin_right, ), ), array( 'selector' => "$selector > .alignwide", 'declarations' => array( 'max-width' => $wide_max_width_value ), ), array( 'selector' => "$selector .alignfull", 'declarations' => array( 'max-width' => 'none' ), ) ); if ( isset( $block_spacing ) ) { $block_spacing_values = wp_style_engine_get_styles( array( 'spacing' => $block_spacing, ) ); if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) { $padding_right = $block_spacing_values['declarations']['padding-right']; $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ), ); } if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) { $padding_left = $block_spacing_values['declarations']['padding-left']; $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ), ); } } } if ( 'left' === $justify_content ) { $layout_styles[] = array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'margin-left' => '0 !important' ), ); } if ( 'right' === $justify_content ) { $layout_styles[] = array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'margin-right' => '0 !important' ), ); } if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $gap_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); $gap_value = "var(--wp--preset--spacing--$slug)"; } array_push( $layout_styles, array( 'selector' => "$selector > *", 'declarations' => array( 'margin-block-start' => '0', 'margin-block-end' => '0', ), ), array( 'selector' => "$selector$selector > * + *", 'declarations' => array( 'margin-block-start' => $gap_value, 'margin-block-end' => '0', ), ) ); } } } elseif ( 'flex' === $layout_type ) { $layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal'; $justify_content_options = array( 'left' => 'flex-start', 'right' => 'flex-end', 'center' => 'center', ); $vertical_alignment_options = array( 'top' => 'flex-start', 'center' => 'center', 'bottom' => 'flex-end', ); if ( 'horizontal' === $layout_orientation ) { $justify_content_options += array( 'space-between' => 'space-between' ); } if ( ! empty( $layout['flexWrap'] ) && 'nowrap' === $layout['flexWrap'] ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'flex-wrap' => 'nowrap' ), ); } if ( $has_block_gap_support && isset( $gap_value ) ) { $combined_gap_value = ''; $gap_sides = is_array( $gap_value ) ? array( 'top', 'left' ) : array( 'top' ); foreach ( $gap_sides as $gap_side ) { $process_value = is_string( $gap_value ) ? $gap_value : _wp_array_get( $gap_value, array( $gap_side ), $fallback_gap_value ); if ( is_string( $process_value ) && str_contains( $process_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $process_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $process_value, $index_to_splice ) ); $process_value = "var(--wp--preset--spacing--$slug)"; } $combined_gap_value .= "$process_value "; } $gap_value = trim( $combined_gap_value ); if ( null !== $gap_value && ! $should_skip_gap_serialization ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'gap' => $gap_value ), ); } } if ( 'horizontal' === $layout_orientation ) { if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'justify-content' => $justify_content_options[ $layout['justifyContent'] ] ), ); } if ( ! empty( $layout['verticalAlignment'] ) && array_key_exists( $layout['verticalAlignment'], $vertical_alignment_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => $vertical_alignment_options[ $layout['verticalAlignment'] ] ), ); } } else { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'flex-direction' => 'column' ), ); if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => $justify_content_options[ $layout['justifyContent'] ] ), ); } else { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => 'flex-start' ), ); } } } if ( ! empty( $layout_styles ) ) { return wp_style_engine_get_stylesheet_from_css_rules( $layout_styles, array( 'context' => 'block-supports', 'prettify' => false, ) ); } return ''; } function wp_render_layout_support_flag( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); if ( ! $support_layout ) { return $block_content; } $block_gap = wp_get_global_settings( array( 'spacing', 'blockGap' ) ); $global_layout_settings = wp_get_global_settings( array( 'layout' ) ); $has_block_gap_support = isset( $block_gap ) ? null !== $block_gap : false; $default_block_layout = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() ); $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout; if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) { if ( ! $global_layout_settings ) { return $block_content; } } $class_names = array(); $layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() ); $block_classname = wp_get_block_default_classname( $block['blockName'] ); $container_class = wp_unique_id( 'wp-container-' ); $layout_classname = ''; if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) { $used_layout['type'] = 'constrained'; } if ( wp_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && isset( $used_layout['type'] ) && 'constrained' === $used_layout['type'] ) { $class_names[] = 'has-global-padding'; } if ( ! empty( $block['attrs']['layout']['orientation'] ) ) { $class_names[] = 'is-' . sanitize_title( $block['attrs']['layout']['orientation'] ); } if ( ! empty( $block['attrs']['layout']['justifyContent'] ) ) { $class_names[] = 'is-content-justification-' . sanitize_title( $block['attrs']['layout']['justifyContent'] ); } if ( ! empty( $block['attrs']['layout']['flexWrap'] ) && 'nowrap' === $block['attrs']['layout']['flexWrap'] ) { $class_names[] = 'is-nowrap'; } if ( isset( $used_layout['type'] ) ) { $layout_classname = _wp_array_get( $layout_definitions, array( $used_layout['type'], 'className' ), '' ); } else { $layout_classname = _wp_array_get( $layout_definitions, array( 'default', 'className' ), '' ); } if ( $layout_classname && is_string( $layout_classname ) ) { $class_names[] = sanitize_title( $layout_classname ); } if ( ! current_theme_supports( 'disable-layout-styles' ) ) { $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) ); if ( is_array( $gap_value ) ) { foreach ( $gap_value as $key => $value ) { $gap_value[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value; } } else { $gap_value = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value; } $fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' ); $block_spacing = _wp_array_get( $block, array( 'attrs', 'style', 'spacing' ), null ); $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' ); $style = wp_get_layout_style( ".$block_classname.$container_class", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value, $block_spacing ); if ( ! empty( $style ) ) { $class_names[] = $container_class; } } $content = preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . esc_attr( implode( ' ', $class_names ) ) . ' ', $block_content, 1 ); return $content; } WP_Block_Supports::get_instance()->register( 'layout', array( 'register_attribute' => 'wp_register_layout_support', ) ); add_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 ); function wp_restore_group_inner_container( $block_content, $block ) { $tag_name = isset( $block['attrs']['tagName'] ) ? $block['attrs']['tagName'] : 'div'; $group_with_inner_container_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U', preg_quote( $tag_name, '/' ) ); if ( WP_Theme_JSON_Resolver::theme_has_support() || 1 === preg_match( $group_with_inner_container_regex, $block_content ) || ( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] ) ) { return $block_content; } $replace_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group[^>]*>)(.*)(<\/%1$s>\s*$)/ms', preg_quote( $tag_name, '/' ) ); $updated_content = preg_replace_callback( $replace_regex, static function( $matches ) { return $matches[1] . '
    ' . $matches[2] . '
    ' . $matches[3]; }, $block_content ); return $updated_content; } add_filter( 'render_block_core/group', 'wp_restore_group_inner_container', 10, 2 ); function wp_restore_image_outer_container( $block_content, $block ) { $image_with_align = " + function wp_register_layout_support( $block_type ) { $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); if ( $support_layout ) { if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( ! array_key_exists( 'layout', $block_type->attributes ) ) { $block_type->attributes['layout'] = array( 'type' => 'object', ); } } } function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em', $block_spacing = null ) { $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default'; $layout_styles = array(); if ( 'default' === $layout_type ) { if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $gap_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); $gap_value = "var(--wp--preset--spacing--$slug)"; } array_push( $layout_styles, array( 'selector' => "$selector > *", 'declarations' => array( 'margin-block-start' => '0', 'margin-block-end' => '0', ), ), array( 'selector' => "$selector$selector > * + *", 'declarations' => array( 'margin-block-start' => $gap_value, 'margin-block-end' => '0', ), ) ); } } } elseif ( 'constrained' === $layout_type ) { $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : ''; $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : ''; $justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center'; $all_max_width_value = $content_size ? $content_size : $wide_size; $wide_max_width_value = $wide_size ? $wide_size : $content_size; $all_max_width_value = safecss_filter_attr( explode( ';', $all_max_width_value )[0] ); $wide_max_width_value = safecss_filter_attr( explode( ';', $wide_max_width_value )[0] ); $margin_left = 'left' === $justify_content ? '0 !important' : 'auto !important'; $margin_right = 'right' === $justify_content ? '0 !important' : 'auto !important'; if ( $content_size || $wide_size ) { array_push( $layout_styles, array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'max-width' => $all_max_width_value, 'margin-left' => $margin_left, 'margin-right' => $margin_right, ), ), array( 'selector' => "$selector > .alignwide", 'declarations' => array( 'max-width' => $wide_max_width_value ), ), array( 'selector' => "$selector .alignfull", 'declarations' => array( 'max-width' => 'none' ), ) ); if ( isset( $block_spacing ) ) { $block_spacing_values = wp_style_engine_get_styles( array( 'spacing' => $block_spacing, ) ); if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) { $padding_right = $block_spacing_values['declarations']['padding-right']; $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ), ); } if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) { $padding_left = $block_spacing_values['declarations']['padding-left']; $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ), ); } } } if ( 'left' === $justify_content ) { $layout_styles[] = array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'margin-left' => '0 !important' ), ); } if ( 'right' === $justify_content ) { $layout_styles[] = array( 'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 'declarations' => array( 'margin-right' => '0 !important' ), ); } if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $gap_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); $gap_value = "var(--wp--preset--spacing--$slug)"; } array_push( $layout_styles, array( 'selector' => "$selector > *", 'declarations' => array( 'margin-block-start' => '0', 'margin-block-end' => '0', ), ), array( 'selector' => "$selector$selector > * + *", 'declarations' => array( 'margin-block-start' => $gap_value, 'margin-block-end' => '0', ), ) ); } } } elseif ( 'flex' === $layout_type ) { $layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal'; $justify_content_options = array( 'left' => 'flex-start', 'right' => 'flex-end', 'center' => 'center', ); $vertical_alignment_options = array( 'top' => 'flex-start', 'center' => 'center', 'bottom' => 'flex-end', ); if ( 'horizontal' === $layout_orientation ) { $justify_content_options += array( 'space-between' => 'space-between' ); } if ( ! empty( $layout['flexWrap'] ) && 'nowrap' === $layout['flexWrap'] ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'flex-wrap' => 'nowrap' ), ); } if ( $has_block_gap_support && isset( $gap_value ) ) { $combined_gap_value = ''; $gap_sides = is_array( $gap_value ) ? array( 'top', 'left' ) : array( 'top' ); foreach ( $gap_sides as $gap_side ) { $process_value = is_string( $gap_value ) ? $gap_value : _wp_array_get( $gap_value, array( $gap_side ), $fallback_gap_value ); if ( is_string( $process_value ) && str_contains( $process_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $process_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $process_value, $index_to_splice ) ); $process_value = "var(--wp--preset--spacing--$slug)"; } $combined_gap_value .= "$process_value "; } $gap_value = trim( $combined_gap_value ); if ( null !== $gap_value && ! $should_skip_gap_serialization ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'gap' => $gap_value ), ); } } if ( 'horizontal' === $layout_orientation ) { if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'justify-content' => $justify_content_options[ $layout['justifyContent'] ] ), ); } if ( ! empty( $layout['verticalAlignment'] ) && array_key_exists( $layout['verticalAlignment'], $vertical_alignment_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => $vertical_alignment_options[ $layout['verticalAlignment'] ] ), ); } } else { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'flex-direction' => 'column' ), ); if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => $justify_content_options[ $layout['justifyContent'] ] ), ); } else { $layout_styles[] = array( 'selector' => $selector, 'declarations' => array( 'align-items' => 'flex-start' ), ); } } } if ( ! empty( $layout_styles ) ) { return wp_style_engine_get_stylesheet_from_css_rules( $layout_styles, array( 'context' => 'block-supports', 'prettify' => false, ) ); } return ''; } function wp_render_layout_support_flag( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); if ( ! $support_layout ) { return $block_content; } $block_gap = wp_get_global_settings( array( 'spacing', 'blockGap' ) ); $global_layout_settings = wp_get_global_settings( array( 'layout' ) ); $has_block_gap_support = isset( $block_gap ) ? null !== $block_gap : false; $default_block_layout = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() ); $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout; if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) { if ( ! $global_layout_settings ) { return $block_content; } } $class_names = array(); $layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() ); $block_classname = wp_get_block_default_classname( $block['blockName'] ); $container_class = wp_unique_id( 'wp-container-' ); $layout_classname = ''; if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) { $used_layout['type'] = 'constrained'; } if ( wp_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && isset( $used_layout['type'] ) && 'constrained' === $used_layout['type'] ) { $class_names[] = 'has-global-padding'; } if ( ! empty( $block['attrs']['layout']['orientation'] ) ) { $class_names[] = 'is-' . sanitize_title( $block['attrs']['layout']['orientation'] ); } if ( ! empty( $block['attrs']['layout']['justifyContent'] ) ) { $class_names[] = 'is-content-justification-' . sanitize_title( $block['attrs']['layout']['justifyContent'] ); } if ( ! empty( $block['attrs']['layout']['flexWrap'] ) && 'nowrap' === $block['attrs']['layout']['flexWrap'] ) { $class_names[] = 'is-nowrap'; } if ( isset( $used_layout['type'] ) ) { $layout_classname = _wp_array_get( $layout_definitions, array( $used_layout['type'], 'className' ), '' ); } else { $layout_classname = _wp_array_get( $layout_definitions, array( 'default', 'className' ), '' ); } if ( $layout_classname && is_string( $layout_classname ) ) { $class_names[] = sanitize_title( $layout_classname ); } if ( ! current_theme_supports( 'disable-layout-styles' ) ) { $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) ); if ( is_array( $gap_value ) ) { foreach ( $gap_value as $key => $value ) { $gap_value[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value; } } else { $gap_value = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value; } $fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' ); $block_spacing = _wp_array_get( $block, array( 'attrs', 'style', 'spacing' ), null ); $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' ); $style = wp_get_layout_style( ".$block_classname.$container_class", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value, $block_spacing ); if ( ! empty( $style ) ) { $class_names[] = $container_class; } } $content = preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . esc_attr( implode( ' ', $class_names ) ) . ' ', $block_content, 1 ); return $content; } WP_Block_Supports::get_instance()->register( 'layout', array( 'register_attribute' => 'wp_register_layout_support', ) ); add_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 ); function wp_restore_group_inner_container( $block_content, $block ) { $tag_name = isset( $block['attrs']['tagName'] ) ? $block['attrs']['tagName'] : 'div'; $group_with_inner_container_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U', preg_quote( $tag_name, '/' ) ); if ( wp_theme_has_theme_json() || 1 === preg_match( $group_with_inner_container_regex, $block_content ) || ( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] ) ) { return $block_content; } $replace_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group[^>]*>)(.*)(<\/%1$s>\s*$)/ms', preg_quote( $tag_name, '/' ) ); $updated_content = preg_replace_callback( $replace_regex, static function( $matches ) { return $matches[1] . '
    ' . $matches[2] . '
    ' . $matches[3]; }, $block_content ); return $updated_content; } add_filter( 'render_block_core/group', 'wp_restore_group_inner_container', 10, 2 ); function wp_restore_image_outer_container( $block_content, $block ) { $image_with_align = " /# 1) everything up to the class attribute contents ( ^\s* @@ -18551,13 +21234,13 @@ function embed_wmedia(width, height, link) { > .* <\/figure> -)/iUx"; if ( WP_Theme_JSON_Resolver::theme_has_support() || 0 === preg_match( $image_with_align, $block_content, $matches ) ) { return $block_content; } $wrapper_classnames = array( 'wp-block-image' ); if ( ! empty( $block['attrs']['className'] ) ) { $wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) ); } $content_classnames = explode( ' ', $matches[2] ); $filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames ); return '
    ' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . '
    '; } add_filter( 'render_block_core/image', 'wp_restore_image_outer_container', 10, 2 ); ' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . ''; } add_filter( 'render_block_core/image', 'wp_restore_image_outer_container', 10, 2 ); attributes ) { $block_type->attributes = array(); } if ( $has_spacing_support && ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } } function wp_apply_spacing_support( $block_type, $block_attributes ) { if ( wp_should_skip_block_supports_serialization( $block_type, 'spacing' ) ) { return array(); } $attributes = array(); $has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false ); $has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false ); $block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null; if ( ! $block_styles ) { return $attributes; } $skip_padding = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'padding' ); $skip_margin = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'margin' ); $spacing_block_styles = array(); $spacing_block_styles['padding'] = $has_padding_support && ! $skip_padding ? _wp_array_get( $block_styles, array( 'spacing', 'padding' ), null ) : null; $spacing_block_styles['margin'] = $has_margin_support && ! $skip_margin ? _wp_array_get( $block_styles, array( 'spacing', 'margin' ), null ) : null; $styles = wp_style_engine_get_styles( array( 'spacing' => $spacing_block_styles ) ); if ( ! empty( $styles['css'] ) ) { $attributes['style'] = $styles['css']; } return $attributes; } WP_Block_Supports::get_instance()->register( 'spacing', array( 'register_attribute' => 'wp_register_spacing_support', 'apply' => 'wp_apply_spacing_support', ) ); supports, array( 'typography' ), false ); if ( ! $typography_supports ) { return; } $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false ); $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false ); $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false ); $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); $has_typography_support = $has_font_family_support || $has_font_size_support || $has_font_style_support || $has_font_weight_support || $has_letter_spacing_support || $has_line_height_support || $has_text_decoration_support || $has_text_transform_support; if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( $has_typography_support && ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } if ( $has_font_size_support && ! array_key_exists( 'fontSize', $block_type->attributes ) ) { $block_type->attributes['fontSize'] = array( 'type' => 'string', ); } if ( $has_font_family_support && ! array_key_exists( 'fontFamily', $block_type->attributes ) ) { $block_type->attributes['fontFamily'] = array( 'type' => 'string', ); } } function wp_apply_typography_support( $block_type, $block_attributes ) { if ( ! property_exists( $block_type, 'supports' ) ) { return array(); } $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false ); if ( ! $typography_supports ) { return array(); } if ( wp_should_skip_block_supports_serialization( $block_type, 'typography' ) ) { return array(); } $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false ); $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false ); $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false ); $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); $should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' ); $should_skip_font_family = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontFamily' ); $should_skip_font_style = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' ); $should_skip_font_weight = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' ); $should_skip_line_height = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' ); $should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' ); $should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' ); $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' ); $typography_block_styles = array(); if ( $has_font_size_support && ! $should_skip_font_size ) { $preset_font_size = array_key_exists( 'fontSize', $block_attributes ) ? "var:preset|font-size|{$block_attributes['fontSize']}" : null; $custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] ) ? $block_attributes['style']['typography']['fontSize'] : null; $typography_block_styles['fontSize'] = $preset_font_size ? $preset_font_size : wp_get_typography_font_size_value( array( 'size' => $custom_font_size, ) ); } if ( $has_font_family_support && ! $should_skip_font_family ) { $preset_font_family = array_key_exists( 'fontFamily', $block_attributes ) ? "var:preset|font-family|{$block_attributes['fontFamily']}" : null; $custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ) ? wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontFamily'], 'font-family' ) : null; $typography_block_styles['fontFamily'] = $preset_font_family ? $preset_font_family : $custom_font_family; } if ( $has_font_style_support && ! $should_skip_font_style && isset( $block_attributes['style']['typography']['fontStyle'] ) ) { $typography_block_styles['fontStyle'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontStyle'], 'font-style' ); } if ( $has_font_weight_support && ! $should_skip_font_weight && isset( $block_attributes['style']['typography']['fontWeight'] ) ) { $typography_block_styles['fontWeight'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontWeight'], 'font-weight' ); } if ( $has_line_height_support && ! $should_skip_line_height ) { $typography_block_styles['lineHeight'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'lineHeight' ) ); } if ( $has_text_decoration_support && ! $should_skip_text_decoration && isset( $block_attributes['style']['typography']['textDecoration'] ) ) { $typography_block_styles['textDecoration'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['textDecoration'], 'text-decoration' ); } if ( $has_text_transform_support && ! $should_skip_text_transform && isset( $block_attributes['style']['typography']['textTransform'] ) ) { $typography_block_styles['textTransform'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['textTransform'], 'text-transform' ); } if ( $has_letter_spacing_support && ! $should_skip_letter_spacing && isset( $block_attributes['style']['typography']['letterSpacing'] ) ) { $typography_block_styles['letterSpacing'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['letterSpacing'], 'letter-spacing' ); } $attributes = array(); $styles = wp_style_engine_get_styles( array( 'typography' => $typography_block_styles ), array( 'convert_vars_to_classnames' => true ) ); if ( ! empty( $styles['classnames'] ) ) { $attributes['class'] = $styles['classnames']; } if ( ! empty( $styles['css'] ) ) { $attributes['style'] = $styles['css']; } return $attributes; } function wp_typography_get_preset_inline_style_value( $style_value, $css_property ) { if ( empty( $style_value ) || ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { return $style_value; } $index_to_splice = strrpos( $style_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $style_value, $index_to_splice ) ); return sprintf( 'var(--wp--preset--%s--%s);', $css_property, $slug ); } function wp_render_typography_support( $block_content, $block ) { if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) { return $block_content; } $custom_font_size = $block['attrs']['style']['typography']['fontSize']; $fluid_font_size = wp_get_typography_font_size_value( array( 'size' => $custom_font_size ) ); if ( ! empty( $fluid_font_size ) && $fluid_font_size !== $custom_font_size ) { return preg_replace( '/font-size\s*:\s*' . preg_quote( $custom_font_size, '/' ) . '\s*;?/', 'font-size:' . esc_attr( $fluid_font_size ) . ';', $block_content, 1 ); } return $block_content; } function wp_get_typography_value_and_unit( $raw_value, $options = array() ) { if ( ! is_string( $raw_value ) && ! is_int( $raw_value ) && ! is_float( $raw_value ) ) { _doing_it_wrong( __FUNCTION__, __( 'Raw size value must be a string, integer, or float.' ), '6.1.0' ); return null; } if ( empty( $raw_value ) ) { return null; } if ( is_numeric( $raw_value ) ) { $raw_value = $raw_value . 'px'; } $defaults = array( 'coerce_to' => '', 'root_size_value' => 16, 'acceptable_units' => array( 'rem', 'px', 'em' ), ); $options = wp_parse_args( $options, $defaults ); $acceptable_units_group = implode( '|', $options['acceptable_units'] ); $pattern = '/^(\d*\.?\d+)(' . $acceptable_units_group . '){1,1}$/'; preg_match( $pattern, $raw_value, $matches ); if ( ! isset( $matches[1] ) || ! isset( $matches[2] ) ) { return null; } $value = $matches[1]; $unit = $matches[2]; if ( 'px' === $options['coerce_to'] && ( 'em' === $unit || 'rem' === $unit ) ) { $value = $value * $options['root_size_value']; $unit = $options['coerce_to']; } if ( 'px' === $unit && ( 'em' === $options['coerce_to'] || 'rem' === $options['coerce_to'] ) ) { $value = $value / $options['root_size_value']; $unit = $options['coerce_to']; } if ( ( 'em' === $options['coerce_to'] || 'rem' === $options['coerce_to'] ) && ( 'em' === $unit || 'rem' === $unit ) ) { $unit = $options['coerce_to']; } return array( 'value' => round( $value, 3 ), 'unit' => $unit, ); } function wp_get_computed_fluid_typography_value( $args = array() ) { $maximum_viewport_width_raw = isset( $args['maximum_viewport_width'] ) ? $args['maximum_viewport_width'] : null; $minimum_viewport_width_raw = isset( $args['minimum_viewport_width'] ) ? $args['minimum_viewport_width'] : null; $maximum_font_size_raw = isset( $args['maximum_font_size'] ) ? $args['maximum_font_size'] : null; $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null; $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null; $minimum_font_size = wp_get_typography_value_and_unit( $minimum_font_size_raw ); $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem'; $maximum_font_size = wp_get_typography_value_and_unit( $maximum_font_size_raw, array( 'coerce_to' => $font_size_unit, ) ); if ( ! $maximum_font_size || ! $minimum_font_size ) { return null; } $minimum_font_size_rem = wp_get_typography_value_and_unit( $minimum_font_size_raw, array( 'coerce_to' => 'rem', ) ); $maximum_viewport_width = wp_get_typography_value_and_unit( $maximum_viewport_width_raw, array( 'coerce_to' => $font_size_unit, ) ); $minimum_viewport_width = wp_get_typography_value_and_unit( $minimum_viewport_width_raw, array( 'coerce_to' => $font_size_unit, ) ); $view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit; $linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $maximum_viewport_width['value'] - $minimum_viewport_width['value'] ) ); $linear_factor_scaled = round( $linear_factor * $scale_factor, 3 ); $linear_factor_scaled = empty( $linear_factor_scaled ) ? 1 : $linear_factor_scaled; $fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor_scaled)"; return "clamp($minimum_font_size_raw, $fluid_target_font_size, $maximum_font_size_raw)"; } function wp_get_typography_font_size_value( $preset, $should_use_fluid_typography = false ) { if ( ! isset( $preset['size'] ) ) { return null; } if ( empty( $preset['size'] ) ) { return $preset['size']; } $typography_settings = wp_get_global_settings( array( 'typography' ) ); $should_use_fluid_typography = isset( $typography_settings['fluid'] ) && true === $typography_settings['fluid'] ? true : $should_use_fluid_typography; if ( ! $should_use_fluid_typography ) { return $preset['size']; } $default_maximum_viewport_width = '1600px'; $default_minimum_viewport_width = '768px'; $default_minimum_font_size_factor = 0.75; $default_scale_factor = 1; $default_minimum_font_size_limit = '14px'; $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; if ( false === $fluid_font_size_settings ) { return $preset['size']; } $minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null; $maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null; $preferred_size = wp_get_typography_value_and_unit( $preset['size'] ); if ( empty( $preferred_size['unit'] ) ) { return $preset['size']; } $minimum_font_size_limit = wp_get_typography_value_and_unit( $default_minimum_font_size_limit, array( 'coerce_to' => $preferred_size['unit'], ) ); if ( ! empty( $minimum_font_size_limit ) && ( ! $minimum_font_size_raw && ! $maximum_font_size_raw ) ) { if ( $preferred_size['value'] <= $minimum_font_size_limit['value'] ) { return $preset['size']; } } if ( ! $maximum_font_size_raw ) { $maximum_font_size_raw = $preferred_size['value'] . $preferred_size['unit']; } if ( ! $minimum_font_size_raw ) { $calculated_minimum_font_size = round( $preferred_size['value'] * $default_minimum_font_size_factor, 3 ); if ( ! empty( $minimum_font_size_limit ) && $calculated_minimum_font_size <= $minimum_font_size_limit['value'] ) { $minimum_font_size_raw = $minimum_font_size_limit['value'] . $minimum_font_size_limit['unit']; } else { $minimum_font_size_raw = $calculated_minimum_font_size . $preferred_size['unit']; } } $fluid_font_size_value = wp_get_computed_fluid_typography_value( array( 'minimum_viewport_width' => $default_minimum_viewport_width, 'maximum_viewport_width' => $default_maximum_viewport_width, 'minimum_font_size' => $minimum_font_size_raw, 'maximum_font_size' => $maximum_font_size_raw, 'scale_factor' => $default_scale_factor, ) ); if ( ! empty( $fluid_font_size_value ) ) { return $fluid_font_size_value; } return $preset['size']; } WP_Block_Supports::get_instance()->register( 'typography', array( 'register_attribute' => 'wp_register_typography_support', 'apply' => 'wp_apply_typography_support', ) ); supports, array( 'typography' ), false ); if ( ! $typography_supports ) { return; } $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false ); $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false ); $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false ); $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); $has_typography_support = $has_font_family_support || $has_font_size_support || $has_font_style_support || $has_font_weight_support || $has_letter_spacing_support || $has_line_height_support || $has_text_decoration_support || $has_text_transform_support; if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( $has_typography_support && ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } if ( $has_font_size_support && ! array_key_exists( 'fontSize', $block_type->attributes ) ) { $block_type->attributes['fontSize'] = array( 'type' => 'string', ); } if ( $has_font_family_support && ! array_key_exists( 'fontFamily', $block_type->attributes ) ) { $block_type->attributes['fontFamily'] = array( 'type' => 'string', ); } } function wp_apply_typography_support( $block_type, $block_attributes ) { if ( ! property_exists( $block_type, 'supports' ) ) { return array(); } $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false ); if ( ! $typography_supports ) { return array(); } if ( wp_should_skip_block_supports_serialization( $block_type, 'typography' ) ) { return array(); } $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false ); $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false ); $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false ); $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false ); $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false ); $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); $should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' ); $should_skip_font_family = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontFamily' ); $should_skip_font_style = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' ); $should_skip_font_weight = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' ); $should_skip_line_height = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' ); $should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' ); $should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' ); $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' ); $typography_block_styles = array(); if ( $has_font_size_support && ! $should_skip_font_size ) { $preset_font_size = array_key_exists( 'fontSize', $block_attributes ) ? "var:preset|font-size|{$block_attributes['fontSize']}" : null; $custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] ) ? $block_attributes['style']['typography']['fontSize'] : null; $typography_block_styles['fontSize'] = $preset_font_size ? $preset_font_size : wp_get_typography_font_size_value( array( 'size' => $custom_font_size, ) ); } if ( $has_font_family_support && ! $should_skip_font_family ) { $preset_font_family = array_key_exists( 'fontFamily', $block_attributes ) ? "var:preset|font-family|{$block_attributes['fontFamily']}" : null; $custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ) ? wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontFamily'], 'font-family' ) : null; $typography_block_styles['fontFamily'] = $preset_font_family ? $preset_font_family : $custom_font_family; } if ( $has_font_style_support && ! $should_skip_font_style && isset( $block_attributes['style']['typography']['fontStyle'] ) ) { $typography_block_styles['fontStyle'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontStyle'], 'font-style' ); } if ( $has_font_weight_support && ! $should_skip_font_weight && isset( $block_attributes['style']['typography']['fontWeight'] ) ) { $typography_block_styles['fontWeight'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontWeight'], 'font-weight' ); } if ( $has_line_height_support && ! $should_skip_line_height ) { $typography_block_styles['lineHeight'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'lineHeight' ) ); } if ( $has_text_decoration_support && ! $should_skip_text_decoration && isset( $block_attributes['style']['typography']['textDecoration'] ) ) { $typography_block_styles['textDecoration'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['textDecoration'], 'text-decoration' ); } if ( $has_text_transform_support && ! $should_skip_text_transform && isset( $block_attributes['style']['typography']['textTransform'] ) ) { $typography_block_styles['textTransform'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['textTransform'], 'text-transform' ); } if ( $has_letter_spacing_support && ! $should_skip_letter_spacing && isset( $block_attributes['style']['typography']['letterSpacing'] ) ) { $typography_block_styles['letterSpacing'] = wp_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['letterSpacing'], 'letter-spacing' ); } $attributes = array(); $styles = wp_style_engine_get_styles( array( 'typography' => $typography_block_styles ), array( 'convert_vars_to_classnames' => true ) ); if ( ! empty( $styles['classnames'] ) ) { $attributes['class'] = $styles['classnames']; } if ( ! empty( $styles['css'] ) ) { $attributes['style'] = $styles['css']; } return $attributes; } function wp_typography_get_preset_inline_style_value( $style_value, $css_property ) { if ( empty( $style_value ) || ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { return $style_value; } $index_to_splice = strrpos( $style_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $style_value, $index_to_splice ) ); return sprintf( 'var(--wp--preset--%s--%s);', $css_property, $slug ); } function wp_render_typography_support( $block_content, $block ) { if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) { return $block_content; } $custom_font_size = $block['attrs']['style']['typography']['fontSize']; $fluid_font_size = wp_get_typography_font_size_value( array( 'size' => $custom_font_size ) ); if ( ! empty( $fluid_font_size ) && $fluid_font_size !== $custom_font_size ) { return preg_replace( '/font-size\s*:\s*' . preg_quote( $custom_font_size, '/' ) . '\s*;?/', 'font-size:' . esc_attr( $fluid_font_size ) . ';', $block_content, 1 ); } return $block_content; } function wp_get_typography_value_and_unit( $raw_value, $options = array() ) { if ( ! is_string( $raw_value ) && ! is_int( $raw_value ) && ! is_float( $raw_value ) ) { _doing_it_wrong( __FUNCTION__, __( 'Raw size value must be a string, integer, or float.' ), '6.1.0' ); return null; } if ( empty( $raw_value ) ) { return null; } if ( is_numeric( $raw_value ) ) { $raw_value = $raw_value . 'px'; } $defaults = array( 'coerce_to' => '', 'root_size_value' => 16, 'acceptable_units' => array( 'rem', 'px', 'em' ), ); $options = wp_parse_args( $options, $defaults ); $acceptable_units_group = implode( '|', $options['acceptable_units'] ); $pattern = '/^(\d*\.?\d+)(' . $acceptable_units_group . '){1,1}$/'; preg_match( $pattern, $raw_value, $matches ); if ( ! isset( $matches[1] ) || ! isset( $matches[2] ) ) { return null; } $value = $matches[1]; $unit = $matches[2]; if ( 'px' === $options['coerce_to'] && ( 'em' === $unit || 'rem' === $unit ) ) { $value = $value * $options['root_size_value']; $unit = $options['coerce_to']; } if ( 'px' === $unit && ( 'em' === $options['coerce_to'] || 'rem' === $options['coerce_to'] ) ) { $value = $value / $options['root_size_value']; $unit = $options['coerce_to']; } if ( ( 'em' === $options['coerce_to'] || 'rem' === $options['coerce_to'] ) && ( 'em' === $unit || 'rem' === $unit ) ) { $unit = $options['coerce_to']; } return array( 'value' => round( $value, 3 ), 'unit' => $unit, ); } function wp_get_computed_fluid_typography_value( $args = array() ) { $maximum_viewport_width_raw = isset( $args['maximum_viewport_width'] ) ? $args['maximum_viewport_width'] : null; $minimum_viewport_width_raw = isset( $args['minimum_viewport_width'] ) ? $args['minimum_viewport_width'] : null; $maximum_font_size_raw = isset( $args['maximum_font_size'] ) ? $args['maximum_font_size'] : null; $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null; $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null; $minimum_font_size = wp_get_typography_value_and_unit( $minimum_font_size_raw ); $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem'; $maximum_font_size = wp_get_typography_value_and_unit( $maximum_font_size_raw, array( 'coerce_to' => $font_size_unit, ) ); if ( ! $maximum_font_size || ! $minimum_font_size ) { return null; } $minimum_font_size_rem = wp_get_typography_value_and_unit( $minimum_font_size_raw, array( 'coerce_to' => 'rem', ) ); $maximum_viewport_width = wp_get_typography_value_and_unit( $maximum_viewport_width_raw, array( 'coerce_to' => $font_size_unit, ) ); $minimum_viewport_width = wp_get_typography_value_and_unit( $minimum_viewport_width_raw, array( 'coerce_to' => $font_size_unit, ) ); $view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit; $linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $maximum_viewport_width['value'] - $minimum_viewport_width['value'] ) ); $linear_factor_scaled = round( $linear_factor * $scale_factor, 3 ); $linear_factor_scaled = empty( $linear_factor_scaled ) ? 1 : $linear_factor_scaled; $fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor_scaled)"; return "clamp($minimum_font_size_raw, $fluid_target_font_size, $maximum_font_size_raw)"; } function wp_get_typography_font_size_value( $preset, $should_use_fluid_typography = false ) { if ( ! isset( $preset['size'] ) ) { return null; } if ( empty( $preset['size'] ) ) { return $preset['size']; } $typography_settings = wp_get_global_settings( array( 'typography' ) ); if ( isset( $typography_settings['fluid'] ) && ( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) ) ) { $should_use_fluid_typography = true; } if ( ! $should_use_fluid_typography ) { return $preset['size']; } $fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array(); $default_maximum_viewport_width = '1600px'; $default_minimum_viewport_width = '768px'; $default_minimum_font_size_factor = 0.75; $default_scale_factor = 1; $has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) ); $default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px'; $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; if ( false === $fluid_font_size_settings ) { return $preset['size']; } $minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null; $maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null; $preferred_size = wp_get_typography_value_and_unit( $preset['size'] ); if ( empty( $preferred_size['unit'] ) ) { return $preset['size']; } $minimum_font_size_limit = wp_get_typography_value_and_unit( $default_minimum_font_size_limit, array( 'coerce_to' => $preferred_size['unit'], ) ); if ( ! empty( $minimum_font_size_limit ) && ( ! $minimum_font_size_raw && ! $maximum_font_size_raw ) ) { if ( $preferred_size['value'] <= $minimum_font_size_limit['value'] ) { return $preset['size']; } } if ( ! $maximum_font_size_raw ) { $maximum_font_size_raw = $preferred_size['value'] . $preferred_size['unit']; } if ( ! $minimum_font_size_raw ) { $calculated_minimum_font_size = round( $preferred_size['value'] * $default_minimum_font_size_factor, 3 ); if ( ! empty( $minimum_font_size_limit ) && $calculated_minimum_font_size <= $minimum_font_size_limit['value'] ) { $minimum_font_size_raw = $minimum_font_size_limit['value'] . $minimum_font_size_limit['unit']; } else { $minimum_font_size_raw = $calculated_minimum_font_size . $preferred_size['unit']; } } $fluid_font_size_value = wp_get_computed_fluid_typography_value( array( 'minimum_viewport_width' => $default_minimum_viewport_width, 'maximum_viewport_width' => $default_maximum_viewport_width, 'minimum_font_size' => $minimum_font_size_raw, 'maximum_font_size' => $maximum_font_size_raw, 'scale_factor' => $default_scale_factor, ) ); if ( ! empty( $fluid_font_size_value ) ) { return $fluid_font_size_value; } return $preset['size']; } WP_Block_Supports::get_instance()->register( 'typography', array( 'register_attribute' => 'wp_register_typography_support', 'apply' => 'wp_apply_typography_support', ) ); supports, $path, false ); if ( is_array( $skip_serialization ) ) { return in_array( $feature, $skip_serialization, true ); } return $skip_serialization; } 'block-templates', 'wp_template_part' => 'block-template-parts', ); } return array( 'wp_template' => 'templates', 'wp_template_part' => 'parts', ); } function get_allowed_block_template_part_areas() { $default_area_definitions = array( array( 'area' => WP_TEMPLATE_PART_AREA_UNCATEGORIZED, 'label' => __( 'General' ), 'description' => __( 'General templates often perform a specific role like displaying post content, and are not tied to any particular area.' ), 'icon' => 'layout', 'area_tag' => 'div', ), array( 'area' => WP_TEMPLATE_PART_AREA_HEADER, 'label' => __( 'Header' ), 'description' => __( 'The Header template defines a page area that typically contains a title, logo, and main navigation.' ), 'icon' => 'header', 'area_tag' => 'header', ), array( 'area' => WP_TEMPLATE_PART_AREA_FOOTER, 'label' => __( 'Footer' ), 'description' => __( 'The Footer template defines a page area that typically contains site credits, social links, or any other combination of blocks.' ), 'icon' => 'footer', 'area_tag' => 'footer', ), ); return apply_filters( 'default_wp_template_part_areas', $default_area_definitions ); } function get_default_block_template_types() { $default_template_types = array( 'index' => array( 'title' => _x( 'Index', 'Template name' ), 'description' => __( 'Displays posts.' ), ), 'home' => array( 'title' => _x( 'Home', 'Template name' ), 'description' => __( 'Displays posts on the homepage, or on the Posts page if a static homepage is set.' ), ), 'front-page' => array( 'title' => _x( 'Front Page', 'Template name' ), 'description' => __( 'Displays the homepage.' ), ), 'singular' => array( 'title' => _x( 'Singular', 'Template name' ), 'description' => __( 'Displays a single post or page.' ), ), 'single' => array( 'title' => _x( 'Single', 'Template name' ), 'description' => __( 'The default template for displaying any single post or attachment.' ), ), 'page' => array( 'title' => _x( 'Page', 'Template name' ), 'description' => __( 'Displays a single page.' ), ), 'archive' => array( 'title' => _x( 'Archive', 'Template name' ), 'description' => __( 'Displays posts by a category, tag, author, or date.' ), ), 'author' => array( 'title' => _x( 'Author', 'Template name' ), 'description' => __( 'Displays latest posts written by a single author.' ), ), 'category' => array( 'title' => _x( 'Category', 'Template name' ), 'description' => __( 'Displays latest posts from a single post category.' ), ), 'taxonomy' => array( 'title' => _x( 'Taxonomy', 'Template name' ), 'description' => __( 'Displays latest posts from a single post taxonomy.' ), ), 'date' => array( 'title' => _x( 'Date', 'Template name' ), 'description' => __( 'Displays posts from a specific date.' ), ), 'tag' => array( 'title' => _x( 'Tag', 'Template name' ), 'description' => __( 'Displays latest posts with a single post tag.' ), ), 'attachment' => array( 'title' => __( 'Media' ), 'description' => __( 'Displays individual media items or attachments.' ), ), 'search' => array( 'title' => _x( 'Search', 'Template name' ), 'description' => __( 'Displays search results.' ), ), 'privacy-policy' => array( 'title' => __( 'Privacy Policy' ), 'description' => __( 'Displays the privacy policy page.' ), ), '404' => array( 'title' => _x( '404', 'Template name' ), 'description' => __( 'Displays when no content is found.' ), ), ); return apply_filters( 'default_template_types', $default_template_types ); } function _filter_block_template_part_area( $type ) { $allowed_areas = array_map( static function ( $item ) { return $item['area']; }, get_allowed_block_template_part_areas() ); if ( in_array( $type, $allowed_areas, true ) ) { return $type; } $warning_message = sprintf( __( '"%1$s" is not a supported wp_template_part area value and has been added as "%2$s".' ), $type, WP_TEMPLATE_PART_AREA_UNCATEGORIZED ); trigger_error( $warning_message, E_USER_NOTICE ); return WP_TEMPLATE_PART_AREA_UNCATEGORIZED; } function _get_block_templates_paths( $base_directory ) { $path_list = array(); if ( file_exists( $base_directory ) ) { $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) ); $nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH ); foreach ( $nested_html_files as $path => $file ) { $path_list[] = $path; } } return $path_list; } function _get_block_template_file( $template_type, $slug ) { if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) { return null; } $themes = array( get_stylesheet() => get_stylesheet_directory(), get_template() => get_template_directory(), ); foreach ( $themes as $theme_slug => $theme_dir ) { $template_base_paths = get_block_theme_folders( $theme_slug ); $file_path = $theme_dir . '/' . $template_base_paths[ $template_type ] . '/' . $slug . '.html'; if ( file_exists( $file_path ) ) { $new_template_item = array( 'slug' => $slug, 'path' => $file_path, 'theme' => $theme_slug, 'type' => $template_type, ); if ( 'wp_template_part' === $template_type ) { return _add_block_template_part_area_info( $new_template_item ); } if ( 'wp_template' === $template_type ) { return _add_block_template_info( $new_template_item ); } return $new_template_item; } } return null; } function _get_block_templates_files( $template_type ) { if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) { return null; } $themes = array( get_stylesheet() => get_stylesheet_directory(), get_template() => get_template_directory(), ); $template_files = array(); foreach ( $themes as $theme_slug => $theme_dir ) { $template_base_paths = get_block_theme_folders( $theme_slug ); $theme_template_files = _get_block_templates_paths( $theme_dir . '/' . $template_base_paths[ $template_type ] ); foreach ( $theme_template_files as $template_file ) { $template_base_path = $template_base_paths[ $template_type ]; $template_slug = substr( $template_file, strpos( $template_file, $template_base_path . DIRECTORY_SEPARATOR ) + 1 + strlen( $template_base_path ), -5 ); $new_template_item = array( 'slug' => $template_slug, 'path' => $template_file, 'theme' => $theme_slug, 'type' => $template_type, ); if ( 'wp_template_part' === $template_type ) { $template_files[] = _add_block_template_part_area_info( $new_template_item ); } if ( 'wp_template' === $template_type ) { $template_files[] = _add_block_template_info( $new_template_item ); } } } return $template_files; } function _add_block_template_info( $template_item ) { if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { return $template_item; } $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); if ( isset( $theme_data[ $template_item['slug'] ] ) ) { $template_item['title'] = $theme_data[ $template_item['slug'] ]['title']; $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes']; } return $template_item; } function _add_block_template_part_area_info( $template_info ) { if ( WP_Theme_JSON_Resolver::theme_has_support() ) { $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts(); } if ( isset( $theme_data[ $template_info['slug'] ]['area'] ) ) { $template_info['title'] = $theme_data[ $template_info['slug'] ]['title']; $template_info['area'] = _filter_block_template_part_area( $theme_data[ $template_info['slug'] ]['area'] ); } else { $template_info['area'] = WP_TEMPLATE_PART_AREA_UNCATEGORIZED; } return $template_info; } function _flatten_blocks( &$blocks ) { $all_blocks = array(); $queue = array(); foreach ( $blocks as &$block ) { $queue[] = &$block; } while ( count( $queue ) > 0 ) { $block = &$queue[0]; array_shift( $queue ); $all_blocks[] = &$block; if ( ! empty( $block['innerBlocks'] ) ) { foreach ( $block['innerBlocks'] as &$inner_block ) { $queue[] = &$inner_block; } } } return $all_blocks; } function _inject_theme_attribute_in_block_template_content( $template_content ) { $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); $blocks = _flatten_blocks( $template_blocks ); foreach ( $blocks as &$block ) { if ( 'core/template-part' === $block['blockName'] && ! isset( $block['attrs']['theme'] ) ) { $block['attrs']['theme'] = get_stylesheet(); $has_updated_content = true; } } if ( $has_updated_content ) { foreach ( $template_blocks as &$block ) { $new_content .= serialize_block( $block ); } return $new_content; } return $template_content; } function _remove_theme_attribute_in_block_template_content( $template_content ) { $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); $blocks = _flatten_blocks( $template_blocks ); foreach ( $blocks as $key => $block ) { if ( 'core/template-part' === $block['blockName'] && isset( $block['attrs']['theme'] ) ) { unset( $blocks[ $key ]['attrs']['theme'] ); $has_updated_content = true; } } if ( ! $has_updated_content ) { return $template_content; } foreach ( $template_blocks as $block ) { $new_content .= serialize_block( $block ); } return $new_content; } function _build_block_template_result_from_file( $template_file, $template_type ) { $default_template_types = get_default_block_template_types(); $template_content = file_get_contents( $template_file['path'] ); $theme = get_stylesheet(); $template = new WP_Block_Template(); $template->id = $theme . '//' . $template_file['slug']; $template->theme = ! empty( $template_file['theme'] ) ? $template_file['theme'] : $theme; $template->content = _inject_theme_attribute_in_block_template_content( $template_content ); $template->slug = $template_file['slug']; $template->source = 'theme'; $template->type = $template_type; $template->title = ! empty( $template_file['title'] ) ? $template_file['title'] : $template_file['slug']; $template->status = 'publish'; $template->has_theme_file = true; $template->is_custom = true; if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) { $template->description = $default_template_types[ $template_file['slug'] ]['description']; $template->title = $default_template_types[ $template_file['slug'] ]['title']; $template->is_custom = false; } if ( 'wp_template' === $template_type && isset( $template_file['postTypes'] ) ) { $template->post_types = $template_file['postTypes']; } if ( 'wp_template_part' === $template_type && isset( $template_file['area'] ) ) { $template->area = $template_file['area']; } return $template; } function _wp_build_title_and_description_for_single_post_type_block_template( $post_type, $slug, WP_Block_Template $template ) { $post_type_object = get_post_type_object( $post_type ); $default_args = array( 'post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => 1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => true, 'no_found_rows' => true, ); $args = array( 'name' => $slug, ); $args = wp_parse_args( $args, $default_args ); $posts_query = new WP_Query( $args ); if ( empty( $posts_query->posts ) ) { $template->title = sprintf( __( 'Not found: %1$s (%2$s)' ), $post_type_object->labels->singular_name, $slug ); return false; } $post_title = $posts_query->posts[0]->post_title; $template->title = sprintf( __( '%1$s: %2$s' ), $post_type_object->labels->singular_name, $post_title ); $template->description = sprintf( __( 'Template for %s' ), $post_title ); $args = array( 'title' => $post_title, ); $args = wp_parse_args( $args, $default_args ); $posts_with_same_title_query = new WP_Query( $args ); if ( count( $posts_with_same_title_query->posts ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $slug ); } return true; } function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, WP_Block_Template $template ) { $taxonomy_object = get_taxonomy( $taxonomy ); $default_args = array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'update_term_meta_cache' => false, ); $term_query = new WP_Term_Query(); $args = array( 'number' => 1, 'slug' => $slug, ); $args = wp_parse_args( $args, $default_args ); $terms_query = $term_query->query( $args ); if ( empty( $terms_query ) ) { $template->title = sprintf( __( 'Not found: %1$s (%2$s)' ), $taxonomy_object->labels->singular_name, $slug ); return false; } $term_title = $terms_query[0]->name; $template->title = sprintf( __( '%1$s: %2$s' ), $taxonomy_object->labels->singular_name, $term_title ); $template->description = sprintf( __( 'Template for %s' ), $term_title ); $term_query = new WP_Term_Query(); $args = array( 'number' => 2, 'name' => $term_title, ); $args = wp_parse_args( $args, $default_args ); $terms_with_same_title_query = $term_query->query( $args ); if ( count( $terms_with_same_title_query ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $slug ); } return true; } function _build_block_template_result_from_post( $post ) { $default_template_types = get_default_block_template_types(); $terms = get_the_terms( $post, 'wp_theme' ); if ( is_wp_error( $terms ) ) { return $terms; } if ( ! $terms ) { return new WP_Error( 'template_missing_theme', __( 'No theme is defined for this template.' ) ); } $theme = $terms[0]->name; $template_file = _get_block_template_file( $post->post_type, $post->post_name ); $has_theme_file = get_stylesheet() === $theme && null !== $template_file; $origin = get_post_meta( $post->ID, 'origin', true ); $is_wp_suggestion = get_post_meta( $post->ID, 'is_wp_suggestion', true ); $template = new WP_Block_Template(); $template->wp_id = $post->ID; $template->id = $theme . '//' . $post->post_name; $template->theme = $theme; $template->content = $post->post_content; $template->slug = $post->post_name; $template->source = 'custom'; $template->origin = ! empty( $origin ) ? $origin : null; $template->type = $post->post_type; $template->description = $post->post_excerpt; $template->title = $post->post_title; $template->status = $post->post_status; $template->has_theme_file = $has_theme_file; $template->is_custom = empty( $is_wp_suggestion ); $template->author = $post->post_author; if ( 'wp_template' === $post->post_type && $has_theme_file && isset( $template_file['postTypes'] ) ) { $template->post_types = $template_file['postTypes']; } if ( 'wp_template' === $post->post_type && isset( $default_template_types[ $template->slug ] ) ) { $template->is_custom = false; } if ( 'wp_template_part' === $post->post_type ) { $type_terms = get_the_terms( $post, 'wp_template_part_area' ); if ( ! is_wp_error( $type_terms ) && false !== $type_terms ) { $template->area = $type_terms[0]->name; } } if ( 'wp_template' === $post->post_type && empty( $template->description ) && ( empty( $template->title ) || $template->title === $template->slug ) ) { $matches = array(); if ( preg_match( '/(author|page|single|tag|category|taxonomy)-(.+)/', $template->slug, $matches ) ) { $type = $matches[1]; $slug_remaining = $matches[2]; switch ( $type ) { case 'author': $nice_name = $slug_remaining; $users = get_users( array( 'capability' => 'edit_posts', 'search' => $nice_name, 'search_columns' => array( 'user_nicename' ), 'fields' => 'display_name', ) ); if ( empty( $users ) ) { $template->title = sprintf( __( 'Deleted author: %s' ), $nice_name ); } else { $author_name = $users[0]; $template->title = sprintf( __( 'Author: %s' ), $author_name ); $template->description = sprintf( __( 'Template for %s' ), $author_name ); $users_with_same_name = get_users( array( 'capability' => 'edit_posts', 'search' => $author_name, 'search_columns' => array( 'display_name' ), 'fields' => 'display_name', ) ); if ( count( $users_with_same_name ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $nice_name ); } } break; case 'page': _wp_build_title_and_description_for_single_post_type_block_template( 'page', $slug_remaining, $template ); break; case 'single': $post_types = get_post_types(); foreach ( $post_types as $post_type ) { $post_type_length = strlen( $post_type ) + 1; if ( 0 === strncmp( $slug_remaining, $post_type . '-', $post_type_length ) ) { $slug = substr( $slug_remaining, $post_type_length, strlen( $slug_remaining ) ); $found = _wp_build_title_and_description_for_single_post_type_block_template( $post_type, $slug, $template ); if ( $found ) { break; } } } break; case 'tag': _wp_build_title_and_description_for_taxonomy_block_template( 'post_tag', $slug_remaining, $template ); break; case 'category': _wp_build_title_and_description_for_taxonomy_block_template( 'category', $slug_remaining, $template ); break; case 'taxonomy': $taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { $taxonomy_length = strlen( $taxonomy ) + 1; if ( 0 === strncmp( $slug_remaining, $taxonomy . '-', $taxonomy_length ) ) { $slug = substr( $slug_remaining, $taxonomy_length, strlen( $slug_remaining ) ); $found = _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, $template ); if ( $found ) { break; } } } break; } } } return $template; } function get_block_templates( $query = array(), $template_type = 'wp_template' ) { $templates = apply_filters( 'pre_get_block_templates', null, $query, $template_type ); if ( ! is_null( $templates ) ) { return $templates; } $post_type = isset( $query['post_type'] ) ? $query['post_type'] : ''; $wp_query_args = array( 'post_status' => array( 'auto-draft', 'draft', 'publish' ), 'post_type' => $template_type, 'posts_per_page' => -1, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => get_stylesheet(), ), ), ); if ( 'wp_template_part' === $template_type && isset( $query['area'] ) ) { $wp_query_args['tax_query'][] = array( 'taxonomy' => 'wp_template_part_area', 'field' => 'name', 'terms' => $query['area'], ); $wp_query_args['tax_query']['relation'] = 'AND'; } if ( isset( $query['slug__in'] ) ) { $wp_query_args['post_name__in'] = $query['slug__in']; } if ( isset( $query['wp_id'] ) ) { $wp_query_args['p'] = $query['wp_id']; } else { $wp_query_args['post_status'] = 'publish'; } $template_query = new WP_Query( $wp_query_args ); $query_result = array(); foreach ( $template_query->posts as $post ) { $template = _build_block_template_result_from_post( $post ); if ( is_wp_error( $template ) ) { continue; } if ( $post_type && ! $template->is_custom ) { continue; } if ( $post_type && isset( $template->post_types ) && ! in_array( $post_type, $template->post_types, true ) ) { continue; } $query_result[] = $template; } if ( ! isset( $query['wp_id'] ) ) { $template_files = _get_block_templates_files( $template_type ); foreach ( $template_files as $template_file ) { $template = _build_block_template_result_from_file( $template_file, $template_type ); if ( $post_type && ! $template->is_custom ) { continue; } if ( $post_type && isset( $template->post_types ) && ! in_array( $post_type, $template->post_types, true ) ) { continue; } $is_not_custom = false === array_search( get_stylesheet() . '//' . $template_file['slug'], wp_list_pluck( $query_result, 'id' ), true ); $fits_slug_query = ! isset( $query['slug__in'] ) || in_array( $template_file['slug'], $query['slug__in'], true ); $fits_area_query = ! isset( $query['area'] ) || $template_file['area'] === $query['area']; $should_include = $is_not_custom && $fits_slug_query && $fits_area_query; if ( $should_include ) { $query_result[] = $template; } } } return apply_filters( 'get_block_templates', $query_result, $query, $template_type ); } function get_block_template( $id, $template_type = 'wp_template' ) { $block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type ); if ( ! is_null( $block_template ) ) { return $block_template; } $parts = explode( '//', $id, 2 ); if ( count( $parts ) < 2 ) { return null; } list( $theme, $slug ) = $parts; $wp_query_args = array( 'post_name__in' => array( $slug ), 'post_type' => $template_type, 'post_status' => array( 'auto-draft', 'draft', 'publish', 'trash' ), 'posts_per_page' => 1, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => $theme, ), ), ); $template_query = new WP_Query( $wp_query_args ); $posts = $template_query->posts; if ( count( $posts ) > 0 ) { $template = _build_block_template_result_from_post( $posts[0] ); if ( ! is_wp_error( $template ) ) { return $template; } } $block_template = get_block_file_template( $id, $template_type ); return apply_filters( 'get_block_template', $block_template, $id, $template_type ); } function get_block_file_template( $id, $template_type = 'wp_template' ) { $block_template = apply_filters( 'pre_get_block_file_template', null, $id, $template_type ); if ( ! is_null( $block_template ) ) { return $block_template; } $parts = explode( '//', $id, 2 ); if ( count( $parts ) < 2 ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } list( $theme, $slug ) = $parts; if ( get_stylesheet() !== $theme ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } $template_file = _get_block_template_file( $template_type, $slug ); if ( null === $template_file ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } $block_template = _build_block_template_result_from_file( $template_file, $template_type ); return apply_filters( 'get_block_file_template', $block_template, $id, $template_type ); } function block_template_part( $part ) { $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' ); if ( ! $template_part || empty( $template_part->content ) ) { return; } echo do_blocks( $template_part->content ); } function block_header_area() { block_template_part( 'header' ); } function block_footer_area() { block_template_part( 'footer' ); } function wp_is_theme_directory_ignored( $path ) { $directories_to_ignore = array( '.DS_Store', '.svn', '.git', '.hg', '.bzr', 'node_modules', 'vendor' ); foreach ( $directories_to_ignore as $directory ) { if ( str_starts_with( $path, $directory ) ) { return true; } } return false; } function wp_generate_block_templates_export_file() { global $wp_version; if ( ! class_exists( 'ZipArchive' ) ) { return new WP_Error( 'missing_zip_package', __( 'Zip Export not supported.' ) ); } $obscura = wp_generate_password( 12, false, false ); $theme_name = basename( get_stylesheet() ); $filename = get_temp_dir() . $theme_name . $obscura . '.zip'; $zip = new ZipArchive(); if ( true !== $zip->open( $filename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) ) { return new WP_Error( 'unable_to_create_zip', __( 'Unable to open export file (archive) for writing.' ) ); } $zip->addEmptyDir( 'templates' ); $zip->addEmptyDir( 'parts' ); $theme_path = wp_normalize_path( get_stylesheet_directory() ); $theme_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $theme_path ), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ( $theme_files as $file ) { if ( ! $file->isDir() ) { $file_path = wp_normalize_path( $file ); $relative_path = substr( $file_path, strlen( $theme_path ) + 1 ); if ( ! wp_is_theme_directory_ignored( $relative_path ) ) { $zip->addFile( $file_path, $relative_path ); } } } $templates = get_block_templates(); foreach ( $templates as $template ) { $template->content = _remove_theme_attribute_in_block_template_content( $template->content ); $zip->addFromString( 'templates/' . $template->slug . '.html', $template->content ); } $template_parts = get_block_templates( array(), 'wp_template_part' ); foreach ( $template_parts as $template_part ) { $zip->addFromString( 'parts/' . $template_part->slug . '.html', $template_part->content ); } $tree = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) ); $tree->merge( WP_Theme_JSON_Resolver::get_user_data() ); $theme_json_raw = $tree->get_data(); if ( $theme_json_raw['version'] ) { $theme_json_version = 'wp/' . substr( $wp_version, 0, 3 ); $schema = array( '$schema' => 'https://schemas.wp.org/' . $theme_json_version . '/theme.json' ); $theme_json_raw = array_merge( $schema, $theme_json_raw ); } $theme_json_encoded = wp_json_encode( $theme_json_raw, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); $theme_json_tabbed = preg_replace( '~(?:^|\G)\h{4}~m', "\t", $theme_json_encoded ); $zip->addFromString( 'theme.json', $theme_json_tabbed ); $zip->close(); return $filename; } function get_template_hierarchy( $slug, $is_custom = false, $template_prefix = '' ) { if ( 'index' === $slug ) { return array( 'index' ); } if ( $is_custom ) { return array( 'page', 'singular', 'index' ); } if ( 'front-page' === $slug ) { return array( 'front-page', 'home', 'index' ); } $template_hierarchy = array( $slug ); if ( $template_prefix ) { list( $type ) = explode( '-', $template_prefix ); if ( ! in_array( $template_prefix, array( $slug, $type ), true ) ) { $template_hierarchy[] = $template_prefix; } if ( $slug !== $type ) { $template_hierarchy[] = $type; } } if ( str_starts_with( $slug, 'author' ) || str_starts_with( $slug, 'taxonomy' ) || str_starts_with( $slug, 'category' ) || str_starts_with( $slug, 'tag' ) || 'date' === $slug ) { $template_hierarchy[] = 'archive'; } if ( 'attachment' === $slug ) { $template_hierarchy[] = 'single'; } if ( str_starts_with( $slug, 'single' ) || str_starts_with( $slug, 'page' ) || 'attachment' === $slug ) { $template_hierarchy[] = 'singular'; } $template_hierarchy[] = 'index'; return $template_hierarchy; } 'block-templates', 'wp_template_part' => 'block-template-parts', ); } return array( 'wp_template' => 'templates', 'wp_template_part' => 'parts', ); } function get_allowed_block_template_part_areas() { $default_area_definitions = array( array( 'area' => WP_TEMPLATE_PART_AREA_UNCATEGORIZED, 'label' => __( 'General' ), 'description' => __( 'General templates often perform a specific role like displaying post content, and are not tied to any particular area.' ), 'icon' => 'layout', 'area_tag' => 'div', ), array( 'area' => WP_TEMPLATE_PART_AREA_HEADER, 'label' => __( 'Header' ), 'description' => __( 'The Header template defines a page area that typically contains a title, logo, and main navigation.' ), 'icon' => 'header', 'area_tag' => 'header', ), array( 'area' => WP_TEMPLATE_PART_AREA_FOOTER, 'label' => __( 'Footer' ), 'description' => __( 'The Footer template defines a page area that typically contains site credits, social links, or any other combination of blocks.' ), 'icon' => 'footer', 'area_tag' => 'footer', ), ); return apply_filters( 'default_wp_template_part_areas', $default_area_definitions ); } function get_default_block_template_types() { $default_template_types = array( 'index' => array( 'title' => _x( 'Index', 'Template name' ), 'description' => __( 'Displays posts.' ), ), 'home' => array( 'title' => _x( 'Home', 'Template name' ), 'description' => __( 'Displays posts on the homepage, or on the Posts page if a static homepage is set.' ), ), 'front-page' => array( 'title' => _x( 'Front Page', 'Template name' ), 'description' => __( 'Displays the homepage.' ), ), 'singular' => array( 'title' => _x( 'Singular', 'Template name' ), 'description' => __( 'Displays a single post or page.' ), ), 'single' => array( 'title' => _x( 'Single', 'Template name' ), 'description' => __( 'The default template for displaying any single post or attachment.' ), ), 'page' => array( 'title' => _x( 'Page', 'Template name' ), 'description' => __( 'Displays a single page.' ), ), 'archive' => array( 'title' => _x( 'Archive', 'Template name' ), 'description' => __( 'Displays posts by a category, tag, author, or date.' ), ), 'author' => array( 'title' => _x( 'Author', 'Template name' ), 'description' => __( 'Displays latest posts written by a single author.' ), ), 'category' => array( 'title' => _x( 'Category', 'Template name' ), 'description' => __( 'Displays latest posts from a single post category.' ), ), 'taxonomy' => array( 'title' => _x( 'Taxonomy', 'Template name' ), 'description' => __( 'Displays latest posts from a single post taxonomy.' ), ), 'date' => array( 'title' => _x( 'Date', 'Template name' ), 'description' => __( 'Displays posts from a specific date.' ), ), 'tag' => array( 'title' => _x( 'Tag', 'Template name' ), 'description' => __( 'Displays latest posts with a single post tag.' ), ), 'attachment' => array( 'title' => __( 'Media' ), 'description' => __( 'Displays individual media items or attachments.' ), ), 'search' => array( 'title' => _x( 'Search', 'Template name' ), 'description' => __( 'Displays search results.' ), ), 'privacy-policy' => array( 'title' => __( 'Privacy Policy' ), 'description' => __( 'Displays the privacy policy page.' ), ), '404' => array( 'title' => _x( '404', 'Template name' ), 'description' => __( 'Displays when no content is found.' ), ), ); return apply_filters( 'default_template_types', $default_template_types ); } function _filter_block_template_part_area( $type ) { $allowed_areas = array_map( static function ( $item ) { return $item['area']; }, get_allowed_block_template_part_areas() ); if ( in_array( $type, $allowed_areas, true ) ) { return $type; } $warning_message = sprintf( __( '"%1$s" is not a supported wp_template_part area value and has been added as "%2$s".' ), $type, WP_TEMPLATE_PART_AREA_UNCATEGORIZED ); trigger_error( $warning_message, E_USER_NOTICE ); return WP_TEMPLATE_PART_AREA_UNCATEGORIZED; } function _get_block_templates_paths( $base_directory ) { $path_list = array(); if ( file_exists( $base_directory ) ) { $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) ); $nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH ); foreach ( $nested_html_files as $path => $file ) { $path_list[] = $path; } } return $path_list; } function _get_block_template_file( $template_type, $slug ) { if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) { return null; } $themes = array( get_stylesheet() => get_stylesheet_directory(), get_template() => get_template_directory(), ); foreach ( $themes as $theme_slug => $theme_dir ) { $template_base_paths = get_block_theme_folders( $theme_slug ); $file_path = $theme_dir . '/' . $template_base_paths[ $template_type ] . '/' . $slug . '.html'; if ( file_exists( $file_path ) ) { $new_template_item = array( 'slug' => $slug, 'path' => $file_path, 'theme' => $theme_slug, 'type' => $template_type, ); if ( 'wp_template_part' === $template_type ) { return _add_block_template_part_area_info( $new_template_item ); } if ( 'wp_template' === $template_type ) { return _add_block_template_info( $new_template_item ); } return $new_template_item; } } return null; } function _get_block_templates_files( $template_type ) { if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) { return null; } $themes = array( get_stylesheet() => get_stylesheet_directory(), get_template() => get_template_directory(), ); $template_files = array(); foreach ( $themes as $theme_slug => $theme_dir ) { $template_base_paths = get_block_theme_folders( $theme_slug ); $theme_template_files = _get_block_templates_paths( $theme_dir . '/' . $template_base_paths[ $template_type ] ); foreach ( $theme_template_files as $template_file ) { $template_base_path = $template_base_paths[ $template_type ]; $template_slug = substr( $template_file, strpos( $template_file, $template_base_path . DIRECTORY_SEPARATOR ) + 1 + strlen( $template_base_path ), -5 ); $new_template_item = array( 'slug' => $template_slug, 'path' => $template_file, 'theme' => $theme_slug, 'type' => $template_type, ); if ( 'wp_template_part' === $template_type ) { $template_files[] = _add_block_template_part_area_info( $new_template_item ); } if ( 'wp_template' === $template_type ) { $template_files[] = _add_block_template_info( $new_template_item ); } } } return $template_files; } function _add_block_template_info( $template_item ) { if ( ! wp_theme_has_theme_json() ) { return $template_item; } $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); if ( isset( $theme_data[ $template_item['slug'] ] ) ) { $template_item['title'] = $theme_data[ $template_item['slug'] ]['title']; $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes']; } return $template_item; } function _add_block_template_part_area_info( $template_info ) { if ( wp_theme_has_theme_json() ) { $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts(); } if ( isset( $theme_data[ $template_info['slug'] ]['area'] ) ) { $template_info['title'] = $theme_data[ $template_info['slug'] ]['title']; $template_info['area'] = _filter_block_template_part_area( $theme_data[ $template_info['slug'] ]['area'] ); } else { $template_info['area'] = WP_TEMPLATE_PART_AREA_UNCATEGORIZED; } return $template_info; } function _flatten_blocks( &$blocks ) { $all_blocks = array(); $queue = array(); foreach ( $blocks as &$block ) { $queue[] = &$block; } while ( count( $queue ) > 0 ) { $block = &$queue[0]; array_shift( $queue ); $all_blocks[] = &$block; if ( ! empty( $block['innerBlocks'] ) ) { foreach ( $block['innerBlocks'] as &$inner_block ) { $queue[] = &$inner_block; } } } return $all_blocks; } function _inject_theme_attribute_in_block_template_content( $template_content ) { $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); $blocks = _flatten_blocks( $template_blocks ); foreach ( $blocks as &$block ) { if ( 'core/template-part' === $block['blockName'] && ! isset( $block['attrs']['theme'] ) ) { $block['attrs']['theme'] = get_stylesheet(); $has_updated_content = true; } } if ( $has_updated_content ) { foreach ( $template_blocks as &$block ) { $new_content .= serialize_block( $block ); } return $new_content; } return $template_content; } function _remove_theme_attribute_in_block_template_content( $template_content ) { $has_updated_content = false; $new_content = ''; $template_blocks = parse_blocks( $template_content ); $blocks = _flatten_blocks( $template_blocks ); foreach ( $blocks as $key => $block ) { if ( 'core/template-part' === $block['blockName'] && isset( $block['attrs']['theme'] ) ) { unset( $blocks[ $key ]['attrs']['theme'] ); $has_updated_content = true; } } if ( ! $has_updated_content ) { return $template_content; } foreach ( $template_blocks as $block ) { $new_content .= serialize_block( $block ); } return $new_content; } function _build_block_template_result_from_file( $template_file, $template_type ) { $default_template_types = get_default_block_template_types(); $template_content = file_get_contents( $template_file['path'] ); $theme = get_stylesheet(); $template = new WP_Block_Template(); $template->id = $theme . '//' . $template_file['slug']; $template->theme = ! empty( $template_file['theme'] ) ? $template_file['theme'] : $theme; $template->content = _inject_theme_attribute_in_block_template_content( $template_content ); $template->slug = $template_file['slug']; $template->source = 'theme'; $template->type = $template_type; $template->title = ! empty( $template_file['title'] ) ? $template_file['title'] : $template_file['slug']; $template->status = 'publish'; $template->has_theme_file = true; $template->is_custom = true; if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) { $template->description = $default_template_types[ $template_file['slug'] ]['description']; $template->title = $default_template_types[ $template_file['slug'] ]['title']; $template->is_custom = false; } if ( 'wp_template' === $template_type && isset( $template_file['postTypes'] ) ) { $template->post_types = $template_file['postTypes']; } if ( 'wp_template_part' === $template_type && isset( $template_file['area'] ) ) { $template->area = $template_file['area']; } return $template; } function _wp_build_title_and_description_for_single_post_type_block_template( $post_type, $slug, WP_Block_Template $template ) { $post_type_object = get_post_type_object( $post_type ); $default_args = array( 'post_type' => $post_type, 'post_status' => 'publish', 'posts_per_page' => 1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => true, 'no_found_rows' => true, ); $args = array( 'name' => $slug, ); $args = wp_parse_args( $args, $default_args ); $posts_query = new WP_Query( $args ); if ( empty( $posts_query->posts ) ) { $template->title = sprintf( __( 'Not found: %1$s (%2$s)' ), $post_type_object->labels->singular_name, $slug ); return false; } $post_title = $posts_query->posts[0]->post_title; $template->title = sprintf( __( '%1$s: %2$s' ), $post_type_object->labels->singular_name, $post_title ); $template->description = sprintf( __( 'Template for %s' ), $post_title ); $args = array( 'title' => $post_title, ); $args = wp_parse_args( $args, $default_args ); $posts_with_same_title_query = new WP_Query( $args ); if ( count( $posts_with_same_title_query->posts ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $slug ); } return true; } function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, WP_Block_Template $template ) { $taxonomy_object = get_taxonomy( $taxonomy ); $default_args = array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'update_term_meta_cache' => false, ); $term_query = new WP_Term_Query(); $args = array( 'number' => 1, 'slug' => $slug, ); $args = wp_parse_args( $args, $default_args ); $terms_query = $term_query->query( $args ); if ( empty( $terms_query ) ) { $template->title = sprintf( __( 'Not found: %1$s (%2$s)' ), $taxonomy_object->labels->singular_name, $slug ); return false; } $term_title = $terms_query[0]->name; $template->title = sprintf( __( '%1$s: %2$s' ), $taxonomy_object->labels->singular_name, $term_title ); $template->description = sprintf( __( 'Template for %s' ), $term_title ); $term_query = new WP_Term_Query(); $args = array( 'number' => 2, 'name' => $term_title, ); $args = wp_parse_args( $args, $default_args ); $terms_with_same_title_query = $term_query->query( $args ); if ( count( $terms_with_same_title_query ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $slug ); } return true; } function _build_block_template_result_from_post( $post ) { $default_template_types = get_default_block_template_types(); $terms = get_the_terms( $post, 'wp_theme' ); if ( is_wp_error( $terms ) ) { return $terms; } if ( ! $terms ) { return new WP_Error( 'template_missing_theme', __( 'No theme is defined for this template.' ) ); } $theme = $terms[0]->name; $template_file = _get_block_template_file( $post->post_type, $post->post_name ); $has_theme_file = get_stylesheet() === $theme && null !== $template_file; $origin = get_post_meta( $post->ID, 'origin', true ); $is_wp_suggestion = get_post_meta( $post->ID, 'is_wp_suggestion', true ); $template = new WP_Block_Template(); $template->wp_id = $post->ID; $template->id = $theme . '//' . $post->post_name; $template->theme = $theme; $template->content = $post->post_content; $template->slug = $post->post_name; $template->source = 'custom'; $template->origin = ! empty( $origin ) ? $origin : null; $template->type = $post->post_type; $template->description = $post->post_excerpt; $template->title = $post->post_title; $template->status = $post->post_status; $template->has_theme_file = $has_theme_file; $template->is_custom = empty( $is_wp_suggestion ); $template->author = $post->post_author; if ( 'wp_template' === $post->post_type && $has_theme_file && isset( $template_file['postTypes'] ) ) { $template->post_types = $template_file['postTypes']; } if ( 'wp_template' === $post->post_type && isset( $default_template_types[ $template->slug ] ) ) { $template->is_custom = false; } if ( 'wp_template_part' === $post->post_type ) { $type_terms = get_the_terms( $post, 'wp_template_part_area' ); if ( ! is_wp_error( $type_terms ) && false !== $type_terms ) { $template->area = $type_terms[0]->name; } } if ( 'wp_template' === $post->post_type && empty( $template->description ) && ( empty( $template->title ) || $template->title === $template->slug ) ) { $matches = array(); if ( preg_match( '/(author|page|single|tag|category|taxonomy)-(.+)/', $template->slug, $matches ) ) { $type = $matches[1]; $slug_remaining = $matches[2]; switch ( $type ) { case 'author': $nice_name = $slug_remaining; $users = get_users( array( 'capability' => 'edit_posts', 'search' => $nice_name, 'search_columns' => array( 'user_nicename' ), 'fields' => 'display_name', ) ); if ( empty( $users ) ) { $template->title = sprintf( __( 'Deleted author: %s' ), $nice_name ); } else { $author_name = $users[0]; $template->title = sprintf( __( 'Author: %s' ), $author_name ); $template->description = sprintf( __( 'Template for %s' ), $author_name ); $users_with_same_name = get_users( array( 'capability' => 'edit_posts', 'search' => $author_name, 'search_columns' => array( 'display_name' ), 'fields' => 'display_name', ) ); if ( count( $users_with_same_name ) > 1 ) { $template->title = sprintf( __( '%1$s (%2$s)' ), $template->title, $nice_name ); } } break; case 'page': _wp_build_title_and_description_for_single_post_type_block_template( 'page', $slug_remaining, $template ); break; case 'single': $post_types = get_post_types(); foreach ( $post_types as $post_type ) { $post_type_length = strlen( $post_type ) + 1; if ( 0 === strncmp( $slug_remaining, $post_type . '-', $post_type_length ) ) { $slug = substr( $slug_remaining, $post_type_length, strlen( $slug_remaining ) ); $found = _wp_build_title_and_description_for_single_post_type_block_template( $post_type, $slug, $template ); if ( $found ) { break; } } } break; case 'tag': _wp_build_title_and_description_for_taxonomy_block_template( 'post_tag', $slug_remaining, $template ); break; case 'category': _wp_build_title_and_description_for_taxonomy_block_template( 'category', $slug_remaining, $template ); break; case 'taxonomy': $taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { $taxonomy_length = strlen( $taxonomy ) + 1; if ( 0 === strncmp( $slug_remaining, $taxonomy . '-', $taxonomy_length ) ) { $slug = substr( $slug_remaining, $taxonomy_length, strlen( $slug_remaining ) ); $found = _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, $template ); if ( $found ) { break; } } } break; } } } return $template; } function get_block_templates( $query = array(), $template_type = 'wp_template' ) { $templates = apply_filters( 'pre_get_block_templates', null, $query, $template_type ); if ( ! is_null( $templates ) ) { return $templates; } $post_type = isset( $query['post_type'] ) ? $query['post_type'] : ''; $wp_query_args = array( 'post_status' => array( 'auto-draft', 'draft', 'publish' ), 'post_type' => $template_type, 'posts_per_page' => -1, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => get_stylesheet(), ), ), ); if ( 'wp_template_part' === $template_type && isset( $query['area'] ) ) { $wp_query_args['tax_query'][] = array( 'taxonomy' => 'wp_template_part_area', 'field' => 'name', 'terms' => $query['area'], ); $wp_query_args['tax_query']['relation'] = 'AND'; } if ( isset( $query['slug__in'] ) ) { $wp_query_args['post_name__in'] = $query['slug__in']; } if ( isset( $query['wp_id'] ) ) { $wp_query_args['p'] = $query['wp_id']; } else { $wp_query_args['post_status'] = 'publish'; } $template_query = new WP_Query( $wp_query_args ); $query_result = array(); foreach ( $template_query->posts as $post ) { $template = _build_block_template_result_from_post( $post ); if ( is_wp_error( $template ) ) { continue; } if ( $post_type && ! $template->is_custom ) { continue; } if ( $post_type && isset( $template->post_types ) && ! in_array( $post_type, $template->post_types, true ) ) { continue; } $query_result[] = $template; } if ( ! isset( $query['wp_id'] ) ) { $template_files = _get_block_templates_files( $template_type ); foreach ( $template_files as $template_file ) { $template = _build_block_template_result_from_file( $template_file, $template_type ); if ( $post_type && ! $template->is_custom ) { continue; } if ( $post_type && isset( $template->post_types ) && ! in_array( $post_type, $template->post_types, true ) ) { continue; } $is_not_custom = false === array_search( get_stylesheet() . '//' . $template_file['slug'], wp_list_pluck( $query_result, 'id' ), true ); $fits_slug_query = ! isset( $query['slug__in'] ) || in_array( $template_file['slug'], $query['slug__in'], true ); $fits_area_query = ! isset( $query['area'] ) || $template_file['area'] === $query['area']; $should_include = $is_not_custom && $fits_slug_query && $fits_area_query; if ( $should_include ) { $query_result[] = $template; } } } return apply_filters( 'get_block_templates', $query_result, $query, $template_type ); } function get_block_template( $id, $template_type = 'wp_template' ) { $block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type ); if ( ! is_null( $block_template ) ) { return $block_template; } $parts = explode( '//', $id, 2 ); if ( count( $parts ) < 2 ) { return null; } list( $theme, $slug ) = $parts; $wp_query_args = array( 'post_name__in' => array( $slug ), 'post_type' => $template_type, 'post_status' => array( 'auto-draft', 'draft', 'publish', 'trash' ), 'posts_per_page' => 1, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => $theme, ), ), ); $template_query = new WP_Query( $wp_query_args ); $posts = $template_query->posts; if ( count( $posts ) > 0 ) { $template = _build_block_template_result_from_post( $posts[0] ); if ( ! is_wp_error( $template ) ) { return $template; } } $block_template = get_block_file_template( $id, $template_type ); return apply_filters( 'get_block_template', $block_template, $id, $template_type ); } function get_block_file_template( $id, $template_type = 'wp_template' ) { $block_template = apply_filters( 'pre_get_block_file_template', null, $id, $template_type ); if ( ! is_null( $block_template ) ) { return $block_template; } $parts = explode( '//', $id, 2 ); if ( count( $parts ) < 2 ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } list( $theme, $slug ) = $parts; if ( get_stylesheet() !== $theme ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } $template_file = _get_block_template_file( $template_type, $slug ); if ( null === $template_file ) { return apply_filters( 'get_block_file_template', null, $id, $template_type ); } $block_template = _build_block_template_result_from_file( $template_file, $template_type ); return apply_filters( 'get_block_file_template', $block_template, $id, $template_type ); } function block_template_part( $part ) { $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' ); if ( ! $template_part || empty( $template_part->content ) ) { return; } echo do_blocks( $template_part->content ); } function block_header_area() { block_template_part( 'header' ); } function block_footer_area() { block_template_part( 'footer' ); } function wp_is_theme_directory_ignored( $path ) { $directories_to_ignore = array( '.DS_Store', '.svn', '.git', '.hg', '.bzr', 'node_modules', 'vendor' ); foreach ( $directories_to_ignore as $directory ) { if ( str_starts_with( $path, $directory ) ) { return true; } } return false; } function wp_generate_block_templates_export_file() { global $wp_version; if ( ! class_exists( 'ZipArchive' ) ) { return new WP_Error( 'missing_zip_package', __( 'Zip Export not supported.' ) ); } $obscura = wp_generate_password( 12, false, false ); $theme_name = basename( get_stylesheet() ); $filename = get_temp_dir() . $theme_name . $obscura . '.zip'; $zip = new ZipArchive(); if ( true !== $zip->open( $filename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) ) { return new WP_Error( 'unable_to_create_zip', __( 'Unable to open export file (archive) for writing.' ) ); } $zip->addEmptyDir( 'templates' ); $zip->addEmptyDir( 'parts' ); $theme_path = wp_normalize_path( get_stylesheet_directory() ); $theme_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $theme_path ), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ( $theme_files as $file ) { if ( ! $file->isDir() ) { $file_path = wp_normalize_path( $file ); $relative_path = substr( $file_path, strlen( $theme_path ) + 1 ); if ( ! wp_is_theme_directory_ignored( $relative_path ) ) { $zip->addFile( $file_path, $relative_path ); } } } $templates = get_block_templates(); foreach ( $templates as $template ) { $template->content = _remove_theme_attribute_in_block_template_content( $template->content ); $zip->addFromString( 'templates/' . $template->slug . '.html', $template->content ); } $template_parts = get_block_templates( array(), 'wp_template_part' ); foreach ( $template_parts as $template_part ) { $zip->addFromString( 'parts/' . $template_part->slug . '.html', $template_part->content ); } $tree = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) ); $tree->merge( WP_Theme_JSON_Resolver::get_user_data() ); $theme_json_raw = $tree->get_data(); if ( $theme_json_raw['version'] ) { $theme_json_version = 'wp/' . substr( $wp_version, 0, 3 ); $schema = array( '$schema' => 'https://schemas.wp.org/' . $theme_json_version . '/theme.json' ); $theme_json_raw = array_merge( $schema, $theme_json_raw ); } $theme_json_encoded = wp_json_encode( $theme_json_raw, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); $theme_json_tabbed = preg_replace( '~(?:^|\G)\h{4}~m', "\t", $theme_json_encoded ); $zip->addFromString( 'theme.json', $theme_json_tabbed ); $zip->close(); return $filename; } function get_template_hierarchy( $slug, $is_custom = false, $template_prefix = '' ) { if ( 'index' === $slug ) { return array( 'index' ); } if ( $is_custom ) { return array( 'page', 'singular', 'index' ); } if ( 'front-page' === $slug ) { return array( 'front-page', 'home', 'index' ); } $template_hierarchy = array( $slug ); if ( $template_prefix ) { list( $type ) = explode( '-', $template_prefix ); if ( ! in_array( $template_prefix, array( $slug, $type ), true ) ) { $template_hierarchy[] = $template_prefix; } if ( $slug !== $type ) { $template_hierarchy[] = $type; } } if ( str_starts_with( $slug, 'author' ) || str_starts_with( $slug, 'taxonomy' ) || str_starts_with( $slug, 'category' ) || str_starts_with( $slug, 'tag' ) || 'date' === $slug ) { $template_hierarchy[] = 'archive'; } if ( 'attachment' === $slug ) { $template_hierarchy[] = 'single'; } if ( str_starts_with( $slug, 'single' ) || str_starts_with( $slug, 'page' ) || 'attachment' === $slug ) { $template_hierarchy[] = 'singular'; } $template_hierarchy[] = 'index'; return $template_hierarchy; } content ) && is_user_logged_in() ) { $_wp_current_template_content = sprintf( __( 'Empty template: %s' ), $block_template->title ); } elseif ( ! empty( $block_template->content ) ) { $_wp_current_template_content = $block_template->content; } if ( isset( $_GET['_wp-find-template'] ) ) { wp_send_json_success( $block_template ); } } else { if ( $template ) { return $template; } if ( 'index' === $type ) { if ( isset( $_GET['_wp-find-template'] ) ) { wp_send_json_error( array( 'message' => __( 'No matching template found.' ) ) ); } } else { return ''; } } add_action( 'wp_head', '_block_template_viewport_meta_tag', 0 ); remove_action( 'wp_head', '_wp_render_title_tag', 1 ); add_action( 'wp_head', '_block_template_render_title_tag', 1 ); return ABSPATH . WPINC . '/template-canvas.php'; } function resolve_block_template( $template_type, $template_hierarchy, $fallback_template ) { if ( ! $template_type ) { return null; } if ( empty( $template_hierarchy ) ) { $template_hierarchy = array( $template_type ); } $slugs = array_map( '_strip_template_file_suffix', $template_hierarchy ); $query = array( 'theme' => get_stylesheet(), 'slug__in' => $slugs, ); $templates = get_block_templates( $query ); $slug_priorities = array_flip( $slugs ); usort( $templates, static function ( $template_a, $template_b ) use ( $slug_priorities ) { return $slug_priorities[ $template_a->slug ] - $slug_priorities[ $template_b->slug ]; } ); $theme_base_path = get_stylesheet_directory() . DIRECTORY_SEPARATOR; $parent_theme_base_path = get_template_directory() . DIRECTORY_SEPARATOR; if ( strpos( $fallback_template, $theme_base_path ) === 0 && strpos( $fallback_template, $parent_theme_base_path ) === false ) { $fallback_template_slug = substr( $fallback_template, strpos( $fallback_template, $theme_base_path ) + strlen( $theme_base_path ), -4 ); if ( count( $templates ) && $fallback_template_slug === $templates[0]->slug && 'theme' === $templates[0]->source ) { $template_file = _get_block_template_file( 'wp_template', $fallback_template_slug ); if ( $template_file && get_template() === $template_file['theme'] ) { array_shift( $templates ); } } } return count( $templates ) ? $templates[0] : null; } function _block_template_render_title_tag() { echo '' . wp_get_document_title() . '' . "\n"; } function get_the_block_template_html() { global $_wp_current_template_content; global $wp_embed; if ( ! $_wp_current_template_content ) { if ( is_user_logged_in() ) { return '

    ' . esc_html__( 'No matching template found' ) . '

    '; } return; } $content = $wp_embed->run_shortcode( $_wp_current_template_content ); $content = $wp_embed->autoembed( $content ); $content = do_blocks( $content ); $content = wptexturize( $content ); $content = convert_smilies( $content ); $content = shortcode_unautop( $content ); $content = wp_filter_content_tags( $content ); $content = do_shortcode( $content ); $content = str_replace( ']]>', ']]>', $content ); return '
    ' . $content . '
    '; } function _block_template_viewport_meta_tag() { echo '' . "\n"; } function _strip_template_file_suffix( $template_file ) { return preg_replace( '/\.(php|html)$/', '', $template_file ); } function _block_template_render_without_post_block_context( $context ) { if ( isset( $context['postType'] ) && 'wp_template' === $context['postType'] ) { unset( $context['postId'] ); unset( $context['postType'] ); } return $context; } function _resolve_template_for_new_post( $wp_query ) { if ( ! $wp_query->is_main_query() ) { return; } remove_filter( 'pre_get_posts', '_resolve_template_for_new_post' ); $page_id = isset( $wp_query->query['page_id'] ) ? $wp_query->query['page_id'] : null; $p = isset( $wp_query->query['p'] ) ? $wp_query->query['p'] : null; $post_id = $page_id ? $page_id : $p; $post = get_post( $post_id ); if ( $post && 'auto-draft' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) { $wp_query->set( 'post_status', 'auto-draft' ); } } function _resolve_home_block_template() { $show_on_front = get_option( 'show_on_front' ); $front_page_id = get_option( 'page_on_front' ); if ( 'page' === $show_on_front && $front_page_id ) { return array( 'postType' => 'page', 'postId' => $front_page_id, ); } $hierarchy = array( 'front-page', 'home', 'index' ); $template = resolve_block_template( 'home', $hierarchy, '' ); if ( ! $template ) { return null; } return array( 'postType' => 'wp_template', 'postId' => $template->id, ); } 0 ) { $asset_handle .= '-' . ( $index + 1 ); } return $asset_handle; } $field_mappings = array( 'editorScript' => 'editor-script', 'script' => 'script', 'viewScript' => 'view-script', 'editorStyle' => 'editor-style', 'style' => 'style', ); $asset_handle = str_replace( '/', '-', $block_name ) . '-' . $field_mappings[ $field_name ]; if ( $index > 0 ) { $asset_handle .= '-' . ( $index + 1 ); } return $asset_handle; } function register_block_script_handle( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } $script_handle = $metadata[ $field_name ]; if ( is_array( $script_handle ) ) { if ( empty( $script_handle[ $index ] ) ) { return false; } $script_handle = $script_handle[ $index ]; } $script_path = remove_block_asset_path_prefix( $script_handle ); if ( $script_handle === $script_path ) { return $script_handle; } $script_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $script_asset_path = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) ) ) ); if ( ! file_exists( $script_asset_path ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.' ), $field_name, $metadata['name'] ), '5.5.0' ); return false; } static $wpinc_path_norm = ''; if ( ! $wpinc_path_norm ) { $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); } $theme_path_norm = wp_normalize_path( get_theme_file_path() ); $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm ); $script_uri = plugins_url( $script_path, $metadata['file'] ); if ( $is_core_block ) { $script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ); } elseif ( $is_theme_block ) { $script_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $script_path_norm ) ); } $script_asset = require $script_asset_path; $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); $result = wp_register_script( $script_handle, $script_uri, $script_dependencies, isset( $script_asset['version'] ) ? $script_asset['version'] : false ); if ( ! $result ) { return false; } if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies, true ) ) { wp_set_script_translations( $script_handle, $metadata['textdomain'] ); } return $script_handle; } function register_block_style_handle( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } static $wpinc_path_norm = ''; if ( ! $wpinc_path_norm ) { $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); } $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { return false; } $style_handle = $metadata[ $field_name ]; if ( is_array( $style_handle ) ) { if ( empty( $style_handle[ $index ] ) ) { return false; } $style_handle = $style_handle[ $index ]; } $style_path = remove_block_asset_path_prefix( $style_handle ); $is_style_handle = $style_handle === $style_path; if ( $is_core_block && ! $is_style_handle ) { return false; } if ( $is_style_handle && ! ( $is_core_block && 0 === $index ) ) { return $style_handle; } $suffix = SCRIPT_DEBUG ? '' : '.min'; if ( $is_core_block ) { $style_path = "style$suffix.css"; } $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) ); $has_style_file = '' !== $style_path_norm; if ( $has_style_file ) { $style_uri = plugins_url( $style_path, $metadata['file'] ); static $theme_path_norm = ''; if ( ! $theme_path_norm ) { $theme_path_norm = wp_normalize_path( get_theme_file_path() ); } $is_theme_block = str_starts_with( $style_path_norm, $theme_path_norm ); if ( $is_theme_block ) { $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) ); } elseif ( $is_core_block ) { $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); } } else { $style_uri = false; } $style_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false; $result = wp_register_style( $style_handle, $style_uri, array(), $version ); if ( ! $result ) { return false; } if ( $has_style_file ) { wp_style_add_data( $style_handle, 'path', $style_path_norm ); $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm ); if ( is_rtl() && file_exists( $rtl_file ) ) { wp_style_add_data( $style_handle, 'rtl', 'replace' ); wp_style_add_data( $style_handle, 'suffix', $suffix ); wp_style_add_data( $style_handle, 'path', $rtl_file ); } } return $style_handle; } function get_block_metadata_i18n_schema() { static $i18n_block_schema; if ( ! isset( $i18n_block_schema ) ) { $i18n_block_schema = wp_json_file_decode( __DIR__ . '/block-i18n.json' ); } return $i18n_block_schema; } function register_block_type_from_metadata( $file_or_folder, $args = array() ) { static $core_blocks_meta; if ( ! $core_blocks_meta ) { $core_blocks_meta = include_once ABSPATH . WPINC . '/blocks/blocks-json.php'; } $metadata_file = ( ! str_ends_with( $file_or_folder, 'block.json' ) ) ? trailingslashit( $file_or_folder ) . 'block.json' : $file_or_folder; if ( ! file_exists( $metadata_file ) ) { return false; } $metadata = false; if ( str_starts_with( $file_or_folder, ABSPATH . WPINC ) ) { $core_block_name = str_replace( ABSPATH . WPINC . '/blocks/', '', $file_or_folder ); if ( ! empty( $core_blocks_meta[ $core_block_name ] ) ) { $metadata = $core_blocks_meta[ $core_block_name ]; } } if ( ! $metadata ) { $metadata = wp_json_file_decode( $metadata_file, array( 'associative' => true ) ); } if ( ! is_array( $metadata ) || empty( $metadata['name'] ) ) { return false; } $metadata['file'] = wp_normalize_path( realpath( $metadata_file ) ); $metadata = apply_filters( 'block_type_metadata', $metadata ); if ( ! empty( $metadata['name'] ) && 0 === strpos( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); if ( ! isset( $metadata['style'] ) ) { $metadata['style'] = "wp-block-$block_name"; } if ( ! isset( $metadata['editorStyle'] ) ) { $metadata['editorStyle'] = "wp-block-{$block_name}-editor"; } } $settings = array(); $property_mappings = array( 'apiVersion' => 'api_version', 'title' => 'title', 'category' => 'category', 'parent' => 'parent', 'ancestor' => 'ancestor', 'icon' => 'icon', 'description' => 'description', 'keywords' => 'keywords', 'attributes' => 'attributes', 'providesContext' => 'provides_context', 'usesContext' => 'uses_context', 'supports' => 'supports', 'styles' => 'styles', 'variations' => 'variations', 'example' => 'example', ); $textdomain = ! empty( $metadata['textdomain'] ) ? $metadata['textdomain'] : null; $i18n_schema = get_block_metadata_i18n_schema(); foreach ( $property_mappings as $key => $mapped_key ) { if ( isset( $metadata[ $key ] ) ) { $settings[ $mapped_key ] = $metadata[ $key ]; if ( $textdomain && isset( $i18n_schema->$key ) ) { $settings[ $mapped_key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $settings[ $key ], $textdomain ); } } } $script_fields = array( 'editorScript' => 'editor_script_handles', 'script' => 'script_handles', 'viewScript' => 'view_script_handles', ); foreach ( $script_fields as $metadata_field_name => $settings_field_name ) { if ( ! empty( $metadata[ $metadata_field_name ] ) ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { for ( $index = 0; $index < count( $scripts ); $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, $index ); if ( $result ) { $processed_scripts[] = $result; } } } else { $result = register_block_script_handle( $metadata, $metadata_field_name ); if ( $result ) { $processed_scripts[] = $result; } } $settings[ $settings_field_name ] = $processed_scripts; } } $style_fields = array( 'editorStyle' => 'editor_style_handles', 'style' => 'style_handles', ); foreach ( $style_fields as $metadata_field_name => $settings_field_name ) { if ( ! empty( $metadata[ $metadata_field_name ] ) ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { for ( $index = 0; $index < count( $styles ); $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, $index ); if ( $result ) { $processed_styles[] = $result; } } } else { $result = register_block_style_handle( $metadata, $metadata_field_name ); if ( $result ) { $processed_styles[] = $result; } } $settings[ $settings_field_name ] = $processed_styles; } } if ( ! empty( $metadata['render'] ) ) { $template_path = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . remove_block_asset_path_prefix( $metadata['render'] ) ) ); if ( $template_path ) { $settings['render_callback'] = function( $attributes, $content, $block ) use ( $template_path ) { ob_start(); require $template_path; return ob_get_clean(); }; } } $settings = apply_filters( 'block_type_metadata_settings', array_merge( $settings, $args ), $metadata ); return WP_Block_Type_Registry::get_instance()->register( $metadata['name'], $settings ); } function register_block_type( $block_type, $args = array() ) { if ( is_string( $block_type ) && file_exists( $block_type ) ) { return register_block_type_from_metadata( $block_type, $args ); } return WP_Block_Type_Registry::get_instance()->register( $block_type, $args ); } function unregister_block_type( $name ) { return WP_Block_Type_Registry::get_instance()->unregister( $name ); } function has_blocks( $post = null ) { if ( ! is_string( $post ) ) { $wp_post = get_post( $post ); if ( ! $wp_post instanceof WP_Post ) { return false; } $post = $wp_post->post_content; } return false !== strpos( (string) $post, '', $serialized_block_name, $serialized_attributes ); } return sprintf( '%s', $serialized_block_name, $serialized_attributes, $block_content, $serialized_block_name ); } function serialize_block( $block ) { $block_content = ''; $index = 0; foreach ( $block['innerContent'] as $chunk ) { $block_content .= is_string( $chunk ) ? $chunk : serialize_block( $block['innerBlocks'][ $index++ ] ); } if ( ! is_array( $block['attrs'] ) ) { $block['attrs'] = array(); } return get_comment_delimited_block_content( $block['blockName'], $block['attrs'], $block_content ); } function serialize_blocks( $blocks ) { return implode( '', array_map( 'serialize_block', $blocks ) ); } function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) { $result = ''; $blocks = parse_blocks( $text ); foreach ( $blocks as $block ) { $block = filter_block_kses( $block, $allowed_html, $allowed_protocols ); $result .= serialize_block( $block ); } return $result; } function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols ); if ( is_array( $block['innerBlocks'] ) ) { foreach ( $block['innerBlocks'] as $i => $inner_block ) { $block['innerBlocks'][ $i ] = filter_block_kses( $inner_block, $allowed_html, $allowed_protocols ); } } return $block; } function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) { if ( is_array( $value ) ) { foreach ( $value as $key => $inner_value ) { $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); if ( $filtered_key !== $key ) { unset( $value[ $key ] ); } $value[ $filtered_key ] = $filtered_value; } } elseif ( is_string( $value ) ) { return wp_kses( $value, $allowed_html, $allowed_protocols ); } return $value; } function excerpt_remove_blocks( $content ) { $allowed_inner_blocks = array( null, 'core/freeform', 'core/heading', 'core/html', 'core/list', 'core/media-text', 'core/paragraph', 'core/preformatted', 'core/pullquote', 'core/quote', 'core/table', 'core/verse', ); $allowed_wrapper_blocks = array( 'core/columns', 'core/column', 'core/group', ); $allowed_wrapper_blocks = apply_filters( 'excerpt_allowed_wrapper_blocks', $allowed_wrapper_blocks ); $allowed_blocks = array_merge( $allowed_inner_blocks, $allowed_wrapper_blocks ); $allowed_blocks = apply_filters( 'excerpt_allowed_blocks', $allowed_blocks ); $blocks = parse_blocks( $content ); $output = ''; foreach ( $blocks as $block ) { if ( in_array( $block['blockName'], $allowed_blocks, true ) ) { if ( ! empty( $block['innerBlocks'] ) ) { if ( in_array( $block['blockName'], $allowed_wrapper_blocks, true ) ) { $output .= _excerpt_render_inner_blocks( $block, $allowed_blocks ); continue; } foreach ( $block['innerBlocks'] as $inner_block ) { if ( ! in_array( $inner_block['blockName'], $allowed_inner_blocks, true ) || ! empty( $inner_block['innerBlocks'] ) ) { continue 2; } } } $output .= render_block( $block ); } } return $output; } function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) { $output = ''; foreach ( $parsed_block['innerBlocks'] as $inner_block ) { if ( ! in_array( $inner_block['blockName'], $allowed_blocks, true ) ) { continue; } if ( empty( $inner_block['innerBlocks'] ) ) { $output .= render_block( $inner_block ); } else { $output .= _excerpt_render_inner_blocks( $inner_block, $allowed_blocks ); } } return $output; } function render_block( $parsed_block ) { global $post; $parent_block = null; $pre_render = apply_filters( 'pre_render_block', null, $parsed_block, $parent_block ); if ( ! is_null( $pre_render ) ) { return $pre_render; } $source_block = $parsed_block; $parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block ); $context = array(); if ( $post instanceof WP_Post ) { $context['postId'] = $post->ID; $context['postType'] = $post->post_type; } $context = apply_filters( 'render_block_context', $context, $parsed_block, $parent_block ); $block = new WP_Block( $parsed_block, $context ); return $block->render(); } function parse_blocks( $content ) { $parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' ); $parser = new $parser_class(); return $parser->parse( $content ); } function do_blocks( $content ) { $blocks = parse_blocks( $content ); $output = ''; foreach ( $blocks as $block ) { $output .= render_block( $block ); } $priority = has_filter( 'the_content', 'wpautop' ); if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) { remove_filter( 'the_content', 'wpautop', $priority ); add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 ); } return $output; } function _restore_wpautop_hook( $content ) { $current_priority = has_filter( 'the_content', '_restore_wpautop_hook' ); add_filter( 'the_content', 'wpautop', $current_priority - 1 ); remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority ); return $content; } function block_version( $content ) { return has_blocks( $content ) ? 1 : 0; } function register_block_style( $block_name, $style_properties ) { return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties ); } function unregister_block_style( $block_name, $block_style_name ) { return WP_Block_Styles_Registry::get_instance()->unregister( $block_name, $block_style_name ); } function block_has_support( $block_type, $feature, $default = false ) { $block_support = $default; if ( $block_type && property_exists( $block_type, 'supports' ) ) { $block_support = _wp_array_get( $block_type->supports, $feature, $default ); } return true === $block_support || is_array( $block_support ); } function wp_migrate_old_typography_shape( $metadata ) { if ( ! isset( $metadata['supports'] ) ) { return $metadata; } $typography_keys = array( '__experimentalFontFamily', '__experimentalFontStyle', '__experimentalFontWeight', '__experimentalLetterSpacing', '__experimentalTextDecoration', '__experimentalTextTransform', 'fontSize', 'lineHeight', ); foreach ( $typography_keys as $typography_key ) { $support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null ); if ( null !== $support_for_key ) { _doing_it_wrong( 'register_block_type_from_metadata()', sprintf( __( 'Block "%1$s" is declaring %2$s support in %3$s file under %4$s. %2$s support is now declared under %5$s.' ), $metadata['name'], "$typography_key", 'block.json', "supports.$typography_key", "supports.typography.$typography_key" ), '5.8.0' ); _wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key ); unset( $metadata['supports'][ $typography_key ] ); } } return $metadata; } function build_query_vars_from_query_block( $block, $page ) { $query = array( 'post_type' => 'post', 'order' => 'DESC', 'orderby' => 'date', 'post__not_in' => array(), ); if ( isset( $block->context['query'] ) ) { if ( ! empty( $block->context['query']['postType'] ) ) { $post_type_param = $block->context['query']['postType']; if ( is_post_type_viewable( $post_type_param ) ) { $query['post_type'] = $post_type_param; } } if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) { $sticky = get_option( 'sticky_posts' ); if ( 'only' === $block->context['query']['sticky'] ) { $query['post__in'] = $sticky; } else { $query['post__not_in'] = array_merge( $query['post__not_in'], $sticky ); } } if ( ! empty( $block->context['query']['exclude'] ) ) { $excluded_post_ids = array_map( 'intval', $block->context['query']['exclude'] ); $excluded_post_ids = array_filter( $excluded_post_ids ); $query['post__not_in'] = array_merge( $query['post__not_in'], $excluded_post_ids ); } if ( isset( $block->context['query']['perPage'] ) && is_numeric( $block->context['query']['perPage'] ) ) { $per_page = absint( $block->context['query']['perPage'] ); $offset = 0; if ( isset( $block->context['query']['offset'] ) && is_numeric( $block->context['query']['offset'] ) ) { $offset = absint( $block->context['query']['offset'] ); } $query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset; $query['posts_per_page'] = $per_page; } if ( ! empty( $block->context['query']['categoryIds'] ) || ! empty( $block->context['query']['tagIds'] ) ) { $tax_query = array(); if ( ! empty( $block->context['query']['categoryIds'] ) ) { $tax_query[] = array( 'taxonomy' => 'category', 'terms' => array_filter( array_map( 'intval', $block->context['query']['categoryIds'] ) ), 'include_children' => false, ); } if ( ! empty( $block->context['query']['tagIds'] ) ) { $tax_query[] = array( 'taxonomy' => 'post_tag', 'terms' => array_filter( array_map( 'intval', $block->context['query']['tagIds'] ) ), 'include_children' => false, ); } $query['tax_query'] = $tax_query; } if ( ! empty( $block->context['query']['taxQuery'] ) ) { $query['tax_query'] = array(); foreach ( $block->context['query']['taxQuery'] as $taxonomy => $terms ) { if ( is_taxonomy_viewable( $taxonomy ) && ! empty( $terms ) ) { $query['tax_query'][] = array( 'taxonomy' => $taxonomy, 'terms' => array_filter( array_map( 'intval', $terms ) ), 'include_children' => false, ); } } } if ( isset( $block->context['query']['order'] ) && in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true ) ) { $query['order'] = strtoupper( $block->context['query']['order'] ); } if ( isset( $block->context['query']['orderBy'] ) ) { $query['orderby'] = $block->context['query']['orderBy']; } if ( isset( $block->context['query']['author'] ) && (int) $block->context['query']['author'] > 0 ) { $query['author'] = (int) $block->context['query']['author']; } if ( ! empty( $block->context['query']['search'] ) ) { $query['s'] = $block->context['query']['search']; } if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) { $query['post_parent__in'] = array_filter( array_map( 'intval', $block->context['query']['parents'] ) ); } } return apply_filters( 'query_loop_block_query_vars', $query, $block, $page ); } function get_query_pagination_arrow( $block, $is_next ) { $arrow_map = array( 'none' => '', 'arrow' => array( 'next' => '→', 'previous' => '←', ), 'chevron' => array( 'next' => '»', 'previous' => '«', ), ); if ( ! empty( $block->context['paginationArrow'] ) && array_key_exists( $block->context['paginationArrow'], $arrow_map ) && ! empty( $arrow_map[ $block->context['paginationArrow'] ] ) ) { $pagination_type = $is_next ? 'next' : 'previous'; $arrow_attribute = $block->context['paginationArrow']; $arrow = $arrow_map[ $block->context['paginationArrow'] ][ $pagination_type ]; $arrow_classes = "wp-block-query-pagination-$pagination_type-arrow is-arrow-$arrow_attribute"; return ""; } return null; } function build_comment_query_vars_from_block( $block ) { $comment_args = array( 'orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'no_found_rows' => false, ); if ( is_user_logged_in() ) { $comment_args['include_unapproved'] = array( get_current_user_id() ); } else { $unapproved_email = wp_get_unapproved_comment_author_email(); if ( $unapproved_email ) { $comment_args['include_unapproved'] = array( $unapproved_email ); } } if ( ! empty( $block->context['postId'] ) ) { $comment_args['post_id'] = (int) $block->context['postId']; } if ( get_option( 'thread_comments' ) ) { $comment_args['hierarchical'] = 'threaded'; } else { $comment_args['hierarchical'] = false; } if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) { $per_page = get_option( 'comments_per_page' ); $default_page = get_option( 'default_comments_page' ); if ( $per_page > 0 ) { $comment_args['number'] = $per_page; $page = (int) get_query_var( 'cpage' ); if ( $page ) { $comment_args['paged'] = $page; } elseif ( 'oldest' === $default_page ) { $comment_args['paged'] = 1; } elseif ( 'newest' === $default_page ) { $max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages; if ( 0 !== $max_num_pages ) { $comment_args['paged'] = $max_num_pages; } } if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) { set_query_var( 'cpage', $comment_args['paged'] ); } } } return $comment_args; } function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) { $arrow_map = array( 'none' => '', 'arrow' => array( 'next' => '→', 'previous' => '←', ), 'chevron' => array( 'next' => '»', 'previous' => '«', ), ); if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) { $arrow_attribute = $block->context['comments/paginationArrow']; $arrow = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ]; $arrow_classes = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute"; return ""; } return null; } 0 ) { $asset_handle .= '-' . ( $index + 1 ); } return $asset_handle; } $field_mappings = array( 'editorScript' => 'editor-script', 'script' => 'script', 'viewScript' => 'view-script', 'editorStyle' => 'editor-style', 'style' => 'style', ); $asset_handle = str_replace( '/', '-', $block_name ) . '-' . $field_mappings[ $field_name ]; if ( $index > 0 ) { $asset_handle .= '-' . ( $index + 1 ); } return $asset_handle; } function register_block_script_handle( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } $script_handle = $metadata[ $field_name ]; if ( is_array( $script_handle ) ) { if ( empty( $script_handle[ $index ] ) ) { return false; } $script_handle = $script_handle[ $index ]; } $script_path = remove_block_asset_path_prefix( $script_handle ); if ( $script_handle === $script_path ) { return $script_handle; } $script_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $script_asset_path = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) ) ) ); if ( ! file_exists( $script_asset_path ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.' ), $field_name, $metadata['name'] ), '5.5.0' ); return false; } static $wpinc_path_norm = ''; if ( ! $wpinc_path_norm ) { $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); } $theme_path_norm = wp_normalize_path( get_theme_file_path() ); $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm ); $script_uri = plugins_url( $script_path, $metadata['file'] ); if ( $is_core_block ) { $script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ); } elseif ( $is_theme_block ) { $script_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $script_path_norm ) ); } $script_asset = require $script_asset_path; $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); $result = wp_register_script( $script_handle, $script_uri, $script_dependencies, isset( $script_asset['version'] ) ? $script_asset['version'] : false ); if ( ! $result ) { return false; } if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies, true ) ) { wp_set_script_translations( $script_handle, $metadata['textdomain'] ); } return $script_handle; } function register_block_style_handle( $metadata, $field_name, $index = 0 ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } static $wpinc_path_norm = ''; if ( ! $wpinc_path_norm ) { $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); } $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { return false; } $style_handle = $metadata[ $field_name ]; if ( is_array( $style_handle ) ) { if ( empty( $style_handle[ $index ] ) ) { return false; } $style_handle = $style_handle[ $index ]; } $style_path = remove_block_asset_path_prefix( $style_handle ); $is_style_handle = $style_handle === $style_path; if ( $is_core_block && ! $is_style_handle ) { return false; } if ( $is_style_handle && ! ( $is_core_block && 0 === $index ) ) { return $style_handle; } $suffix = SCRIPT_DEBUG ? '' : '.min'; if ( $is_core_block ) { $style_path = "style$suffix.css"; } $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) ); $has_style_file = '' !== $style_path_norm; if ( $has_style_file ) { $style_uri = plugins_url( $style_path, $metadata['file'] ); static $theme_path_norm = ''; if ( ! $theme_path_norm ) { $theme_path_norm = wp_normalize_path( get_theme_file_path() ); } $is_theme_block = str_starts_with( $style_path_norm, $theme_path_norm ); if ( $is_theme_block ) { $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) ); } elseif ( $is_core_block ) { $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); } } else { $style_uri = false; } $style_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index ); $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false; $result = wp_register_style( $style_handle, $style_uri, array(), $version ); if ( ! $result ) { return false; } if ( $has_style_file ) { wp_style_add_data( $style_handle, 'path', $style_path_norm ); $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm ); if ( is_rtl() && file_exists( $rtl_file ) ) { wp_style_add_data( $style_handle, 'rtl', 'replace' ); wp_style_add_data( $style_handle, 'suffix', $suffix ); wp_style_add_data( $style_handle, 'path', $rtl_file ); } } return $style_handle; } function get_block_metadata_i18n_schema() { static $i18n_block_schema; if ( ! isset( $i18n_block_schema ) ) { $i18n_block_schema = wp_json_file_decode( __DIR__ . '/block-i18n.json' ); } return $i18n_block_schema; } function register_block_type_from_metadata( $file_or_folder, $args = array() ) { static $core_blocks_meta; if ( ! $core_blocks_meta ) { $core_blocks_meta = include_once ABSPATH . WPINC . '/blocks/blocks-json.php'; } $metadata_file = ( ! str_ends_with( $file_or_folder, 'block.json' ) ) ? trailingslashit( $file_or_folder ) . 'block.json' : $file_or_folder; if ( ! file_exists( $metadata_file ) ) { return false; } $metadata = false; if ( str_starts_with( $file_or_folder, ABSPATH . WPINC ) ) { $core_block_name = str_replace( ABSPATH . WPINC . '/blocks/', '', $file_or_folder ); if ( ! empty( $core_blocks_meta[ $core_block_name ] ) ) { $metadata = $core_blocks_meta[ $core_block_name ]; } } if ( ! $metadata ) { $metadata = wp_json_file_decode( $metadata_file, array( 'associative' => true ) ); } if ( ! is_array( $metadata ) || empty( $metadata['name'] ) ) { return false; } $metadata['file'] = wp_normalize_path( realpath( $metadata_file ) ); $metadata = apply_filters( 'block_type_metadata', $metadata ); if ( ! empty( $metadata['name'] ) && 0 === strpos( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); if ( ! isset( $metadata['style'] ) ) { $metadata['style'] = "wp-block-$block_name"; } if ( ! isset( $metadata['editorStyle'] ) ) { $metadata['editorStyle'] = "wp-block-{$block_name}-editor"; } } $settings = array(); $property_mappings = array( 'apiVersion' => 'api_version', 'title' => 'title', 'category' => 'category', 'parent' => 'parent', 'ancestor' => 'ancestor', 'icon' => 'icon', 'description' => 'description', 'keywords' => 'keywords', 'attributes' => 'attributes', 'providesContext' => 'provides_context', 'usesContext' => 'uses_context', 'supports' => 'supports', 'styles' => 'styles', 'variations' => 'variations', 'example' => 'example', ); $textdomain = ! empty( $metadata['textdomain'] ) ? $metadata['textdomain'] : null; $i18n_schema = get_block_metadata_i18n_schema(); foreach ( $property_mappings as $key => $mapped_key ) { if ( isset( $metadata[ $key ] ) ) { $settings[ $mapped_key ] = $metadata[ $key ]; if ( $textdomain && isset( $i18n_schema->$key ) ) { $settings[ $mapped_key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $settings[ $key ], $textdomain ); } } } $script_fields = array( 'editorScript' => 'editor_script_handles', 'script' => 'script_handles', 'viewScript' => 'view_script_handles', ); foreach ( $script_fields as $metadata_field_name => $settings_field_name ) { if ( ! empty( $metadata[ $metadata_field_name ] ) ) { $scripts = $metadata[ $metadata_field_name ]; $processed_scripts = array(); if ( is_array( $scripts ) ) { for ( $index = 0; $index < count( $scripts ); $index++ ) { $result = register_block_script_handle( $metadata, $metadata_field_name, $index ); if ( $result ) { $processed_scripts[] = $result; } } } else { $result = register_block_script_handle( $metadata, $metadata_field_name ); if ( $result ) { $processed_scripts[] = $result; } } $settings[ $settings_field_name ] = $processed_scripts; } } $style_fields = array( 'editorStyle' => 'editor_style_handles', 'style' => 'style_handles', ); foreach ( $style_fields as $metadata_field_name => $settings_field_name ) { if ( ! empty( $metadata[ $metadata_field_name ] ) ) { $styles = $metadata[ $metadata_field_name ]; $processed_styles = array(); if ( is_array( $styles ) ) { for ( $index = 0; $index < count( $styles ); $index++ ) { $result = register_block_style_handle( $metadata, $metadata_field_name, $index ); if ( $result ) { $processed_styles[] = $result; } } } else { $result = register_block_style_handle( $metadata, $metadata_field_name ); if ( $result ) { $processed_styles[] = $result; } } $settings[ $settings_field_name ] = $processed_styles; } } if ( ! empty( $metadata['render'] ) ) { $template_path = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . remove_block_asset_path_prefix( $metadata['render'] ) ) ); if ( $template_path ) { $settings['render_callback'] = function( $attributes, $content, $block ) use ( $template_path ) { ob_start(); require $template_path; return ob_get_clean(); }; } } $settings = apply_filters( 'block_type_metadata_settings', array_merge( $settings, $args ), $metadata ); return WP_Block_Type_Registry::get_instance()->register( $metadata['name'], $settings ); } function register_block_type( $block_type, $args = array() ) { if ( is_string( $block_type ) && file_exists( $block_type ) ) { return register_block_type_from_metadata( $block_type, $args ); } return WP_Block_Type_Registry::get_instance()->register( $block_type, $args ); } function unregister_block_type( $name ) { return WP_Block_Type_Registry::get_instance()->unregister( $name ); } function has_blocks( $post = null ) { if ( ! is_string( $post ) ) { $wp_post = get_post( $post ); if ( ! $wp_post instanceof WP_Post ) { return false; } $post = $wp_post->post_content; } return false !== strpos( (string) $post, '', $serialized_block_name, $serialized_attributes ); } return sprintf( '%s', $serialized_block_name, $serialized_attributes, $block_content, $serialized_block_name ); } function serialize_block( $block ) { $block_content = ''; $index = 0; foreach ( $block['innerContent'] as $chunk ) { $block_content .= is_string( $chunk ) ? $chunk : serialize_block( $block['innerBlocks'][ $index++ ] ); } if ( ! is_array( $block['attrs'] ) ) { $block['attrs'] = array(); } return get_comment_delimited_block_content( $block['blockName'], $block['attrs'], $block_content ); } function serialize_blocks( $blocks ) { return implode( '', array_map( 'serialize_block', $blocks ) ); } function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) { $result = ''; $blocks = parse_blocks( $text ); foreach ( $blocks as $block ) { $block = filter_block_kses( $block, $allowed_html, $allowed_protocols ); $result .= serialize_block( $block ); } return $result; } function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols ); if ( is_array( $block['innerBlocks'] ) ) { foreach ( $block['innerBlocks'] as $i => $inner_block ) { $block['innerBlocks'][ $i ] = filter_block_kses( $inner_block, $allowed_html, $allowed_protocols ); } } return $block; } function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) { if ( is_array( $value ) ) { foreach ( $value as $key => $inner_value ) { $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); if ( $filtered_key !== $key ) { unset( $value[ $key ] ); } $value[ $filtered_key ] = $filtered_value; } } elseif ( is_string( $value ) ) { return wp_kses( $value, $allowed_html, $allowed_protocols ); } return $value; } function excerpt_remove_blocks( $content ) { $allowed_inner_blocks = array( null, 'core/freeform', 'core/heading', 'core/html', 'core/list', 'core/media-text', 'core/paragraph', 'core/preformatted', 'core/pullquote', 'core/quote', 'core/table', 'core/verse', ); $allowed_wrapper_blocks = array( 'core/columns', 'core/column', 'core/group', ); $allowed_wrapper_blocks = apply_filters( 'excerpt_allowed_wrapper_blocks', $allowed_wrapper_blocks ); $allowed_blocks = array_merge( $allowed_inner_blocks, $allowed_wrapper_blocks ); $allowed_blocks = apply_filters( 'excerpt_allowed_blocks', $allowed_blocks ); $blocks = parse_blocks( $content ); $output = ''; foreach ( $blocks as $block ) { if ( in_array( $block['blockName'], $allowed_blocks, true ) ) { if ( ! empty( $block['innerBlocks'] ) ) { if ( in_array( $block['blockName'], $allowed_wrapper_blocks, true ) ) { $output .= _excerpt_render_inner_blocks( $block, $allowed_blocks ); continue; } foreach ( $block['innerBlocks'] as $inner_block ) { if ( ! in_array( $inner_block['blockName'], $allowed_inner_blocks, true ) || ! empty( $inner_block['innerBlocks'] ) ) { continue 2; } } } $output .= render_block( $block ); } } return $output; } function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) { $output = ''; foreach ( $parsed_block['innerBlocks'] as $inner_block ) { if ( ! in_array( $inner_block['blockName'], $allowed_blocks, true ) ) { continue; } if ( empty( $inner_block['innerBlocks'] ) ) { $output .= render_block( $inner_block ); } else { $output .= _excerpt_render_inner_blocks( $inner_block, $allowed_blocks ); } } return $output; } function render_block( $parsed_block ) { global $post; $parent_block = null; $pre_render = apply_filters( 'pre_render_block', null, $parsed_block, $parent_block ); if ( ! is_null( $pre_render ) ) { return $pre_render; } $source_block = $parsed_block; $parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block ); $context = array(); if ( $post instanceof WP_Post ) { $context['postId'] = $post->ID; $context['postType'] = $post->post_type; } $context = apply_filters( 'render_block_context', $context, $parsed_block, $parent_block ); $block = new WP_Block( $parsed_block, $context ); return $block->render(); } function parse_blocks( $content ) { $parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' ); $parser = new $parser_class(); return $parser->parse( $content ); } function do_blocks( $content ) { $blocks = parse_blocks( $content ); $output = ''; foreach ( $blocks as $block ) { $output .= render_block( $block ); } $priority = has_filter( 'the_content', 'wpautop' ); if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) { remove_filter( 'the_content', 'wpautop', $priority ); add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 ); } return $output; } function _restore_wpautop_hook( $content ) { $current_priority = has_filter( 'the_content', '_restore_wpautop_hook' ); add_filter( 'the_content', 'wpautop', $current_priority - 1 ); remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority ); return $content; } function block_version( $content ) { return has_blocks( $content ) ? 1 : 0; } function register_block_style( $block_name, $style_properties ) { return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties ); } function unregister_block_style( $block_name, $block_style_name ) { return WP_Block_Styles_Registry::get_instance()->unregister( $block_name, $block_style_name ); } function block_has_support( $block_type, $feature, $default_value = false ) { $block_support = $default_value; if ( $block_type && property_exists( $block_type, 'supports' ) ) { $block_support = _wp_array_get( $block_type->supports, $feature, $default_value ); } return true === $block_support || is_array( $block_support ); } function wp_migrate_old_typography_shape( $metadata ) { if ( ! isset( $metadata['supports'] ) ) { return $metadata; } $typography_keys = array( '__experimentalFontFamily', '__experimentalFontStyle', '__experimentalFontWeight', '__experimentalLetterSpacing', '__experimentalTextDecoration', '__experimentalTextTransform', 'fontSize', 'lineHeight', ); foreach ( $typography_keys as $typography_key ) { $support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null ); if ( null !== $support_for_key ) { _doing_it_wrong( 'register_block_type_from_metadata()', sprintf( __( 'Block "%1$s" is declaring %2$s support in %3$s file under %4$s. %2$s support is now declared under %5$s.' ), $metadata['name'], "$typography_key", 'block.json', "supports.$typography_key", "supports.typography.$typography_key" ), '5.8.0' ); _wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key ); unset( $metadata['supports'][ $typography_key ] ); } } return $metadata; } function build_query_vars_from_query_block( $block, $page ) { $query = array( 'post_type' => 'post', 'order' => 'DESC', 'orderby' => 'date', 'post__not_in' => array(), ); if ( isset( $block->context['query'] ) ) { if ( ! empty( $block->context['query']['postType'] ) ) { $post_type_param = $block->context['query']['postType']; if ( is_post_type_viewable( $post_type_param ) ) { $query['post_type'] = $post_type_param; } } if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) { $sticky = get_option( 'sticky_posts' ); if ( 'only' === $block->context['query']['sticky'] ) { $query['post__in'] = $sticky; } else { $query['post__not_in'] = array_merge( $query['post__not_in'], $sticky ); } } if ( ! empty( $block->context['query']['exclude'] ) ) { $excluded_post_ids = array_map( 'intval', $block->context['query']['exclude'] ); $excluded_post_ids = array_filter( $excluded_post_ids ); $query['post__not_in'] = array_merge( $query['post__not_in'], $excluded_post_ids ); } if ( isset( $block->context['query']['perPage'] ) && is_numeric( $block->context['query']['perPage'] ) ) { $per_page = absint( $block->context['query']['perPage'] ); $offset = 0; if ( isset( $block->context['query']['offset'] ) && is_numeric( $block->context['query']['offset'] ) ) { $offset = absint( $block->context['query']['offset'] ); } $query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset; $query['posts_per_page'] = $per_page; } if ( ! empty( $block->context['query']['categoryIds'] ) || ! empty( $block->context['query']['tagIds'] ) ) { $tax_query = array(); if ( ! empty( $block->context['query']['categoryIds'] ) ) { $tax_query[] = array( 'taxonomy' => 'category', 'terms' => array_filter( array_map( 'intval', $block->context['query']['categoryIds'] ) ), 'include_children' => false, ); } if ( ! empty( $block->context['query']['tagIds'] ) ) { $tax_query[] = array( 'taxonomy' => 'post_tag', 'terms' => array_filter( array_map( 'intval', $block->context['query']['tagIds'] ) ), 'include_children' => false, ); } $query['tax_query'] = $tax_query; } if ( ! empty( $block->context['query']['taxQuery'] ) ) { $query['tax_query'] = array(); foreach ( $block->context['query']['taxQuery'] as $taxonomy => $terms ) { if ( is_taxonomy_viewable( $taxonomy ) && ! empty( $terms ) ) { $query['tax_query'][] = array( 'taxonomy' => $taxonomy, 'terms' => array_filter( array_map( 'intval', $terms ) ), 'include_children' => false, ); } } } if ( isset( $block->context['query']['order'] ) && in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true ) ) { $query['order'] = strtoupper( $block->context['query']['order'] ); } if ( isset( $block->context['query']['orderBy'] ) ) { $query['orderby'] = $block->context['query']['orderBy']; } if ( isset( $block->context['query']['author'] ) && (int) $block->context['query']['author'] > 0 ) { $query['author'] = (int) $block->context['query']['author']; } if ( ! empty( $block->context['query']['search'] ) ) { $query['s'] = $block->context['query']['search']; } if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) { $query['post_parent__in'] = array_filter( array_map( 'intval', $block->context['query']['parents'] ) ); } } return apply_filters( 'query_loop_block_query_vars', $query, $block, $page ); } function get_query_pagination_arrow( $block, $is_next ) { $arrow_map = array( 'none' => '', 'arrow' => array( 'next' => '→', 'previous' => '←', ), 'chevron' => array( 'next' => '»', 'previous' => '«', ), ); if ( ! empty( $block->context['paginationArrow'] ) && array_key_exists( $block->context['paginationArrow'], $arrow_map ) && ! empty( $arrow_map[ $block->context['paginationArrow'] ] ) ) { $pagination_type = $is_next ? 'next' : 'previous'; $arrow_attribute = $block->context['paginationArrow']; $arrow = $arrow_map[ $block->context['paginationArrow'] ][ $pagination_type ]; $arrow_classes = "wp-block-query-pagination-$pagination_type-arrow is-arrow-$arrow_attribute"; return ""; } return null; } function build_comment_query_vars_from_block( $block ) { $comment_args = array( 'orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'no_found_rows' => false, ); if ( is_user_logged_in() ) { $comment_args['include_unapproved'] = array( get_current_user_id() ); } else { $unapproved_email = wp_get_unapproved_comment_author_email(); if ( $unapproved_email ) { $comment_args['include_unapproved'] = array( $unapproved_email ); } } if ( ! empty( $block->context['postId'] ) ) { $comment_args['post_id'] = (int) $block->context['postId']; } if ( get_option( 'thread_comments' ) ) { $comment_args['hierarchical'] = 'threaded'; } else { $comment_args['hierarchical'] = false; } if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) { $per_page = get_option( 'comments_per_page' ); $default_page = get_option( 'default_comments_page' ); if ( $per_page > 0 ) { $comment_args['number'] = $per_page; $page = (int) get_query_var( 'cpage' ); if ( $page ) { $comment_args['paged'] = $page; } elseif ( 'oldest' === $default_page ) { $comment_args['paged'] = 1; } elseif ( 'newest' === $default_page ) { $max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages; if ( 0 !== $max_num_pages ) { $comment_args['paged'] = $max_num_pages; } } if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) { set_query_var( 'cpage', $comment_args['paged'] ); } } } return $comment_args; } function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) { $arrow_map = array( 'none' => '', 'arrow' => array( 'next' => '→', 'previous' => '←', ), 'chevron' => array( 'next' => '»', 'previous' => '«', ), ); if ( ! empty( $block->context['comments/paginationArrow'] ) && ! empty( $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ] ) ) { $arrow_attribute = $block->context['comments/paginationArrow']; $arrow = $arrow_map[ $block->context['comments/paginationArrow'] ][ $pagination_type ]; $arrow_classes = "wp-block-comments-pagination-$pagination_type-arrow is-arrow-$arrow_attribute"; return ""; } return null; } $type, 'format' => 'option', 'show_post_count' => $show_post_count, ) ); $dropdown_args['echo'] = 0; $archives = wp_get_archives( $dropdown_args ); $classnames = esc_attr( $class ); $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); switch ( $dropdown_args['type'] ) { case 'yearly': $label = __( 'Select Year' ); break; case 'monthly': $label = __( 'Select Month' ); break; case 'daily': $label = __( 'Select Day' ); break; case 'weekly': $label = __( 'Select Week' ); break; default: $label = __( 'Select Post' ); break; } $show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : ''; $block_content = ' '; return sprintf( '
    %2$s
    ', $wrapper_attributes, $block_content ); } $class .= ' wp-block-archives-list'; $archives_args = apply_filters( 'widget_archives_args', array( 'type' => $type, 'show_post_count' => $show_post_count, ) ); $archives_args['echo'] = 0; $archives = wp_get_archives( $archives_args ); $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); if ( empty( $archives ) ) { return sprintf( '
    %2$s
    ', $wrapper_attributes, __( 'No archives to show.' ) ); } return sprintf( '
      %2$s
    ', $wrapper_attributes, $archives ); } function register_block_core_archives() { register_block_type_from_metadata( __DIR__ . '/archives', array( 'render_callback' => 'render_block_core_archives', ) ); } add_action( 'init', 'register_block_core_archives' ); { @@ -18666,7 +21349,7 @@ ul.wp-block-archives{padding-left:2.5em}.wp-block-archives-dropdown label{displa "editorStyle": "wp-block-audio-editor", "style": "wp-block-audio" } -.wp-block-audio{margin-left:0;margin-right:0;position:relative}.wp-block-audio.is-transient audio{opacity:.3}.wp-block-audio .components-spinner{position:absolute;top:50%;left:50%;margin-top:-9px;margin-left:-9px}.wp-block-audio{box-sizing:border-box}.wp-block-audio figcaption{margin-top:.5em;margin-bottom:1em}.wp-block-audio audio{width:100%;min-width:300px}.wp-block-audio figcaption{color:#555;font-size:13px;text-align:center}.is-dark-theme .wp-block-audio figcaption{color:hsla(0,0%,100%,.65)}.wp-block-audio{margin:0 0 1em} $value ) { if ( null !== $value ) { $name = _wp_to_kebab_case( $key ); $border_style = sprintf( 'border-%s-radius: %s;', esc_attr( $name ), esc_attr( $value ) ); $image_styles[] = $border_style; } } } else { $border_style = sprintf( 'border-radius: %s;', esc_attr( $border_radius ) ); $image_styles[] = $border_style; } } $has_border_color = ! empty( $attributes['style']['border']['color'] ); if ( $has_border_color ) { $border_color = $attributes['style']['border']['color']; $image_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) ); } $has_border_style = ! empty( $attributes['style']['border']['style'] ); if ( $has_border_style ) { $border_style = $attributes['style']['border']['style']; $image_styles[] = sprintf( 'border-style: %s;', esc_attr( $border_style ) ); } $image_classes = ''; if ( $has_border_color || isset( $attributes['borderColor'] ) ) { $image_classes .= 'has-border-color'; } if ( isset( $attributes['borderColor'] ) ) { $image_classes .= ' has-' . $attributes['borderColor'] . '-border-color'; } if ( ! isset( $block->context['commentId'] ) ) { $author_id = isset( $attributes['userId'] ) ? $attributes['userId'] : get_post_field( 'post_author', $block->context['postId'] ); $author_name = get_the_author_meta( 'display_name', $author_id ); $alt = sprintf( __( '%s Avatar' ), $author_name ); $avatar_block = get_avatar( $author_id, $size, '', $alt, array( 'extra_attr' => isset( $image_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $image_styles ) ) ) : '', 'class' => "wp-block-avatar__image $image_classes ", ) ); if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { $label = ''; if ( '_blank' === $attributes['linkTarget'] ) { $label = 'aria-label="' . sprintf( esc_attr__( '(%s author archive, opens in a new tab)' ), $author_name ) . '"'; } $avatar_block = sprintf( '%4$s', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); } return sprintf( '
    %2s
    ', $wrapper_attributes, $avatar_block ); } $comment = get_comment( $block->context['commentId'] ); if ( ! $comment ) { return ''; } $alt = sprintf( __( '%s Avatar' ), $comment->comment_author ); $avatar_block = get_avatar( $comment, $size, '', $alt, array( 'extra_attr' => isset( $image_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $image_styles ) ) ) : '', 'class' => "wp-block-avatar__image $image_classes", ) ); if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) { $label = ''; if ( '_blank' === $attributes['linkTarget'] ) { $label = 'aria-label="' . sprintf( esc_attr__( '(%s website link, opens in a new tab)' ), $comment->comment_author ) . '"'; } $avatar_block = sprintf( '%4$s', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); } return sprintf( '
    %2s
    ', $wrapper_attributes, $avatar_block ); } function register_block_core_avatar() { register_block_type_from_metadata( __DIR__ . '/avatar', array( 'render_callback' => 'render_block_core_avatar', ) ); } add_action( 'init', 'register_block_core_avatar' ); { "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, @@ -18846,8 +21529,8 @@ ul.wp-block-archives{padding-left:2.5em}.wp-block-archives-dropdown label{displa "editorStyle": "wp-block-button-editor", "style": "wp-block-button" } -.wp-block[data-align=center]>.wp-block-button{text-align:center;margin-left:auto;margin-right:auto}.wp-block[data-align=right]>.wp-block-button{ - /*!rtl:ignore*/text-align:right}.wp-block-button{position:relative;cursor:text}.wp-block-button:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px var(--wp-admin-theme-color);outline:2px solid transparent;outline-offset:-2px}.wp-block-button[data-rich-text-placeholder]:after{opacity:.8}.wp-block-button__inline-link{color:#757575;height:0;overflow:hidden;max-width:290px}.wp-block-button__inline-link-input__suggestions{max-width:290px}@media (min-width:782px){.wp-block-button__inline-link,.wp-block-button__inline-link-input__suggestions{max-width:260px}}@media (min-width:960px){.wp-block-button__inline-link,.wp-block-button__inline-link-input__suggestions{max-width:290px}}.is-selected .wp-block-button__inline-link{height:auto;overflow:visible}.wp-button-label__width .components-button-group{display:block}.wp-button-label__width .components-base-control__field{margin-bottom:12px}div[data-type="core/button"]{display:table}.editor-styles-wrapper .wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-button__link{cursor:pointer;display:inline-block;text-align:center;word-break:break-word;box-sizing:border-box}.wp-block-button__link.aligncenter{text-align:center}.wp-block-button__link.alignright{text-align:right}:where(.wp-block-button__link){box-shadow:none;text-decoration:none;border-radius:9999px;padding:calc(.667em + 2px) calc(1.333em + 2px)}.wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons>.wp-block-button.has-custom-width{max-width:none}.wp-block-buttons>.wp-block-button.has-custom-width .wp-block-button__link{width:100%}.wp-block-buttons>.wp-block-button.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons>.wp-block-button.wp-block-button__width-25{width:calc(25% - var(--wp--style--block-gap, .5em)*0.75)}.wp-block-buttons>.wp-block-button.wp-block-button__width-50{width:calc(50% - var(--wp--style--block-gap, .5em)*0.5)}.wp-block-buttons>.wp-block-button.wp-block-button__width-75{width:calc(75% - var(--wp--style--block-gap, .5em)*0.25)}.wp-block-buttons>.wp-block-button.wp-block-button__width-100{width:100%;flex-basis:100%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-25{width:25%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-50{width:50%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-75{width:75%}.wp-block-button.is-style-squared,.wp-block-button__link.wp-block-button.is-style-squared{border-radius:0}.wp-block-button.no-border-radius,.wp-block-button__link.no-border-radius{border-radius:0!important}.wp-block-button.is-style-outline>.wp-block-button__link,.wp-block-button .wp-block-button__link.is-style-outline{border:2px solid;padding:.667em 1.333em}.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-text-color),.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color){color:currentColor}.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-background),.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background){background-color:transparent;background-image:none}{ +.wp-block[data-align=center]>.wp-block-button{margin-left:auto;margin-right:auto;text-align:center}.wp-block[data-align=right]>.wp-block-button{ + /*!rtl:ignore*/text-align:right}.wp-block-button{cursor:text;position:relative}.wp-block-button:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px var(--wp-admin-theme-color);outline:2px solid transparent;outline-offset:-2px}.wp-block-button[data-rich-text-placeholder]:after{opacity:.8}.wp-block-button__inline-link{color:#757575;height:0;max-width:290px;overflow:hidden}.wp-block-button__inline-link-input__suggestions{max-width:290px}@media (min-width:782px){.wp-block-button__inline-link,.wp-block-button__inline-link-input__suggestions{max-width:260px}}@media (min-width:960px){.wp-block-button__inline-link,.wp-block-button__inline-link-input__suggestions{max-width:290px}}.is-selected .wp-block-button__inline-link{height:auto;overflow:visible}.wp-button-label__width .components-button-group{display:block}.wp-button-label__width .components-base-control__field{margin-bottom:12px}div[data-type="core/button"]{display:table}.editor-styles-wrapper .wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-button__link{box-sizing:border-box;cursor:pointer;display:inline-block;text-align:center;word-break:break-word}.wp-block-button__link.aligncenter{text-align:center}.wp-block-button__link.alignright{text-align:right}:where(.wp-block-button__link){border-radius:9999px;box-shadow:none;padding:calc(.667em + 2px) calc(1.333em + 2px);text-decoration:none}.wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons>.wp-block-button.has-custom-width{max-width:none}.wp-block-buttons>.wp-block-button.has-custom-width .wp-block-button__link{width:100%}.wp-block-buttons>.wp-block-button.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons>.wp-block-button.wp-block-button__width-25{width:calc(25% - var(--wp--style--block-gap, .5em)*.75)}.wp-block-buttons>.wp-block-button.wp-block-button__width-50{width:calc(50% - var(--wp--style--block-gap, .5em)*.5)}.wp-block-buttons>.wp-block-button.wp-block-button__width-75{width:calc(75% - var(--wp--style--block-gap, .5em)*.25)}.wp-block-buttons>.wp-block-button.wp-block-button__width-100{flex-basis:100%;width:100%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-25{width:25%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-50{width:50%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-75{width:75%}.wp-block-button.is-style-squared,.wp-block-button__link.wp-block-button.is-style-squared{border-radius:0}.wp-block-button.no-border-radius,.wp-block-button__link.no-border-radius{border-radius:0!important}.wp-block-button .wp-block-button__link.is-style-outline,.wp-block-button.is-style-outline>.wp-block-button__link{border:2px solid;padding:.667em 1.333em}.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color),.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-text-color){color:currentColor}.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background),.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-background){background-color:initial;background-image:none}{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "core/buttons", @@ -18891,7 +21574,7 @@ ul.wp-block-archives{padding-left:2.5em}.wp-block-archives-dropdown label{displa "editorStyle": "wp-block-buttons-editor", "style": "wp-block-buttons" } -.wp-block-buttons>.wp-block,.wp-block-buttons>.wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button{margin:0}.wp-block-buttons>.block-list-appender{display:inline-flex;align-items:center}.wp-block-buttons.is-vertical>.block-list-appender .block-list-appender__toggle{justify-content:flex-start}.wp-block-buttons>.wp-block-button:focus{box-shadow:none}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center]{margin-left:auto;margin-right:auto;margin-top:0;width:100%}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center] .wp-block-button{margin-bottom:0}.editor-styles-wrapper .wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block[data-align=center]>.wp-block-buttons{align-items:center;justify-content:center}.wp-block[data-align=right]>.wp-block-buttons{justify-content:flex-end}.wp-block-buttons.is-vertical{flex-direction:column}.wp-block-buttons.is-vertical>.wp-block-button:last-child{margin-bottom:0}.wp-block-buttons>.wp-block-button{display:inline-block;margin:0}.wp-block-buttons.is-content-justification-left{justify-content:flex-start}.wp-block-buttons.is-content-justification-left.is-vertical{align-items:flex-start}.wp-block-buttons.is-content-justification-center{justify-content:center}.wp-block-buttons.is-content-justification-center.is-vertical{align-items:center}.wp-block-buttons.is-content-justification-right{justify-content:flex-end}.wp-block-buttons.is-content-justification-right.is-vertical{align-items:flex-end}.wp-block-buttons.is-content-justification-space-between{justify-content:space-between}.wp-block-buttons.aligncenter{text-align:center}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block-button.aligncenter{margin-left:auto;margin-right:auto;width:100%}.wp-block-buttons[style*=text-decoration] .wp-block-button,.wp-block-buttons[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-button.aligncenter{text-align:center}.wp-block,.wp-block-buttons>.wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button{margin:0}.wp-block-buttons>.block-list-appender{align-items:center;display:inline-flex}.wp-block-buttons.is-vertical>.block-list-appender .block-list-appender__toggle{justify-content:flex-start}.wp-block-buttons>.wp-block-button:focus{box-shadow:none}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center]{margin-left:auto;margin-right:auto;margin-top:0;width:100%}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center] .wp-block-button{margin-bottom:0}.editor-styles-wrapper .wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block[data-align=center]>.wp-block-buttons{align-items:center;justify-content:center}.wp-block[data-align=right]>.wp-block-buttons{justify-content:flex-end}.wp-block-buttons.is-vertical{flex-direction:column}.wp-block-buttons.is-vertical>.wp-block-button:last-child{margin-bottom:0}.wp-block-buttons>.wp-block-button{display:inline-block;margin:0}.wp-block-buttons.is-content-justification-left{justify-content:flex-start}.wp-block-buttons.is-content-justification-left.is-vertical{align-items:flex-start}.wp-block-buttons.is-content-justification-center{justify-content:center}.wp-block-buttons.is-content-justification-center.is-vertical{align-items:center}.wp-block-buttons.is-content-justification-right{justify-content:flex-end}.wp-block-buttons.is-content-justification-right.is-vertical{align-items:flex-end}.wp-block-buttons.is-content-justification-space-between{justify-content:space-between}.wp-block-buttons.aligncenter{text-align:center}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block-button.aligncenter{margin-left:auto;margin-right:auto;width:100%}.wp-block-buttons[style*=text-decoration] .wp-block-button,.wp-block-buttons[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-button.aligncenter{text-align:center}' . __( 'The calendar block is hidden because there are no published posts.' ) . ''; } return ''; } $previous_monthnum = $monthnum; $previous_year = $year; if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) { $permalink_structure = get_option( 'permalink_structure' ); if ( str_contains( $permalink_structure, '%monthnum%' ) && str_contains( $permalink_structure, '%year%' ) ) { $monthnum = $attributes['month']; $year = $attributes['year']; } } $wrapper_attributes = get_block_wrapper_attributes(); $output = sprintf( '
    %2$s
    ', $wrapper_attributes, get_calendar( true, false ) ); $monthnum = $previous_monthnum; $year = $previous_year; return $output; } function register_block_core_calendar() { register_block_type_from_metadata( __DIR__ . '/calendar', array( 'render_callback' => 'render_block_core_calendar', ) ); } add_action( 'init', 'register_block_core_calendar' ); function block_core_calendar_has_published_posts() { if ( is_multisite() ) { return 0 < (int) get_option( 'post_count' ); } $has_published_posts = get_option( 'wp_calendar_block_has_published_posts', null ); if ( null !== $has_published_posts ) { return (bool) $has_published_posts; } return block_core_calendar_update_has_published_posts(); } function block_core_calendar_update_has_published_posts() { global $wpdb; $has_published_posts = (bool) $wpdb->get_var( "SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" ); update_option( 'wp_calendar_block_has_published_posts', $has_published_posts ); return $has_published_posts; } if ( ! is_multisite() ) { function block_core_calendar_update_has_published_post_on_delete( $post_id ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { return; } block_core_calendar_update_has_published_posts(); } function block_core_calendar_update_has_published_post_on_transition_post_status( $new_status, $old_status, $post ) { if ( $new_status === $old_status ) { return; } if ( 'post' !== get_post_type( $post ) ) { return; } if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } block_core_calendar_update_has_published_posts(); } add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' ); add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 ); } { "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, @@ -18926,7 +21609,7 @@ ul.wp-block-archives{padding-left:2.5em}.wp-block-archives-dropdown label{displa }, "style": "wp-block-calendar" } -.wp-block-calendar{text-align:center}.wp-block-calendar tbody td,.wp-block-calendar th{padding:.25em;border:1px solid #ddd}.wp-block-calendar tfoot td{border:none}.wp-block-calendar table{width:100%;border-collapse:collapse}.wp-block-calendar table th{font-weight:400;background:#ddd}.wp-block-calendar a{text-decoration:underline}.wp-block-calendar table caption,.wp-block-calendar table tbody{color:#40464d} false, 'hierarchical' => ! empty( $attributes['showHierarchy'] ), 'orderby' => 'name', 'show_count' => ! empty( $attributes['showPostCounts'] ), 'title_li' => '', 'hide_empty' => empty( $attributes['showEmpty'] ), ); if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) { $args['parent'] = 0; } if ( ! empty( $attributes['displayAsDropdown'] ) ) { $id = 'wp-block-categories-' . $block_id; $args['id'] = $id; $args['show_option_none'] = __( 'Select Category' ); $wrapper_markup = '
    %2$s
    '; $items_markup = wp_dropdown_categories( $args ); $type = 'dropdown'; if ( ! is_admin() ) { $items_markup = preg_replace( '#(?<=)#', build_dropdown_script_block_core_categories( $id ), $items_markup, 1 ); } } else { $wrapper_markup = '
      %2$s
    '; $items_markup = wp_list_categories( $args ); $type = 'list'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type}" ) ); return sprintf( $wrapper_markup, $wrapper_attributes, $items_markup ); } function build_dropdown_script_block_core_categories( $dropdown_id ) { ob_start(); ?> \n", {$where} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']} - "; $this->terms = null; $this->terms = apply_filters_ref_array( 'terms_pre_query', array( $this->terms, &$this ) ); if ( null !== $this->terms ) { return $this->terms; } $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); unset( $cache_args['update_term_meta_cache'] ); if ( 'count' !== $_fields && 'all_with_object_id' !== $_fields ) { $cache_args['fields'] = 'all'; } $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $this->request ); $last_changed = wp_cache_get_last_changed( 'terms' ); $cache_key = "get_terms:$key:$last_changed"; $cache = wp_cache_get( $cache_key, 'terms' ); if ( false !== $cache ) { if ( 'ids' === $_fields ) { $cache = array_map( 'intval', $cache ); } elseif ( 'count' !== $_fields ) { if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) || ( 'all' === $_fields && $args['pad_counts'] ) ) { $term_ids = wp_list_pluck( $cache, 'term_id' ); } else { $term_ids = array_map( 'intval', $cache ); } _prime_term_caches( $term_ids, $args['update_term_meta_cache'] ); $term_objects = $this->populate_terms( $cache ); $cache = $this->format_terms( $term_objects, $_fields ); } $this->terms = $cache; return $this->terms; } if ( 'count' === $_fields ) { $count = $wpdb->get_var( $this->request ); wp_cache_set( $cache_key, $count, 'terms' ); return $count; } $terms = $wpdb->get_results( $this->request ); if ( empty( $terms ) ) { wp_cache_add( $cache_key, array(), 'terms' ); return array(); } $term_ids = wp_list_pluck( $terms, 'term_id' ); _prime_term_caches( $term_ids, false ); $term_objects = $this->populate_terms( $terms ); if ( $child_of ) { foreach ( $taxonomies as $_tax ) { $children = _get_term_hierarchy( $_tax ); if ( ! empty( $children ) ) { $term_objects = _get_term_children( $child_of, $term_objects, $_tax ); } } } if ( $args['pad_counts'] && 'all' === $_fields ) { foreach ( $taxonomies as $_tax ) { _pad_term_counts( $term_objects, $_tax ); } } if ( $hierarchical && $args['hide_empty'] && is_array( $term_objects ) ) { foreach ( $term_objects as $k => $term ) { if ( ! $term->count ) { $children = get_term_children( $term->term_id, $term->taxonomy ); if ( is_array( $children ) ) { foreach ( $children as $child_id ) { $child = get_term( $child_id, $term->taxonomy ); if ( $child->count ) { continue 2; } } } unset( $term_objects[ $k ] ); } } } if ( $hierarchical && $number && is_array( $term_objects ) ) { if ( $offset >= count( $term_objects ) ) { $term_objects = array(); } else { $term_objects = array_slice( $term_objects, $offset, $number, true ); } } if ( $args['update_term_meta_cache'] ) { $term_ids = wp_list_pluck( $term_objects, 'term_id' ); update_termmeta_cache( $term_ids ); } if ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) { $term_cache = array(); foreach ( $term_objects as $term ) { $object = new stdClass(); $object->term_id = $term->term_id; $object->object_id = $term->object_id; $term_cache[] = $object; } } elseif ( 'all' === $_fields && $args['pad_counts'] ) { $term_cache = array(); foreach ( $term_objects as $term ) { $object = new stdClass(); $object->term_id = $term->term_id; $object->count = $term->count; $term_cache[] = $object; } } else { $term_cache = wp_list_pluck( $term_objects, 'term_id' ); } wp_cache_add( $cache_key, $term_cache, 'terms' ); $this->terms = $this->format_terms( $term_objects, $_fields ); return $this->terms; } protected function parse_orderby( $orderby_raw ) { $_orderby = strtolower( $orderby_raw ); $maybe_orderby_meta = false; if ( in_array( $_orderby, array( 'term_id', 'name', 'slug', 'term_group' ), true ) ) { $orderby = "t.$_orderby"; } elseif ( in_array( $_orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id', 'description' ), true ) ) { $orderby = "tt.$_orderby"; } elseif ( 'term_order' === $_orderby ) { $orderby = 'tr.term_order'; } elseif ( 'include' === $_orderby && ! empty( $this->query_vars['include'] ) ) { $include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) ); $orderby = "FIELD( t.term_id, $include )"; } elseif ( 'slug__in' === $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) { $slugs = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) ); $orderby = "FIELD( t.slug, '" . $slugs . "')"; } elseif ( 'none' === $_orderby ) { $orderby = ''; } elseif ( empty( $_orderby ) || 'id' === $_orderby || 'term_id' === $_orderby ) { $orderby = 't.term_id'; } else { $orderby = 't.name'; $maybe_orderby_meta = true; } $orderby = apply_filters( 'get_terms_orderby', $orderby, $this->query_vars, $this->query_vars['taxonomy'] ); if ( $maybe_orderby_meta ) { $maybe_orderby_meta = $this->parse_orderby_meta( $_orderby ); if ( $maybe_orderby_meta ) { $orderby = $maybe_orderby_meta; } } return $orderby; } protected function format_terms( $term_objects, $_fields ) { $_terms = array(); if ( 'id=>parent' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->parent; } } elseif ( 'ids' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = (int) $term->term_id; } } elseif ( 'tt_ids' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = (int) $term->term_taxonomy_id; } } elseif ( 'names' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = $term->name; } } elseif ( 'slugs' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = $term->slug; } } elseif ( 'id=>name' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->name; } } elseif ( 'id=>slug' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->slug; } } elseif ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { $_terms = $term_objects; } return $_terms; } protected function parse_orderby_meta( $orderby_raw ) { $orderby = ''; $this->meta_query->get_sql( 'term', 't', 'term_id' ); $meta_clauses = $this->meta_query->get_clauses(); if ( ! $meta_clauses || ! $orderby_raw ) { return $orderby; } $allowed_keys = array(); $primary_meta_key = null; $primary_meta_query = reset( $meta_clauses ); if ( ! empty( $primary_meta_query['key'] ) ) { $primary_meta_key = $primary_meta_query['key']; $allowed_keys[] = $primary_meta_key; } $allowed_keys[] = 'meta_value'; $allowed_keys[] = 'meta_value_num'; $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_clauses ) ); if ( ! in_array( $orderby_raw, $allowed_keys, true ) ) { return $orderby; } switch ( $orderby_raw ) { case $primary_meta_key: case 'meta_value': if ( ! empty( $primary_meta_query['type'] ) ) { $orderby = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})"; } else { $orderby = "{$primary_meta_query['alias']}.meta_value"; } break; case 'meta_value_num': $orderby = "{$primary_meta_query['alias']}.meta_value+0"; break; default: if ( array_key_exists( $orderby_raw, $meta_clauses ) ) { $meta_clause = $meta_clauses[ $orderby_raw ]; $orderby = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; } break; } return $orderby; } protected function parse_order( $order ) { if ( ! is_string( $order ) || empty( $order ) ) { return 'DESC'; } if ( 'ASC' === strtoupper( $order ) ) { return 'ASC'; } else { return 'DESC'; } } protected function get_search_sql( $search ) { global $wpdb; $like = '%' . $wpdb->esc_like( $search ) . '%'; return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); } protected function populate_terms( $terms ) { $term_objects = array(); if ( ! is_array( $terms ) ) { return $term_objects; } foreach ( $terms as $key => $term_data ) { if ( is_object( $term_data ) && property_exists( $term_data, 'term_id' ) ) { $term = get_term( $term_data->term_id ); if ( property_exists( $term_data, 'object_id' ) ) { $term->object_id = (int) $term_data->object_id; } if ( property_exists( $term_data, 'count' ) ) { $term->count = (int) $term_data->count; } } else { $term = get_term( $term_data ); } if ( $term instanceof WP_Term ) { $term_objects[ $key ] = $term; } } return $term_objects; } } terms = null; $this->terms = apply_filters_ref_array( 'terms_pre_query', array( $this->terms, &$this ) ); if ( null !== $this->terms ) { return $this->terms; } $cache_key = $this->generate_cache_key( $args, $this->request ); $cache = wp_cache_get( $cache_key, 'terms' ); if ( false !== $cache ) { if ( 'ids' === $_fields ) { $cache = array_map( 'intval', $cache ); } elseif ( 'count' !== $_fields ) { if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) || ( 'all' === $_fields && $args['pad_counts'] ) ) { $term_ids = wp_list_pluck( $cache, 'term_id' ); } else { $term_ids = array_map( 'intval', $cache ); } _prime_term_caches( $term_ids, $args['update_term_meta_cache'] ); $term_objects = $this->populate_terms( $cache ); $cache = $this->format_terms( $term_objects, $_fields ); } $this->terms = $cache; return $this->terms; } if ( 'count' === $_fields ) { $count = $wpdb->get_var( $this->request ); wp_cache_set( $cache_key, $count, 'terms' ); return $count; } $terms = $wpdb->get_results( $this->request ); if ( empty( $terms ) ) { wp_cache_add( $cache_key, array(), 'terms' ); return array(); } $term_ids = wp_list_pluck( $terms, 'term_id' ); _prime_term_caches( $term_ids, false ); $term_objects = $this->populate_terms( $terms ); if ( $child_of ) { foreach ( $taxonomies as $_tax ) { $children = _get_term_hierarchy( $_tax ); if ( ! empty( $children ) ) { $term_objects = _get_term_children( $child_of, $term_objects, $_tax ); } } } if ( $args['pad_counts'] && 'all' === $_fields ) { foreach ( $taxonomies as $_tax ) { _pad_term_counts( $term_objects, $_tax ); } } if ( $hierarchical && $args['hide_empty'] && is_array( $term_objects ) ) { foreach ( $term_objects as $k => $term ) { if ( ! $term->count ) { $children = get_term_children( $term->term_id, $term->taxonomy ); if ( is_array( $children ) ) { foreach ( $children as $child_id ) { $child = get_term( $child_id, $term->taxonomy ); if ( $child->count ) { continue 2; } } } unset( $term_objects[ $k ] ); } } } if ( $hierarchical && $number && is_array( $term_objects ) ) { if ( $offset >= count( $term_objects ) ) { $term_objects = array(); } else { $term_objects = array_slice( $term_objects, $offset, $number, true ); } } if ( $args['update_term_meta_cache'] ) { $term_ids = wp_list_pluck( $term_objects, 'term_id' ); update_termmeta_cache( $term_ids ); } if ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) { $term_cache = array(); foreach ( $term_objects as $term ) { $object = new stdClass(); $object->term_id = $term->term_id; $object->object_id = $term->object_id; $term_cache[] = $object; } } elseif ( 'all' === $_fields && $args['pad_counts'] ) { $term_cache = array(); foreach ( $term_objects as $term ) { $object = new stdClass(); $object->term_id = $term->term_id; $object->count = $term->count; $term_cache[] = $object; } } else { $term_cache = wp_list_pluck( $term_objects, 'term_id' ); } wp_cache_add( $cache_key, $term_cache, 'terms' ); $this->terms = $this->format_terms( $term_objects, $_fields ); return $this->terms; } protected function parse_orderby( $orderby_raw ) { $_orderby = strtolower( $orderby_raw ); $maybe_orderby_meta = false; if ( in_array( $_orderby, array( 'term_id', 'name', 'slug', 'term_group' ), true ) ) { $orderby = "t.$_orderby"; } elseif ( in_array( $_orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id', 'description' ), true ) ) { $orderby = "tt.$_orderby"; } elseif ( 'term_order' === $_orderby ) { $orderby = 'tr.term_order'; } elseif ( 'include' === $_orderby && ! empty( $this->query_vars['include'] ) ) { $include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) ); $orderby = "FIELD( t.term_id, $include )"; } elseif ( 'slug__in' === $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) { $slugs = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) ); $orderby = "FIELD( t.slug, '" . $slugs . "')"; } elseif ( 'none' === $_orderby ) { $orderby = ''; } elseif ( empty( $_orderby ) || 'id' === $_orderby || 'term_id' === $_orderby ) { $orderby = 't.term_id'; } else { $orderby = 't.name'; $maybe_orderby_meta = true; } $orderby = apply_filters( 'get_terms_orderby', $orderby, $this->query_vars, $this->query_vars['taxonomy'] ); if ( $maybe_orderby_meta ) { $maybe_orderby_meta = $this->parse_orderby_meta( $_orderby ); if ( $maybe_orderby_meta ) { $orderby = $maybe_orderby_meta; } } return $orderby; } protected function format_terms( $term_objects, $_fields ) { $_terms = array(); if ( 'id=>parent' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->parent; } } elseif ( 'ids' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = (int) $term->term_id; } } elseif ( 'tt_ids' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = (int) $term->term_taxonomy_id; } } elseif ( 'names' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = $term->name; } } elseif ( 'slugs' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[] = $term->slug; } } elseif ( 'id=>name' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->name; } } elseif ( 'id=>slug' === $_fields ) { foreach ( $term_objects as $term ) { $_terms[ $term->term_id ] = $term->slug; } } elseif ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { $_terms = $term_objects; } return $_terms; } protected function parse_orderby_meta( $orderby_raw ) { $orderby = ''; $this->meta_query->get_sql( 'term', 't', 'term_id' ); $meta_clauses = $this->meta_query->get_clauses(); if ( ! $meta_clauses || ! $orderby_raw ) { return $orderby; } $allowed_keys = array(); $primary_meta_key = null; $primary_meta_query = reset( $meta_clauses ); if ( ! empty( $primary_meta_query['key'] ) ) { $primary_meta_key = $primary_meta_query['key']; $allowed_keys[] = $primary_meta_key; } $allowed_keys[] = 'meta_value'; $allowed_keys[] = 'meta_value_num'; $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_clauses ) ); if ( ! in_array( $orderby_raw, $allowed_keys, true ) ) { return $orderby; } switch ( $orderby_raw ) { case $primary_meta_key: case 'meta_value': if ( ! empty( $primary_meta_query['type'] ) ) { $orderby = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})"; } else { $orderby = "{$primary_meta_query['alias']}.meta_value"; } break; case 'meta_value_num': $orderby = "{$primary_meta_query['alias']}.meta_value+0"; break; default: if ( array_key_exists( $orderby_raw, $meta_clauses ) ) { $meta_clause = $meta_clauses[ $orderby_raw ]; $orderby = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; } break; } return $orderby; } protected function parse_order( $order ) { if ( ! is_string( $order ) || empty( $order ) ) { return 'DESC'; } if ( 'ASC' === strtoupper( $order ) ) { return 'ASC'; } else { return 'DESC'; } } protected function get_search_sql( $search ) { global $wpdb; $like = '%' . $wpdb->esc_like( $search ) . '%'; return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); } protected function populate_terms( $terms ) { $term_objects = array(); if ( ! is_array( $terms ) ) { return $term_objects; } foreach ( $terms as $key => $term_data ) { if ( is_object( $term_data ) && property_exists( $term_data, 'term_id' ) ) { $term = get_term( $term_data->term_id ); if ( property_exists( $term_data, 'object_id' ) ) { $term->object_id = (int) $term_data->object_id; } if ( property_exists( $term_data, 'count' ) ) { $term->count = (int) $term_data->count; } } else { $term = get_term( $term_data ); } if ( $term instanceof WP_Term ) { $term_objects[ $key ] = $term; } } return $term_objects; } protected function generate_cache_key( array $args, $sql ) { global $wpdb; $cache_args = wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ); unset( $cache_args['update_term_meta_cache'] ); if ( 'count' !== $args['fields'] && 'all_with_object_id' !== $args['fields'] ) { $cache_args['fields'] = 'all'; } $taxonomies = (array) $args['taxonomy']; $sql = $wpdb->remove_placeholder_escape( $sql ); $key = md5( serialize( $cache_args ) . serialize( $taxonomies ) . $sql ); $last_changed = wp_cache_get_last_changed( 'terms' ); return "get_terms:$key:$last_changed"; } } taxonomy ) ) { $_term = false; $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $term_id ) ); if ( ! $terms ) { return false; } if ( $taxonomy ) { foreach ( $terms as $match ) { if ( $taxonomy === $match->taxonomy ) { $_term = $match; break; } } } elseif ( 1 === count( $terms ) ) { $_term = reset( $terms ); } else { foreach ( $terms as $t ) { if ( ! taxonomy_exists( $t->taxonomy ) ) { continue; } if ( $_term ) { return new WP_Error( 'ambiguous_term_id', __( 'Term ID is shared between multiple taxonomies' ), $term_id ); } $_term = $t; } } if ( ! $_term ) { return false; } if ( ! taxonomy_exists( $_term->taxonomy ) ) { return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); } $_term = sanitize_term( $_term, $_term->taxonomy, 'raw' ); if ( 1 === count( $terms ) ) { wp_cache_add( $term_id, $_term, 'terms' ); } } $term_obj = new WP_Term( $_term ); $term_obj->filter( $term_obj->filter ); return $term_obj; } public function __construct( $term ) { foreach ( get_object_vars( $term ) as $key => $value ) { $this->$key = $value; } } public function filter( $filter ) { sanitize_term( $this, $this->taxonomy, $filter ); } public function to_array() { return get_object_vars( $this ); } public function __get( $key ) { switch ( $key ) { case 'data': $data = new stdClass(); $columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' ); foreach ( $columns as $column ) { $data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null; } return sanitize_term( $data, $data->taxonomy, 'raw' ); } } } _show_split_view = $params['show_split_view']; } } public function _startBlock( $header ) { return ''; } public function _lines( $lines, $prefix = ' ' ) { } public function addedLine( $line ) { return "" . __( 'Added:' ) . " {$line}"; } public function deletedLine( $line ) { return "" . __( 'Deleted:' ) . " {$line}"; } public function contextLine( $line ) { return "" . __( 'Unchanged:' ) . " {$line}"; } public function emptyLine() { return ' '; } public function _added( $lines, $encode = true ) { $r = ''; foreach ( $lines as $line ) { if ( $encode ) { $processed_line = htmlspecialchars( $line ); $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); } if ( $this->_show_split_view ) { $r .= '' . $this->emptyLine() . $this->addedLine( $line ) . "\n"; } else { $r .= '' . $this->addedLine( $line ) . "\n"; } } return $r; } public function _deleted( $lines, $encode = true ) { $r = ''; foreach ( $lines as $line ) { if ( $encode ) { $processed_line = htmlspecialchars( $line ); $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); } if ( $this->_show_split_view ) { $r .= '' . $this->deletedLine( $line ) . $this->emptyLine() . "\n"; } else { $r .= '' . $this->deletedLine( $line ) . "\n"; } } return $r; } public function _context( $lines, $encode = true ) { $r = ''; foreach ( $lines as $line ) { if ( $encode ) { $processed_line = htmlspecialchars( $line ); $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); } if ( $this->_show_split_view ) { $r .= '' . $this->contextLine( $line ) . $this->contextLine( $line ) . "\n"; } else { $r .= '' . $this->contextLine( $line ) . "\n"; } } return $r; } public function _changed( $orig, $final ) { $r = ''; list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final ); $orig_diffs = array(); $final_diffs = array(); foreach ( $orig_matches as $o => $f ) { if ( is_numeric( $o ) && is_numeric( $f ) ) { $text_diff = new Text_Diff( 'auto', array( array( $orig[ $o ] ), array( $final[ $f ] ) ) ); $renderer = new $this->inline_diff_renderer(); $diff = $renderer->render( $text_diff ); if ( preg_match_all( '!(.*?|.*?)!', $diff, $diff_matches ) ) { $stripped_matches = strlen( strip_tags( implode( ' ', $diff_matches[0] ) ) ); $stripped_diff = strlen( strip_tags( $diff ) ) * 2 - $stripped_matches; $diff_ratio = $stripped_matches / $stripped_diff; if ( $diff_ratio > $this->_diff_threshold ) { continue; } } $orig_diffs[ $o ] = preg_replace( '|.*?|', '', $diff ); $final_diffs[ $f ] = preg_replace( '|.*?|', '', $diff ); } } foreach ( array_keys( $orig_rows ) as $row ) { if ( $orig_rows[ $row ] < 0 && $final_rows[ $row ] < 0 ) { continue; } if ( isset( $orig_diffs[ $orig_rows[ $row ] ] ) ) { $orig_line = $orig_diffs[ $orig_rows[ $row ] ]; } elseif ( isset( $orig[ $orig_rows[ $row ] ] ) ) { $orig_line = htmlspecialchars( $orig[ $orig_rows[ $row ] ] ); } else { $orig_line = ''; } if ( isset( $final_diffs[ $final_rows[ $row ] ] ) ) { $final_line = $final_diffs[ $final_rows[ $row ] ]; } elseif ( isset( $final[ $final_rows[ $row ] ] ) ) { $final_line = htmlspecialchars( $final[ $final_rows[ $row ] ] ); } else { $final_line = ''; } if ( $orig_rows[ $row ] < 0 ) { $r .= $this->_added( array( $final_line ), false ); } elseif ( $final_rows[ $row ] < 0 ) { $r .= $this->_deleted( array( $orig_line ), false ); } else { if ( $this->_show_split_view ) { $r .= '' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "\n"; } else { $r .= '' . $this->deletedLine( $orig_line ) . '' . $this->addedLine( $final_line ) . "\n"; } } } return $r; } public function interleave_changed_lines( $orig, $final ) { $matches = array(); foreach ( array_keys( $orig ) as $o ) { foreach ( array_keys( $final ) as $f ) { $matches[ "$o,$f" ] = $this->compute_string_distance( $orig[ $o ], $final[ $f ] ); } } asort( $matches ); $orig_matches = array(); $final_matches = array(); foreach ( $matches as $keys => $difference ) { list($o, $f) = explode( ',', $keys ); $o = (int) $o; $f = (int) $f; if ( isset( $orig_matches[ $o ] ) && isset( $final_matches[ $f ] ) ) { continue; } if ( ! isset( $orig_matches[ $o ] ) && ! isset( $final_matches[ $f ] ) ) { $orig_matches[ $o ] = $f; $final_matches[ $f ] = $o; continue; } if ( isset( $orig_matches[ $o ] ) ) { $final_matches[ $f ] = 'x'; } elseif ( isset( $final_matches[ $f ] ) ) { $orig_matches[ $o ] = 'x'; } } ksort( $orig_matches ); ksort( $final_matches ); $orig_rows = array_keys( $orig_matches ); $orig_rows_copy = $orig_rows; $final_rows = array_keys( $final_matches ); foreach ( $orig_rows_copy as $orig_row ) { $final_pos = array_search( $orig_matches[ $orig_row ], $final_rows, true ); $orig_pos = (int) array_search( $orig_row, $orig_rows, true ); if ( false === $final_pos ) { array_splice( $final_rows, $orig_pos, 0, -1 ); } elseif ( $final_pos < $orig_pos ) { $diff_array = range( -1, $final_pos - $orig_pos ); array_splice( $final_rows, $orig_pos, 0, $diff_array ); } elseif ( $final_pos > $orig_pos ) { $diff_array = range( -1, $orig_pos - $final_pos ); array_splice( $orig_rows, $orig_pos, 0, $diff_array ); } } $diff_count = count( $orig_rows ) - count( $final_rows ); if ( $diff_count < 0 ) { while ( $diff_count < 0 ) { array_push( $orig_rows, $diff_count++ ); } } elseif ( $diff_count > 0 ) { $diff_count = -1 * $diff_count; while ( $diff_count < 0 ) { array_push( $final_rows, $diff_count++ ); } } return array( $orig_matches, $final_matches, $orig_rows, $final_rows ); } public function compute_string_distance( $string1, $string2 ) { $count_key1 = md5( $string1 ); $count_key2 = md5( $string2 ); if ( ! isset( $this->count_cache[ $count_key1 ] ) ) { $this->count_cache[ $count_key1 ] = count_chars( $string1 ); } if ( ! isset( $this->count_cache[ $count_key2 ] ) ) { $this->count_cache[ $count_key2 ] = count_chars( $string2 ); } $chars1 = $this->count_cache[ $count_key1 ]; $chars2 = $this->count_cache[ $count_key2 ]; $difference_key = md5( implode( ',', $chars1 ) . ':' . implode( ',', $chars2 ) ); if ( ! isset( $this->difference_cache[ $difference_key ] ) ) { $this->difference_cache[ $difference_key ] = array_sum( array_map( array( $this, 'difference' ), $chars1, $chars2 ) ); } $difference = $this->difference_cache[ $difference_key ]; if ( ! $string1 ) { return $difference; } return $difference / strlen( $string1 ); } public function difference( $a, $b ) { return abs( $a - $b ); } public function __get( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name; } } public function __set( $name, $value ) { if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name = $value; } } public function __isset( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { return isset( $this->$name ); } } public function __unset( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { unset( $this->$name ); } } } all[ $domain ][ $locale ] ) ) { return $this->all[ $domain ][ $locale ]; } return $this->get_path_from_lang_dir( $domain, $locale ); } public function has( $domain ) { return ( ! empty( $this->current[ $domain ] ) || empty( $this->all[ $domain ] ) || in_array( $domain, $this->domains_with_translations, true ) ); } public function set( $domain, $locale, $path ) { $this->all[ $domain ][ $locale ] = $path ? trailingslashit( $path ) : false; $this->current[ $domain ] = $this->all[ $domain ][ $locale ]; } public function set_custom_path( $domain, $path ) { $this->custom_paths[ $domain ] = untrailingslashit( $path ); } private function get_paths_for_domain( $domain ) { $locations = array( WP_LANG_DIR . '/plugins', WP_LANG_DIR . '/themes', ); if ( isset( $this->custom_paths[ $domain ] ) ) { $locations[] = $this->custom_paths[ $domain ]; } return $locations; } private function get_path_from_lang_dir( $domain, $locale ) { $locations = $this->get_paths_for_domain( $domain ); $found_location = false; foreach ( $locations as $location ) { if ( ! isset( $this->cached_mo_files[ $location ] ) ) { $this->set_cached_mo_files( $location ); } $path = "$location/$domain-$locale.mo"; foreach ( $this->cached_mo_files[ $location ] as $mo_path ) { if ( ! in_array( $domain, $this->domains_with_translations, true ) && str_starts_with( str_replace( "$location/", '', $mo_path ), "$domain-" ) ) { $this->domains_with_translations[] = $domain; } if ( $mo_path === $path ) { $found_location = trailingslashit( $location ); } } } if ( $found_location ) { $this->set( $domain, $locale, $found_location ); return $found_location; } if ( 'en_US' !== $locale && isset( $this->custom_paths[ $domain ] ) ) { $fallback_location = trailingslashit( $this->custom_paths[ $domain ] ); $this->set( $domain, $locale, $fallback_location ); return $fallback_location; } $this->set( $domain, $locale, false ); return false; } private function set_cached_mo_files( $path ) { $this->cached_mo_files[ $path ] = array(); $mo_files = glob( $path . '/*.mo' ); if ( $mo_files ) { $this->cached_mo_files[ $path ] = $mo_files; } } } origin = $origin; $this->theme_json = new WP_Theme_JSON( $data, $this->origin ); } public function update_with( $new_data ) { $this->theme_json->merge( new WP_Theme_JSON( $new_data, $this->origin ) ); return $this; } public function get_data() { return $this->theme_json->get_raw_data(); } } array(), 'blocks' => array(), 'theme' => array(), 'user' => array(), ); protected static $core = null; protected static $blocks = null; protected static $theme = null; protected static $theme_has_support = null; protected static $user = null; protected static $user_custom_post_type_id = null; protected static $i18n_schema = null; protected static $theme_json_file_cache = array(); protected static function read_json_file( $file_path ) { if ( $file_path ) { if ( array_key_exists( $file_path, static::$theme_json_file_cache ) ) { return static::$theme_json_file_cache[ $file_path ]; } $decoded_file = wp_json_file_decode( $file_path, array( 'associative' => true ) ); if ( is_array( $decoded_file ) ) { static::$theme_json_file_cache[ $file_path ] = $decoded_file; return static::$theme_json_file_cache[ $file_path ]; } } return array(); } public static function get_fields_to_translate() { _deprecated_function( __METHOD__, '5.9.0' ); return array(); } protected static function translate( $theme_json, $domain = 'default' ) { if ( null === static::$i18n_schema ) { $i18n_schema = wp_json_file_decode( __DIR__ . '/theme-i18n.json' ); static::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema; } return translate_settings_using_i18n_schema( static::$i18n_schema, $theme_json, $domain ); } public static function get_core_data() { if ( null !== static::$core && static::has_same_registered_blocks( 'core' ) ) { return static::$core; } $config = static::read_json_file( __DIR__ . '/theme.json' ); $config = static::translate( $config ); $theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) ); $config = $theme_json->get_data(); static::$core = new WP_Theme_JSON( $config, 'default' ); return static::$core; } protected static function has_same_registered_blocks( $origin ) { if ( ! isset( static::$blocks_cache[ $origin ] ) ) { return false; } $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); $block_diff = array_diff_key( $blocks, static::$blocks_cache[ $origin ] ); if ( empty( $block_diff ) ) { return true; } foreach ( $blocks as $block_name => $block_type ) { static::$blocks_cache[ $origin ][ $block_name ] = true; } return false; } public static function get_theme_data( $deprecated = array(), $options = array() ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __METHOD__, '5.9.0' ); } $options = wp_parse_args( $options, array( 'with_supports' => true ) ); if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) { $theme_json_file = static::get_file_path_from_theme( 'theme.json' ); $wp_theme = wp_get_theme(); if ( '' !== $theme_json_file ) { $theme_json_data = static::read_json_file( $theme_json_file ); $theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) ); } else { $theme_json_data = array(); } $theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) ); $theme_json_data = $theme_json->get_data(); static::$theme = new WP_Theme_JSON( $theme_json_data ); if ( $wp_theme->parent() ) { $parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true ); if ( '' !== $parent_theme_json_file ) { $parent_theme_json_data = static::read_json_file( $parent_theme_json_file ); $parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) ); $parent_theme = new WP_Theme_JSON( $parent_theme_json_data ); $parent_theme->merge( static::$theme ); static::$theme = $parent_theme; } } } if ( ! $options['with_supports'] ) { return static::$theme; } $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_default_block_editor_settings() ); if ( ! static::theme_has_support() ) { if ( ! isset( $theme_support_data['settings']['color'] ) ) { $theme_support_data['settings']['color'] = array(); } $default_palette = false; if ( current_theme_supports( 'default-color-palette' ) ) { $default_palette = true; } if ( ! isset( $theme_support_data['settings']['color']['palette'] ) ) { $default_palette = true; } $theme_support_data['settings']['color']['defaultPalette'] = $default_palette; $default_gradients = false; if ( current_theme_supports( 'default-gradient-presets' ) ) { $default_gradients = true; } if ( ! isset( $theme_support_data['settings']['color']['gradients'] ) ) { $default_gradients = true; } $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients; $theme_support_data['settings']['color']['defaultDuotone'] = false; } $with_theme_supports = new WP_Theme_JSON( $theme_support_data ); $with_theme_supports->merge( static::$theme ); return $with_theme_supports; } public static function get_block_data() { $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); if ( null !== static::$blocks && static::has_same_registered_blocks( 'blocks' ) ) { return static::$blocks; } $config = array( 'version' => 2 ); foreach ( $blocks as $block_name => $block_type ) { if ( isset( $block_type->supports['__experimentalStyle'] ) ) { $config['styles']['blocks'][ $block_name ] = static::remove_json_comments( $block_type->supports['__experimentalStyle'] ); } if ( isset( $block_type->supports['spacing']['blockGap']['__experimentalDefault'] ) && null === _wp_array_get( $config, array( 'styles', 'blocks', $block_name, 'spacing', 'blockGap' ), null ) ) { $config['styles']['blocks'][ $block_name ]['spacing']['blockGap'] = null; } } $theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) ); $config = $theme_json->get_data(); static::$blocks = new WP_Theme_JSON( $config, 'blocks' ); return static::$blocks; } private static function remove_json_comments( $array ) { unset( $array['//'] ); foreach ( $array as $k => $v ) { if ( is_array( $v ) ) { $array[ $k ] = static::remove_json_comments( $v ); } } return $array; } public static function get_user_data_from_wp_global_styles( $theme, $create_post = false, $post_status_filter = array( 'publish' ) ) { if ( ! $theme instanceof WP_Theme ) { $theme = wp_get_theme(); } if ( $theme->get_stylesheet() === get_stylesheet() && ! static::theme_has_support() ) { return array(); } $user_cpt = array(); $post_type_filter = 'wp_global_styles'; $stylesheet = $theme->get_stylesheet(); $args = array( 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'desc', 'post_type' => $post_type_filter, 'post_status' => $post_status_filter, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => $stylesheet, ), ), ); $global_style_query = new WP_Query(); $recent_posts = $global_style_query->query( $args ); if ( count( $recent_posts ) === 1 ) { $user_cpt = get_post( $recent_posts[0], ARRAY_A ); } elseif ( $create_post ) { $cpt_post_id = wp_insert_post( array( 'post_content' => '{"version": ' . WP_Theme_JSON::LATEST_SCHEMA . ', "isGlobalStylesUserThemeJSON": true }', 'post_status' => 'publish', 'post_title' => 'Custom Styles', 'post_type' => $post_type_filter, 'post_name' => sprintf( 'wp-global-styles-%s', urlencode( $stylesheet ) ), 'tax_input' => array( 'wp_theme' => array( $stylesheet ), ), ), true ); if ( ! is_wp_error( $cpt_post_id ) ) { $user_cpt = get_post( $cpt_post_id, ARRAY_A ); } } return $user_cpt; } public static function get_user_data() { if ( null !== static::$user && static::has_same_registered_blocks( 'user' ) ) { return static::$user; } $config = array(); $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme() ); if ( array_key_exists( 'post_content', $user_cpt ) ) { $decoded_data = json_decode( $user_cpt['post_content'], true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE !== $json_decoding_error ) { trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() ); $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); $config = $theme_json->get_data(); return new WP_Theme_JSON( $config, 'custom' ); } if ( is_array( $decoded_data ) && isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && $decoded_data['isGlobalStylesUserThemeJSON'] ) { unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); $config = $decoded_data; } } $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); $config = $theme_json->get_data(); static::$user = new WP_Theme_JSON( $config, 'custom' ); return static::$user; } public static function get_merged_data( $origin = 'custom' ) { if ( is_array( $origin ) ) { _deprecated_argument( __FUNCTION__, '5.9.0' ); } $result = static::get_core_data(); $result->merge( static::get_block_data() ); $result->merge( static::get_theme_data() ); if ( 'custom' === $origin ) { $result->merge( static::get_user_data() ); } $result->set_spacing_sizes(); return $result; } public static function get_user_global_styles_post_id() { if ( null !== static::$user_custom_post_type_id ) { return static::$user_custom_post_type_id; } $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme(), true ); if ( array_key_exists( 'ID', $user_cpt ) ) { static::$user_custom_post_type_id = $user_cpt['ID']; } return static::$user_custom_post_type_id; } public static function theme_has_support() { if ( ! isset( static::$theme_has_support ) ) { static::$theme_has_support = ( static::get_file_path_from_theme( 'theme.json' ) !== '' || static::get_file_path_from_theme( 'theme.json', true ) !== '' ); } return static::$theme_has_support; } protected static function get_file_path_from_theme( $file_name, $template = false ) { $path = $template ? get_template_directory() : get_stylesheet_directory(); $candidate = $path . '/' . $file_name; return is_readable( $candidate ) ? $candidate : ''; } public static function clean_cached_data() { static::$core = null; static::$blocks = null; static::$blocks_cache = array( 'core' => array(), 'blocks' => array(), 'theme' => array(), 'user' => array(), ); static::$theme = null; static::$user = null; static::$user_custom_post_type_id = null; static::$theme_has_support = null; static::$i18n_schema = null; } public static function get_style_variations() { $variations = array(); $base_directory = get_stylesheet_directory() . '/styles'; if ( is_dir( $base_directory ) ) { $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) ); $nested_html_files = iterator_to_array( new RegexIterator( $nested_files, '/^.+\.json$/i', RecursiveRegexIterator::GET_MATCH ) ); ksort( $nested_html_files ); foreach ( $nested_html_files as $path => $file ) { $decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) ); if ( is_array( $decoded_file ) ) { $translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) ); $variation = ( new WP_Theme_JSON( $translated ) )->get_raw_data(); if ( empty( $variation['title'] ) ) { $variation['title'] = basename( $path, '.json' ); } $variations[] = $variation; } } } return $variations; } } array(), 'blocks' => array(), 'theme' => array(), 'user' => array(), ); protected static $core = null; protected static $blocks = null; protected static $theme = null; protected static $user = null; protected static $user_custom_post_type_id = null; protected static $i18n_schema = null; protected static $theme_json_file_cache = array(); protected static function read_json_file( $file_path ) { if ( $file_path ) { if ( array_key_exists( $file_path, static::$theme_json_file_cache ) ) { return static::$theme_json_file_cache[ $file_path ]; } $decoded_file = wp_json_file_decode( $file_path, array( 'associative' => true ) ); if ( is_array( $decoded_file ) ) { static::$theme_json_file_cache[ $file_path ] = $decoded_file; return static::$theme_json_file_cache[ $file_path ]; } } return array(); } public static function get_fields_to_translate() { _deprecated_function( __METHOD__, '5.9.0' ); return array(); } protected static function translate( $theme_json, $domain = 'default' ) { if ( null === static::$i18n_schema ) { $i18n_schema = wp_json_file_decode( __DIR__ . '/theme-i18n.json' ); static::$i18n_schema = null === $i18n_schema ? array() : $i18n_schema; } return translate_settings_using_i18n_schema( static::$i18n_schema, $theme_json, $domain ); } public static function get_core_data() { if ( null !== static::$core && static::has_same_registered_blocks( 'core' ) ) { return static::$core; } $config = static::read_json_file( __DIR__ . '/theme.json' ); $config = static::translate( $config ); $theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) ); $config = $theme_json->get_data(); static::$core = new WP_Theme_JSON( $config, 'default' ); return static::$core; } protected static function has_same_registered_blocks( $origin ) { if ( ! isset( static::$blocks_cache[ $origin ] ) ) { return false; } $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); $block_diff = array_diff_key( $blocks, static::$blocks_cache[ $origin ] ); if ( empty( $block_diff ) ) { return true; } foreach ( $blocks as $block_name => $block_type ) { static::$blocks_cache[ $origin ][ $block_name ] = true; } return false; } public static function get_theme_data( $deprecated = array(), $options = array() ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __METHOD__, '5.9.0' ); } $options = wp_parse_args( $options, array( 'with_supports' => true ) ); if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) { $theme_json_file = static::get_file_path_from_theme( 'theme.json' ); $wp_theme = wp_get_theme(); if ( '' !== $theme_json_file ) { $theme_json_data = static::read_json_file( $theme_json_file ); $theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) ); } else { $theme_json_data = array(); } $theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) ); $theme_json_data = $theme_json->get_data(); static::$theme = new WP_Theme_JSON( $theme_json_data ); if ( $wp_theme->parent() ) { $parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true ); if ( '' !== $parent_theme_json_file ) { $parent_theme_json_data = static::read_json_file( $parent_theme_json_file ); $parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) ); $parent_theme = new WP_Theme_JSON( $parent_theme_json_data ); $parent_theme->merge( static::$theme ); static::$theme = $parent_theme; } } } if ( ! $options['with_supports'] ) { return static::$theme; } $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); if ( ! wp_theme_has_theme_json() ) { if ( ! isset( $theme_support_data['settings']['color'] ) ) { $theme_support_data['settings']['color'] = array(); } $default_palette = false; if ( current_theme_supports( 'default-color-palette' ) ) { $default_palette = true; } if ( ! isset( $theme_support_data['settings']['color']['palette'] ) ) { $default_palette = true; } $theme_support_data['settings']['color']['defaultPalette'] = $default_palette; $default_gradients = false; if ( current_theme_supports( 'default-gradient-presets' ) ) { $default_gradients = true; } if ( ! isset( $theme_support_data['settings']['color']['gradients'] ) ) { $default_gradients = true; } $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients; $theme_support_data['settings']['color']['defaultDuotone'] = false; if ( current_theme_supports( 'appearance-tools' ) ) { $theme_support_data['settings']['appearanceTools'] = true; } } $with_theme_supports = new WP_Theme_JSON( $theme_support_data ); $with_theme_supports->merge( static::$theme ); return $with_theme_supports; } public static function get_block_data() { $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); if ( null !== static::$blocks && static::has_same_registered_blocks( 'blocks' ) ) { return static::$blocks; } $config = array( 'version' => 2 ); foreach ( $blocks as $block_name => $block_type ) { if ( isset( $block_type->supports['__experimentalStyle'] ) ) { $config['styles']['blocks'][ $block_name ] = static::remove_json_comments( $block_type->supports['__experimentalStyle'] ); } if ( isset( $block_type->supports['spacing']['blockGap']['__experimentalDefault'] ) && null === _wp_array_get( $config, array( 'styles', 'blocks', $block_name, 'spacing', 'blockGap' ), null ) ) { $config['styles']['blocks'][ $block_name ]['spacing']['blockGap'] = null; } } $theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) ); $config = $theme_json->get_data(); static::$blocks = new WP_Theme_JSON( $config, 'blocks' ); return static::$blocks; } private static function remove_json_comments( $input_array ) { unset( $input_array['//'] ); foreach ( $input_array as $k => $v ) { if ( is_array( $v ) ) { $input_array[ $k ] = static::remove_json_comments( $v ); } } return $input_array; } public static function get_user_data_from_wp_global_styles( $theme, $create_post = false, $post_status_filter = array( 'publish' ) ) { if ( ! $theme instanceof WP_Theme ) { $theme = wp_get_theme(); } if ( $theme->get_stylesheet() === get_stylesheet() && ! wp_theme_has_theme_json() ) { return array(); } $user_cpt = array(); $post_type_filter = 'wp_global_styles'; $stylesheet = $theme->get_stylesheet(); $args = array( 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'desc', 'post_type' => $post_type_filter, 'post_status' => $post_status_filter, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => $stylesheet, ), ), ); $global_style_query = new WP_Query(); $recent_posts = $global_style_query->query( $args ); if ( count( $recent_posts ) === 1 ) { $user_cpt = get_post( $recent_posts[0], ARRAY_A ); } elseif ( $create_post ) { $cpt_post_id = wp_insert_post( array( 'post_content' => '{"version": ' . WP_Theme_JSON::LATEST_SCHEMA . ', "isGlobalStylesUserThemeJSON": true }', 'post_status' => 'publish', 'post_title' => 'Custom Styles', 'post_type' => $post_type_filter, 'post_name' => sprintf( 'wp-global-styles-%s', urlencode( $stylesheet ) ), 'tax_input' => array( 'wp_theme' => array( $stylesheet ), ), ), true ); if ( ! is_wp_error( $cpt_post_id ) ) { $user_cpt = get_post( $cpt_post_id, ARRAY_A ); } } return $user_cpt; } public static function get_user_data() { if ( null !== static::$user && static::has_same_registered_blocks( 'user' ) ) { return static::$user; } $config = array(); $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme() ); if ( array_key_exists( 'post_content', $user_cpt ) ) { $decoded_data = json_decode( $user_cpt['post_content'], true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE !== $json_decoding_error ) { trigger_error( 'Error when decoding a theme.json schema for user data. ' . json_last_error_msg() ); $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); $config = $theme_json->get_data(); return new WP_Theme_JSON( $config, 'custom' ); } if ( is_array( $decoded_data ) && isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && $decoded_data['isGlobalStylesUserThemeJSON'] ) { unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); $config = $decoded_data; } } $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); $config = $theme_json->get_data(); static::$user = new WP_Theme_JSON( $config, 'custom' ); return static::$user; } public static function get_merged_data( $origin = 'custom' ) { if ( is_array( $origin ) ) { _deprecated_argument( __FUNCTION__, '5.9.0' ); } $result = static::get_core_data(); $result->merge( static::get_block_data() ); $result->merge( static::get_theme_data() ); if ( 'custom' === $origin ) { $result->merge( static::get_user_data() ); } $result->set_spacing_sizes(); return $result; } public static function get_user_global_styles_post_id() { if ( null !== static::$user_custom_post_type_id ) { return static::$user_custom_post_type_id; } $user_cpt = static::get_user_data_from_wp_global_styles( wp_get_theme(), true ); if ( array_key_exists( 'ID', $user_cpt ) ) { static::$user_custom_post_type_id = $user_cpt['ID']; } return static::$user_custom_post_type_id; } public static function theme_has_support() { _deprecated_function( __METHOD__, '6.2.0', 'wp_theme_has_theme_json()' ); return wp_theme_has_theme_json(); } protected static function get_file_path_from_theme( $file_name, $template = false ) { $path = $template ? get_template_directory() : get_stylesheet_directory(); $candidate = $path . '/' . $file_name; return is_readable( $candidate ) ? $candidate : ''; } public static function clean_cached_data() { static::$core = null; static::$blocks = null; static::$blocks_cache = array( 'core' => array(), 'blocks' => array(), 'theme' => array(), 'user' => array(), ); static::$theme = null; static::$user = null; static::$user_custom_post_type_id = null; static::$i18n_schema = null; } public static function get_style_variations() { $variations = array(); $base_directory = get_stylesheet_directory() . '/styles'; if ( is_dir( $base_directory ) ) { $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) ); $nested_html_files = iterator_to_array( new RegexIterator( $nested_files, '/^.+\.json$/i', RecursiveRegexIterator::GET_MATCH ) ); ksort( $nested_html_files ); foreach ( $nested_html_files as $path => $file ) { $decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) ); if ( is_array( $decoded_file ) ) { $translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) ); $variation = ( new WP_Theme_JSON( $translated ) )->get_raw_data(); if ( empty( $variation['title'] ) ) { $variation['title'] = basename( $path, '.json' ); } $variations[] = $variation; } } } return $variations; } } 'border.radius', 'spacing.customMargin' => 'spacing.margin', 'spacing.customPadding' => 'spacing.padding', 'typography.customLineHeight' => 'typography.lineHeight', ); public static function migrate( $theme_json ) { if ( ! isset( $theme_json['version'] ) ) { $theme_json = array( 'version' => WP_Theme_JSON::LATEST_SCHEMA, ); } if ( 1 === $theme_json['version'] ) { $theme_json = self::migrate_v1_to_v2( $theme_json ); } return $theme_json; } private static function migrate_v1_to_v2( $old ) { $new = $old; if ( isset( $old['settings'] ) ) { $new['settings'] = self::rename_paths( $old['settings'], self::V1_TO_V2_RENAMED_PATHS ); } $new['version'] = 2; return $new; } private static function rename_paths( $settings, $paths_to_rename ) { $new_settings = $settings; self::rename_settings( $new_settings, $paths_to_rename ); if ( isset( $new_settings['blocks'] ) && is_array( $new_settings['blocks'] ) ) { foreach ( $new_settings['blocks'] as &$block_settings ) { self::rename_settings( $block_settings, $paths_to_rename ); } } return $new_settings; } private static function rename_settings( &$settings, $paths_to_rename ) { foreach ( $paths_to_rename as $original => $renamed ) { $original_path = explode( '.', $original ); $renamed_path = explode( '.', $renamed ); $current_value = _wp_array_get( $settings, $original_path, null ); if ( null !== $current_value ) { _wp_array_set( $settings, $renamed_path, $current_value ); self::unset_setting_by_path( $settings, $original_path ); } } } private static function unset_setting_by_path( &$settings, $path ) { $tmp_settings = &$settings; $last_key = array_pop( $path ); foreach ( $path as $key ) { $tmp_settings = &$tmp_settings[ $key ]; } unset( $tmp_settings[ $last_key ] ); } } array( 'color', 'palette' ), 'prevent_override' => array( 'color', 'defaultPalette' ), 'use_default_names' => false, 'value_key' => 'color', 'css_vars' => '--wp--preset--color--$slug', 'classes' => array( '.has-$slug-color' => 'color', '.has-$slug-background-color' => 'background-color', '.has-$slug-border-color' => 'border-color', ), 'properties' => array( 'color', 'background-color', 'border-color' ), ), array( 'path' => array( 'color', 'gradients' ), 'prevent_override' => array( 'color', 'defaultGradients' ), 'use_default_names' => false, 'value_key' => 'gradient', 'css_vars' => '--wp--preset--gradient--$slug', 'classes' => array( '.has-$slug-gradient-background' => 'background' ), 'properties' => array( 'background' ), ), array( 'path' => array( 'color', 'duotone' ), 'prevent_override' => array( 'color', 'defaultDuotone' ), 'use_default_names' => false, 'value_func' => 'wp_get_duotone_filter_property', 'css_vars' => '--wp--preset--duotone--$slug', 'classes' => array(), 'properties' => array( 'filter' ), ), array( 'path' => array( 'typography', 'fontSizes' ), 'prevent_override' => false, 'use_default_names' => true, 'value_func' => 'wp_get_typography_font_size_value', 'css_vars' => '--wp--preset--font-size--$slug', 'classes' => array( '.has-$slug-font-size' => 'font-size' ), 'properties' => array( 'font-size' ), ), array( 'path' => array( 'typography', 'fontFamilies' ), 'prevent_override' => false, 'use_default_names' => false, 'value_key' => 'fontFamily', 'css_vars' => '--wp--preset--font-family--$slug', 'classes' => array( '.has-$slug-font-family' => 'font-family' ), 'properties' => array( 'font-family' ), ), array( 'path' => array( 'spacing', 'spacingSizes' ), 'prevent_override' => false, 'use_default_names' => true, 'value_key' => 'size', 'css_vars' => '--wp--preset--spacing--$slug', 'classes' => array(), 'properties' => array( 'padding', 'margin' ), ), ); const PROPERTIES_METADATA = array( 'background' => array( 'color', 'gradient' ), 'background-color' => array( 'color', 'background' ), 'border-radius' => array( 'border', 'radius' ), 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ), 'border-top-right-radius' => array( 'border', 'radius', 'topRight' ), 'border-bottom-left-radius' => array( 'border', 'radius', 'bottomLeft' ), 'border-bottom-right-radius' => array( 'border', 'radius', 'bottomRight' ), 'border-color' => array( 'border', 'color' ), 'border-width' => array( 'border', 'width' ), 'border-style' => array( 'border', 'style' ), 'border-top-color' => array( 'border', 'top', 'color' ), 'border-top-width' => array( 'border', 'top', 'width' ), 'border-top-style' => array( 'border', 'top', 'style' ), 'border-right-color' => array( 'border', 'right', 'color' ), 'border-right-width' => array( 'border', 'right', 'width' ), 'border-right-style' => array( 'border', 'right', 'style' ), 'border-bottom-color' => array( 'border', 'bottom', 'color' ), 'border-bottom-width' => array( 'border', 'bottom', 'width' ), 'border-bottom-style' => array( 'border', 'bottom', 'style' ), 'border-left-color' => array( 'border', 'left', 'color' ), 'border-left-width' => array( 'border', 'left', 'width' ), 'border-left-style' => array( 'border', 'left', 'style' ), 'color' => array( 'color', 'text' ), 'font-family' => array( 'typography', 'fontFamily' ), 'font-size' => array( 'typography', 'fontSize' ), 'font-style' => array( 'typography', 'fontStyle' ), 'font-weight' => array( 'typography', 'fontWeight' ), 'letter-spacing' => array( 'typography', 'letterSpacing' ), 'line-height' => array( 'typography', 'lineHeight' ), 'margin' => array( 'spacing', 'margin' ), 'margin-top' => array( 'spacing', 'margin', 'top' ), 'margin-right' => array( 'spacing', 'margin', 'right' ), 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ), 'margin-left' => array( 'spacing', 'margin', 'left' ), 'outline-color' => array( 'outline', 'color' ), 'outline-offset' => array( 'outline', 'offset' ), 'outline-style' => array( 'outline', 'style' ), 'outline-width' => array( 'outline', 'width' ), 'padding' => array( 'spacing', 'padding' ), 'padding-top' => array( 'spacing', 'padding', 'top' ), 'padding-right' => array( 'spacing', 'padding', 'right' ), 'padding-bottom' => array( 'spacing', 'padding', 'bottom' ), 'padding-left' => array( 'spacing', 'padding', 'left' ), '--wp--style--root--padding' => array( 'spacing', 'padding' ), '--wp--style--root--padding-top' => array( 'spacing', 'padding', 'top' ), '--wp--style--root--padding-right' => array( 'spacing', 'padding', 'right' ), '--wp--style--root--padding-bottom' => array( 'spacing', 'padding', 'bottom' ), '--wp--style--root--padding-left' => array( 'spacing', 'padding', 'left' ), 'text-decoration' => array( 'typography', 'textDecoration' ), 'text-transform' => array( 'typography', 'textTransform' ), 'filter' => array( 'filter', 'duotone' ), 'box-shadow' => array( 'shadow' ), ); const PROTECTED_PROPERTIES = array( 'spacing.blockGap' => array( 'spacing', 'blockGap' ), ); const VALID_TOP_LEVEL_KEYS = array( 'customTemplates', 'patterns', 'settings', 'styles', 'templateParts', 'title', 'version', ); const VALID_SETTINGS = array( 'appearanceTools' => null, 'useRootPaddingAwareAlignments' => null, 'border' => array( 'color' => null, 'radius' => null, 'style' => null, 'width' => null, ), 'color' => array( 'background' => null, 'custom' => null, 'customDuotone' => null, 'customGradient' => null, 'defaultDuotone' => null, 'defaultGradients' => null, 'defaultPalette' => null, 'duotone' => null, 'gradients' => null, 'link' => null, 'palette' => null, 'text' => null, ), 'custom' => null, 'layout' => array( 'contentSize' => null, 'definitions' => null, 'wideSize' => null, ), 'spacing' => array( 'customSpacingSize' => null, 'spacingSizes' => null, 'spacingScale' => null, 'blockGap' => null, 'margin' => null, 'padding' => null, 'units' => null, ), 'typography' => array( 'fluid' => null, 'customFontSize' => null, 'dropCap' => null, 'fontFamilies' => null, 'fontSizes' => null, 'fontStyle' => null, 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, 'textDecoration' => null, 'textTransform' => null, ), ); const VALID_STYLES = array( 'border' => array( 'color' => null, 'radius' => null, 'style' => null, 'width' => null, 'top' => null, 'right' => null, 'bottom' => null, 'left' => null, ), 'color' => array( 'background' => null, 'gradient' => null, 'text' => null, ), 'filter' => array( 'duotone' => null, ), 'outline' => array( 'color' => null, 'offset' => null, 'style' => null, 'width' => null, ), 'shadow' => null, 'spacing' => array( 'margin' => null, 'padding' => null, 'blockGap' => null, ), 'typography' => array( 'fontFamily' => null, 'fontSize' => null, 'fontStyle' => null, 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, 'textDecoration' => null, 'textTransform' => null, ), ); const VALID_ELEMENT_PSEUDO_SELECTORS = array( 'link' => array( ':visited', ':hover', ':focus', ':active' ), 'button' => array( ':visited', ':hover', ':focus', ':active' ), ); const ELEMENTS = array( 'link' => 'a:where(:not(.wp-element-button))', 'heading' => 'h1, h2, h3, h4, h5, h6', 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', 'button' => '.wp-element-button, .wp-block-button__link', 'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', 'cite' => 'cite', ); const __EXPERIMENTAL_ELEMENT_CLASS_NAMES = array( 'button' => 'wp-element-button', 'caption' => 'wp-element-caption', ); const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = array( '__experimentalBorder' => 'border', 'color' => 'color', 'spacing' => 'spacing', 'typography' => 'typography', ); public static function get_element_class_name( $element ) { $class_name = ''; if ( array_key_exists( $element, static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES ) ) { $class_name = static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[ $element ]; } return $class_name; } const APPEARANCE_TOOLS_OPT_INS = array( array( 'border', 'color' ), array( 'border', 'radius' ), array( 'border', 'style' ), array( 'border', 'width' ), array( 'color', 'link' ), array( 'spacing', 'blockGap' ), array( 'spacing', 'margin' ), array( 'spacing', 'padding' ), array( 'typography', 'lineHeight' ), ); const LATEST_SCHEMA = 2; public function __construct( $theme_json = array(), $origin = 'theme' ) { if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) { $origin = 'theme'; } $this->theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); $valid_block_names = array_keys( static::get_blocks_metadata() ); $valid_element_names = array_keys( static::ELEMENTS ); $theme_json = static::sanitize( $this->theme_json, $valid_block_names, $valid_element_names ); $this->theme_json = static::maybe_opt_in_into_settings( $theme_json ); $nodes = static::get_setting_nodes( $this->theme_json ); foreach ( $nodes as $node ) { foreach ( static::PRESETS_METADATA as $preset_metadata ) { $path = $node['path']; foreach ( $preset_metadata['path'] as $subpath ) { $path[] = $subpath; } $preset = _wp_array_get( $this->theme_json, $path, null ); if ( null !== $preset ) { if ( isset( $preset[0] ) || empty( $preset ) ) { _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) ); } } } } } protected static function maybe_opt_in_into_settings( $theme_json ) { $new_theme_json = $theme_json; if ( isset( $new_theme_json['settings']['appearanceTools'] ) && true === $new_theme_json['settings']['appearanceTools'] ) { static::do_opt_in_into_settings( $new_theme_json['settings'] ); } if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) { foreach ( $new_theme_json['settings']['blocks'] as &$block ) { if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) { static::do_opt_in_into_settings( $block ); } } } return $new_theme_json; } protected static function do_opt_in_into_settings( &$context ) { foreach ( static::APPEARANCE_TOOLS_OPT_INS as $path ) { if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) { _wp_array_set( $context, $path, true ); } } unset( $context['appearanceTools'] ); } protected static function sanitize( $input, $valid_block_names, $valid_element_names ) { $output = array(); if ( ! is_array( $input ) ) { return $output; } $output = array_intersect_key( $input, array_flip( static::VALID_TOP_LEVEL_KEYS ) ); $styles_non_top_level = static::VALID_STYLES; foreach ( array_keys( $styles_non_top_level ) as $section ) { if ( array_key_exists( $section, $styles_non_top_level ) && is_array( $styles_non_top_level[ $section ] ) ) { foreach ( array_keys( $styles_non_top_level[ $section ] ) as $prop ) { if ( 'top' === $styles_non_top_level[ $section ][ $prop ] ) { unset( $styles_non_top_level[ $section ][ $prop ] ); } } } } $schema = array(); $schema_styles_elements = array(); foreach ( $valid_element_names as $element ) { $schema_styles_elements[ $element ] = $styles_non_top_level; if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { $schema_styles_elements[ $element ][ $pseudo_selector ] = $styles_non_top_level; } } } $schema_styles_blocks = array(); $schema_settings_blocks = array(); foreach ( $valid_block_names as $block ) { $schema_settings_blocks[ $block ] = static::VALID_SETTINGS; $schema_styles_blocks[ $block ] = $styles_non_top_level; $schema_styles_blocks[ $block ]['elements'] = $schema_styles_elements; } $schema['styles'] = static::VALID_STYLES; $schema['styles']['blocks'] = $schema_styles_blocks; $schema['styles']['elements'] = $schema_styles_elements; $schema['settings'] = static::VALID_SETTINGS; $schema['settings']['blocks'] = $schema_settings_blocks; foreach ( array( 'styles', 'settings' ) as $subtree ) { if ( ! isset( $input[ $subtree ] ) ) { continue; } if ( ! is_array( $input[ $subtree ] ) ) { unset( $output[ $subtree ] ); continue; } $result = static::remove_keys_not_in_schema( $input[ $subtree ], $schema[ $subtree ] ); if ( empty( $result ) ) { unset( $output[ $subtree ] ); } else { $output[ $subtree ] = $result; } } return $output; } protected static function append_to_selector( $selector, $to_append, $position = 'right' ) { $new_selectors = array(); $selectors = explode( ',', $selector ); foreach ( $selectors as $sel ) { $new_selectors[] = 'right' === $position ? $sel . $to_append : $to_append . $sel; } return implode( ',', $new_selectors ); } protected static function get_blocks_metadata() { $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); $blocks = array_diff_key( $blocks, static::$blocks_metadata ); if ( empty( $blocks ) ) { return static::$blocks_metadata; } foreach ( $blocks as $block_name => $block_type ) { if ( isset( $block_type->supports['__experimentalSelector'] ) && is_string( $block_type->supports['__experimentalSelector'] ) ) { static::$blocks_metadata[ $block_name ]['selector'] = $block_type->supports['__experimentalSelector']; } else { static::$blocks_metadata[ $block_name ]['selector'] = '.wp-block-' . str_replace( '/', '-', str_replace( 'core/', '', $block_name ) ); } if ( isset( $block_type->supports['color']['__experimentalDuotone'] ) && is_string( $block_type->supports['color']['__experimentalDuotone'] ) ) { static::$blocks_metadata[ $block_name ]['duotone'] = $block_type->supports['color']['__experimentalDuotone']; } $features = array(); foreach ( static::BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS as $key => $feature ) { if ( isset( $block_type->supports[ $key ]['__experimentalSelector'] ) && $block_type->supports[ $key ]['__experimentalSelector'] ) { $features[ $feature ] = static::scope_selector( static::$blocks_metadata[ $block_name ]['selector'], $block_type->supports[ $key ]['__experimentalSelector'] ); } } if ( ! empty( $features ) ) { static::$blocks_metadata[ $block_name ]['features'] = $features; } $block_selectors = explode( ',', static::$blocks_metadata[ $block_name ]['selector'] ); foreach ( static::ELEMENTS as $el_name => $el_selector ) { $element_selector = array(); foreach ( $block_selectors as $selector ) { if ( $selector === $el_selector ) { $element_selector = array( $el_selector ); break; } $element_selector[] = static::append_to_selector( $el_selector, $selector . ' ', 'left' ); } static::$blocks_metadata[ $block_name ]['elements'][ $el_name ] = implode( ',', $element_selector ); } } return static::$blocks_metadata; } protected static function remove_keys_not_in_schema( $tree, $schema ) { $tree = array_intersect_key( $tree, $schema ); foreach ( $schema as $key => $data ) { if ( ! isset( $tree[ $key ] ) ) { continue; } if ( is_array( $schema[ $key ] ) && is_array( $tree[ $key ] ) ) { $tree[ $key ] = static::remove_keys_not_in_schema( $tree[ $key ], $schema[ $key ] ); if ( empty( $tree[ $key ] ) ) { unset( $tree[ $key ] ); } } elseif ( is_array( $schema[ $key ] ) && ! is_array( $tree[ $key ] ) ) { unset( $tree[ $key ] ); } } return $tree; } public function get_settings() { if ( ! isset( $this->theme_json['settings'] ) ) { return array(); } else { return $this->theme_json['settings']; } } public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null ) { if ( null === $origins ) { $origins = static::VALID_ORIGINS; } if ( is_string( $types ) ) { _deprecated_argument( __FUNCTION__, '5.9.0' ); if ( 'block_styles' === $types ) { $types = array( 'styles', 'presets' ); } elseif ( 'css_variables' === $types ) { $types = array( 'variables' ); } else { $types = array( 'variables', 'styles', 'presets' ); } } $blocks_metadata = static::get_blocks_metadata(); $style_nodes = static::get_style_nodes( $this->theme_json, $blocks_metadata ); $setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata ); $stylesheet = ''; if ( in_array( 'variables', $types, true ) ) { $stylesheet .= $this->get_css_variables( $setting_nodes, $origins ); } if ( in_array( 'styles', $types, true ) ) { $root_block_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $style_nodes, 'selector' ), true ); if ( false !== $root_block_key ) { $stylesheet .= $this->get_root_layout_rules( static::ROOT_BLOCK_SELECTOR, $style_nodes[ $root_block_key ] ); } $stylesheet .= $this->get_block_classes( $style_nodes ); } elseif ( in_array( 'base-layout-styles', $types, true ) ) { $base_styles_nodes = array( array( 'path' => array( 'styles' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ), array( 'path' => array( 'styles', 'blocks', 'core/columns' ), 'selector' => '.wp-block-columns', 'name' => 'core/columns', ), ); foreach ( $base_styles_nodes as $base_style_node ) { $stylesheet .= $this->get_layout_styles( $base_style_node ); } } if ( in_array( 'presets', $types, true ) ) { $stylesheet .= $this->get_preset_classes( $setting_nodes, $origins ); } return $stylesheet; } public function get_custom_templates() { $custom_templates = array(); if ( ! isset( $this->theme_json['customTemplates'] ) || ! is_array( $this->theme_json['customTemplates'] ) ) { return $custom_templates; } foreach ( $this->theme_json['customTemplates'] as $item ) { if ( isset( $item['name'] ) ) { $custom_templates[ $item['name'] ] = array( 'title' => isset( $item['title'] ) ? $item['title'] : '', 'postTypes' => isset( $item['postTypes'] ) ? $item['postTypes'] : array( 'page' ), ); } } return $custom_templates; } public function get_template_parts() { $template_parts = array(); if ( ! isset( $this->theme_json['templateParts'] ) || ! is_array( $this->theme_json['templateParts'] ) ) { return $template_parts; } foreach ( $this->theme_json['templateParts'] as $item ) { if ( isset( $item['name'] ) ) { $template_parts[ $item['name'] ] = array( 'title' => isset( $item['title'] ) ? $item['title'] : '', 'area' => isset( $item['area'] ) ? $item['area'] : '', ); } } return $template_parts; } protected function get_block_classes( $style_nodes ) { $block_rules = ''; foreach ( $style_nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $block_rules .= static::get_styles_for_block( $metadata ); } return $block_rules; } protected function get_layout_styles( $block_metadata ) { $block_rules = ''; $block_type = null; if ( current_theme_supports( 'disable-layout-styles' ) ) { return $block_rules; } if ( isset( $block_metadata['name'] ) ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); if ( ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) { return $block_rules; } } $selector = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : ''; $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; $has_fallback_gap_support = ! $has_block_gap_support; $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); $layout_definitions = _wp_array_get( $this->theme_json, array( 'settings', 'layout', 'definitions' ), array() ); $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; if ( $has_block_gap_support || $has_fallback_gap_support ) { $block_gap_value = null; if ( ! $has_block_gap_support ) { $block_gap_value = static::ROOT_BLOCK_SELECTOR === $selector ? '0.5em' : null; if ( ! empty( $block_type ) ) { $block_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), null ); } } else { $block_gap_value = static::get_property_value( $node, array( 'spacing', 'blockGap' ) ); } if ( is_array( $block_gap_value ) ) { if ( isset( $block_gap_value['top'] ) && isset( $block_gap_value['left'] ) ) { $gap_row = static::get_property_value( $node, array( 'spacing', 'blockGap', 'top' ) ); $gap_column = static::get_property_value( $node, array( 'spacing', 'blockGap', 'left' ) ); $block_gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column; } else { $block_gap_value = null; } } if ( null !== $block_gap_value && false !== $block_gap_value && '' !== $block_gap_value ) { foreach ( $layout_definitions as $layout_definition_key => $layout_definition ) { if ( ! $has_block_gap_support && 'flex' !== $layout_definition_key ) { continue; } $class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) ); $spacing_rules = _wp_array_get( $layout_definition, array( 'spacingStyles' ), array() ); if ( ! empty( $class_name ) && ! empty( $spacing_rules ) ) { foreach ( $spacing_rules as $spacing_rule ) { $declarations = array(); if ( isset( $spacing_rule['selector'] ) && preg_match( $layout_selector_pattern, $spacing_rule['selector'] ) && ! empty( $spacing_rule['rules'] ) ) { foreach ( $spacing_rule['rules'] as $css_property => $css_value ) { $current_css_value = is_string( $css_value ) ? $css_value : $block_gap_value; if ( static::is_safe_css_declaration( $css_property, $current_css_value ) ) { $declarations[] = array( 'name' => $css_property, 'value' => $current_css_value, ); } } if ( ! $has_block_gap_support ) { $format = static::ROOT_BLOCK_SELECTOR === $selector ? ':where(.%2$s%3$s)' : ':where(%1$s.%2$s%3$s)'; $layout_selector = sprintf( $format, $selector, $class_name, $spacing_rule['selector'] ); } else { $format = static::ROOT_BLOCK_SELECTOR === $selector ? '%s .%s%s' : '%s.%s%s'; $layout_selector = sprintf( $format, $selector, $class_name, $spacing_rule['selector'] ); } $block_rules .= static::to_ruleset( $layout_selector, $declarations ); } } } } } } if ( static::ROOT_BLOCK_SELECTOR === $selector ) { $valid_display_modes = array( 'block', 'flex', 'grid' ); foreach ( $layout_definitions as $layout_definition ) { $class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) ); $base_style_rules = _wp_array_get( $layout_definition, array( 'baseStyles' ), array() ); if ( ! empty( $class_name ) && ! empty( $base_style_rules ) ) { if ( ! empty( $layout_definition['displayMode'] ) && is_string( $layout_definition['displayMode'] ) && in_array( $layout_definition['displayMode'], $valid_display_modes, true ) ) { $layout_selector = sprintf( '%s .%s', $selector, $class_name ); $block_rules .= static::to_ruleset( $layout_selector, array( array( 'name' => 'display', 'value' => $layout_definition['displayMode'], ), ) ); } foreach ( $base_style_rules as $base_style_rule ) { $declarations = array(); if ( isset( $base_style_rule['selector'] ) && preg_match( $layout_selector_pattern, $base_style_rule['selector'] ) && ! empty( $base_style_rule['rules'] ) ) { foreach ( $base_style_rule['rules'] as $css_property => $css_value ) { if ( static::is_safe_css_declaration( $css_property, $css_value ) ) { $declarations[] = array( 'name' => $css_property, 'value' => $css_value, ); } } $layout_selector = sprintf( '%s .%s%s', $selector, $class_name, $base_style_rule['selector'] ); $block_rules .= static::to_ruleset( $layout_selector, $declarations ); } } } } } return $block_rules; } protected function get_preset_classes( $setting_nodes, $origins ) { $preset_rules = ''; foreach ( $setting_nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $selector = $metadata['selector']; $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); $preset_rules .= static::compute_preset_classes( $node, $selector, $origins ); } return $preset_rules; } protected function get_css_variables( $nodes, $origins ) { $stylesheet = ''; foreach ( $nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $selector = $metadata['selector']; $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); $declarations = static::compute_preset_vars( $node, $origins ); $theme_vars_declarations = static::compute_theme_vars( $node ); foreach ( $theme_vars_declarations as $theme_vars_declaration ) { $declarations[] = $theme_vars_declaration; } $stylesheet .= static::to_ruleset( $selector, $declarations ); } return $stylesheet; } protected static function to_ruleset( $selector, $declarations ) { if ( empty( $declarations ) ) { return ''; } $declaration_block = array_reduce( $declarations, static function ( $carry, $element ) { return $carry .= $element['name'] . ': ' . $element['value'] . ';'; }, '' ); return $selector . '{' . $declaration_block . '}'; } protected static function compute_preset_classes( $settings, $selector, $origins ) { if ( static::ROOT_BLOCK_SELECTOR === $selector ) { $selector = ''; } $stylesheet = ''; foreach ( static::PRESETS_METADATA as $preset_metadata ) { $slugs = static::get_settings_slugs( $settings, $preset_metadata, $origins ); foreach ( $preset_metadata['classes'] as $class => $property ) { foreach ( $slugs as $slug ) { $css_var = static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ); $class_name = static::replace_slug_in_string( $class, $slug ); $stylesheet .= static::to_ruleset( static::append_to_selector( $selector, $class_name ), array( array( 'name' => $property, 'value' => 'var(' . $css_var . ') !important', ), ) ); } } } return $stylesheet; } protected static function scope_selector( $scope, $selector ) { $scopes = explode( ',', $scope ); $selectors = explode( ',', $selector ); $selectors_scoped = array(); foreach ( $scopes as $outer ) { foreach ( $selectors as $inner ) { $selectors_scoped[] = trim( $outer ) . ' ' . trim( $inner ); } } return implode( ', ', $selectors_scoped ); } protected static function get_settings_values_by_slug( $settings, $preset_metadata, $origins ) { $preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() ); $result = array(); foreach ( $origins as $origin ) { if ( ! isset( $preset_per_origin[ $origin ] ) ) { continue; } foreach ( $preset_per_origin[ $origin ] as $preset ) { $slug = _wp_to_kebab_case( $preset['slug'] ); $value = ''; if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value_key = $preset_metadata['value_key']; $value = $preset[ $value_key ]; } elseif ( isset( $preset_metadata['value_func'] ) && is_callable( $preset_metadata['value_func'] ) ) { $value_func = $preset_metadata['value_func']; $value = call_user_func( $value_func, $preset ); } else { continue; } $result[ $slug ] = $value; } } return $result; } protected static function get_settings_slugs( $settings, $preset_metadata, $origins = null ) { if ( null === $origins ) { $origins = static::VALID_ORIGINS; } $preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() ); $result = array(); foreach ( $origins as $origin ) { if ( ! isset( $preset_per_origin[ $origin ] ) ) { continue; } foreach ( $preset_per_origin[ $origin ] as $preset ) { $slug = _wp_to_kebab_case( $preset['slug'] ); $result[ $slug ] = $slug; } } return $result; } protected static function replace_slug_in_string( $input, $slug ) { return strtr( $input, array( '$slug' => $slug ) ); } protected static function compute_preset_vars( $settings, $origins ) { $declarations = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { $values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins ); foreach ( $values_by_slug as $slug => $value ) { $declarations[] = array( 'name' => static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ), 'value' => $value, ); } } return $declarations; } protected static function compute_theme_vars( $settings ) { $declarations = array(); $custom_values = _wp_array_get( $settings, array( 'custom' ), array() ); $css_vars = static::flatten_tree( $custom_values ); foreach ( $css_vars as $key => $value ) { $declarations[] = array( 'name' => '--wp--custom--' . $key, 'value' => $value, ); } return $declarations; } protected static function flatten_tree( $tree, $prefix = '', $token = '--' ) { $result = array(); foreach ( $tree as $property => $value ) { $new_key = $prefix . str_replace( '/', '-', strtolower( _wp_to_kebab_case( $property ) ) ); if ( is_array( $value ) ) { $new_prefix = $new_key . $token; $flattened_subtree = static::flatten_tree( $value, $new_prefix, $token ); foreach ( $flattened_subtree as $subtree_key => $subtree_value ) { $result[ $subtree_key ] = $subtree_value; } } else { $result[ $new_key ] = $value; } } return $result; } protected static function compute_style_properties( $styles, $settings = array(), $properties = null, $theme_json = null, $selector = null, $use_root_padding = null ) { if ( null === $properties ) { $properties = static::PROPERTIES_METADATA; } $declarations = array(); if ( empty( $styles ) ) { return $declarations; } $root_variable_duplicates = array(); foreach ( $properties as $css_property => $value_path ) { $value = static::get_property_value( $styles, $value_path, $theme_json ); if ( str_starts_with( $css_property, '--wp--style--root--' ) && ( static::ROOT_BLOCK_SELECTOR !== $selector || ! $use_root_padding ) ) { continue; } if ( '--wp--style--root--padding' === $css_property && is_string( $value ) ) { continue; } if ( str_starts_with( $css_property, '--wp--style--root--' ) && $use_root_padding ) { $root_variable_duplicates[] = substr( $css_property, strlen( '--wp--style--root--' ) ); } if ( is_array( $value_path ) ) { $path_string = implode( '.', $value_path ); if ( array_key_exists( $path_string, static::PROTECTED_PROPERTIES ) && _wp_array_get( $settings, static::PROTECTED_PROPERTIES[ $path_string ], null ) === null ) { continue; } } $has_missing_value = empty( $value ) && ! is_numeric( $value ); if ( $has_missing_value || is_array( $value ) ) { continue; } if ( 'font-size' === $css_property ) { $value = wp_get_typography_font_size_value( array( 'size' => $value ) ); } $declarations[] = array( 'name' => $css_property, 'value' => $value, ); } foreach ( $root_variable_duplicates as $duplicate ) { $discard = array_search( $duplicate, array_column( $declarations, 'name' ), true ); if ( is_numeric( $discard ) ) { array_splice( $declarations, $discard, 1 ); } } return $declarations; } protected static function get_property_value( $styles, $path, $theme_json = null ) { $value = _wp_array_get( $styles, $path, '' ); if ( '' === $value || null === $value ) { return ''; } if ( is_array( $value ) && isset( $value['ref'] ) ) { $value_path = explode( '.', $value['ref'] ); $ref_value = _wp_array_get( $theme_json, $value_path ); if ( ! empty( $ref_value ) && is_string( $ref_value ) ) { $value = $ref_value; } if ( is_array( $ref_value ) && isset( $ref_value['ref'] ) ) { $path_string = json_encode( $path ); $ref_value_string = json_encode( $ref_value ); _doing_it_wrong( 'get_property_value', sprintf( __( 'Your %1$s file uses a dynamic value (%2$s) for the path at %3$s. However, the value at %3$s is also a dynamic value (pointing to %4$s) and pointing to another dynamic value is not supported. Please update %3$s to point directly to %4$s.' ), 'theme.json', $ref_value_string, $path_string, $ref_value['ref'] ), '6.1.0' ); } } if ( is_array( $value ) ) { return $value; } $prefix = 'var:'; $prefix_len = strlen( $prefix ); $token_in = '|'; $token_out = '--'; if ( 0 === strncmp( $value, $prefix, $prefix_len ) ) { $unwrapped_name = str_replace( $token_in, $token_out, substr( $value, $prefix_len ) ); $value = "var(--wp--$unwrapped_name)"; } return $value; } protected static function get_setting_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['settings'] ) ) { return $nodes; } $nodes[] = array( 'path' => array( 'settings' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ); if ( ! isset( $theme_json['settings']['blocks'] ) ) { return $nodes; } foreach ( $theme_json['settings']['blocks'] as $name => $node ) { $selector = null; if ( isset( $selectors[ $name ]['selector'] ) ) { $selector = $selectors[ $name ]['selector']; } $nodes[] = array( 'path' => array( 'settings', 'blocks', $name ), 'selector' => $selector, ); } return $nodes; } protected static function get_style_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; } $nodes[] = array( 'path' => array( 'styles' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ); if ( isset( $theme_json['styles']['elements'] ) ) { foreach ( self::ELEMENTS as $element => $selector ) { if ( ! isset( $theme_json['styles']['elements'][ $element ] ) ) { continue; } $nodes[] = array( 'path' => array( 'styles', 'elements', $element ), 'selector' => static::ELEMENTS[ $element ], ); if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { if ( isset( $theme_json['styles']['elements'][ $element ][ $pseudo_selector ] ) ) { $nodes[] = array( 'path' => array( 'styles', 'elements', $element ), 'selector' => static::append_to_selector( static::ELEMENTS[ $element ], $pseudo_selector ), ); } } } } } if ( ! isset( $theme_json['styles']['blocks'] ) ) { return $nodes; } $block_nodes = static::get_block_nodes( $theme_json ); foreach ( $block_nodes as $block_node ) { $nodes[] = $block_node; } return apply_filters( 'wp_theme_json_get_style_nodes', $nodes ); } public function get_styles_block_nodes() { return static::get_block_nodes( $this->theme_json ); } private static function update_separator_declarations( $declarations ) { $background_color = ''; $border_color_matches = false; $text_color_matches = false; foreach ( $declarations as $declaration ) { if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) { $background_color = $declaration['value']; } elseif ( 'border-color' === $declaration['name'] ) { $border_color_matches = true; } elseif ( 'color' === $declaration['name'] ) { $text_color_matches = true; } if ( $background_color && $border_color_matches && $text_color_matches ) { break; } } if ( $background_color && ! $border_color_matches && ! $text_color_matches ) { $declarations[] = array( 'name' => 'color', 'value' => $background_color, ); } return $declarations; } private static function get_block_nodes( $theme_json ) { $selectors = static::get_blocks_metadata(); $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; } if ( ! isset( $theme_json['styles']['blocks'] ) ) { return $nodes; } foreach ( $theme_json['styles']['blocks'] as $name => $node ) { $selector = null; if ( isset( $selectors[ $name ]['selector'] ) ) { $selector = $selectors[ $name ]['selector']; } $duotone_selector = null; if ( isset( $selectors[ $name ]['duotone'] ) ) { $duotone_selector = $selectors[ $name ]['duotone']; } $feature_selectors = null; if ( isset( $selectors[ $name ]['features'] ) ) { $feature_selectors = $selectors[ $name ]['features']; } $nodes[] = array( 'name' => $name, 'path' => array( 'styles', 'blocks', $name ), 'selector' => $selector, 'duotone' => $duotone_selector, 'features' => $feature_selectors, ); if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'] ) ) { foreach ( $theme_json['styles']['blocks'][ $name ]['elements'] as $element => $node ) { $nodes[] = array( 'path' => array( 'styles', 'blocks', $name, 'elements', $element ), 'selector' => $selectors[ $name ]['elements'][ $element ], ); if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'][ $element ][ $pseudo_selector ] ) ) { $nodes[] = array( 'path' => array( 'styles', 'blocks', $name, 'elements', $element ), 'selector' => static::append_to_selector( $selectors[ $name ]['elements'][ $element ], $pseudo_selector ), ); } } } } } } return $nodes; } public function get_styles_for_block( $block_metadata ) { $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); $use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments']; $selector = $block_metadata['selector']; $settings = _wp_array_get( $this->theme_json, array( 'settings' ) ); $feature_declarations = array(); if ( ! empty( $block_metadata['features'] ) ) { foreach ( $block_metadata['features'] as $feature_name => $feature_selector ) { if ( ! empty( $node[ $feature_name ] ) ) { $feature = array( $feature_name => $node[ $feature_name ] ); $new_feature_declarations = static::compute_style_properties( $feature, $settings, null, $this->theme_json ); if ( isset( $feature_declarations[ $feature_selector ] ) ) { foreach ( $new_feature_declarations as $new_feature_declaration ) { $feature_declarations[ $feature_selector ][] = $feature_declaration; } } else { $feature_declarations[ $feature_selector ] = $new_feature_declarations; } unset( $node[ $feature_name ] ); } } } $is_processing_element = in_array( 'elements', $block_metadata['path'], true ); $current_element = $is_processing_element ? $block_metadata['path'][ count( $block_metadata['path'] ) - 1 ] : null; $element_pseudo_allowed = array(); if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { $element_pseudo_allowed = static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ]; } $pseudo_matches = array_values( array_filter( $element_pseudo_allowed, function( $pseudo_selector ) use ( $selector ) { return str_contains( $selector, $pseudo_selector ); } ) ); $pseudo_selector = isset( $pseudo_matches[0] ) ? $pseudo_matches[0] : null; if ( $pseudo_selector && isset( $node[ $pseudo_selector ] ) && array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) && in_array( $pseudo_selector, static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ], true ) ) { $declarations = static::compute_style_properties( $node[ $pseudo_selector ], $settings, null, $this->theme_json, $selector, $use_root_padding ); } else { $declarations = static::compute_style_properties( $node, $settings, null, $this->theme_json, $selector, $use_root_padding ); } $block_rules = ''; $declarations_duotone = array(); foreach ( $declarations as $index => $declaration ) { if ( 'filter' === $declaration['name'] ) { unset( $declarations[ $index ] ); $declarations_duotone[] = $declaration; } } if ( '.wp-block-separator' === $selector ) { $declarations = static::update_separator_declarations( $declarations ); } $block_rules .= static::to_ruleset( $selector, $declarations ); if ( isset( $block_metadata['duotone'] ) && ! empty( $declarations_duotone ) ) { $selector_duotone = static::scope_selector( $block_metadata['selector'], $block_metadata['duotone'] ); $block_rules .= static::to_ruleset( $selector_duotone, $declarations_duotone ); } if ( static::ROOT_BLOCK_SELECTOR !== $selector && ! empty( $block_metadata['name'] ) ) { $block_rules .= $this->get_layout_styles( $block_metadata ); } foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) { $block_rules .= static::to_ruleset( $feature_selector, $individual_feature_declarations ); } return $block_rules; } public function get_root_layout_rules( $selector, $block_metadata ) { $css = ''; $settings = _wp_array_get( $this->theme_json, array( 'settings' ) ); $use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments']; $css .= 'body { margin: 0;'; if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) { $content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize']; $content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial'; $wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize']; $wide_size = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial'; $css .= '--wp--style--global--content-size: ' . $content_size . ';'; $css .= '--wp--style--global--wide-size: ' . $wide_size . ';'; } $css .= ' }'; if ( $use_root_padding ) { $css .= '.wp-site-blocks { padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom); }'; $css .= '.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }'; $css .= '.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }'; $css .= '.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }'; $css .= '.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }'; $css .= '.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }'; $css .= '.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0; }'; } $css .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }'; $css .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }'; $css .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'; $block_gap_value = _wp_array_get( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ), '0.5em' ); $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; if ( $has_block_gap_support ) { $block_gap_value = static::get_property_value( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ) ); $css .= '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }'; $css .= ".wp-site-blocks > * + * { margin-block-start: $block_gap_value; }"; $css .= "$selector { --wp--style--block-gap: $block_gap_value; }"; } $css .= $this->get_layout_styles( $block_metadata ); return $css; } protected static function get_metadata_boolean( $data, $path, $default = false ) { if ( is_bool( $path ) ) { return $path; } if ( is_array( $path ) ) { $value = _wp_array_get( $data, $path ); if ( null !== $value ) { return $value; } } return $default; } public function merge( $incoming ) { $incoming_data = $incoming->get_raw_data(); $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data ); $nodes = static::get_setting_nodes( $incoming_data ); $slugs_global = static::get_default_slugs( $this->theme_json, array( 'settings' ) ); foreach ( $nodes as $node ) { $path = $node['path']; $path[] = 'spacing'; $path[] = 'units'; $content = _wp_array_get( $incoming_data, $path, null ); if ( isset( $content ) ) { _wp_array_set( $this->theme_json, $path, $content ); } foreach ( static::PRESETS_METADATA as $preset ) { $override_preset = ! static::get_metadata_boolean( $this->theme_json['settings'], $preset['prevent_override'], true ); foreach ( static::VALID_ORIGINS as $origin ) { $base_path = $node['path']; foreach ( $preset['path'] as $leaf ) { $base_path[] = $leaf; } $path = $base_path; $path[] = $origin; $content = _wp_array_get( $incoming_data, $path, null ); if ( ! isset( $content ) ) { continue; } if ( 'theme' === $origin && $preset['use_default_names'] ) { foreach ( $content as $key => $item ) { if ( ! isset( $item['name'] ) ) { $name = static::get_name_from_defaults( $item['slug'], $base_path ); if ( null !== $name ) { $content[ $key ]['name'] = $name; } } } } if ( ( 'theme' !== $origin ) || ( 'theme' === $origin && $override_preset ) ) { _wp_array_set( $this->theme_json, $path, $content ); } else { $slugs_node = static::get_default_slugs( $this->theme_json, $node['path'] ); $slugs = array_merge_recursive( $slugs_global, $slugs_node ); $slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() ); $content = static::filter_slugs( $content, $slugs_for_preset ); _wp_array_set( $this->theme_json, $path, $content ); } } } } } public function get_svg_filters( $origins ) { $blocks_metadata = static::get_blocks_metadata(); $setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata ); $filters = ''; foreach ( $setting_nodes as $metadata ) { $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); if ( empty( $node['color']['duotone'] ) ) { continue; } $duotone_presets = $node['color']['duotone']; foreach ( $origins as $origin ) { if ( ! isset( $duotone_presets[ $origin ] ) ) { continue; } foreach ( $duotone_presets[ $origin ] as $duotone_preset ) { $filters .= wp_get_duotone_filter_svg( $duotone_preset ); } } } return $filters; } protected static function should_override_preset( $theme_json, $path, $override ) { _deprecated_function( __METHOD__, '6.0.0', 'get_metadata_boolean' ); if ( is_bool( $override ) ) { return $override; } if ( is_array( $override ) ) { $value = _wp_array_get( $theme_json, array_merge( $path, $override ) ); if ( isset( $value ) ) { return ! $value; } $value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $override ) ); if ( isset( $value ) ) { return ! $value; } return true; } } protected static function get_default_slugs( $data, $node_path ) { $slugs = array(); foreach ( static::PRESETS_METADATA as $metadata ) { $path = $node_path; foreach ( $metadata['path'] as $leaf ) { $path[] = $leaf; } $path[] = 'default'; $preset = _wp_array_get( $data, $path, null ); if ( ! isset( $preset ) ) { continue; } $slugs_for_preset = array(); foreach ( $preset as $item ) { if ( isset( $item['slug'] ) ) { $slugs_for_preset[] = $item['slug']; } } _wp_array_set( $slugs, $metadata['path'], $slugs_for_preset ); } return $slugs; } protected function get_name_from_defaults( $slug, $base_path ) { $path = $base_path; $path[] = 'default'; $default_content = _wp_array_get( $this->theme_json, $path, null ); if ( ! $default_content ) { return null; } foreach ( $default_content as $item ) { if ( $slug === $item['slug'] ) { return $item['name']; } } return null; } protected static function filter_slugs( $node, $slugs ) { if ( empty( $slugs ) ) { return $node; } $new_node = array(); foreach ( $node as $value ) { if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) { $new_node[] = $value; } } return $new_node; } public static function remove_insecure_properties( $theme_json ) { $sanitized = array(); $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); $valid_block_names = array_keys( static::get_blocks_metadata() ); $valid_element_names = array_keys( static::ELEMENTS ); $theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names ); $blocks_metadata = static::get_blocks_metadata(); $style_nodes = static::get_style_nodes( $theme_json, $blocks_metadata ); foreach ( $style_nodes as $metadata ) { $input = _wp_array_get( $theme_json, $metadata['path'], array() ); if ( empty( $input ) ) { continue; } $output = static::remove_insecure_styles( $input ); $current_element = $metadata['path'][ count( $metadata['path'] ) - 1 ]; if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] as $pseudo_selector ) { if ( isset( $input[ $pseudo_selector ] ) ) { $output[ $pseudo_selector ] = static::remove_insecure_styles( $input[ $pseudo_selector ] ); } } } if ( ! empty( $output ) ) { _wp_array_set( $sanitized, $metadata['path'], $output ); } } $setting_nodes = static::get_setting_nodes( $theme_json ); foreach ( $setting_nodes as $metadata ) { $input = _wp_array_get( $theme_json, $metadata['path'], array() ); if ( empty( $input ) ) { continue; } $output = static::remove_insecure_settings( $input ); if ( ! empty( $output ) ) { _wp_array_set( $sanitized, $metadata['path'], $output ); } } if ( empty( $sanitized['styles'] ) ) { unset( $theme_json['styles'] ); } else { $theme_json['styles'] = $sanitized['styles']; } if ( empty( $sanitized['settings'] ) ) { unset( $theme_json['settings'] ); } else { $theme_json['settings'] = $sanitized['settings']; } return $theme_json; } protected static function remove_insecure_settings( $input ) { $output = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { foreach ( static::VALID_ORIGINS as $origin ) { $path_with_origin = $preset_metadata['path']; $path_with_origin[] = $origin; $presets = _wp_array_get( $input, $path_with_origin, null ); if ( null === $presets ) { continue; } $escaped_preset = array(); foreach ( $presets as $preset ) { if ( esc_attr( esc_html( $preset['name'] ) ) === $preset['name'] && sanitize_html_class( $preset['slug'] ) === $preset['slug'] ) { $value = null; if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value = $preset[ $preset_metadata['value_key'] ]; } elseif ( isset( $preset_metadata['value_func'] ) && is_callable( $preset_metadata['value_func'] ) ) { $value = call_user_func( $preset_metadata['value_func'], $preset ); } $preset_is_valid = true; foreach ( $preset_metadata['properties'] as $property ) { if ( ! static::is_safe_css_declaration( $property, $value ) ) { $preset_is_valid = false; break; } } if ( $preset_is_valid ) { $escaped_preset[] = $preset; } } } if ( ! empty( $escaped_preset ) ) { _wp_array_set( $output, $path_with_origin, $escaped_preset ); } } } return $output; } protected static function remove_insecure_styles( $input ) { $output = array(); $declarations = static::compute_style_properties( $input ); foreach ( $declarations as $declaration ) { if ( static::is_safe_css_declaration( $declaration['name'], $declaration['value'] ) ) { $path = static::PROPERTIES_METADATA[ $declaration['name'] ]; $value = _wp_array_get( $input, $path, array() ); if ( ! is_array( $value ) ) { _wp_array_set( $output, $path, $value ); } } } return $output; } protected static function is_safe_css_declaration( $property_name, $property_value ) { $style_to_validate = $property_name . ': ' . $property_value; $filtered = esc_html( safecss_filter_attr( $style_to_validate ) ); return ! empty( trim( $filtered ) ); } public function get_raw_data() { return $this->theme_json; } public static function get_from_editor_settings( $settings ) { $theme_settings = array( 'version' => static::LATEST_SCHEMA, 'settings' => array(), ); if ( isset( $settings['disableCustomColors'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['custom'] = ! $settings['disableCustomColors']; } if ( isset( $settings['disableCustomGradients'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['customGradient'] = ! $settings['disableCustomGradients']; } if ( isset( $settings['disableCustomFontSizes'] ) ) { if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['customFontSize'] = ! $settings['disableCustomFontSizes']; } if ( isset( $settings['enableCustomLineHeight'] ) ) { if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['lineHeight'] = $settings['enableCustomLineHeight']; } if ( isset( $settings['enableCustomUnits'] ) ) { if ( ! isset( $theme_settings['settings']['spacing'] ) ) { $theme_settings['settings']['spacing'] = array(); } $theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ? array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) : $settings['enableCustomUnits']; } if ( isset( $settings['colors'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['palette'] = $settings['colors']; } if ( isset( $settings['gradients'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['gradients'] = $settings['gradients']; } if ( isset( $settings['fontSizes'] ) ) { $font_sizes = $settings['fontSizes']; foreach ( $font_sizes as $key => $font_size ) { if ( is_numeric( $font_size['size'] ) ) { $font_sizes[ $key ]['size'] = $font_size['size'] . 'px'; } } if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['fontSizes'] = $font_sizes; } if ( isset( $settings['enableCustomSpacing'] ) ) { if ( ! isset( $theme_settings['settings']['spacing'] ) ) { $theme_settings['settings']['spacing'] = array(); } $theme_settings['settings']['spacing']['padding'] = $settings['enableCustomSpacing']; } return $theme_settings; } public function get_patterns() { if ( isset( $this->theme_json['patterns'] ) && is_array( $this->theme_json['patterns'] ) ) { return $this->theme_json['patterns']; } return array(); } public function get_data() { $output = $this->theme_json; $nodes = static::get_setting_nodes( $output ); foreach ( $nodes as $node ) { foreach ( static::PRESETS_METADATA as $preset_metadata ) { $path = $node['path']; foreach ( $preset_metadata['path'] as $preset_metadata_path ) { $path[] = $preset_metadata_path; } $preset = _wp_array_get( $output, $path, null ); if ( null === $preset ) { continue; } $items = array(); if ( isset( $preset['theme'] ) ) { foreach ( $preset['theme'] as $item ) { $slug = $item['slug']; unset( $item['slug'] ); $items[ $slug ] = $item; } } if ( isset( $preset['custom'] ) ) { foreach ( $preset['custom'] as $item ) { $slug = $item['slug']; unset( $item['slug'] ); $items[ $slug ] = $item; } } $flattened_preset = array(); foreach ( $items as $slug => $value ) { $flattened_preset[] = array_merge( array( 'slug' => (string) $slug ), $value ); } _wp_array_set( $output, $path, $flattened_preset ); } } foreach ( $nodes as $node ) { $all_opt_ins_are_set = true; foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) { $full_path = $node['path']; foreach ( $opt_in_path as $opt_in_path_item ) { $full_path[] = $opt_in_path_item; } $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); if ( 'unset prop' === $opt_in_value ) { $all_opt_ins_are_set = false; break; } } if ( $all_opt_ins_are_set ) { $node_path_with_appearance_tools = $node['path']; $node_path_with_appearance_tools[] = 'appearanceTools'; _wp_array_set( $output, $node_path_with_appearance_tools, true ); foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) { $full_path = $node['path']; foreach ( $opt_in_path as $opt_in_path_item ) { $full_path[] = $opt_in_path_item; } $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); if ( true !== $opt_in_value ) { continue; } if ( ( 1 === count( $node['path'] ) ) && ( 'settings' === $node['path'][0] ) ) { unset( $output['settings'][ $opt_in_path[0] ][ $opt_in_path[1] ] ); if ( empty( $output['settings'][ $opt_in_path[0] ] ) ) { unset( $output['settings'][ $opt_in_path[0] ] ); } } elseif ( ( 3 === count( $node['path'] ) ) && ( 'settings' === $node['path'][0] ) && ( 'blocks' === $node['path'][1] ) ) { $block_name = $node['path'][2]; unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ][ $opt_in_path[1] ] ); if ( empty( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] ) ) { unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] ); } } } } } wp_recursive_ksort( $output ); return $output; } public function set_spacing_sizes() { $spacing_scale = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'spacingScale' ), array() ); if ( ! isset( $spacing_scale['steps'] ) || ! is_numeric( $spacing_scale['steps'] ) || ! isset( $spacing_scale['mediumStep'] ) || ! isset( $spacing_scale['unit'] ) || ! isset( $spacing_scale['operator'] ) || ! isset( $spacing_scale['increment'] ) || ! isset( $spacing_scale['steps'] ) || ! is_numeric( $spacing_scale['increment'] ) || ! is_numeric( $spacing_scale['mediumStep'] ) || ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) { if ( ! empty( $spacing_scale ) ) { trigger_error( __( 'Some of the theme.json settings.spacing.spacingScale values are invalid' ), E_USER_NOTICE ); } return null; } if ( 0 === $spacing_scale['steps'] ) { return null; } $unit = '%' === $spacing_scale['unit'] ? '%' : sanitize_title( $spacing_scale['unit'] ); $current_step = $spacing_scale['mediumStep']; $steps_mid_point = round( $spacing_scale['steps'] / 2, 0 ); $x_small_count = null; $below_sizes = array(); $slug = 40; $remainder = 0; for ( $below_midpoint_count = $steps_mid_point - 1; $spacing_scale['steps'] > 1 && $slug > 0 && $below_midpoint_count > 0; $below_midpoint_count-- ) { if ( '+' === $spacing_scale['operator'] ) { $current_step -= $spacing_scale['increment']; } elseif ( $spacing_scale['increment'] > 1 ) { $current_step /= $spacing_scale['increment']; } else { $current_step *= $spacing_scale['increment']; } if ( $current_step <= 0 ) { $remainder = $below_midpoint_count; break; } $below_sizes[] = array( 'name' => $below_midpoint_count === $steps_mid_point - 1 ? __( 'Small' ) : sprintf( __( '%sX-Small' ), (string) $x_small_count ), 'slug' => (string) $slug, 'size' => round( $current_step, 2 ) . $unit, ); if ( $below_midpoint_count === $steps_mid_point - 2 ) { $x_small_count = 2; } if ( $below_midpoint_count < $steps_mid_point - 2 ) { $x_small_count++; } $slug -= 10; } $below_sizes = array_reverse( $below_sizes ); $below_sizes[] = array( 'name' => __( 'Medium' ), 'slug' => '50', 'size' => $spacing_scale['mediumStep'] . $unit, ); $current_step = $spacing_scale['mediumStep']; $x_large_count = null; $above_sizes = array(); $slug = 60; $steps_above = ( $spacing_scale['steps'] - $steps_mid_point ) + $remainder; for ( $above_midpoint_count = 0; $above_midpoint_count < $steps_above; $above_midpoint_count++ ) { $current_step = '+' === $spacing_scale['operator'] ? $current_step + $spacing_scale['increment'] : ( $spacing_scale['increment'] >= 1 ? $current_step * $spacing_scale['increment'] : $current_step / $spacing_scale['increment'] ); $above_sizes[] = array( 'name' => 0 === $above_midpoint_count ? __( 'Large' ) : sprintf( __( '%sX-Large' ), (string) $x_large_count ), 'slug' => (string) $slug, 'size' => round( $current_step, 2 ) . $unit, ); if ( 1 === $above_midpoint_count ) { $x_large_count = 2; } if ( $above_midpoint_count > 1 ) { $x_large_count++; } $slug += 10; } $spacing_sizes = $below_sizes; foreach ( $above_sizes as $above_sizes_item ) { $spacing_sizes[] = $above_sizes_item; } if ( $spacing_scale['steps'] <= 7 ) { for ( $spacing_sizes_count = 0; $spacing_sizes_count < count( $spacing_sizes ); $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } } _wp_array_set( $this->theme_json, array( 'settings', 'spacing', 'spacingSizes', 'default' ), $spacing_sizes ); } } array( 'color', 'palette' ), 'prevent_override' => array( 'color', 'defaultPalette' ), 'use_default_names' => false, 'value_key' => 'color', 'css_vars' => '--wp--preset--color--$slug', 'classes' => array( '.has-$slug-color' => 'color', '.has-$slug-background-color' => 'background-color', '.has-$slug-border-color' => 'border-color', ), 'properties' => array( 'color', 'background-color', 'border-color' ), ), array( 'path' => array( 'color', 'gradients' ), 'prevent_override' => array( 'color', 'defaultGradients' ), 'use_default_names' => false, 'value_key' => 'gradient', 'css_vars' => '--wp--preset--gradient--$slug', 'classes' => array( '.has-$slug-gradient-background' => 'background' ), 'properties' => array( 'background' ), ), array( 'path' => array( 'color', 'duotone' ), 'prevent_override' => array( 'color', 'defaultDuotone' ), 'use_default_names' => false, 'value_func' => 'wp_get_duotone_filter_property', 'css_vars' => '--wp--preset--duotone--$slug', 'classes' => array(), 'properties' => array( 'filter' ), ), array( 'path' => array( 'typography', 'fontSizes' ), 'prevent_override' => false, 'use_default_names' => true, 'value_func' => 'wp_get_typography_font_size_value', 'css_vars' => '--wp--preset--font-size--$slug', 'classes' => array( '.has-$slug-font-size' => 'font-size' ), 'properties' => array( 'font-size' ), ), array( 'path' => array( 'typography', 'fontFamilies' ), 'prevent_override' => false, 'use_default_names' => false, 'value_key' => 'fontFamily', 'css_vars' => '--wp--preset--font-family--$slug', 'classes' => array( '.has-$slug-font-family' => 'font-family' ), 'properties' => array( 'font-family' ), ), array( 'path' => array( 'spacing', 'spacingSizes' ), 'prevent_override' => false, 'use_default_names' => true, 'value_key' => 'size', 'css_vars' => '--wp--preset--spacing--$slug', 'classes' => array(), 'properties' => array( 'padding', 'margin' ), ), ); const PROPERTIES_METADATA = array( 'background' => array( 'color', 'gradient' ), 'background-color' => array( 'color', 'background' ), 'border-radius' => array( 'border', 'radius' ), 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ), 'border-top-right-radius' => array( 'border', 'radius', 'topRight' ), 'border-bottom-left-radius' => array( 'border', 'radius', 'bottomLeft' ), 'border-bottom-right-radius' => array( 'border', 'radius', 'bottomRight' ), 'border-color' => array( 'border', 'color' ), 'border-width' => array( 'border', 'width' ), 'border-style' => array( 'border', 'style' ), 'border-top-color' => array( 'border', 'top', 'color' ), 'border-top-width' => array( 'border', 'top', 'width' ), 'border-top-style' => array( 'border', 'top', 'style' ), 'border-right-color' => array( 'border', 'right', 'color' ), 'border-right-width' => array( 'border', 'right', 'width' ), 'border-right-style' => array( 'border', 'right', 'style' ), 'border-bottom-color' => array( 'border', 'bottom', 'color' ), 'border-bottom-width' => array( 'border', 'bottom', 'width' ), 'border-bottom-style' => array( 'border', 'bottom', 'style' ), 'border-left-color' => array( 'border', 'left', 'color' ), 'border-left-width' => array( 'border', 'left', 'width' ), 'border-left-style' => array( 'border', 'left', 'style' ), 'color' => array( 'color', 'text' ), 'font-family' => array( 'typography', 'fontFamily' ), 'font-size' => array( 'typography', 'fontSize' ), 'font-style' => array( 'typography', 'fontStyle' ), 'font-weight' => array( 'typography', 'fontWeight' ), 'letter-spacing' => array( 'typography', 'letterSpacing' ), 'line-height' => array( 'typography', 'lineHeight' ), 'margin' => array( 'spacing', 'margin' ), 'margin-top' => array( 'spacing', 'margin', 'top' ), 'margin-right' => array( 'spacing', 'margin', 'right' ), 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ), 'margin-left' => array( 'spacing', 'margin', 'left' ), 'outline-color' => array( 'outline', 'color' ), 'outline-offset' => array( 'outline', 'offset' ), 'outline-style' => array( 'outline', 'style' ), 'outline-width' => array( 'outline', 'width' ), 'padding' => array( 'spacing', 'padding' ), 'padding-top' => array( 'spacing', 'padding', 'top' ), 'padding-right' => array( 'spacing', 'padding', 'right' ), 'padding-bottom' => array( 'spacing', 'padding', 'bottom' ), 'padding-left' => array( 'spacing', 'padding', 'left' ), '--wp--style--root--padding' => array( 'spacing', 'padding' ), '--wp--style--root--padding-top' => array( 'spacing', 'padding', 'top' ), '--wp--style--root--padding-right' => array( 'spacing', 'padding', 'right' ), '--wp--style--root--padding-bottom' => array( 'spacing', 'padding', 'bottom' ), '--wp--style--root--padding-left' => array( 'spacing', 'padding', 'left' ), 'text-decoration' => array( 'typography', 'textDecoration' ), 'text-transform' => array( 'typography', 'textTransform' ), 'filter' => array( 'filter', 'duotone' ), 'box-shadow' => array( 'shadow' ), ); const PROTECTED_PROPERTIES = array( 'spacing.blockGap' => array( 'spacing', 'blockGap' ), ); const VALID_TOP_LEVEL_KEYS = array( 'customTemplates', 'patterns', 'settings', 'styles', 'templateParts', 'title', 'version', ); const VALID_SETTINGS = array( 'appearanceTools' => null, 'useRootPaddingAwareAlignments' => null, 'border' => array( 'color' => null, 'radius' => null, 'style' => null, 'width' => null, ), 'color' => array( 'background' => null, 'custom' => null, 'customDuotone' => null, 'customGradient' => null, 'defaultDuotone' => null, 'defaultGradients' => null, 'defaultPalette' => null, 'duotone' => null, 'gradients' => null, 'link' => null, 'palette' => null, 'text' => null, ), 'custom' => null, 'layout' => array( 'contentSize' => null, 'definitions' => null, 'wideSize' => null, ), 'spacing' => array( 'customSpacingSize' => null, 'spacingSizes' => null, 'spacingScale' => null, 'blockGap' => null, 'margin' => null, 'padding' => null, 'units' => null, ), 'typography' => array( 'fluid' => null, 'customFontSize' => null, 'dropCap' => null, 'fontFamilies' => null, 'fontSizes' => null, 'fontStyle' => null, 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, 'textDecoration' => null, 'textTransform' => null, ), ); const VALID_STYLES = array( 'border' => array( 'color' => null, 'radius' => null, 'style' => null, 'width' => null, 'top' => null, 'right' => null, 'bottom' => null, 'left' => null, ), 'color' => array( 'background' => null, 'gradient' => null, 'text' => null, ), 'filter' => array( 'duotone' => null, ), 'outline' => array( 'color' => null, 'offset' => null, 'style' => null, 'width' => null, ), 'shadow' => null, 'spacing' => array( 'margin' => null, 'padding' => null, 'blockGap' => null, ), 'typography' => array( 'fontFamily' => null, 'fontSize' => null, 'fontStyle' => null, 'fontWeight' => null, 'letterSpacing' => null, 'lineHeight' => null, 'textDecoration' => null, 'textTransform' => null, ), ); const VALID_ELEMENT_PSEUDO_SELECTORS = array( 'link' => array( ':link', ':any-link', ':visited', ':hover', ':focus', ':active' ), 'button' => array( ':link', ':any-link', ':visited', ':hover', ':focus', ':active' ), ); const ELEMENTS = array( 'link' => 'a:where(:not(.wp-element-button))', 'heading' => 'h1, h2, h3, h4, h5, h6', 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', 'button' => '.wp-element-button, .wp-block-button__link', 'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', 'cite' => 'cite', ); const __EXPERIMENTAL_ELEMENT_CLASS_NAMES = array( 'button' => 'wp-element-button', 'caption' => 'wp-element-caption', ); const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = array( '__experimentalBorder' => 'border', 'color' => 'color', 'spacing' => 'spacing', 'typography' => 'typography', ); public static function get_element_class_name( $element ) { $class_name = ''; if ( array_key_exists( $element, static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES ) ) { $class_name = static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[ $element ]; } return $class_name; } const APPEARANCE_TOOLS_OPT_INS = array( array( 'border', 'color' ), array( 'border', 'radius' ), array( 'border', 'style' ), array( 'border', 'width' ), array( 'color', 'link' ), array( 'spacing', 'blockGap' ), array( 'spacing', 'margin' ), array( 'spacing', 'padding' ), array( 'typography', 'lineHeight' ), ); const LATEST_SCHEMA = 2; public function __construct( $theme_json = array(), $origin = 'theme' ) { if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) { $origin = 'theme'; } $this->theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); $valid_block_names = array_keys( static::get_blocks_metadata() ); $valid_element_names = array_keys( static::ELEMENTS ); $theme_json = static::sanitize( $this->theme_json, $valid_block_names, $valid_element_names ); $this->theme_json = static::maybe_opt_in_into_settings( $theme_json ); $nodes = static::get_setting_nodes( $this->theme_json ); foreach ( $nodes as $node ) { foreach ( static::PRESETS_METADATA as $preset_metadata ) { $path = $node['path']; foreach ( $preset_metadata['path'] as $subpath ) { $path[] = $subpath; } $preset = _wp_array_get( $this->theme_json, $path, null ); if ( null !== $preset ) { if ( isset( $preset[0] ) || empty( $preset ) ) { _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) ); } } } } } protected static function maybe_opt_in_into_settings( $theme_json ) { $new_theme_json = $theme_json; if ( isset( $new_theme_json['settings']['appearanceTools'] ) && true === $new_theme_json['settings']['appearanceTools'] ) { static::do_opt_in_into_settings( $new_theme_json['settings'] ); } if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) { foreach ( $new_theme_json['settings']['blocks'] as &$block ) { if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) { static::do_opt_in_into_settings( $block ); } } } return $new_theme_json; } protected static function do_opt_in_into_settings( &$context ) { foreach ( static::APPEARANCE_TOOLS_OPT_INS as $path ) { if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) { _wp_array_set( $context, $path, true ); } } unset( $context['appearanceTools'] ); } protected static function sanitize( $input, $valid_block_names, $valid_element_names ) { $output = array(); if ( ! is_array( $input ) ) { return $output; } $output = array_intersect_key( $input, array_flip( static::VALID_TOP_LEVEL_KEYS ) ); $styles_non_top_level = static::VALID_STYLES; foreach ( array_keys( $styles_non_top_level ) as $section ) { if ( array_key_exists( $section, $styles_non_top_level ) && is_array( $styles_non_top_level[ $section ] ) ) { foreach ( array_keys( $styles_non_top_level[ $section ] ) as $prop ) { if ( 'top' === $styles_non_top_level[ $section ][ $prop ] ) { unset( $styles_non_top_level[ $section ][ $prop ] ); } } } } $schema = array(); $schema_styles_elements = array(); foreach ( $valid_element_names as $element ) { $schema_styles_elements[ $element ] = $styles_non_top_level; if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { $schema_styles_elements[ $element ][ $pseudo_selector ] = $styles_non_top_level; } } } $schema_styles_blocks = array(); $schema_settings_blocks = array(); foreach ( $valid_block_names as $block ) { $schema_settings_blocks[ $block ] = static::VALID_SETTINGS; $schema_styles_blocks[ $block ] = $styles_non_top_level; $schema_styles_blocks[ $block ]['elements'] = $schema_styles_elements; } $schema['styles'] = static::VALID_STYLES; $schema['styles']['blocks'] = $schema_styles_blocks; $schema['styles']['elements'] = $schema_styles_elements; $schema['settings'] = static::VALID_SETTINGS; $schema['settings']['blocks'] = $schema_settings_blocks; foreach ( array( 'styles', 'settings' ) as $subtree ) { if ( ! isset( $input[ $subtree ] ) ) { continue; } if ( ! is_array( $input[ $subtree ] ) ) { unset( $output[ $subtree ] ); continue; } $result = static::remove_keys_not_in_schema( $input[ $subtree ], $schema[ $subtree ] ); if ( empty( $result ) ) { unset( $output[ $subtree ] ); } else { $output[ $subtree ] = $result; } } return $output; } protected static function append_to_selector( $selector, $to_append, $position = 'right' ) { $new_selectors = array(); $selectors = explode( ',', $selector ); foreach ( $selectors as $sel ) { $new_selectors[] = 'right' === $position ? $sel . $to_append : $to_append . $sel; } return implode( ',', $new_selectors ); } protected static function get_blocks_metadata() { $registry = WP_Block_Type_Registry::get_instance(); $blocks = $registry->get_all_registered(); $blocks = array_diff_key( $blocks, static::$blocks_metadata ); if ( empty( $blocks ) ) { return static::$blocks_metadata; } foreach ( $blocks as $block_name => $block_type ) { if ( isset( $block_type->supports['__experimentalSelector'] ) && is_string( $block_type->supports['__experimentalSelector'] ) ) { static::$blocks_metadata[ $block_name ]['selector'] = $block_type->supports['__experimentalSelector']; } else { static::$blocks_metadata[ $block_name ]['selector'] = '.wp-block-' . str_replace( '/', '-', str_replace( 'core/', '', $block_name ) ); } if ( isset( $block_type->supports['color']['__experimentalDuotone'] ) && is_string( $block_type->supports['color']['__experimentalDuotone'] ) ) { static::$blocks_metadata[ $block_name ]['duotone'] = $block_type->supports['color']['__experimentalDuotone']; } $features = array(); foreach ( static::BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS as $key => $feature ) { if ( isset( $block_type->supports[ $key ]['__experimentalSelector'] ) && $block_type->supports[ $key ]['__experimentalSelector'] ) { $features[ $feature ] = static::scope_selector( static::$blocks_metadata[ $block_name ]['selector'], $block_type->supports[ $key ]['__experimentalSelector'] ); } } if ( ! empty( $features ) ) { static::$blocks_metadata[ $block_name ]['features'] = $features; } $block_selectors = explode( ',', static::$blocks_metadata[ $block_name ]['selector'] ); foreach ( static::ELEMENTS as $el_name => $el_selector ) { $element_selector = array(); foreach ( $block_selectors as $selector ) { if ( $selector === $el_selector ) { $element_selector = array( $el_selector ); break; } $element_selector[] = static::append_to_selector( $el_selector, $selector . ' ', 'left' ); } static::$blocks_metadata[ $block_name ]['elements'][ $el_name ] = implode( ',', $element_selector ); } } return static::$blocks_metadata; } protected static function remove_keys_not_in_schema( $tree, $schema ) { $tree = array_intersect_key( $tree, $schema ); foreach ( $schema as $key => $data ) { if ( ! isset( $tree[ $key ] ) ) { continue; } if ( is_array( $schema[ $key ] ) && is_array( $tree[ $key ] ) ) { $tree[ $key ] = static::remove_keys_not_in_schema( $tree[ $key ], $schema[ $key ] ); if ( empty( $tree[ $key ] ) ) { unset( $tree[ $key ] ); } } elseif ( is_array( $schema[ $key ] ) && ! is_array( $tree[ $key ] ) ) { unset( $tree[ $key ] ); } } return $tree; } public function get_settings() { if ( ! isset( $this->theme_json['settings'] ) ) { return array(); } else { return $this->theme_json['settings']; } } public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null ) { if ( null === $origins ) { $origins = static::VALID_ORIGINS; } if ( is_string( $types ) ) { _deprecated_argument( __FUNCTION__, '5.9.0' ); if ( 'block_styles' === $types ) { $types = array( 'styles', 'presets' ); } elseif ( 'css_variables' === $types ) { $types = array( 'variables' ); } else { $types = array( 'variables', 'styles', 'presets' ); } } $blocks_metadata = static::get_blocks_metadata(); $style_nodes = static::get_style_nodes( $this->theme_json, $blocks_metadata ); $setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata ); $stylesheet = ''; if ( in_array( 'variables', $types, true ) ) { $stylesheet .= $this->get_css_variables( $setting_nodes, $origins ); } if ( in_array( 'styles', $types, true ) ) { $root_block_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $style_nodes, 'selector' ), true ); if ( false !== $root_block_key ) { $stylesheet .= $this->get_root_layout_rules( static::ROOT_BLOCK_SELECTOR, $style_nodes[ $root_block_key ] ); } $stylesheet .= $this->get_block_classes( $style_nodes ); } elseif ( in_array( 'base-layout-styles', $types, true ) ) { $base_styles_nodes = array( array( 'path' => array( 'styles' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ), array( 'path' => array( 'styles', 'blocks', 'core/columns' ), 'selector' => '.wp-block-columns', 'name' => 'core/columns', ), ); foreach ( $base_styles_nodes as $base_style_node ) { $stylesheet .= $this->get_layout_styles( $base_style_node ); } } if ( in_array( 'presets', $types, true ) ) { $stylesheet .= $this->get_preset_classes( $setting_nodes, $origins ); } return $stylesheet; } public function get_custom_templates() { $custom_templates = array(); if ( ! isset( $this->theme_json['customTemplates'] ) || ! is_array( $this->theme_json['customTemplates'] ) ) { return $custom_templates; } foreach ( $this->theme_json['customTemplates'] as $item ) { if ( isset( $item['name'] ) ) { $custom_templates[ $item['name'] ] = array( 'title' => isset( $item['title'] ) ? $item['title'] : '', 'postTypes' => isset( $item['postTypes'] ) ? $item['postTypes'] : array( 'page' ), ); } } return $custom_templates; } public function get_template_parts() { $template_parts = array(); if ( ! isset( $this->theme_json['templateParts'] ) || ! is_array( $this->theme_json['templateParts'] ) ) { return $template_parts; } foreach ( $this->theme_json['templateParts'] as $item ) { if ( isset( $item['name'] ) ) { $template_parts[ $item['name'] ] = array( 'title' => isset( $item['title'] ) ? $item['title'] : '', 'area' => isset( $item['area'] ) ? $item['area'] : '', ); } } return $template_parts; } protected function get_block_classes( $style_nodes ) { $block_rules = ''; foreach ( $style_nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $block_rules .= static::get_styles_for_block( $metadata ); } return $block_rules; } protected function get_layout_styles( $block_metadata ) { $block_rules = ''; $block_type = null; if ( current_theme_supports( 'disable-layout-styles' ) ) { return $block_rules; } if ( isset( $block_metadata['name'] ) ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); if ( ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) { return $block_rules; } } $selector = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : ''; $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; $has_fallback_gap_support = ! $has_block_gap_support; $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); $layout_definitions = _wp_array_get( $this->theme_json, array( 'settings', 'layout', 'definitions' ), array() ); $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; if ( $has_block_gap_support || $has_fallback_gap_support ) { $block_gap_value = null; if ( ! $has_block_gap_support ) { $block_gap_value = static::ROOT_BLOCK_SELECTOR === $selector ? '0.5em' : null; if ( ! empty( $block_type ) ) { $block_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), null ); } } else { $block_gap_value = static::get_property_value( $node, array( 'spacing', 'blockGap' ) ); } if ( is_array( $block_gap_value ) ) { if ( isset( $block_gap_value['top'] ) && isset( $block_gap_value['left'] ) ) { $gap_row = static::get_property_value( $node, array( 'spacing', 'blockGap', 'top' ) ); $gap_column = static::get_property_value( $node, array( 'spacing', 'blockGap', 'left' ) ); $block_gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column; } else { $block_gap_value = null; } } if ( null !== $block_gap_value && false !== $block_gap_value && '' !== $block_gap_value ) { foreach ( $layout_definitions as $layout_definition_key => $layout_definition ) { if ( ! $has_block_gap_support && 'flex' !== $layout_definition_key ) { continue; } $class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) ); $spacing_rules = _wp_array_get( $layout_definition, array( 'spacingStyles' ), array() ); if ( ! empty( $class_name ) && ! empty( $spacing_rules ) ) { foreach ( $spacing_rules as $spacing_rule ) { $declarations = array(); if ( isset( $spacing_rule['selector'] ) && preg_match( $layout_selector_pattern, $spacing_rule['selector'] ) && ! empty( $spacing_rule['rules'] ) ) { foreach ( $spacing_rule['rules'] as $css_property => $css_value ) { $current_css_value = is_string( $css_value ) ? $css_value : $block_gap_value; if ( static::is_safe_css_declaration( $css_property, $current_css_value ) ) { $declarations[] = array( 'name' => $css_property, 'value' => $current_css_value, ); } } if ( ! $has_block_gap_support ) { $format = static::ROOT_BLOCK_SELECTOR === $selector ? ':where(.%2$s%3$s)' : ':where(%1$s.%2$s%3$s)'; $layout_selector = sprintf( $format, $selector, $class_name, $spacing_rule['selector'] ); } else { $format = static::ROOT_BLOCK_SELECTOR === $selector ? '%s .%s%s' : '%s.%s%s'; $layout_selector = sprintf( $format, $selector, $class_name, $spacing_rule['selector'] ); } $block_rules .= static::to_ruleset( $layout_selector, $declarations ); } } } } } } if ( static::ROOT_BLOCK_SELECTOR === $selector ) { $valid_display_modes = array( 'block', 'flex', 'grid' ); foreach ( $layout_definitions as $layout_definition ) { $class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) ); $base_style_rules = _wp_array_get( $layout_definition, array( 'baseStyles' ), array() ); if ( ! empty( $class_name ) && ! empty( $base_style_rules ) ) { if ( ! empty( $layout_definition['displayMode'] ) && is_string( $layout_definition['displayMode'] ) && in_array( $layout_definition['displayMode'], $valid_display_modes, true ) ) { $layout_selector = sprintf( '%s .%s', $selector, $class_name ); $block_rules .= static::to_ruleset( $layout_selector, array( array( 'name' => 'display', 'value' => $layout_definition['displayMode'], ), ) ); } foreach ( $base_style_rules as $base_style_rule ) { $declarations = array(); if ( isset( $base_style_rule['selector'] ) && preg_match( $layout_selector_pattern, $base_style_rule['selector'] ) && ! empty( $base_style_rule['rules'] ) ) { foreach ( $base_style_rule['rules'] as $css_property => $css_value ) { if ( static::is_safe_css_declaration( $css_property, $css_value ) ) { $declarations[] = array( 'name' => $css_property, 'value' => $css_value, ); } } $layout_selector = sprintf( '%s .%s%s', $selector, $class_name, $base_style_rule['selector'] ); $block_rules .= static::to_ruleset( $layout_selector, $declarations ); } } } } } return $block_rules; } protected function get_preset_classes( $setting_nodes, $origins ) { $preset_rules = ''; foreach ( $setting_nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $selector = $metadata['selector']; $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); $preset_rules .= static::compute_preset_classes( $node, $selector, $origins ); } return $preset_rules; } protected function get_css_variables( $nodes, $origins ) { $stylesheet = ''; foreach ( $nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $selector = $metadata['selector']; $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); $declarations = static::compute_preset_vars( $node, $origins ); $theme_vars_declarations = static::compute_theme_vars( $node ); foreach ( $theme_vars_declarations as $theme_vars_declaration ) { $declarations[] = $theme_vars_declaration; } $stylesheet .= static::to_ruleset( $selector, $declarations ); } return $stylesheet; } protected static function to_ruleset( $selector, $declarations ) { if ( empty( $declarations ) ) { return ''; } $declaration_block = array_reduce( $declarations, static function ( $carry, $element ) { return $carry .= $element['name'] . ': ' . $element['value'] . ';'; }, '' ); return $selector . '{' . $declaration_block . '}'; } protected static function compute_preset_classes( $settings, $selector, $origins ) { if ( static::ROOT_BLOCK_SELECTOR === $selector ) { $selector = ''; } $stylesheet = ''; foreach ( static::PRESETS_METADATA as $preset_metadata ) { $slugs = static::get_settings_slugs( $settings, $preset_metadata, $origins ); foreach ( $preset_metadata['classes'] as $class => $property ) { foreach ( $slugs as $slug ) { $css_var = static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ); $class_name = static::replace_slug_in_string( $class, $slug ); $stylesheet .= static::to_ruleset( static::append_to_selector( $selector, $class_name ), array( array( 'name' => $property, 'value' => 'var(' . $css_var . ') !important', ), ) ); } } } return $stylesheet; } protected static function scope_selector( $scope, $selector ) { $scopes = explode( ',', $scope ); $selectors = explode( ',', $selector ); $selectors_scoped = array(); foreach ( $scopes as $outer ) { foreach ( $selectors as $inner ) { $selectors_scoped[] = trim( $outer ) . ' ' . trim( $inner ); } } return implode( ', ', $selectors_scoped ); } protected static function get_settings_values_by_slug( $settings, $preset_metadata, $origins ) { $preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() ); $result = array(); foreach ( $origins as $origin ) { if ( ! isset( $preset_per_origin[ $origin ] ) ) { continue; } foreach ( $preset_per_origin[ $origin ] as $preset ) { $slug = _wp_to_kebab_case( $preset['slug'] ); $value = ''; if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value_key = $preset_metadata['value_key']; $value = $preset[ $value_key ]; } elseif ( isset( $preset_metadata['value_func'] ) && is_callable( $preset_metadata['value_func'] ) ) { $value_func = $preset_metadata['value_func']; $value = call_user_func( $value_func, $preset ); } else { continue; } $result[ $slug ] = $value; } } return $result; } protected static function get_settings_slugs( $settings, $preset_metadata, $origins = null ) { if ( null === $origins ) { $origins = static::VALID_ORIGINS; } $preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() ); $result = array(); foreach ( $origins as $origin ) { if ( ! isset( $preset_per_origin[ $origin ] ) ) { continue; } foreach ( $preset_per_origin[ $origin ] as $preset ) { $slug = _wp_to_kebab_case( $preset['slug'] ); $result[ $slug ] = $slug; } } return $result; } protected static function replace_slug_in_string( $input, $slug ) { return strtr( $input, array( '$slug' => $slug ) ); } protected static function compute_preset_vars( $settings, $origins ) { $declarations = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { $values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins ); foreach ( $values_by_slug as $slug => $value ) { $declarations[] = array( 'name' => static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ), 'value' => $value, ); } } return $declarations; } protected static function compute_theme_vars( $settings ) { $declarations = array(); $custom_values = _wp_array_get( $settings, array( 'custom' ), array() ); $css_vars = static::flatten_tree( $custom_values ); foreach ( $css_vars as $key => $value ) { $declarations[] = array( 'name' => '--wp--custom--' . $key, 'value' => $value, ); } return $declarations; } protected static function flatten_tree( $tree, $prefix = '', $token = '--' ) { $result = array(); foreach ( $tree as $property => $value ) { $new_key = $prefix . str_replace( '/', '-', strtolower( _wp_to_kebab_case( $property ) ) ); if ( is_array( $value ) ) { $new_prefix = $new_key . $token; $flattened_subtree = static::flatten_tree( $value, $new_prefix, $token ); foreach ( $flattened_subtree as $subtree_key => $subtree_value ) { $result[ $subtree_key ] = $subtree_value; } } else { $result[ $new_key ] = $value; } } return $result; } protected static function compute_style_properties( $styles, $settings = array(), $properties = null, $theme_json = null, $selector = null, $use_root_padding = null ) { if ( null === $properties ) { $properties = static::PROPERTIES_METADATA; } $declarations = array(); if ( empty( $styles ) ) { return $declarations; } $root_variable_duplicates = array(); foreach ( $properties as $css_property => $value_path ) { $value = static::get_property_value( $styles, $value_path, $theme_json ); if ( str_starts_with( $css_property, '--wp--style--root--' ) && ( static::ROOT_BLOCK_SELECTOR !== $selector || ! $use_root_padding ) ) { continue; } if ( '--wp--style--root--padding' === $css_property && is_string( $value ) ) { continue; } if ( str_starts_with( $css_property, '--wp--style--root--' ) && $use_root_padding ) { $root_variable_duplicates[] = substr( $css_property, strlen( '--wp--style--root--' ) ); } if ( is_array( $value_path ) ) { $path_string = implode( '.', $value_path ); if ( array_key_exists( $path_string, static::PROTECTED_PROPERTIES ) && _wp_array_get( $settings, static::PROTECTED_PROPERTIES[ $path_string ], null ) === null ) { continue; } } $has_missing_value = empty( $value ) && ! is_numeric( $value ); if ( $has_missing_value || is_array( $value ) ) { continue; } if ( 'font-size' === $css_property ) { $value = wp_get_typography_font_size_value( array( 'size' => $value ) ); } $declarations[] = array( 'name' => $css_property, 'value' => $value, ); } foreach ( $root_variable_duplicates as $duplicate ) { $discard = array_search( $duplicate, array_column( $declarations, 'name' ), true ); if ( is_numeric( $discard ) ) { array_splice( $declarations, $discard, 1 ); } } return $declarations; } protected static function get_property_value( $styles, $path, $theme_json = null ) { $value = _wp_array_get( $styles, $path, '' ); if ( '' === $value || null === $value ) { return ''; } if ( is_array( $value ) && isset( $value['ref'] ) ) { $value_path = explode( '.', $value['ref'] ); $ref_value = _wp_array_get( $theme_json, $value_path ); if ( ! empty( $ref_value ) && is_string( $ref_value ) ) { $value = $ref_value; } if ( is_array( $ref_value ) && isset( $ref_value['ref'] ) ) { $path_string = json_encode( $path ); $ref_value_string = json_encode( $ref_value ); _doing_it_wrong( 'get_property_value', sprintf( __( 'Your %1$s file uses a dynamic value (%2$s) for the path at %3$s. However, the value at %3$s is also a dynamic value (pointing to %4$s) and pointing to another dynamic value is not supported. Please update %3$s to point directly to %4$s.' ), 'theme.json', $ref_value_string, $path_string, $ref_value['ref'] ), '6.1.0' ); } } if ( is_array( $value ) ) { return $value; } $prefix = 'var:'; $prefix_len = strlen( $prefix ); $token_in = '|'; $token_out = '--'; if ( 0 === strncmp( $value, $prefix, $prefix_len ) ) { $unwrapped_name = str_replace( $token_in, $token_out, substr( $value, $prefix_len ) ); $value = "var(--wp--$unwrapped_name)"; } return $value; } protected static function get_setting_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['settings'] ) ) { return $nodes; } $nodes[] = array( 'path' => array( 'settings' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ); if ( ! isset( $theme_json['settings']['blocks'] ) ) { return $nodes; } foreach ( $theme_json['settings']['blocks'] as $name => $node ) { $selector = null; if ( isset( $selectors[ $name ]['selector'] ) ) { $selector = $selectors[ $name ]['selector']; } $nodes[] = array( 'path' => array( 'settings', 'blocks', $name ), 'selector' => $selector, ); } return $nodes; } protected static function get_style_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; } $nodes[] = array( 'path' => array( 'styles' ), 'selector' => static::ROOT_BLOCK_SELECTOR, ); if ( isset( $theme_json['styles']['elements'] ) ) { foreach ( self::ELEMENTS as $element => $selector ) { if ( ! isset( $theme_json['styles']['elements'][ $element ] ) ) { continue; } $nodes[] = array( 'path' => array( 'styles', 'elements', $element ), 'selector' => static::ELEMENTS[ $element ], ); if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { if ( isset( $theme_json['styles']['elements'][ $element ][ $pseudo_selector ] ) ) { $nodes[] = array( 'path' => array( 'styles', 'elements', $element ), 'selector' => static::append_to_selector( static::ELEMENTS[ $element ], $pseudo_selector ), ); } } } } } if ( ! isset( $theme_json['styles']['blocks'] ) ) { return $nodes; } $block_nodes = static::get_block_nodes( $theme_json ); foreach ( $block_nodes as $block_node ) { $nodes[] = $block_node; } return apply_filters( 'wp_theme_json_get_style_nodes', $nodes ); } public function get_styles_block_nodes() { return static::get_block_nodes( $this->theme_json ); } private static function update_separator_declarations( $declarations ) { $background_color = ''; $border_color_matches = false; $text_color_matches = false; foreach ( $declarations as $declaration ) { if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) { $background_color = $declaration['value']; } elseif ( 'border-color' === $declaration['name'] ) { $border_color_matches = true; } elseif ( 'color' === $declaration['name'] ) { $text_color_matches = true; } if ( $background_color && $border_color_matches && $text_color_matches ) { break; } } if ( $background_color && ! $border_color_matches && ! $text_color_matches ) { $declarations[] = array( 'name' => 'color', 'value' => $background_color, ); } return $declarations; } private static function get_block_nodes( $theme_json ) { $selectors = static::get_blocks_metadata(); $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; } if ( ! isset( $theme_json['styles']['blocks'] ) ) { return $nodes; } foreach ( $theme_json['styles']['blocks'] as $name => $node ) { $selector = null; if ( isset( $selectors[ $name ]['selector'] ) ) { $selector = $selectors[ $name ]['selector']; } $duotone_selector = null; if ( isset( $selectors[ $name ]['duotone'] ) ) { $duotone_selector = $selectors[ $name ]['duotone']; } $feature_selectors = null; if ( isset( $selectors[ $name ]['features'] ) ) { $feature_selectors = $selectors[ $name ]['features']; } $nodes[] = array( 'name' => $name, 'path' => array( 'styles', 'blocks', $name ), 'selector' => $selector, 'duotone' => $duotone_selector, 'features' => $feature_selectors, ); if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'] ) ) { foreach ( $theme_json['styles']['blocks'][ $name ]['elements'] as $element => $node ) { $nodes[] = array( 'path' => array( 'styles', 'blocks', $name, 'elements', $element ), 'selector' => $selectors[ $name ]['elements'][ $element ], ); if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'][ $element ][ $pseudo_selector ] ) ) { $nodes[] = array( 'path' => array( 'styles', 'blocks', $name, 'elements', $element ), 'selector' => static::append_to_selector( $selectors[ $name ]['elements'][ $element ], $pseudo_selector ), ); } } } } } } return $nodes; } public function get_styles_for_block( $block_metadata ) { $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); $use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments']; $selector = $block_metadata['selector']; $settings = _wp_array_get( $this->theme_json, array( 'settings' ) ); $feature_declarations = array(); if ( ! empty( $block_metadata['features'] ) ) { foreach ( $block_metadata['features'] as $feature_name => $feature_selector ) { if ( ! empty( $node[ $feature_name ] ) ) { $feature = array( $feature_name => $node[ $feature_name ] ); $new_feature_declarations = static::compute_style_properties( $feature, $settings, null, $this->theme_json ); if ( isset( $feature_declarations[ $feature_selector ] ) ) { foreach ( $new_feature_declarations as $new_feature_declaration ) { $feature_declarations[ $feature_selector ][] = $new_feature_declaration; } } else { $feature_declarations[ $feature_selector ] = $new_feature_declarations; } unset( $node[ $feature_name ] ); } } } $is_processing_element = in_array( 'elements', $block_metadata['path'], true ); $current_element = $is_processing_element ? $block_metadata['path'][ count( $block_metadata['path'] ) - 1 ] : null; $element_pseudo_allowed = array(); if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { $element_pseudo_allowed = static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ]; } $pseudo_matches = array_values( array_filter( $element_pseudo_allowed, function( $pseudo_selector ) use ( $selector ) { return str_contains( $selector, $pseudo_selector ); } ) ); $pseudo_selector = isset( $pseudo_matches[0] ) ? $pseudo_matches[0] : null; if ( $pseudo_selector && isset( $node[ $pseudo_selector ] ) && array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) && in_array( $pseudo_selector, static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ], true ) ) { $declarations = static::compute_style_properties( $node[ $pseudo_selector ], $settings, null, $this->theme_json, $selector, $use_root_padding ); } else { $declarations = static::compute_style_properties( $node, $settings, null, $this->theme_json, $selector, $use_root_padding ); } $block_rules = ''; $declarations_duotone = array(); foreach ( $declarations as $index => $declaration ) { if ( 'filter' === $declaration['name'] ) { unset( $declarations[ $index ] ); $declarations_duotone[] = $declaration; } } if ( '.wp-block-separator' === $selector ) { $declarations = static::update_separator_declarations( $declarations ); } $block_rules .= static::to_ruleset( $selector, $declarations ); if ( isset( $block_metadata['duotone'] ) && ! empty( $declarations_duotone ) ) { $selector_duotone = static::scope_selector( $block_metadata['selector'], $block_metadata['duotone'] ); $block_rules .= static::to_ruleset( $selector_duotone, $declarations_duotone ); } if ( static::ROOT_BLOCK_SELECTOR !== $selector && ! empty( $block_metadata['name'] ) ) { $block_rules .= $this->get_layout_styles( $block_metadata ); } foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) { $block_rules .= static::to_ruleset( $feature_selector, $individual_feature_declarations ); } return $block_rules; } public function get_root_layout_rules( $selector, $block_metadata ) { $css = ''; $settings = _wp_array_get( $this->theme_json, array( 'settings' ) ); $use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments']; $css .= 'body { margin: 0;'; if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) { $content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize']; $content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial'; $wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize']; $wide_size = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial'; $css .= '--wp--style--global--content-size: ' . $content_size . ';'; $css .= '--wp--style--global--wide-size: ' . $wide_size . ';'; } $css .= ' }'; if ( $use_root_padding ) { $css .= '.wp-site-blocks { padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom); }'; $css .= '.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }'; $css .= '.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }'; $css .= '.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }'; $css .= '.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }'; $css .= '.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }'; $css .= '.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0; }'; } $css .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }'; $css .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }'; $css .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'; $block_gap_value = _wp_array_get( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ), '0.5em' ); $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; if ( $has_block_gap_support ) { $block_gap_value = static::get_property_value( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ) ); $css .= '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }'; $css .= ".wp-site-blocks > * + * { margin-block-start: $block_gap_value; }"; $css .= "$selector { --wp--style--block-gap: $block_gap_value; }"; } $css .= $this->get_layout_styles( $block_metadata ); return $css; } protected static function get_metadata_boolean( $data, $path, $default_value = false ) { if ( is_bool( $path ) ) { return $path; } if ( is_array( $path ) ) { $value = _wp_array_get( $data, $path ); if ( null !== $value ) { return $value; } } return $default_value; } public function merge( $incoming ) { $incoming_data = $incoming->get_raw_data(); $this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data ); $nodes = static::get_setting_nodes( $incoming_data ); $slugs_global = static::get_default_slugs( $this->theme_json, array( 'settings' ) ); foreach ( $nodes as $node ) { $path = $node['path']; $path[] = 'spacing'; $path[] = 'units'; $content = _wp_array_get( $incoming_data, $path, null ); if ( isset( $content ) ) { _wp_array_set( $this->theme_json, $path, $content ); } foreach ( static::PRESETS_METADATA as $preset ) { $override_preset = ! static::get_metadata_boolean( $this->theme_json['settings'], $preset['prevent_override'], true ); foreach ( static::VALID_ORIGINS as $origin ) { $base_path = $node['path']; foreach ( $preset['path'] as $leaf ) { $base_path[] = $leaf; } $path = $base_path; $path[] = $origin; $content = _wp_array_get( $incoming_data, $path, null ); if ( ! isset( $content ) ) { continue; } if ( 'theme' === $origin && $preset['use_default_names'] ) { foreach ( $content as $key => $item ) { if ( ! isset( $item['name'] ) ) { $name = static::get_name_from_defaults( $item['slug'], $base_path ); if ( null !== $name ) { $content[ $key ]['name'] = $name; } } } } if ( ( 'theme' !== $origin ) || ( 'theme' === $origin && $override_preset ) ) { _wp_array_set( $this->theme_json, $path, $content ); } else { $slugs_node = static::get_default_slugs( $this->theme_json, $node['path'] ); $slugs = array_merge_recursive( $slugs_global, $slugs_node ); $slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() ); $content = static::filter_slugs( $content, $slugs_for_preset ); _wp_array_set( $this->theme_json, $path, $content ); } } } } } public function get_svg_filters( $origins ) { $blocks_metadata = static::get_blocks_metadata(); $setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata ); $filters = ''; foreach ( $setting_nodes as $metadata ) { $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); if ( empty( $node['color']['duotone'] ) ) { continue; } $duotone_presets = $node['color']['duotone']; foreach ( $origins as $origin ) { if ( ! isset( $duotone_presets[ $origin ] ) ) { continue; } foreach ( $duotone_presets[ $origin ] as $duotone_preset ) { $filters .= wp_get_duotone_filter_svg( $duotone_preset ); } } } return $filters; } protected static function should_override_preset( $theme_json, $path, $override ) { _deprecated_function( __METHOD__, '6.0.0', 'get_metadata_boolean' ); if ( is_bool( $override ) ) { return $override; } if ( is_array( $override ) ) { $value = _wp_array_get( $theme_json, array_merge( $path, $override ) ); if ( isset( $value ) ) { return ! $value; } $value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $override ) ); if ( isset( $value ) ) { return ! $value; } return true; } } protected static function get_default_slugs( $data, $node_path ) { $slugs = array(); foreach ( static::PRESETS_METADATA as $metadata ) { $path = $node_path; foreach ( $metadata['path'] as $leaf ) { $path[] = $leaf; } $path[] = 'default'; $preset = _wp_array_get( $data, $path, null ); if ( ! isset( $preset ) ) { continue; } $slugs_for_preset = array(); foreach ( $preset as $item ) { if ( isset( $item['slug'] ) ) { $slugs_for_preset[] = $item['slug']; } } _wp_array_set( $slugs, $metadata['path'], $slugs_for_preset ); } return $slugs; } protected function get_name_from_defaults( $slug, $base_path ) { $path = $base_path; $path[] = 'default'; $default_content = _wp_array_get( $this->theme_json, $path, null ); if ( ! $default_content ) { return null; } foreach ( $default_content as $item ) { if ( $slug === $item['slug'] ) { return $item['name']; } } return null; } protected static function filter_slugs( $node, $slugs ) { if ( empty( $slugs ) ) { return $node; } $new_node = array(); foreach ( $node as $value ) { if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) { $new_node[] = $value; } } return $new_node; } public static function remove_insecure_properties( $theme_json ) { $sanitized = array(); $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); $valid_block_names = array_keys( static::get_blocks_metadata() ); $valid_element_names = array_keys( static::ELEMENTS ); $theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names ); $blocks_metadata = static::get_blocks_metadata(); $style_nodes = static::get_style_nodes( $theme_json, $blocks_metadata ); foreach ( $style_nodes as $metadata ) { $input = _wp_array_get( $theme_json, $metadata['path'], array() ); if ( empty( $input ) ) { continue; } $output = static::remove_insecure_styles( $input ); $current_element = $metadata['path'][ count( $metadata['path'] ) - 1 ]; if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] as $pseudo_selector ) { if ( isset( $input[ $pseudo_selector ] ) ) { $output[ $pseudo_selector ] = static::remove_insecure_styles( $input[ $pseudo_selector ] ); } } } if ( ! empty( $output ) ) { _wp_array_set( $sanitized, $metadata['path'], $output ); } } $setting_nodes = static::get_setting_nodes( $theme_json ); foreach ( $setting_nodes as $metadata ) { $input = _wp_array_get( $theme_json, $metadata['path'], array() ); if ( empty( $input ) ) { continue; } $output = static::remove_insecure_settings( $input ); if ( ! empty( $output ) ) { _wp_array_set( $sanitized, $metadata['path'], $output ); } } if ( empty( $sanitized['styles'] ) ) { unset( $theme_json['styles'] ); } else { $theme_json['styles'] = $sanitized['styles']; } if ( empty( $sanitized['settings'] ) ) { unset( $theme_json['settings'] ); } else { $theme_json['settings'] = $sanitized['settings']; } return $theme_json; } protected static function remove_insecure_settings( $input ) { $output = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { foreach ( static::VALID_ORIGINS as $origin ) { $path_with_origin = $preset_metadata['path']; $path_with_origin[] = $origin; $presets = _wp_array_get( $input, $path_with_origin, null ); if ( null === $presets ) { continue; } $escaped_preset = array(); foreach ( $presets as $preset ) { if ( esc_attr( esc_html( $preset['name'] ) ) === $preset['name'] && sanitize_html_class( $preset['slug'] ) === $preset['slug'] ) { $value = null; if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value = $preset[ $preset_metadata['value_key'] ]; } elseif ( isset( $preset_metadata['value_func'] ) && is_callable( $preset_metadata['value_func'] ) ) { $value = call_user_func( $preset_metadata['value_func'], $preset ); } $preset_is_valid = true; foreach ( $preset_metadata['properties'] as $property ) { if ( ! static::is_safe_css_declaration( $property, $value ) ) { $preset_is_valid = false; break; } } if ( $preset_is_valid ) { $escaped_preset[] = $preset; } } } if ( ! empty( $escaped_preset ) ) { _wp_array_set( $output, $path_with_origin, $escaped_preset ); } } } return $output; } protected static function remove_insecure_styles( $input ) { $output = array(); $declarations = static::compute_style_properties( $input ); foreach ( $declarations as $declaration ) { if ( static::is_safe_css_declaration( $declaration['name'], $declaration['value'] ) ) { $path = static::PROPERTIES_METADATA[ $declaration['name'] ]; $value = _wp_array_get( $input, $path, array() ); if ( ! is_array( $value ) ) { _wp_array_set( $output, $path, $value ); } } } return $output; } protected static function is_safe_css_declaration( $property_name, $property_value ) { $style_to_validate = $property_name . ': ' . $property_value; $filtered = esc_html( safecss_filter_attr( $style_to_validate ) ); return ! empty( trim( $filtered ) ); } public function get_raw_data() { return $this->theme_json; } public static function get_from_editor_settings( $settings ) { $theme_settings = array( 'version' => static::LATEST_SCHEMA, 'settings' => array(), ); if ( isset( $settings['disableCustomColors'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['custom'] = ! $settings['disableCustomColors']; } if ( isset( $settings['disableCustomGradients'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['customGradient'] = ! $settings['disableCustomGradients']; } if ( isset( $settings['disableCustomFontSizes'] ) ) { if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['customFontSize'] = ! $settings['disableCustomFontSizes']; } if ( isset( $settings['enableCustomLineHeight'] ) ) { if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['lineHeight'] = $settings['enableCustomLineHeight']; } if ( isset( $settings['enableCustomUnits'] ) ) { if ( ! isset( $theme_settings['settings']['spacing'] ) ) { $theme_settings['settings']['spacing'] = array(); } $theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ? array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) : $settings['enableCustomUnits']; } if ( isset( $settings['colors'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['palette'] = $settings['colors']; } if ( isset( $settings['gradients'] ) ) { if ( ! isset( $theme_settings['settings']['color'] ) ) { $theme_settings['settings']['color'] = array(); } $theme_settings['settings']['color']['gradients'] = $settings['gradients']; } if ( isset( $settings['fontSizes'] ) ) { $font_sizes = $settings['fontSizes']; foreach ( $font_sizes as $key => $font_size ) { if ( is_numeric( $font_size['size'] ) ) { $font_sizes[ $key ]['size'] = $font_size['size'] . 'px'; } } if ( ! isset( $theme_settings['settings']['typography'] ) ) { $theme_settings['settings']['typography'] = array(); } $theme_settings['settings']['typography']['fontSizes'] = $font_sizes; } if ( isset( $settings['enableCustomSpacing'] ) ) { if ( ! isset( $theme_settings['settings']['spacing'] ) ) { $theme_settings['settings']['spacing'] = array(); } $theme_settings['settings']['spacing']['padding'] = $settings['enableCustomSpacing']; } return $theme_settings; } public function get_patterns() { if ( isset( $this->theme_json['patterns'] ) && is_array( $this->theme_json['patterns'] ) ) { return $this->theme_json['patterns']; } return array(); } public function get_data() { $output = $this->theme_json; $nodes = static::get_setting_nodes( $output ); foreach ( $nodes as $node ) { foreach ( static::PRESETS_METADATA as $preset_metadata ) { $path = $node['path']; foreach ( $preset_metadata['path'] as $preset_metadata_path ) { $path[] = $preset_metadata_path; } $preset = _wp_array_get( $output, $path, null ); if ( null === $preset ) { continue; } $items = array(); if ( isset( $preset['theme'] ) ) { foreach ( $preset['theme'] as $item ) { $slug = $item['slug']; unset( $item['slug'] ); $items[ $slug ] = $item; } } if ( isset( $preset['custom'] ) ) { foreach ( $preset['custom'] as $item ) { $slug = $item['slug']; unset( $item['slug'] ); $items[ $slug ] = $item; } } $flattened_preset = array(); foreach ( $items as $slug => $value ) { $flattened_preset[] = array_merge( array( 'slug' => (string) $slug ), $value ); } _wp_array_set( $output, $path, $flattened_preset ); } } foreach ( $nodes as $node ) { $all_opt_ins_are_set = true; foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) { $full_path = $node['path']; foreach ( $opt_in_path as $opt_in_path_item ) { $full_path[] = $opt_in_path_item; } $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); if ( 'unset prop' === $opt_in_value ) { $all_opt_ins_are_set = false; break; } } if ( $all_opt_ins_are_set ) { $node_path_with_appearance_tools = $node['path']; $node_path_with_appearance_tools[] = 'appearanceTools'; _wp_array_set( $output, $node_path_with_appearance_tools, true ); foreach ( static::APPEARANCE_TOOLS_OPT_INS as $opt_in_path ) { $full_path = $node['path']; foreach ( $opt_in_path as $opt_in_path_item ) { $full_path[] = $opt_in_path_item; } $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); if ( true !== $opt_in_value ) { continue; } if ( ( 1 === count( $node['path'] ) ) && ( 'settings' === $node['path'][0] ) ) { unset( $output['settings'][ $opt_in_path[0] ][ $opt_in_path[1] ] ); if ( empty( $output['settings'][ $opt_in_path[0] ] ) ) { unset( $output['settings'][ $opt_in_path[0] ] ); } } elseif ( ( 3 === count( $node['path'] ) ) && ( 'settings' === $node['path'][0] ) && ( 'blocks' === $node['path'][1] ) ) { $block_name = $node['path'][2]; unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ][ $opt_in_path[1] ] ); if ( empty( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] ) ) { unset( $output['settings']['blocks'][ $block_name ][ $opt_in_path[0] ] ); } } } } } wp_recursive_ksort( $output ); return $output; } public function set_spacing_sizes() { $spacing_scale = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'spacingScale' ), array() ); if ( ! isset( $spacing_scale['steps'] ) || ! is_numeric( $spacing_scale['steps'] ) || ! isset( $spacing_scale['mediumStep'] ) || ! isset( $spacing_scale['unit'] ) || ! isset( $spacing_scale['operator'] ) || ! isset( $spacing_scale['increment'] ) || ! isset( $spacing_scale['steps'] ) || ! is_numeric( $spacing_scale['increment'] ) || ! is_numeric( $spacing_scale['mediumStep'] ) || ( '+' !== $spacing_scale['operator'] && '*' !== $spacing_scale['operator'] ) ) { if ( ! empty( $spacing_scale ) ) { trigger_error( __( 'Some of the theme.json settings.spacing.spacingScale values are invalid' ), E_USER_NOTICE ); } return null; } if ( 0 === $spacing_scale['steps'] ) { return null; } $unit = '%' === $spacing_scale['unit'] ? '%' : sanitize_title( $spacing_scale['unit'] ); $current_step = $spacing_scale['mediumStep']; $steps_mid_point = round( $spacing_scale['steps'] / 2, 0 ); $x_small_count = null; $below_sizes = array(); $slug = 40; $remainder = 0; for ( $below_midpoint_count = $steps_mid_point - 1; $spacing_scale['steps'] > 1 && $slug > 0 && $below_midpoint_count > 0; $below_midpoint_count-- ) { if ( '+' === $spacing_scale['operator'] ) { $current_step -= $spacing_scale['increment']; } elseif ( $spacing_scale['increment'] > 1 ) { $current_step /= $spacing_scale['increment']; } else { $current_step *= $spacing_scale['increment']; } if ( $current_step <= 0 ) { $remainder = $below_midpoint_count; break; } $below_sizes[] = array( 'name' => $below_midpoint_count === $steps_mid_point - 1 ? __( 'Small' ) : sprintf( __( '%sX-Small' ), (string) $x_small_count ), 'slug' => (string) $slug, 'size' => round( $current_step, 2 ) . $unit, ); if ( $below_midpoint_count === $steps_mid_point - 2 ) { $x_small_count = 2; } if ( $below_midpoint_count < $steps_mid_point - 2 ) { $x_small_count++; } $slug -= 10; } $below_sizes = array_reverse( $below_sizes ); $below_sizes[] = array( 'name' => __( 'Medium' ), 'slug' => '50', 'size' => $spacing_scale['mediumStep'] . $unit, ); $current_step = $spacing_scale['mediumStep']; $x_large_count = null; $above_sizes = array(); $slug = 60; $steps_above = ( $spacing_scale['steps'] - $steps_mid_point ) + $remainder; for ( $above_midpoint_count = 0; $above_midpoint_count < $steps_above; $above_midpoint_count++ ) { $current_step = '+' === $spacing_scale['operator'] ? $current_step + $spacing_scale['increment'] : ( $spacing_scale['increment'] >= 1 ? $current_step * $spacing_scale['increment'] : $current_step / $spacing_scale['increment'] ); $above_sizes[] = array( 'name' => 0 === $above_midpoint_count ? __( 'Large' ) : sprintf( __( '%sX-Large' ), (string) $x_large_count ), 'slug' => (string) $slug, 'size' => round( $current_step, 2 ) . $unit, ); if ( 1 === $above_midpoint_count ) { $x_large_count = 2; } if ( $above_midpoint_count > 1 ) { $x_large_count++; } $slug += 10; } $spacing_sizes = $below_sizes; foreach ( $above_sizes as $above_sizes_item ) { $spacing_sizes[] = $above_sizes_item; } if ( $spacing_scale['steps'] <= 7 ) { for ( $spacing_sizes_count = 0; $spacing_sizes_count < count( $spacing_sizes ); $spacing_sizes_count++ ) { $spacing_sizes[ $spacing_sizes_count ]['name'] = (string) ( $spacing_sizes_count + 1 ); } } _wp_array_set( $this->theme_json, array( 'settings', 'spacing', 'spacingSizes', 'default' ), $spacing_sizes ); } } 'Theme Name', 'ThemeURI' => 'Theme URI', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'Version' => 'Version', 'Template' => 'Template', 'Status' => 'Status', 'Tags' => 'Tags', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'RequiresWP' => 'Requires at least', 'RequiresPHP' => 'Requires PHP', 'UpdateURI' => 'Update URI', ); private static $default_themes = array( 'classic' => 'WordPress Classic', 'default' => 'WordPress Default', 'twentyten' => 'Twenty Ten', 'twentyeleven' => 'Twenty Eleven', 'twentytwelve' => 'Twenty Twelve', 'twentythirteen' => 'Twenty Thirteen', 'twentyfourteen' => 'Twenty Fourteen', 'twentyfifteen' => 'Twenty Fifteen', 'twentysixteen' => 'Twenty Sixteen', 'twentyseventeen' => 'Twenty Seventeen', 'twentynineteen' => 'Twenty Nineteen', 'twentytwenty' => 'Twenty Twenty', 'twentytwentyone' => 'Twenty Twenty-One', 'twentytwentytwo' => 'Twenty Twenty-Two', 'twentytwentythree' => 'Twenty Twenty-Three', ); private static $tag_map = array( 'fixed-width' => 'fixed-layout', 'flexible-width' => 'fluid-layout', ); private $theme_root; private $headers = array(); private $headers_sanitized; private $name_translated; private $errors; private $stylesheet; private $template; private $parent; private $theme_root_uri; private $textdomain_loaded; private $cache_hash; private static $persistently_cache; private static $cache_expiration = 1800; public function __construct( $theme_dir, $theme_root, $_child = null ) { global $wp_theme_directories; if ( ! isset( self::$persistently_cache ) ) { self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' ); if ( self::$persistently_cache ) { wp_cache_add_global_groups( 'themes' ); if ( is_int( self::$persistently_cache ) ) { self::$cache_expiration = self::$persistently_cache; } } else { wp_cache_add_non_persistent_groups( 'themes' ); } } $this->theme_root = $theme_root; $this->stylesheet = $theme_dir; if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories, true ) ) { $this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet; $this->theme_root = dirname( $theme_root ); } $this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet ); $theme_file = $this->stylesheet . '/style.css'; $cache = $this->cache_get( 'theme' ); if ( is_array( $cache ) ) { foreach ( array( 'errors', 'headers', 'template' ) as $key ) { if ( isset( $cache[ $key ] ) ) { $this->$key = $cache[ $key ]; } } if ( $this->errors ) { return; } if ( isset( $cache['theme_root_template'] ) ) { $theme_root_template = $cache['theme_root_template']; } } elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) { $this->headers['Name'] = $this->stylesheet; if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) { $this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), esc_html( $this->stylesheet ) ) ); } else { $this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) ); } $this->template = $this->stylesheet; $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ) ); if ( ! file_exists( $this->theme_root ) ) { $this->errors->add( 'theme_root_missing', __( 'Error: The themes directory is either empty or does not exist. Please check your installation.' ) ); } return; } elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) { $this->headers['Name'] = $this->stylesheet; $this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) ); $this->template = $this->stylesheet; $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ) ); return; } else { $this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes, true ); if ( $default_theme_slug ) { if ( basename( $this->stylesheet ) != $default_theme_slug ) { $this->headers['Name'] .= '/' . $this->stylesheet; } } } if ( ! $this->template && $this->stylesheet === $this->headers['Template'] ) { $this->errors = new WP_Error( 'theme_child_invalid', sprintf( __( 'The theme defines itself as its parent theme. Please check the %s header.' ), 'Template' ) ); $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, ) ); return; } if ( ! $this->template ) { $this->template = $this->headers['Template']; } if ( ! $this->template ) { $this->template = $this->stylesheet; $theme_path = $this->theme_root . '/' . $this->stylesheet; if ( ! file_exists( $theme_path . '/templates/index.html' ) && ! file_exists( $theme_path . '/block-templates/index.html' ) && ! file_exists( $theme_path . '/index.php' ) ) { $error_message = sprintf( __( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. Child themes need to have a %4$s header in the %5$s stylesheet.' ), 'templates/index.html', 'index.php', __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), 'Template', 'style.css' ); $this->errors = new WP_Error( 'theme_no_index', $error_message ); $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ) ); return; } } if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) { $parent_dir = dirname( $this->stylesheet ); $directories = search_theme_directories(); if ( '.' !== $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) { $this->template = $parent_dir . '/' . $this->template; } elseif ( $directories && isset( $directories[ $this->template ] ) ) { $theme_root_template = $directories[ $this->template ]['theme_root']; } else { $this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), esc_html( $this->template ) ) ); $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ) ); $this->parent = new WP_Theme( $this->template, $this->theme_root, $this ); return; } } if ( $this->template != $this->stylesheet ) { if ( $_child instanceof WP_Theme && $_child->template == $this->stylesheet ) { $_child->parent = null; $_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $_child->template ) ) ); $_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template, ) ); if ( $_child->stylesheet == $this->template ) { $this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $this->template ) ) ); $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ) ); } return; } $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this ); } if ( wp_paused_themes()->get( $this->stylesheet ) && ( ! is_wp_error( $this->errors ) || ! isset( $this->errors->errors['theme_paused'] ) ) ) { $this->errors = new WP_Error( 'theme_paused', __( 'This theme failed to load properly and was paused within the admin backend.' ) ); } if ( ! is_array( $cache ) ) { $cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template, ); if ( isset( $theme_root_template ) ) { $cache['theme_root_template'] = $theme_root_template; } $this->cache_add( 'theme', $cache ); } } public function __toString() { return (string) $this->display( 'Name' ); } public function __isset( $offset ) { static $properties = array( 'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet', 'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri', ); return in_array( $offset, $properties, true ); } public function __get( $offset ) { switch ( $offset ) { case 'name': case 'title': return $this->get( 'Name' ); case 'version': return $this->get( 'Version' ); case 'parent_theme': return $this->parent() ? $this->parent()->get( 'Name' ) : ''; case 'template_dir': return $this->get_template_directory(); case 'stylesheet_dir': return $this->get_stylesheet_directory(); case 'template': return $this->get_template(); case 'stylesheet': return $this->get_stylesheet(); case 'screenshot': return $this->get_screenshot( 'relative' ); case 'description': return $this->display( 'Description' ); case 'author': return $this->display( 'Author' ); case 'tags': return $this->get( 'Tags' ); case 'theme_root': return $this->get_theme_root(); case 'theme_root_uri': return $this->get_theme_root_uri(); default: return $this->offsetGet( $offset ); } } public function offsetSet( $offset, $value ) {} public function offsetUnset( $offset ) {} public function offsetExists( $offset ) { static $keys = array( 'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description', 'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir', 'Screenshot', 'Tags', 'Theme Root', 'Theme Root URI', 'Parent Theme', ); return in_array( $offset, $keys, true ); } public function offsetGet( $offset ) { switch ( $offset ) { case 'Name': case 'Title': return $this->get( 'Name' ); case 'Author': return $this->display( 'Author' ); case 'Author Name': return $this->display( 'Author', false ); case 'Author URI': return $this->display( 'AuthorURI' ); case 'Description': return $this->display( 'Description' ); case 'Version': case 'Status': return $this->get( $offset ); case 'Template': return $this->get_template(); case 'Stylesheet': return $this->get_stylesheet(); case 'Template Files': return $this->get_files( 'php', 1, true ); case 'Stylesheet Files': return $this->get_files( 'css', 0, false ); case 'Template Dir': return $this->get_template_directory(); case 'Stylesheet Dir': return $this->get_stylesheet_directory(); case 'Screenshot': return $this->get_screenshot( 'relative' ); case 'Tags': return $this->get( 'Tags' ); case 'Theme Root': return $this->get_theme_root(); case 'Theme Root URI': return $this->get_theme_root_uri(); case 'Parent Theme': return $this->parent() ? $this->parent()->get( 'Name' ) : ''; default: return null; } } public function errors() { return is_wp_error( $this->errors ) ? $this->errors : false; } public function exists() { return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes(), true ) ); } public function parent() { return isset( $this->parent ) ? $this->parent : false; } private function cache_add( $key, $data ) { return wp_cache_add( $key . '-' . $this->cache_hash, $data, 'themes', self::$cache_expiration ); } private function cache_get( $key ) { return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' ); } public function cache_delete() { foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) { wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); } $this->template = null; $this->textdomain_loaded = null; $this->theme_root_uri = null; $this->parent = null; $this->errors = null; $this->headers_sanitized = null; $this->name_translated = null; $this->headers = array(); $this->__construct( $this->stylesheet, $this->theme_root ); } public function get( $header ) { if ( ! isset( $this->headers[ $header ] ) ) { return false; } if ( ! isset( $this->headers_sanitized ) ) { $this->headers_sanitized = $this->cache_get( 'headers' ); if ( ! is_array( $this->headers_sanitized ) ) { $this->headers_sanitized = array(); } } if ( isset( $this->headers_sanitized[ $header ] ) ) { return $this->headers_sanitized[ $header ]; } if ( self::$persistently_cache ) { foreach ( array_keys( $this->headers ) as $_header ) { $this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] ); } $this->cache_add( 'headers', $this->headers_sanitized ); } else { $this->headers_sanitized[ $header ] = $this->sanitize_header( $header, $this->headers[ $header ] ); } return $this->headers_sanitized[ $header ]; } public function display( $header, $markup = true, $translate = true ) { $value = $this->get( $header ); if ( false === $value ) { return false; } if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) { $translate = false; } if ( $translate ) { $value = $this->translate_header( $header, $value ); } if ( $markup ) { $value = $this->markup_header( $header, $value, $translate ); } return $value; } private function sanitize_header( $header, $value ) { switch ( $header ) { case 'Status': if ( ! $value ) { $value = 'publish'; break; } case 'Name': static $header_tags = array( 'abbr' => array( 'title' => true ), 'acronym' => array( 'title' => true ), 'code' => true, 'em' => true, 'strong' => true, ); $value = wp_kses( $value, $header_tags ); break; case 'Author': case 'Description': static $header_tags_with_a = array( 'a' => array( 'href' => true, 'title' => true, ), 'abbr' => array( 'title' => true ), 'acronym' => array( 'title' => true ), 'code' => true, 'em' => true, 'strong' => true, ); $value = wp_kses( $value, $header_tags_with_a ); break; case 'ThemeURI': case 'AuthorURI': $value = sanitize_url( $value ); break; case 'Tags': $value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) ); break; case 'Version': case 'RequiresWP': case 'RequiresPHP': case 'UpdateURI': $value = strip_tags( $value ); break; } return $value; } private function markup_header( $header, $value, $translate ) { switch ( $header ) { case 'Name': if ( empty( $value ) ) { $value = esc_html( $this->get_stylesheet() ); } break; case 'Description': $value = wptexturize( $value ); break; case 'Author': if ( $this->get( 'AuthorURI' ) ) { $value = sprintf( '%2$s', $this->display( 'AuthorURI', true, $translate ), $value ); } elseif ( ! $value ) { $value = __( 'Anonymous' ); } break; case 'Tags': static $comma = null; if ( ! isset( $comma ) ) { $comma = wp_get_list_item_separator(); } $value = implode( $comma, $value ); break; case 'ThemeURI': case 'AuthorURI': $value = esc_url( $value ); break; } return $value; } private function translate_header( $header, $value ) { switch ( $header ) { case 'Name': if ( isset( $this->name_translated ) ) { return $this->name_translated; } $this->name_translated = translate( $value, $this->get( 'TextDomain' ) ); return $this->name_translated; case 'Tags': if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) { return $value; } static $tags_list; if ( ! isset( $tags_list ) ) { $tags_list = array( 'black' => __( 'Black' ), 'blue' => __( 'Blue' ), 'brown' => __( 'Brown' ), 'gray' => __( 'Gray' ), 'green' => __( 'Green' ), 'orange' => __( 'Orange' ), 'pink' => __( 'Pink' ), 'purple' => __( 'Purple' ), 'red' => __( 'Red' ), 'silver' => __( 'Silver' ), 'tan' => __( 'Tan' ), 'white' => __( 'White' ), 'yellow' => __( 'Yellow' ), 'dark' => _x( 'Dark', 'color scheme' ), 'light' => _x( 'Light', 'color scheme' ), 'fixed-layout' => __( 'Fixed Layout' ), 'fluid-layout' => __( 'Fluid Layout' ), 'responsive-layout' => __( 'Responsive Layout' ), 'blavatar' => __( 'Blavatar' ), 'photoblogging' => __( 'Photoblogging' ), 'seasonal' => __( 'Seasonal' ), ); $feature_list = get_theme_feature_list( false ); foreach ( $feature_list as $tags ) { $tags_list += $tags; } } foreach ( $value as &$tag ) { if ( isset( $tags_list[ $tag ] ) ) { $tag = $tags_list[ $tag ]; } elseif ( isset( self::$tag_map[ $tag ] ) ) { $tag = $tags_list[ self::$tag_map[ $tag ] ]; } } return $value; default: $value = translate( $value, $this->get( 'TextDomain' ) ); } return $value; } public function get_stylesheet() { return $this->stylesheet; } public function get_template() { return $this->template; } public function get_stylesheet_directory() { if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes(), true ) ) { return ''; } return $this->theme_root . '/' . $this->stylesheet; } public function get_template_directory() { if ( $this->parent() ) { $theme_root = $this->parent()->theme_root; } else { $theme_root = $this->theme_root; } return $theme_root . '/' . $this->template; } public function get_stylesheet_directory_uri() { return $this->get_theme_root_uri() . '/' . str_replace( '%2F', '/', rawurlencode( $this->stylesheet ) ); } public function get_template_directory_uri() { if ( $this->parent() ) { $theme_root_uri = $this->parent()->get_theme_root_uri(); } else { $theme_root_uri = $this->get_theme_root_uri(); } return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) ); } public function get_theme_root() { return $this->theme_root; } public function get_theme_root_uri() { if ( ! isset( $this->theme_root_uri ) ) { $this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root ); } return $this->theme_root_uri; } public function get_screenshot( $uri = 'uri' ) { $screenshot = $this->cache_get( 'screenshot' ); if ( $screenshot ) { if ( 'relative' === $uri ) { return $screenshot; } return $this->get_stylesheet_directory_uri() . '/' . $screenshot; } elseif ( 0 === $screenshot ) { return false; } foreach ( array( 'png', 'gif', 'jpg', 'jpeg', 'webp' ) as $ext ) { if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { $this->cache_add( 'screenshot', 'screenshot.' . $ext ); if ( 'relative' === $uri ) { return 'screenshot.' . $ext; } return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext; } } $this->cache_add( 'screenshot', 0 ); return false; } public function get_files( $type = null, $depth = 0, $search_parent = false ) { $files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth ); if ( $search_parent && $this->parent() ) { $files += (array) self::scandir( $this->get_template_directory(), $type, $depth ); } return array_filter( $files ); } public function get_post_templates() { if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) { return array(); } $post_templates = $this->cache_get( 'post_templates' ); if ( ! is_array( $post_templates ) ) { $post_templates = array(); $files = (array) $this->get_files( 'php', 1, true ); foreach ( $files as $file => $full_path ) { if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) { continue; } $types = array( 'page' ); if ( preg_match( '|Template Post Type:(.*)$|mi', file_get_contents( $full_path ), $type ) ) { $types = explode( ',', _cleanup_header_comment( $type[1] ) ); } foreach ( $types as $type ) { $type = sanitize_key( $type ); if ( ! isset( $post_templates[ $type ] ) ) { $post_templates[ $type ] = array(); } $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] ); } } if ( current_theme_supports( 'block-templates' ) ) { $block_templates = get_block_templates( array(), 'wp_template' ); foreach ( get_post_types( array( 'public' => true ) ) as $type ) { foreach ( $block_templates as $block_template ) { if ( ! $block_template->is_custom ) { continue; } if ( isset( $block_template->post_types ) && ! in_array( $type, $block_template->post_types, true ) ) { continue; } $post_templates[ $type ][ $block_template->slug ] = $block_template->title; } } } $this->cache_add( 'post_templates', $post_templates ); } if ( $this->load_textdomain() ) { foreach ( $post_templates as &$post_type ) { foreach ( $post_type as &$post_template ) { $post_template = $this->translate_header( 'Template Name', $post_template ); } } } return $post_templates; } public function get_page_templates( $post = null, $post_type = 'page' ) { if ( $post ) { $post_type = get_post_type( $post ); } $post_templates = $this->get_post_templates(); $post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array(); $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type ); $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type ); return $post_templates; } private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) { if ( ! is_dir( $path ) ) { return false; } if ( $extensions ) { $extensions = (array) $extensions; $_extensions = implode( '|', $extensions ); } $relative_path = trailingslashit( $relative_path ); if ( '/' === $relative_path ) { $relative_path = ''; } $results = scandir( $path ); $files = array(); $exclusions = (array) apply_filters( 'theme_scandir_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); foreach ( $results as $result ) { if ( '.' === $result[0] || in_array( $result, $exclusions, true ) ) { continue; } if ( is_dir( $path . '/' . $result ) ) { if ( ! $depth ) { continue; } $found = self::scandir( $path . '/' . $result, $extensions, $depth - 1, $relative_path . $result ); $files = array_merge_recursive( $files, $found ); } elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) { $files[ $relative_path . $result ] = $path . '/' . $result; } } return $files; } public function load_textdomain() { if ( isset( $this->textdomain_loaded ) ) { return $this->textdomain_loaded; } $textdomain = $this->get( 'TextDomain' ); if ( ! $textdomain ) { $this->textdomain_loaded = false; return false; } if ( is_textdomain_loaded( $textdomain ) ) { $this->textdomain_loaded = true; return true; } $path = $this->get_stylesheet_directory(); $domainpath = $this->get( 'DomainPath' ); if ( $domainpath ) { $path .= $domainpath; } else { $path .= '/languages'; } $this->textdomain_loaded = load_theme_textdomain( $textdomain, $path ); return $this->textdomain_loaded; } public function is_allowed( $check = 'both', $blog_id = null ) { if ( ! is_multisite() ) { return true; } if ( 'both' === $check || 'network' === $check ) { $allowed = self::get_allowed_on_network(); if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { return true; } } if ( 'both' === $check || 'site' === $check ) { $allowed = self::get_allowed_on_site( $blog_id ); if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { return true; } } return false; } public function is_block_theme() { $paths_to_index_block_template = array( $this->get_file_path( '/block-templates/index.html' ), $this->get_file_path( '/templates/index.html' ), ); foreach ( $paths_to_index_block_template as $path_to_index_block_template ) { if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) { return true; } } return false; } public function get_file_path( $file = '' ) { $file = ltrim( $file, '/' ); $stylesheet_directory = $this->get_stylesheet_directory(); $template_directory = $this->get_template_directory(); if ( empty( $file ) ) { $path = $stylesheet_directory; } elseif ( file_exists( $stylesheet_directory . '/' . $file ) ) { $path = $stylesheet_directory . '/' . $file; } else { $path = $template_directory . '/' . $file; } return apply_filters( 'theme_file_path', $path, $file ); } public static function get_core_default_theme() { foreach ( array_reverse( self::$default_themes ) as $slug => $name ) { $theme = wp_get_theme( $slug ); if ( $theme->exists() ) { return $theme; } } return false; } public static function get_allowed( $blog_id = null ) { $network = (array) apply_filters( 'network_allowed_themes', self::get_allowed_on_network(), $blog_id ); return $network + self::get_allowed_on_site( $blog_id ); } public static function get_allowed_on_network() { static $allowed_themes; if ( ! isset( $allowed_themes ) ) { $allowed_themes = (array) get_site_option( 'allowedthemes' ); } $allowed_themes = apply_filters( 'allowed_themes', $allowed_themes ); return $allowed_themes; } public static function get_allowed_on_site( $blog_id = null ) { static $allowed_themes = array(); if ( ! $blog_id || ! is_multisite() ) { $blog_id = get_current_blog_id(); } if ( isset( $allowed_themes[ $blog_id ] ) ) { return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); } $current = get_current_blog_id() == $blog_id; if ( $current ) { $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); } else { switch_to_blog( $blog_id ); $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); restore_current_blog(); } if ( false === $allowed_themes[ $blog_id ] ) { if ( $current ) { $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); } else { switch_to_blog( $blog_id ); $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); restore_current_blog(); } if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { $allowed_themes[ $blog_id ] = array(); } else { $converted = array(); $themes = wp_get_themes(); foreach ( $themes as $stylesheet => $theme_data ) { if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get( 'Name' ) ] ) ) { $converted[ $stylesheet ] = true; } } $allowed_themes[ $blog_id ] = $converted; } if ( is_admin() && $allowed_themes[ $blog_id ] ) { if ( $current ) { update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); delete_option( 'allowed_themes' ); } else { switch_to_blog( $blog_id ); update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); delete_option( 'allowed_themes' ); restore_current_blog(); } } } return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); } public static function network_enable_theme( $stylesheets ) { if ( ! is_multisite() ) { return; } if ( ! is_array( $stylesheets ) ) { $stylesheets = array( $stylesheets ); } $allowed_themes = get_site_option( 'allowedthemes' ); foreach ( $stylesheets as $stylesheet ) { $allowed_themes[ $stylesheet ] = true; } update_site_option( 'allowedthemes', $allowed_themes ); } public static function network_disable_theme( $stylesheets ) { if ( ! is_multisite() ) { return; } if ( ! is_array( $stylesheets ) ) { $stylesheets = array( $stylesheets ); } $allowed_themes = get_site_option( 'allowedthemes' ); foreach ( $stylesheets as $stylesheet ) { if ( isset( $allowed_themes[ $stylesheet ] ) ) { unset( $allowed_themes[ $stylesheet ] ); } } update_site_option( 'allowedthemes', $allowed_themes ); } public static function sort_by_name( &$themes ) { if ( 0 === strpos( get_user_locale(), 'en_' ) ) { uasort( $themes, array( 'WP_Theme', '_name_sort' ) ); } else { foreach ( $themes as $key => $theme ) { $theme->translate_header( 'Name', $theme->headers['Name'] ); } uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) ); } } private static function _name_sort( $a, $b ) { return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] ); } private static function _name_sort_i18n( $a, $b ) { return strnatcasecmp( $a->name_translated, $b->name_translated ); } } user_id, 'session_tokens', true ); if ( ! is_array( $sessions ) ) { return array(); } $sessions = array_map( array( $this, 'prepare_session' ), $sessions ); return array_filter( $sessions, array( $this, 'is_still_valid' ) ); } protected function prepare_session( $session ) { if ( is_int( $session ) ) { return array( 'expiration' => $session ); } return $session; } protected function get_session( $verifier ) { $sessions = $this->get_sessions(); if ( isset( $sessions[ $verifier ] ) ) { return $sessions[ $verifier ]; } return null; } protected function update_session( $verifier, $session = null ) { $sessions = $this->get_sessions(); if ( $session ) { $sessions[ $verifier ] = $session; } else { unset( $sessions[ $verifier ] ); } $this->update_sessions( $sessions ); } protected function update_sessions( $sessions ) { if ( $sessions ) { update_user_meta( $this->user_id, 'session_tokens', $sessions ); } else { delete_user_meta( $this->user_id, 'session_tokens' ); } } protected function destroy_other_sessions( $verifier ) { $session = $this->get_session( $verifier ); $this->update_sessions( array( $verifier => $session ) ); } protected function destroy_all_sessions() { $this->update_sessions( array() ); } public static function drop_sessions() { delete_metadata( 'user', 0, 'session_tokens', false, true ); } } prepare_query( $query ); $this->query(); } } public static function fill_query_vars( $args ) { $defaults = array( 'blog_id' => get_current_blog_id(), 'role' => '', 'role__in' => array(), 'role__not_in' => array(), 'capability' => '', 'capability__in' => array(), 'capability__not_in' => array(), 'meta_key' => '', 'meta_value' => '', 'meta_compare' => '', 'include' => array(), 'exclude' => array(), 'search' => '', 'search_columns' => array(), 'orderby' => 'login', 'order' => 'ASC', 'offset' => '', 'number' => '', 'paged' => 1, 'count_total' => true, 'fields' => 'all', 'who' => '', 'has_published_posts' => null, 'nicename' => '', 'nicename__in' => array(), 'nicename__not_in' => array(), 'login' => '', 'login__in' => array(), 'login__not_in' => array(), ); return wp_parse_args( $args, $defaults ); } public function prepare_query( $query = array() ) { global $wpdb, $wp_roles; if ( empty( $this->query_vars ) || ! empty( $query ) ) { $this->query_limit = null; $this->query_vars = $this->fill_query_vars( $query ); } do_action_ref_array( 'pre_get_users', array( &$this ) ); $qv =& $this->query_vars; $qv = $this->fill_query_vars( $qv ); $allowed_fields = array( 'id', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name', ); if ( is_multisite() ) { $allowed_fields[] = 'spam'; $allowed_fields[] = 'deleted'; } if ( is_array( $qv['fields'] ) ) { $qv['fields'] = array_map( 'strtolower', $qv['fields'] ); $qv['fields'] = array_intersect( array_unique( $qv['fields'] ), $allowed_fields ); if ( empty( $qv['fields'] ) ) { $qv['fields'] = array( 'id' ); } $this->query_fields = array(); foreach ( $qv['fields'] as $field ) { $field = 'id' === $field ? 'ID' : sanitize_key( $field ); $this->query_fields[] = "$wpdb->users.$field"; } $this->query_fields = implode( ',', $this->query_fields ); } elseif ( 'all_with_meta' === $qv['fields'] || 'all' === $qv['fields'] || ! in_array( $qv['fields'], $allowed_fields, true ) ) { $this->query_fields = "$wpdb->users.ID"; } else { $field = 'id' === strtolower( $qv['fields'] ) ? 'ID' : sanitize_key( $qv['fields'] ); $this->query_fields = "$wpdb->users.$field"; } if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; } $this->query_from = "FROM $wpdb->users"; $this->query_where = 'WHERE 1=1'; if ( ! empty( $qv['include'] ) ) { $include = wp_parse_id_list( $qv['include'] ); } else { $include = false; } $blog_id = 0; if ( isset( $qv['blog_id'] ) ) { $blog_id = absint( $qv['blog_id'] ); } if ( $qv['has_published_posts'] && $blog_id ) { if ( true === $qv['has_published_posts'] ) { $post_types = get_post_types( array( 'public' => true ) ); } else { $post_types = (array) $qv['has_published_posts']; } foreach ( $post_types as &$post_type ) { $post_type = $wpdb->prepare( '%s', $post_type ); } $posts_table = $wpdb->get_blog_prefix( $blog_id ) . 'posts'; $this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . implode( ', ', $post_types ) . ' ) )'; } if ( '' !== $qv['nicename'] ) { $this->query_where .= $wpdb->prepare( ' AND user_nicename = %s', $qv['nicename'] ); } if ( ! empty( $qv['nicename__in'] ) ) { $sanitized_nicename__in = array_map( 'esc_sql', $qv['nicename__in'] ); $nicename__in = implode( "','", $sanitized_nicename__in ); $this->query_where .= " AND user_nicename IN ( '$nicename__in' )"; } if ( ! empty( $qv['nicename__not_in'] ) ) { $sanitized_nicename__not_in = array_map( 'esc_sql', $qv['nicename__not_in'] ); $nicename__not_in = implode( "','", $sanitized_nicename__not_in ); $this->query_where .= " AND user_nicename NOT IN ( '$nicename__not_in' )"; } if ( '' !== $qv['login'] ) { $this->query_where .= $wpdb->prepare( ' AND user_login = %s', $qv['login'] ); } if ( ! empty( $qv['login__in'] ) ) { $sanitized_login__in = array_map( 'esc_sql', $qv['login__in'] ); $login__in = implode( "','", $sanitized_login__in ); $this->query_where .= " AND user_login IN ( '$login__in' )"; } if ( ! empty( $qv['login__not_in'] ) ) { $sanitized_login__not_in = array_map( 'esc_sql', $qv['login__not_in'] ); $login__not_in = implode( "','", $sanitized_login__not_in ); $this->query_where .= " AND user_login NOT IN ( '$login__not_in' )"; } $this->meta_query = new WP_Meta_Query(); $this->meta_query->parse_query_vars( $qv ); if ( isset( $qv['who'] ) && 'authors' === $qv['who'] && $blog_id ) { _deprecated_argument( 'WP_User_Query', '5.9.0', sprintf( __( '%1$s is deprecated. Use %2$s instead.' ), 'who', 'capability' ) ); $who_query = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level', 'value' => 0, 'compare' => '!=', ); $qv['blog_id'] = 0; $blog_id = 0; if ( empty( $this->meta_query->queries ) ) { $this->meta_query->queries = array( $who_query ); } else { $this->meta_query->queries = array( 'relation' => 'AND', array( $this->meta_query->queries, $who_query ), ); } $this->meta_query->parse_query_vars( $this->meta_query->queries ); } $roles = array(); if ( isset( $qv['role'] ) ) { if ( is_array( $qv['role'] ) ) { $roles = $qv['role']; } elseif ( is_string( $qv['role'] ) && ! empty( $qv['role'] ) ) { $roles = array_map( 'trim', explode( ',', $qv['role'] ) ); } } $role__in = array(); if ( isset( $qv['role__in'] ) ) { $role__in = (array) $qv['role__in']; } $role__not_in = array(); if ( isset( $qv['role__not_in'] ) ) { $role__not_in = (array) $qv['role__not_in']; } $available_roles = array(); if ( ! empty( $qv['capability'] ) || ! empty( $qv['capability__in'] ) || ! empty( $qv['capability__not_in'] ) ) { $wp_roles->for_site( $blog_id ); $available_roles = $wp_roles->roles; } $capabilities = array(); if ( ! empty( $qv['capability'] ) ) { if ( is_array( $qv['capability'] ) ) { $capabilities = $qv['capability']; } elseif ( is_string( $qv['capability'] ) ) { $capabilities = array_map( 'trim', explode( ',', $qv['capability'] ) ); } } $capability__in = array(); if ( ! empty( $qv['capability__in'] ) ) { $capability__in = (array) $qv['capability__in']; } $capability__not_in = array(); if ( ! empty( $qv['capability__not_in'] ) ) { $capability__not_in = (array) $qv['capability__not_in']; } $caps_with_roles = array(); foreach ( $available_roles as $role => $role_data ) { $role_caps = array_keys( array_filter( $role_data['capabilities'] ) ); foreach ( $capabilities as $cap ) { if ( in_array( $cap, $role_caps, true ) ) { $caps_with_roles[ $cap ][] = $role; break; } } foreach ( $capability__in as $cap ) { if ( in_array( $cap, $role_caps, true ) ) { $role__in[] = $role; break; } } foreach ( $capability__not_in as $cap ) { if ( in_array( $cap, $role_caps, true ) ) { $role__not_in[] = $role; break; } } } $role__in = array_merge( $role__in, $capability__in ); $role__not_in = array_merge( $role__not_in, $capability__not_in ); $roles = array_unique( $roles ); $role__in = array_unique( $role__in ); $role__not_in = array_unique( $role__not_in ); if ( $blog_id && ! empty( $capabilities ) ) { $capabilities_clauses = array( 'relation' => 'AND' ); foreach ( $capabilities as $cap ) { $clause = array( 'relation' => 'OR' ); $clause[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => '"' . $cap . '"', 'compare' => 'LIKE', ); if ( ! empty( $caps_with_roles[ $cap ] ) ) { foreach ( $caps_with_roles[ $cap ] as $role ) { $clause[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => '"' . $role . '"', 'compare' => 'LIKE', ); } } $capabilities_clauses[] = $clause; } $role_queries[] = $capabilities_clauses; if ( empty( $this->meta_query->queries ) ) { $this->meta_query->queries[] = $capabilities_clauses; } else { $this->meta_query->queries = array( 'relation' => 'AND', array( $this->meta_query->queries, array( $capabilities_clauses ) ), ); } $this->meta_query->parse_query_vars( $this->meta_query->queries ); } if ( $blog_id && ( ! empty( $roles ) || ! empty( $role__in ) || ! empty( $role__not_in ) || is_multisite() ) ) { $role_queries = array(); $roles_clauses = array( 'relation' => 'AND' ); if ( ! empty( $roles ) ) { foreach ( $roles as $role ) { $roles_clauses[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => '"' . $role . '"', 'compare' => 'LIKE', ); } $role_queries[] = $roles_clauses; } $role__in_clauses = array( 'relation' => 'OR' ); if ( ! empty( $role__in ) ) { foreach ( $role__in as $role ) { $role__in_clauses[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => '"' . $role . '"', 'compare' => 'LIKE', ); } $role_queries[] = $role__in_clauses; } $role__not_in_clauses = array( 'relation' => 'AND' ); if ( ! empty( $role__not_in ) ) { foreach ( $role__not_in as $role ) { $role__not_in_clauses[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => '"' . $role . '"', 'compare' => 'NOT LIKE', ); } $role_queries[] = $role__not_in_clauses; } if ( empty( $role_queries ) ) { $role_queries[] = array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'compare' => 'EXISTS', ); } $role_queries['relation'] = 'AND'; if ( empty( $this->meta_query->queries ) ) { $this->meta_query->queries = $role_queries; } else { $this->meta_query->queries = array( 'relation' => 'AND', array( $this->meta_query->queries, $role_queries ), ); } $this->meta_query->parse_query_vars( $this->meta_query->queries ); } if ( ! empty( $this->meta_query->queries ) ) { $clauses = $this->meta_query->get_sql( 'user', $wpdb->users, 'ID', $this ); $this->query_from .= $clauses['join']; $this->query_where .= $clauses['where']; if ( $this->meta_query->has_or_relation() ) { $this->query_fields = 'DISTINCT ' . $this->query_fields; } } $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; $order = $this->parse_order( $qv['order'] ); if ( empty( $qv['orderby'] ) ) { $ordersby = array( 'user_login' => $order ); } elseif ( is_array( $qv['orderby'] ) ) { $ordersby = $qv['orderby']; } else { $ordersby = preg_split( '/[,\s]+/', $qv['orderby'] ); } $orderby_array = array(); foreach ( $ordersby as $_key => $_value ) { if ( ! $_value ) { continue; } if ( is_int( $_key ) ) { $_orderby = $_value; $_order = $order; } else { $_orderby = $_key; $_order = $_value; } $parsed = $this->parse_orderby( $_orderby ); if ( ! $parsed ) { continue; } if ( 'nicename__in' === $_orderby || 'login__in' === $_orderby ) { $orderby_array[] = $parsed; } else { $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); } } if ( empty( $orderby_array ) ) { $orderby_array[] = "user_login $order"; } $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { if ( $qv['offset'] ) { $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] ); } else { $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); } } $search = ''; if ( isset( $qv['search'] ) ) { $search = trim( $qv['search'] ); } if ( $search ) { $leading_wild = ( ltrim( $search, '*' ) != $search ); $trailing_wild = ( rtrim( $search, '*' ) != $search ); if ( $leading_wild && $trailing_wild ) { $wild = 'both'; } elseif ( $leading_wild ) { $wild = 'leading'; } elseif ( $trailing_wild ) { $wild = 'trailing'; } else { $wild = false; } if ( $wild ) { $search = trim( $search, '*' ); } $search_columns = array(); if ( $qv['search_columns'] ) { $search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name' ) ); } if ( ! $search_columns ) { if ( false !== strpos( $search, '@' ) ) { $search_columns = array( 'user_email' ); } elseif ( is_numeric( $search ) ) { $search_columns = array( 'user_login', 'ID' ); } elseif ( preg_match( '|^https?://|', $search ) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) ) { $search_columns = array( 'user_url' ); } else { $search_columns = array( 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name' ); } } $search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this ); $this->query_where .= $this->get_search_sql( $search, $search_columns, $wild ); } if ( ! empty( $include ) ) { $ids = implode( ',', $include ); $this->query_where .= " AND $wpdb->users.ID IN ($ids)"; } elseif ( ! empty( $qv['exclude'] ) ) { $ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) ); $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)"; } if ( ! empty( $qv['date_query'] ) && is_array( $qv['date_query'] ) ) { $date_query = new WP_Date_Query( $qv['date_query'], 'user_registered' ); $this->query_where .= $date_query->get_sql(); } do_action_ref_array( 'pre_user_query', array( &$this ) ); } public function query() { global $wpdb; if ( ! did_action( 'plugins_loaded' ) ) { _doing_it_wrong( 'WP_User_Query::query', sprintf( __( 'User queries should not be run before the %s hook.' ), 'plugins_loaded' ), '6.1.1' ); } $qv =& $this->query_vars; $this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) ); if ( null === $this->results ) { $this->request = " @@ -28427,7 +31110,7 @@ if ( $display ) { printf( "\n%s\n\n", ORDER BY ID " ); $num_pages = count( $page_list ); for ( $i = 0; $i < $num_pages; $i++ ) { $page_list[ $i ]->dateCreated = $this->_convert_date( $page_list[ $i ]->post_date ); $page_list[ $i ]->date_created_gmt = $this->_convert_date_gmt( $page_list[ $i ]->post_date_gmt, $page_list[ $i ]->post_date ); unset( $page_list[ $i ]->post_date_gmt ); unset( $page_list[ $i ]->post_date ); unset( $page_list[ $i ]->post_status ); } return $page_list; } public function wp_getAuthors( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); } do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this ); $authors = array(); foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { $authors[] = array( 'user_id' => $user->ID, 'user_login' => $user->user_login, 'display_name' => $user->display_name, ); } return $authors; } public function wp_getTags( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); } do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this ); $tags = array(); $all_tags = get_tags(); if ( $all_tags ) { foreach ( (array) $all_tags as $tag ) { $struct = array(); $struct['tag_id'] = $tag->term_id; $struct['name'] = $tag->name; $struct['count'] = $tag->count; $struct['slug'] = $tag->slug; $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) ); $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) ); $tags[] = $struct; } } return $tags; } public function wp_newCategory( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $category = $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this ); if ( ! current_user_can( 'manage_categories' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); } if ( empty( $category['slug'] ) ) { $category['slug'] = ''; } if ( ! isset( $category['parent_id'] ) ) { $category['parent_id'] = ''; } if ( empty( $category['description'] ) ) { $category['description'] = ''; } $new_category = array( 'cat_name' => $category['name'], 'category_nicename' => $category['slug'], 'category_parent' => $category['parent_id'], 'category_description' => $category['description'], ); $cat_id = wp_insert_category( $new_category, true ); if ( is_wp_error( $cat_id ) ) { if ( 'term_exists' === $cat_id->get_error_code() ) { return (int) $cat_id->get_error_data(); } else { return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) ); } } elseif ( ! $cat_id ) { return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) ); } do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args ); return $cat_id; } public function wp_deleteCategory( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $category_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this ); if ( ! current_user_can( 'delete_term', $category_id ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); } $status = wp_delete_term( $category_id, 'category' ); if ( true == $status ) { do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); } return $status; } public function wp_suggestCategories( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $category = $args[3]; $max_results = (int) $args[4]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); } do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this ); $category_suggestions = array(); $args = array( 'get' => 'all', 'number' => $max_results, 'name__like' => $category, ); foreach ( (array) get_categories( $args ) as $cat ) { $category_suggestions[] = array( 'category_id' => $cat->term_id, 'category_name' => $cat->name, ); } return $category_suggestions; } public function wp_getComment( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $comment_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.getComment', $args, $this ); $comment = get_comment( $comment_id ); if ( ! $comment ) { return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); } if ( ! current_user_can( 'edit_comment', $comment_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); } return $this->_prepare_comment( $comment ); } public function wp_getComments( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $struct = isset( $args[3] ) ? $args[3] : array(); $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); if ( isset( $struct['status'] ) ) { $status = $struct['status']; } else { $status = ''; } if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { return new IXR_Error( 401, __( 'Invalid comment status.' ) ); } $post_id = ''; if ( isset( $struct['post_id'] ) ) { $post_id = absint( $struct['post_id'] ); } $post_type = ''; if ( isset( $struct['post_type'] ) ) { $post_type_object = get_post_type_object( $struct['post_type'] ); if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) { return new IXR_Error( 404, __( 'Invalid post type.' ) ); } $post_type = $struct['post_type']; } $offset = 0; if ( isset( $struct['offset'] ) ) { $offset = absint( $struct['offset'] ); } $number = 10; if ( isset( $struct['number'] ) ) { $number = absint( $struct['number'] ); } $comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number, 'post_type' => $post_type, ) ); $comments_struct = array(); if ( is_array( $comments ) ) { foreach ( $comments as $comment ) { $comments_struct[] = $this->_prepare_comment( $comment ); } } return $comments_struct; } public function wp_deleteComment( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $comment_ID = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! get_comment( $comment_ID ) ) { return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); } if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); } do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); $status = wp_delete_comment( $comment_ID ); if ( $status ) { do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); } return $status; } public function wp_editComment( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $comment_ID = (int) $args[3]; $content_struct = $args[4]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! get_comment( $comment_ID ) ) { return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); } if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); } do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); $comment = array( 'comment_ID' => $comment_ID, ); if ( isset( $content_struct['status'] ) ) { $statuses = get_comment_statuses(); $statuses = array_keys( $statuses ); if ( ! in_array( $content_struct['status'], $statuses, true ) ) { return new IXR_Error( 401, __( 'Invalid comment status.' ) ); } $comment['comment_approved'] = $content_struct['status']; } if ( ! empty( $content_struct['date_created_gmt'] ) ) { $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; $comment['comment_date'] = get_date_from_gmt( $dateCreated ); $comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' ); } if ( isset( $content_struct['content'] ) ) { $comment['comment_content'] = $content_struct['content']; } if ( isset( $content_struct['author'] ) ) { $comment['comment_author'] = $content_struct['author']; } if ( isset( $content_struct['author_url'] ) ) { $comment['comment_author_url'] = $content_struct['author_url']; } if ( isset( $content_struct['author_email'] ) ) { $comment['comment_author_email'] = $content_struct['author_email']; } $result = wp_update_comment( $comment, true ); if ( is_wp_error( $result ) ) { return new IXR_Error( 500, $result->get_error_message() ); } if ( ! $result ) { return new IXR_Error( 500, __( 'Sorry, the comment could not be updated.' ) ); } do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args ); return true; } public function wp_newComment( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $post = $args[3]; $content_struct = $args[4]; $allow_anon = apply_filters( 'xmlrpc_allow_anonymous_comments', false ); $user = $this->login( $username, $password ); if ( ! $user ) { $logged_in = false; if ( $allow_anon && get_option( 'comment_registration' ) ) { return new IXR_Error( 403, __( 'Sorry, you must be logged in to comment.' ) ); } elseif ( ! $allow_anon ) { return $this->error; } } else { $logged_in = true; } if ( is_numeric( $post ) ) { $post_id = absint( $post ); } else { $post_id = url_to_postid( $post ); } if ( ! $post_id ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! get_post( $post_id ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! comments_open( $post_id ) ) { return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) ); } if ( 'publish' === get_post_status( $post_id ) && ! current_user_can( 'edit_post', $post_id ) && post_password_required( $post_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) ); } if ( 'private' === get_post_status( $post_id ) && ! current_user_can( 'read_post', $post_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) ); } $comment = array( 'comment_post_ID' => $post_id, 'comment_content' => trim( $content_struct['content'] ), ); if ( $logged_in ) { $display_name = $user->display_name; $user_email = $user->user_email; $user_url = $user->user_url; $comment['comment_author'] = $this->escape( $display_name ); $comment['comment_author_email'] = $this->escape( $user_email ); $comment['comment_author_url'] = $this->escape( $user_url ); $comment['user_id'] = $user->ID; } else { $comment['comment_author'] = ''; if ( isset( $content_struct['author'] ) ) { $comment['comment_author'] = $content_struct['author']; } $comment['comment_author_email'] = ''; if ( isset( $content_struct['author_email'] ) ) { $comment['comment_author_email'] = $content_struct['author_email']; } $comment['comment_author_url'] = ''; if ( isset( $content_struct['author_url'] ) ) { $comment['comment_author_url'] = $content_struct['author_url']; } $comment['user_id'] = 0; if ( get_option( 'require_name_email' ) ) { if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) { return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); } elseif ( ! is_email( $comment['comment_author_email'] ) ) { return new IXR_Error( 403, __( 'A valid email address is required.' ) ); } } } $comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0; $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); if ( ! $allow_empty && '' === $comment['comment_content'] ) { return new IXR_Error( 403, __( 'Comment is required.' ) ); } do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); $comment_ID = wp_new_comment( $comment, true ); if ( is_wp_error( $comment_ID ) ) { return new IXR_Error( 403, $comment_ID->get_error_message() ); } if ( ! $comment_ID ) { return new IXR_Error( 403, __( 'Something went wrong.' ) ); } do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); return $comment_ID; } public function wp_getCommentStatusList( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'publish_posts' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); } do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); return get_comment_statuses(); } public function wp_getCommentCount( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $post_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } $post = get_post( $post_id, ARRAY_A ); if ( empty( $post['ID'] ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); } do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); $count = wp_count_comments( $post_id ); return array( 'approved' => $count->approved, 'awaiting_moderation' => $count->moderated, 'spam' => $count->spam, 'total_comments' => $count->total_comments, ); } public function wp_getPostStatusList( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); } do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); return get_post_statuses(); } public function wp_getPageStatusList( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_pages' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); } do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); return get_page_statuses(); } public function wp_getPageTemplates( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_pages' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); } $templates = get_page_templates(); $templates['Default'] = 'default'; return $templates; } public function wp_getOptions( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $options = isset( $args[3] ) ? (array) $args[3] : array(); $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( count( $options ) == 0 ) { $options = array_keys( $this->blog_options ); } return $this->_getOptions( $options ); } public function _getOptions( $options ) { $data = array(); $can_manage = current_user_can( 'manage_options' ); foreach ( $options as $option ) { if ( array_key_exists( $option, $this->blog_options ) ) { $data[ $option ] = $this->blog_options[ $option ]; if ( isset( $data[ $option ]['option'] ) ) { $data[ $option ]['value'] = get_option( $data[ $option ]['option'] ); unset( $data[ $option ]['option'] ); } if ( ! $can_manage ) { $data[ $option ]['readonly'] = true; } } } return $data; } public function wp_setOptions( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $options = (array) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'manage_options' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to update options.' ) ); } $option_names = array(); foreach ( $options as $o_name => $o_value ) { $option_names[] = $o_name; if ( ! array_key_exists( $o_name, $this->blog_options ) ) { continue; } if ( true == $this->blog_options[ $o_name ]['readonly'] ) { continue; } update_option( $this->blog_options[ $o_name ]['option'], wp_unslash( $o_value ) ); } return $this->_getOptions( $option_names ); } public function wp_getMediaItem( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $attachment_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'upload_files' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); } do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); $attachment = get_post( $attachment_id ); if ( ! $attachment || 'attachment' !== $attachment->post_type ) { return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); } return $this->_prepare_media_item( $attachment ); } public function wp_getMediaLibrary( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $struct = isset( $args[3] ) ? $args[3] : array(); $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'upload_files' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); } do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this ); $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; $attachments = get_posts( array( 'post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type, ) ); $attachments_struct = array(); foreach ( $attachments as $attachment ) { $attachments_struct[] = $this->_prepare_media_item( $attachment ); } return $attachments_struct; } public function wp_getPostFormats( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); } do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); $formats = get_post_format_strings(); if ( isset( $args[3] ) && is_array( $args[3] ) ) { if ( $args[3]['show-supported'] ) { if ( current_theme_supports( 'post-formats' ) ) { $supported = get_theme_support( 'post-formats' ); $data = array(); $data['all'] = $formats; $data['supported'] = $supported[0]; $formats = $data; } } } return $formats; } public function wp_getPostType( $args ) { if ( ! $this->minimum_args( $args, 4 ) ) { return $this->error; } $this->escape( $args ); $username = $args[1]; $password = $args[2]; $post_type_name = $args[3]; if ( isset( $args[4] ) ) { $fields = $args[4]; } else { $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); if ( ! post_type_exists( $post_type_name ) ) { return new IXR_Error( 403, __( 'Invalid post type.' ) ); } $post_type = get_post_type_object( $post_type_name ); if ( ! current_user_can( $post_type->cap->edit_posts ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); } return $this->_prepare_post_type( $post_type, $fields ); } public function wp_getPostTypes( $args ) { if ( ! $this->minimum_args( $args, 3 ) ) { return $this->error; } $this->escape( $args ); $username = $args[1]; $password = $args[2]; $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); if ( isset( $args[4] ) ) { $fields = $args[4]; } else { $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); $post_types = get_post_types( $filter, 'objects' ); $struct = array(); foreach ( $post_types as $post_type ) { if ( ! current_user_can( $post_type->cap->edit_posts ) ) { continue; } $struct[ $post_type->name ] = $this->_prepare_post_type( $post_type, $fields ); } return $struct; } public function wp_getRevisions( $args ) { if ( ! $this->minimum_args( $args, 4 ) ) { return $this->error; } $this->escape( $args ); $username = $args[1]; $password = $args[2]; $post_id = (int) $args[3]; if ( isset( $args[4] ) ) { $fields = $args[4]; } else { $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this ); $post = get_post( $post_id ); if ( ! $post ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_id ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); } if ( ! wp_revisions_enabled( $post ) ) { return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); } $revisions = wp_get_post_revisions( $post_id ); if ( ! $revisions ) { return array(); } $struct = array(); foreach ( $revisions as $revision ) { if ( ! current_user_can( 'read_post', $revision->ID ) ) { continue; } if ( wp_is_post_autosave( $revision ) ) { continue; } $struct[] = $this->_prepare_post( get_object_vars( $revision ), $fields ); } return $struct; } public function wp_restoreRevision( $args ) { if ( ! $this->minimum_args( $args, 3 ) ) { return $this->error; } $this->escape( $args ); $username = $args[1]; $password = $args[2]; $revision_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); $revision = wp_get_post_revision( $revision_id ); if ( ! $revision ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( wp_is_post_autosave( $revision ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } $post = get_post( $revision->post_parent ); if ( ! $post ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } if ( ! wp_revisions_enabled( $post ) ) { return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); } $post = wp_restore_post_revision( $revision_id ); return (bool) $post; } public function blogger_getUsersBlogs( $args ) { if ( ! $this->minimum_args( $args, 3 ) ) { return $this->error; } if ( is_multisite() ) { return $this->_multisite_getUsersBlogs( $args ); } $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this ); $is_admin = current_user_can( 'manage_options' ); $struct = array( 'isAdmin' => $is_admin, 'url' => get_option( 'home' ) . '/', 'blogid' => '1', 'blogName' => get_option( 'blogname' ), 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), ); return array( $struct ); } protected function _multisite_getUsersBlogs( $args ) { $current_blog = get_site(); $domain = $current_blog->domain; $path = $current_blog->path . 'xmlrpc.php'; $blogs = $this->wp_getUsersBlogs( $args ); if ( $blogs instanceof IXR_Error ) { return $blogs; } if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { return $blogs; } else { foreach ( (array) $blogs as $blog ) { if ( strpos( $blog['url'], $_SERVER['HTTP_HOST'] ) ) { return array( $blog ); } } return array(); } } public function blogger_getUserInfo( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); } do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); $struct = array( 'nickname' => $user->nickname, 'userid' => $user->ID, 'url' => $user->user_url, 'lastname' => $user->last_name, 'firstname' => $user->first_name, ); return $struct; } public function blogger_getPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[1]; $username = $args[2]; $password = $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } $post_data = get_post( $post_ID, ARRAY_A ); if ( ! $post_data ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); $categories = implode( ',', wp_get_post_categories( $post_ID ) ); $content = '' . wp_unslash( $post_data['post_title'] ) . ''; $content .= '' . $categories . ''; $content .= wp_unslash( $post_data['post_content'] ); $struct = array( 'userid' => $post_data['post_author'], 'dateCreated' => $this->_convert_date( $post_data['post_date'] ), 'content' => $content, 'postid' => (string) $post_data['ID'], ); return $struct; } public function blogger_getRecentPosts( $args ) { $this->escape( $args ); $username = $args[2]; $password = $args[3]; if ( isset( $args[4] ) ) { $query = array( 'numberposts' => absint( $args[4] ) ); } else { $query = array(); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); } do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); $posts_list = wp_get_recent_posts( $query ); if ( ! $posts_list ) { $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); return $this->error; } $recent_posts = array(); foreach ( $posts_list as $entry ) { if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) { continue; } $post_date = $this->_convert_date( $entry['post_date'] ); $categories = implode( ',', wp_get_post_categories( $entry['ID'] ) ); $content = '' . wp_unslash( $entry['post_title'] ) . ''; $content .= '' . $categories . ''; $content .= wp_unslash( $entry['post_content'] ); $recent_posts[] = array( 'userid' => $entry['post_author'], 'dateCreated' => $post_date, 'content' => $content, 'postid' => (string) $entry['ID'], ); } return $recent_posts; } public function blogger_getTemplate( $args ) { return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) ); } public function blogger_setTemplate( $args ) { return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) ); } public function blogger_newPost( $args ) { $this->escape( $args ); $username = $args[2]; $password = $args[3]; $content = $args[4]; $publish = $args[5]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); } $post_status = ( $publish ) ? 'publish' : 'draft'; $post_author = $user->ID; $post_title = xmlrpc_getposttitle( $content ); $post_category = xmlrpc_getpostcategory( $content ); $post_content = xmlrpc_removepostdata( $content ); $post_date = current_time( 'mysql' ); $post_date_gmt = current_time( 'mysql', 1 ); $post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' ); $post_ID = wp_insert_post( $post_data ); if ( is_wp_error( $post_ID ) ) { return new IXR_Error( 500, $post_ID->get_error_message() ); } if ( ! $post_ID ) { return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) ); } $this->attach_uploads( $post_ID, $post_content ); do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args ); return $post_ID; } public function blogger_editPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[1]; $username = $args[2]; $password = $args[3]; $content = $args[4]; $publish = $args[5]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); $actual_post = get_post( $post_ID, ARRAY_A ); if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); } $this->escape( $actual_post ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); } $postdata = array(); $postdata['ID'] = $actual_post['ID']; $postdata['post_content'] = xmlrpc_removepostdata( $content ); $postdata['post_title'] = xmlrpc_getposttitle( $content ); $postdata['post_category'] = xmlrpc_getpostcategory( $content ); $postdata['post_status'] = $actual_post['post_status']; $postdata['post_excerpt'] = $actual_post['post_excerpt']; $postdata['post_status'] = $publish ? 'publish' : 'draft'; $result = wp_update_post( $postdata ); if ( ! $result ) { return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) ); } $this->attach_uploads( $actual_post['ID'], $postdata['post_content'] ); do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args ); return true; } public function blogger_deletePost( $args ) { $this->escape( $args ); $post_ID = (int) $args[1]; $username = $args[2]; $password = $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); $actual_post = get_post( $post_ID, ARRAY_A ); if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); } if ( ! current_user_can( 'delete_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); } $result = wp_delete_post( $post_ID ); if ( ! $result ) { return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) ); } do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); return true; } public function mw_newPost( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $content_struct = $args[3]; $publish = isset( $args[4] ) ? $args[4] : 0; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); $page_template = ''; if ( ! empty( $content_struct['post_type'] ) ) { if ( 'page' === $content_struct['post_type'] ) { if ( $publish ) { $cap = 'publish_pages'; } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { $cap = 'publish_pages'; } else { $cap = 'edit_pages'; } $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); $post_type = 'page'; if ( ! empty( $content_struct['wp_page_template'] ) ) { $page_template = $content_struct['wp_page_template']; } } elseif ( 'post' === $content_struct['post_type'] ) { if ( $publish ) { $cap = 'publish_posts'; } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); $post_type = 'post'; } else { return new IXR_Error( 401, __( 'Invalid post type.' ) ); } } else { if ( $publish ) { $cap = 'publish_posts'; } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); $post_type = 'post'; } if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) ); } if ( ! current_user_can( $cap ) ) { return new IXR_Error( 401, $error_message ); } if ( isset( $content_struct['wp_post_format'] ) ) { $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { return new IXR_Error( 404, __( 'Invalid post format.' ) ); } } $post_name = null; if ( isset( $content_struct['wp_slug'] ) ) { $post_name = $content_struct['wp_slug']; } $post_password = ''; if ( isset( $content_struct['wp_password'] ) ) { $post_password = $content_struct['wp_password']; } $post_parent = 0; if ( isset( $content_struct['wp_page_parent_id'] ) ) { $post_parent = $content_struct['wp_page_parent_id']; } $menu_order = 0; if ( isset( $content_struct['wp_page_order'] ) ) { $menu_order = $content_struct['wp_page_order']; } $post_author = $user->ID; if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID != $content_struct['wp_author_id'] ) ) { switch ( $post_type ) { case 'post': if ( ! current_user_can( 'edit_others_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) ); } break; case 'page': if ( ! current_user_can( 'edit_others_pages' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) ); } break; default: return new IXR_Error( 401, __( 'Invalid post type.' ) ); } $author = get_userdata( $content_struct['wp_author_id'] ); if ( ! $author ) { return new IXR_Error( 404, __( 'Invalid author ID.' ) ); } $post_author = $content_struct['wp_author_id']; } $post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : ''; $post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : ''; $post_status = $publish ? 'publish' : 'draft'; if ( isset( $content_struct[ "{$post_type}_status" ] ) ) { switch ( $content_struct[ "{$post_type}_status" ] ) { case 'draft': case 'pending': case 'private': case 'publish': $post_status = $content_struct[ "{$post_type}_status" ]; break; default: break; } } $post_excerpt = isset( $content_struct['mt_excerpt'] ) ? $content_struct['mt_excerpt'] : ''; $post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : ''; $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array(); if ( isset( $content_struct['mt_allow_comments'] ) ) { if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) { switch ( $content_struct['mt_allow_comments'] ) { case 'closed': $comment_status = 'closed'; break; case 'open': $comment_status = 'open'; break; default: $comment_status = get_default_comment_status( $post_type ); break; } } else { switch ( (int) $content_struct['mt_allow_comments'] ) { case 0: case 2: $comment_status = 'closed'; break; case 1: $comment_status = 'open'; break; default: $comment_status = get_default_comment_status( $post_type ); break; } } } else { $comment_status = get_default_comment_status( $post_type ); } if ( isset( $content_struct['mt_allow_pings'] ) ) { if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) { switch ( $content_struct['mt_allow_pings'] ) { case 'closed': $ping_status = 'closed'; break; case 'open': $ping_status = 'open'; break; default: $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } else { switch ( (int) $content_struct['mt_allow_pings'] ) { case 0: $ping_status = 'closed'; break; case 1: $ping_status = 'open'; break; default: $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } } else { $ping_status = get_default_comment_status( $post_type, 'pingback' ); } if ( $post_more ) { $post_content .= '' . $post_more; } $to_ping = ''; if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { $to_ping = $content_struct['mt_tb_ping_urls']; if ( is_array( $to_ping ) ) { $to_ping = implode( ' ', $to_ping ); } } if ( ! empty( $content_struct['date_created_gmt'] ) ) { $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; } elseif ( ! empty( $content_struct['dateCreated'] ) ) { $dateCreated = $content_struct['dateCreated']->getIso(); } $post_date = ''; $post_date_gmt = ''; if ( ! empty( $dateCreated ) ) { $post_date = iso8601_to_datetime( $dateCreated ); $post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' ); } $post_category = array(); if ( isset( $content_struct['categories'] ) ) { $catnames = $content_struct['categories']; if ( is_array( $catnames ) ) { foreach ( $catnames as $cat ) { $post_category[] = get_cat_ID( $cat ); } } } $postdata = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template' ); $post_ID = get_default_post_to_edit( $post_type, true )->ID; $postdata['ID'] = $post_ID; if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) { $data = $postdata; $data['sticky'] = $content_struct['sticky']; $error = $this->_toggle_sticky( $data ); if ( $error ) { return $error; } } if ( isset( $content_struct['custom_fields'] ) ) { $this->set_custom_fields( $post_ID, $content_struct['custom_fields'] ); } if ( isset( $content_struct['wp_post_thumbnail'] ) ) { if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) { return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); } unset( $content_struct['wp_post_thumbnail'] ); } $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null; $this->add_enclosure_if_new( $post_ID, $thisEnclosure ); $this->attach_uploads( $post_ID, $post_content ); if ( isset( $content_struct['wp_post_format'] ) ) { set_post_format( $post_ID, $content_struct['wp_post_format'] ); } $post_ID = wp_insert_post( $postdata, true ); if ( is_wp_error( $post_ID ) ) { return new IXR_Error( 500, $post_ID->get_error_message() ); } if ( ! $post_ID ) { return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) ); } do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); return (string) $post_ID; } public function add_enclosure_if_new( $post_ID, $enclosure ) { if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) { $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n"; $found = false; $enclosures = get_post_meta( $post_ID, 'enclosure' ); if ( $enclosures ) { foreach ( $enclosures as $enc ) { if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) { $found = true; break; } } } if ( ! $found ) { add_post_meta( $post_ID, 'enclosure', $encstring ); } } } public function attach_uploads( $post_ID, $post_content ) { global $wpdb; $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); if ( is_array( $attachments ) ) { foreach ( $attachments as $file ) { if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) { $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) ); } } } } public function mw_editPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $content_struct = $args[3]; $publish = isset( $args[4] ) ? $args[4] : 0; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); $postdata = get_post( $post_ID, ARRAY_A ); if ( ! $postdata || empty( $postdata['ID'] ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } if ( ! in_array( $postdata['post_type'], array( 'post', 'page' ), true ) ) { return new IXR_Error( 401, __( 'Invalid post type.' ) ); } if ( ! empty( $content_struct['post_type'] ) && ( $content_struct['post_type'] != $postdata['post_type'] ) ) { return new IXR_Error( 401, __( 'The post type may not be changed.' ) ); } if ( isset( $content_struct['wp_post_format'] ) ) { $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { return new IXR_Error( 404, __( 'Invalid post format.' ) ); } } $this->escape( $postdata ); $ID = $postdata['ID']; $post_content = $postdata['post_content']; $post_title = $postdata['post_title']; $post_excerpt = $postdata['post_excerpt']; $post_password = $postdata['post_password']; $post_parent = $postdata['post_parent']; $post_type = $postdata['post_type']; $menu_order = $postdata['menu_order']; $ping_status = $postdata['ping_status']; $comment_status = $postdata['comment_status']; $post_name = $postdata['post_name']; if ( isset( $content_struct['wp_slug'] ) ) { $post_name = $content_struct['wp_slug']; } if ( isset( $content_struct['wp_password'] ) ) { $post_password = $content_struct['wp_password']; } if ( isset( $content_struct['wp_page_parent_id'] ) ) { $post_parent = $content_struct['wp_page_parent_id']; } if ( isset( $content_struct['wp_page_order'] ) ) { $menu_order = $content_struct['wp_page_order']; } $page_template = ''; if ( ! empty( $content_struct['wp_page_template'] ) && 'page' === $post_type ) { $page_template = $content_struct['wp_page_template']; } $post_author = $postdata['post_author']; if ( isset( $content_struct['wp_author_id'] ) ) { if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) { switch ( $post_type ) { case 'post': if ( ! current_user_can( 'edit_others_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) ); } break; case 'page': if ( ! current_user_can( 'edit_others_pages' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) ); } break; default: return new IXR_Error( 401, __( 'Invalid post type.' ) ); } $post_author = $content_struct['wp_author_id']; } } if ( isset( $content_struct['mt_allow_comments'] ) ) { if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) { switch ( $content_struct['mt_allow_comments'] ) { case 'closed': $comment_status = 'closed'; break; case 'open': $comment_status = 'open'; break; default: $comment_status = get_default_comment_status( $post_type ); break; } } else { switch ( (int) $content_struct['mt_allow_comments'] ) { case 0: case 2: $comment_status = 'closed'; break; case 1: $comment_status = 'open'; break; default: $comment_status = get_default_comment_status( $post_type ); break; } } } if ( isset( $content_struct['mt_allow_pings'] ) ) { if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) { switch ( $content_struct['mt_allow_pings'] ) { case 'closed': $ping_status = 'closed'; break; case 'open': $ping_status = 'open'; break; default: $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } else { switch ( (int) $content_struct['mt_allow_pings'] ) { case 0: $ping_status = 'closed'; break; case 1: $ping_status = 'open'; break; default: $ping_status = get_default_comment_status( $post_type, 'pingback' ); break; } } } if ( isset( $content_struct['title'] ) ) { $post_title = $content_struct['title']; } if ( isset( $content_struct['description'] ) ) { $post_content = $content_struct['description']; } $post_category = array(); if ( isset( $content_struct['categories'] ) ) { $catnames = $content_struct['categories']; if ( is_array( $catnames ) ) { foreach ( $catnames as $cat ) { $post_category[] = get_cat_ID( $cat ); } } } if ( isset( $content_struct['mt_excerpt'] ) ) { $post_excerpt = $content_struct['mt_excerpt']; } $post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : ''; $post_status = $publish ? 'publish' : 'draft'; if ( isset( $content_struct[ "{$post_type}_status" ] ) ) { switch ( $content_struct[ "{$post_type}_status" ] ) { case 'draft': case 'pending': case 'private': case 'publish': $post_status = $content_struct[ "{$post_type}_status" ]; break; default: $post_status = $publish ? 'publish' : 'draft'; break; } } $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array(); if ( 'publish' === $post_status || 'private' === $post_status ) { if ( 'page' === $post_type && ! current_user_can( 'publish_pages' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) ); } elseif ( ! current_user_can( 'publish_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); } } if ( $post_more ) { $post_content = $post_content . '' . $post_more; } $to_ping = ''; if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { $to_ping = $content_struct['mt_tb_ping_urls']; if ( is_array( $to_ping ) ) { $to_ping = implode( ' ', $to_ping ); } } if ( ! empty( $content_struct['date_created_gmt'] ) ) { $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; } elseif ( ! empty( $content_struct['dateCreated'] ) ) { $dateCreated = $content_struct['dateCreated']->getIso(); } $edit_date = false; if ( ! empty( $dateCreated ) ) { $post_date = iso8601_to_datetime( $dateCreated ); $post_date_gmt = iso8601_to_datetime( $dateCreated, 'gmt' ); $edit_date = true; } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; } $newpost = compact( 'ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'edit_date', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template' ); $result = wp_update_post( $newpost, true ); if ( is_wp_error( $result ) ) { return new IXR_Error( 500, $result->get_error_message() ); } if ( ! $result ) { return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) ); } if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) { $data = $newpost; $data['sticky'] = $content_struct['sticky']; $data['post_type'] = 'post'; $error = $this->_toggle_sticky( $data, true ); if ( $error ) { return $error; } } if ( isset( $content_struct['custom_fields'] ) ) { $this->set_custom_fields( $post_ID, $content_struct['custom_fields'] ); } if ( isset( $content_struct['wp_post_thumbnail'] ) ) { if ( empty( $content_struct['wp_post_thumbnail'] ) ) { delete_post_thumbnail( $post_ID ); } else { if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) { return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); } } unset( $content_struct['wp_post_thumbnail'] ); } $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null; $this->add_enclosure_if_new( $post_ID, $thisEnclosure ); $this->attach_uploads( $ID, $post_content ); if ( isset( $content_struct['wp_post_format'] ) ) { set_post_format( $post_ID, $content_struct['wp_post_format'] ); } do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args ); return true; } public function mw_getPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } $postdata = get_post( $post_ID, ARRAY_A ); if ( ! $postdata ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); if ( '' !== $postdata['post_date'] ) { $post_date = $this->_convert_date( $postdata['post_date'] ); $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); $post_modified = $this->_convert_date( $postdata['post_modified'] ); $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); $categories = array(); $catids = wp_get_post_categories( $post_ID ); foreach ( $catids as $catid ) { $categories[] = get_cat_name( $catid ); } $tagnames = array(); $tags = wp_get_post_tags( $post_ID ); if ( ! empty( $tags ) ) { foreach ( $tags as $tag ) { $tagnames[] = $tag->name; } $tagnames = implode( ', ', $tagnames ); } else { $tagnames = ''; } $post = get_extended( $postdata['post_content'] ); $link = get_permalink( $postdata['ID'] ); $author = get_userdata( $postdata['post_author'] ); $allow_comments = ( 'open' === $postdata['comment_status'] ) ? 1 : 0; $allow_pings = ( 'open' === $postdata['ping_status'] ) ? 1 : 0; if ( 'future' === $postdata['post_status'] ) { $postdata['post_status'] = 'publish'; } $post_format = get_post_format( $post_ID ); if ( empty( $post_format ) ) { $post_format = 'standard'; } $sticky = false; if ( is_sticky( $post_ID ) ) { $sticky = true; } $enclosure = array(); foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) { if ( 'enclosure' === $key ) { foreach ( (array) $val as $enc ) { $encdata = explode( "\n", $enc ); $enclosure['url'] = trim( htmlspecialchars( $encdata[0] ) ); $enclosure['length'] = (int) trim( $encdata[1] ); $enclosure['type'] = trim( $encdata[2] ); break 2; } } } $resp = array( 'dateCreated' => $post_date, 'userid' => $postdata['post_author'], 'postid' => $postdata['ID'], 'description' => $post['main'], 'title' => $postdata['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $postdata['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $postdata['post_name'], 'wp_password' => $postdata['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $postdata['post_status'], 'custom_fields' => $this->get_custom_fields( $post_ID ), 'wp_post_format' => $post_format, 'sticky' => $sticky, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt, ); if ( ! empty( $enclosure ) ) { $resp['enclosure'] = $enclosure; } $resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] ); return $resp; } else { return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); } } public function mw_getRecentPosts( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; if ( isset( $args[3] ) ) { $query = array( 'numberposts' => absint( $args[3] ) ); } else { $query = array(); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); } do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); $posts_list = wp_get_recent_posts( $query ); if ( ! $posts_list ) { return array(); } $recent_posts = array(); foreach ( $posts_list as $entry ) { if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) { continue; } $post_date = $this->_convert_date( $entry['post_date'] ); $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); $post_modified = $this->_convert_date( $entry['post_modified'] ); $post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] ); $categories = array(); $catids = wp_get_post_categories( $entry['ID'] ); foreach ( $catids as $catid ) { $categories[] = get_cat_name( $catid ); } $tagnames = array(); $tags = wp_get_post_tags( $entry['ID'] ); if ( ! empty( $tags ) ) { foreach ( $tags as $tag ) { $tagnames[] = $tag->name; } $tagnames = implode( ', ', $tagnames ); } else { $tagnames = ''; } $post = get_extended( $entry['post_content'] ); $link = get_permalink( $entry['ID'] ); $author = get_userdata( $entry['post_author'] ); $allow_comments = ( 'open' === $entry['comment_status'] ) ? 1 : 0; $allow_pings = ( 'open' === $entry['ping_status'] ) ? 1 : 0; if ( 'future' === $entry['post_status'] ) { $entry['post_status'] = 'publish'; } $post_format = get_post_format( $entry['ID'] ); if ( empty( $post_format ) ) { $post_format = 'standard'; } $recent_posts[] = array( 'dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields( $entry['ID'] ), 'wp_post_format' => $post_format, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt, 'sticky' => ( 'post' === $entry['post_type'] && is_sticky( $entry['ID'] ) ), 'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] ), ); } return $recent_posts; } public function mw_getCategories( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); } do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); $categories_struct = array(); $cats = get_categories( array( 'get' => 'all' ) ); if ( $cats ) { foreach ( $cats as $cat ) { $struct = array(); $struct['categoryId'] = $cat->term_id; $struct['parentId'] = $cat->parent; $struct['description'] = $cat->name; $struct['categoryDescription'] = $cat->description; $struct['categoryName'] = $cat->name; $struct['htmlUrl'] = esc_html( get_category_link( $cat->term_id ) ); $struct['rssUrl'] = esc_html( get_category_feed_link( $cat->term_id, 'rss2' ) ); $categories_struct[] = $struct; } } return $categories_struct; } public function mw_newMediaObject( $args ) { global $wpdb; $username = $this->escape( $args[1] ); $password = $this->escape( $args[2] ); $data = $args[3]; $name = sanitize_file_name( $data['name'] ); $type = $data['type']; $bits = $data['bits']; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); if ( ! current_user_can( 'upload_files' ) ) { $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); return $this->error; } if ( is_multisite() && upload_is_user_over_quota( false ) ) { $this->error = new IXR_Error( 401, sprintf( __( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ), size_format( get_space_allowed() * MB_IN_BYTES ) ) ); return $this->error; } $upload_err = apply_filters( 'pre_upload_error', false ); if ( $upload_err ) { return new IXR_Error( 500, $upload_err ); } $upload = wp_upload_bits( $name, null, $bits ); if ( ! empty( $upload['error'] ) ) { $errorString = sprintf( __( 'Could not write file %1$s (%2$s).' ), $name, $upload['error'] ); return new IXR_Error( 500, $errorString ); } $post_id = 0; if ( ! empty( $data['post_id'] ) ) { $post_id = (int) $data['post_id']; if ( ! current_user_can( 'edit_post', $post_id ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } } $attachment = array( 'post_title' => $name, 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => $type, 'guid' => $upload['url'], ); $id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args ); $struct = $this->_prepare_media_item( get_post( $id ) ); $struct['id'] = $struct['attachment_id']; $struct['file'] = $struct['title']; $struct['url'] = $struct['link']; return $struct; } public function mt_getRecentPostTitles( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; if ( isset( $args[3] ) ) { $query = array( 'numberposts' => absint( $args[3] ) ); } else { $query = array(); } $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); $posts_list = wp_get_recent_posts( $query ); if ( ! $posts_list ) { $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); return $this->error; } $recent_posts = array(); foreach ( $posts_list as $entry ) { if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) { continue; } $post_date = $this->_convert_date( $entry['post_date'] ); $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); $recent_posts[] = array( 'dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'title' => $entry['post_title'], 'post_status' => $entry['post_status'], 'date_created_gmt' => $post_date_gmt, ); } return $recent_posts; } public function mt_getCategoryList( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! current_user_can( 'edit_posts' ) ) { return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); } do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); $categories_struct = array(); $cats = get_categories( array( 'hide_empty' => 0, 'hierarchical' => 0, ) ); if ( $cats ) { foreach ( $cats as $cat ) { $struct = array(); $struct['categoryId'] = $cat->term_id; $struct['categoryName'] = $cat->name; $categories_struct[] = $struct; } } return $categories_struct; } public function mt_getPostCategories( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } if ( ! get_post( $post_ID ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); $categories = array(); $catids = wp_get_post_categories( (int) $post_ID ); $isPrimary = true; foreach ( $catids as $catid ) { $categories[] = array( 'categoryName' => get_cat_name( $catid ), 'categoryId' => (string) $catid, 'isPrimary' => $isPrimary, ); $isPrimary = false; } return $categories; } public function mt_setPostCategories( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $categories = $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); if ( ! get_post( $post_ID ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } $catids = array(); foreach ( $categories as $cat ) { $catids[] = $cat['categoryId']; } wp_set_post_categories( $post_ID, $catids ); return true; } public function mt_supportedMethods() { do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); return array_keys( $this->methods ); } public function mt_supportedTextFilters() { do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); return apply_filters( 'xmlrpc_text_filters', array() ); } public function mt_getTrackbackPings( $post_ID ) { global $wpdb; do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this ); $actual_post = get_post( $post_ID, ARRAY_A ); if ( ! $actual_post ) { return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); } $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID ) ); if ( ! $comments ) { return array(); } $trackback_pings = array(); foreach ( $comments as $comment ) { if ( 'trackback' === $comment->comment_type ) { $content = $comment->comment_content; $title = substr( $content, 8, ( strpos( $content, '' ) - 8 ) ); $trackback_pings[] = array( 'pingTitle' => $title, 'pingURL' => $comment->comment_author_url, 'pingIP' => $comment->comment_author_IP, ); } } return $trackback_pings; } public function mt_publishPost( $args ) { $this->escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); $postdata = get_post( $post_ID, ARRAY_A ); if ( ! $postdata ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); } $postdata['post_status'] = 'publish'; $postdata['post_category'] = wp_get_post_categories( $post_ID ); $this->escape( $postdata ); return wp_update_post( $postdata ); } public function pingback_ping( $args ) { global $wpdb; do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); $this->escape( $args ); $pagelinkedfrom = str_replace( '&', '&', $args[0] ); $pagelinkedto = str_replace( '&', '&', $args[1] ); $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); $pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto ); if ( ! $pagelinkedfrom ) { return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) ); } $pos1 = strpos( $pagelinkedto, str_replace( array( 'http://www.', 'http://', 'https://www.', 'https://' ), '', get_option( 'home' ) ) ); if ( ! $pos1 ) { return $this->pingback_error( 0, __( 'Is there no link to us?' ) ); } $urltest = parse_url( $pagelinkedto ); $post_ID = url_to_postid( $pagelinkedto ); if ( $post_ID ) { } elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) { $blah = explode( '/', $match[0] ); $post_ID = (int) $blah[1]; } elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) { $blah = explode( '=', $match[0] ); $post_ID = (int) $blah[1]; } elseif ( isset( $urltest['fragment'] ) ) { if ( (int) $urltest['fragment'] ) { $post_ID = (int) $urltest['fragment']; } elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) { $post_ID = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] ); } elseif ( is_string( $urltest['fragment'] ) ) { $title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] ); $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title ); $post_ID = $wpdb->get_var( $sql ); if ( ! $post_ID ) { return $this->pingback_error( 0, '' ); } } } else { return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); } $post_ID = (int) $post_ID; $post = get_post( $post_ID ); if ( ! $post ) { return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); } if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) { return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); } if ( ! pings_open( $post ) ) { return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); } if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) { return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); } sleep( 1 ); $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom ); $http_api_args = array( 'timeout' => 10, 'redirection' => 0, 'limit_response_size' => 153600, 'user-agent' => "$user_agent; verifying pingback from $remote_ip", 'headers' => array( 'X-Pingback-Forwarded-For' => $remote_ip, ), ); $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args ); $remote_source = wp_remote_retrieve_body( $request ); $remote_source_original = $remote_source; if ( ! $remote_source ) { return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); } $remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto ); $remote_source = str_replace( ']*>/', "\n\n", $remote_source ); preg_match( '|([^<]*?)|is', $remote_source, $matchtitle ); $title = isset( $matchtitle[1] ) ? $matchtitle[1] : ''; if ( empty( $title ) ) { return $this->pingback_error( 32, __( 'A title on that page cannot be found.' ) ); } $remote_source = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $remote_source ); $remote_source = strip_tags( $remote_source, '' ); $p = explode( "\n\n", $remote_source ); $preg_target = preg_quote( $pagelinkedto, '|' ); foreach ( $p as $para ) { if ( strpos( $para, $pagelinkedto ) !== false ) { preg_match( '|]+?' . $preg_target . '[^>]*>([^>]+?)|', $para, $context ); if ( empty( $context ) ) { continue; } $excerpt = preg_replace( '|\|', '', $para ); if ( strlen( $context[1] ) > 100 ) { $context[1] = substr( $context[1], 0, 100 ) . '…'; } $marker = '' . $context[1] . ''; $excerpt = str_replace( $context[0], $marker, $excerpt ); $excerpt = strip_tags( $excerpt, '' ); $excerpt = trim( $excerpt ); $preg_marker = preg_quote( $marker, '|' ); $excerpt = preg_replace( "|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt ); $excerpt = strip_tags( $excerpt ); break; } } if ( empty( $context ) ) { return $this->pingback_error( 17, __( 'The source URL does not contain a link to the target URL, and so cannot be used as a source.' ) ); } $pagelinkedfrom = str_replace( '&', '&', $pagelinkedfrom ); $context = '[…] ' . esc_html( $excerpt ) . ' […]'; $pagelinkedfrom = $this->escape( $pagelinkedfrom ); $comment_post_id = (int) $post_ID; $comment_author = $title; $comment_author_email = ''; $this->escape( $comment_author ); $comment_author_url = $pagelinkedfrom; $comment_content = $context; $this->escape( $comment_content ); $comment_type = 'pingback'; $commentdata = array( 'comment_post_ID' => $comment_post_id, ); $commentdata += compact( 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type', 'remote_source', 'remote_source_original' ); $comment_ID = wp_new_comment( $commentdata ); if ( is_wp_error( $comment_ID ) ) { return $this->pingback_error( 0, $comment_ID->get_error_message() ); } do_action( 'pingback_post', $comment_ID ); return sprintf( __( 'Pingback from %1$s to %2$s registered. Keep the web talking! :-)' ), $pagelinkedfrom, $pagelinkedto ); } public function pingback_extensions_getPingbacks( $url ) { global $wpdb; do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); $url = $this->escape( $url ); $post_ID = url_to_postid( $url ); if ( ! $post_ID ) { return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); } $actual_post = get_post( $post_ID, ARRAY_A ); if ( ! $actual_post ) { return $this->pingback_error( 32, __( 'The specified target URL does not exist.' ) ); } $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID ) ); if ( ! $comments ) { return array(); } $pingbacks = array(); foreach ( $comments as $comment ) { if ( 'pingback' === $comment->comment_type ) { $pingbacks[] = $comment->comment_author_url; } } return $pingbacks; } protected function pingback_error( $code, $message ) { return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) ); } } public_query_vars, true ) ) { $this->public_query_vars[] = $qv; } } public function remove_query_var( $name ) { $this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) ); } public function set_query_var( $key, $value ) { $this->query_vars[ $key ] = $value; } public function parse_request( $extra_query_vars = '' ) { global $wp_rewrite; if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) { return false; } $this->query_vars = array(); $post_type_query_vars = array(); if ( is_array( $extra_query_vars ) ) { $this->extra_query_vars = & $extra_query_vars; } elseif ( ! empty( $extra_query_vars ) ) { parse_str( $extra_query_vars, $this->extra_query_vars ); } $rewrite = $wp_rewrite->wp_rewrite_rules(); if ( ! empty( $rewrite ) ) { $error = '404'; $this->did_permalink = true; $pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : ''; list( $pathinfo ) = explode( '?', $pathinfo ); $pathinfo = str_replace( '%', '%25', $pathinfo ); list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); $self = $_SERVER['PHP_SELF']; $home_path = parse_url( home_url(), PHP_URL_PATH ); $home_path_regex = ''; if ( is_string( $home_path ) && '' !== $home_path ) { $home_path = trim( $home_path, '/' ); $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); } $req_uri = str_replace( $pathinfo, '', $req_uri ); $req_uri = trim( $req_uri, '/' ); $pathinfo = trim( $pathinfo, '/' ); $self = trim( $self, '/' ); if ( ! empty( $home_path_regex ) ) { $req_uri = preg_replace( $home_path_regex, '', $req_uri ); $req_uri = trim( $req_uri, '/' ); $pathinfo = preg_replace( $home_path_regex, '', $pathinfo ); $pathinfo = trim( $pathinfo, '/' ); $self = preg_replace( $home_path_regex, '', $self ); $self = trim( $self, '/' ); } if ( ! empty( $pathinfo ) && ! preg_match( '|^.*' . $wp_rewrite->index . '$|', $pathinfo ) ) { $requested_path = $pathinfo; } else { if ( $req_uri == $wp_rewrite->index ) { $req_uri = ''; } $requested_path = $req_uri; } $requested_file = $req_uri; $this->request = $requested_path; $request_match = $requested_path; if ( empty( $request_match ) ) { if ( isset( $rewrite['$'] ) ) { $this->matched_rule = '$'; $query = $rewrite['$']; $matches = array( '' ); } } else { foreach ( (array) $rewrite as $match => $query ) { if ( ! empty( $requested_file ) && strpos( $match, $requested_file ) === 0 && $requested_file != $requested_path ) { $request_match = $requested_file . '/' . $requested_path; } if ( preg_match( "#^$match#", $request_match, $matches ) || preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) { if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { $page = get_page_by_path( $matches[ $varmatch[1] ] ); if ( ! $page ) { continue; } $post_status_obj = get_post_status_object( $page->post_status ); if ( ! $post_status_obj->public && ! $post_status_obj->protected && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) { continue; } } $this->matched_rule = $match; break; } } } if ( ! empty( $this->matched_rule ) ) { $query = preg_replace( '!^.+\?!', '', $query ); $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) ); $this->matched_query = $query; parse_str( $query, $perma_query_vars ); if ( '404' == $error ) { unset( $error, $_GET['error'] ); } } if ( empty( $requested_path ) || $requested_file == $self || strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) { unset( $error, $_GET['error'] ); if ( isset( $perma_query_vars ) && strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) { unset( $perma_query_vars ); } $this->did_permalink = false; } } $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars ); foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) { if ( is_post_type_viewable( $t ) && $t->query_var ) { $post_type_query_vars[ $t->query_var ] = $post_type; } } foreach ( $this->public_query_vars as $wpvar ) { if ( isset( $this->extra_query_vars[ $wpvar ] ) ) { $this->query_vars[ $wpvar ] = $this->extra_query_vars[ $wpvar ]; } elseif ( isset( $_GET[ $wpvar ] ) && isset( $_POST[ $wpvar ] ) && $_GET[ $wpvar ] !== $_POST[ $wpvar ] ) { wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 ); } elseif ( isset( $_POST[ $wpvar ] ) ) { $this->query_vars[ $wpvar ] = $_POST[ $wpvar ]; } elseif ( isset( $_GET[ $wpvar ] ) ) { $this->query_vars[ $wpvar ] = $_GET[ $wpvar ]; } elseif ( isset( $perma_query_vars[ $wpvar ] ) ) { $this->query_vars[ $wpvar ] = $perma_query_vars[ $wpvar ]; } if ( ! empty( $this->query_vars[ $wpvar ] ) ) { if ( ! is_array( $this->query_vars[ $wpvar ] ) ) { $this->query_vars[ $wpvar ] = (string) $this->query_vars[ $wpvar ]; } else { foreach ( $this->query_vars[ $wpvar ] as $vkey => $v ) { if ( is_scalar( $v ) ) { $this->query_vars[ $wpvar ][ $vkey ] = (string) $v; } } } if ( isset( $post_type_query_vars[ $wpvar ] ) ) { $this->query_vars['post_type'] = $post_type_query_vars[ $wpvar ]; $this->query_vars['name'] = $this->query_vars[ $wpvar ]; } } } foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) { if ( $t->query_var && isset( $this->query_vars[ $t->query_var ] ) ) { $this->query_vars[ $t->query_var ] = str_replace( ' ', '+', $this->query_vars[ $t->query_var ] ); } } if ( ! is_admin() ) { foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); } } } if ( isset( $this->query_vars['post_type'] ) ) { $queryable_post_types = get_post_types( array( 'publicly_queryable' => true ) ); if ( ! is_array( $this->query_vars['post_type'] ) ) { if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types, true ) ) { unset( $this->query_vars['post_type'] ); } } else { $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); } } $this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars ); foreach ( (array) $this->private_query_vars as $var ) { if ( isset( $this->extra_query_vars[ $var ] ) ) { $this->query_vars[ $var ] = $this->extra_query_vars[ $var ]; } } if ( isset( $error ) ) { $this->query_vars['error'] = $error; } $this->query_vars = apply_filters( 'request', $this->query_vars ); do_action_ref_array( 'parse_request', array( &$this ) ); return true; } public function send_headers() { global $wp_query; $headers = array(); $status = null; $exit_required = false; $date_format = 'D, d M Y H:i:s'; if ( is_user_logged_in() ) { $headers = array_merge( $headers, wp_get_nocache_headers() ); } elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) { $expires = 10 * MINUTE_IN_SECONDS; $headers['Expires'] = gmdate( $date_format, time() + $expires ); $headers['Cache-Control'] = sprintf( 'max-age=%d, must-revalidate', $expires ); } if ( ! empty( $this->query_vars['error'] ) ) { $status = (int) $this->query_vars['error']; if ( 404 === $status ) { if ( ! is_user_logged_in() ) { $headers = array_merge( $headers, wp_get_nocache_headers() ); } $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ); } elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) { $exit_required = true; } } elseif ( empty( $this->query_vars['feed'] ) ) { $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ); } else { $type = $this->query_vars['feed']; if ( 'feed' === $this->query_vars['feed'] ) { $type = get_default_feed(); } $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); if ( ! empty( $this->query_vars['withcomments'] ) || false !== strpos( $this->query_vars['feed'], 'comments-' ) || ( empty( $this->query_vars['withoutcomments'] ) && ( ! empty( $this->query_vars['p'] ) || ! empty( $this->query_vars['name'] ) || ! empty( $this->query_vars['page_id'] ) || ! empty( $this->query_vars['pagename'] ) || ! empty( $this->query_vars['attachment'] ) || ! empty( $this->query_vars['attachment_id'] ) ) ) ) { $wp_last_modified_post = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false ); $wp_last_modified_comment = mysql2date( $date_format, get_lastcommentmodified( 'GMT' ), false ); if ( strtotime( $wp_last_modified_post ) > strtotime( $wp_last_modified_comment ) ) { $wp_last_modified = $wp_last_modified_post; } else { $wp_last_modified = $wp_last_modified_comment; } } else { $wp_last_modified = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false ); } if ( ! $wp_last_modified ) { $wp_last_modified = gmdate( $date_format ); } $wp_last_modified .= ' GMT'; $wp_etag = '"' . md5( $wp_last_modified ) . '"'; $headers['Last-Modified'] = $wp_last_modified; $headers['ETag'] = $wp_etag; if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); } else { $client_etag = false; } $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; $wp_modified_timestamp = strtotime( $wp_last_modified ); if ( ( $client_last_modified && $client_etag ) ? ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag == $wp_etag ) ) : ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag == $wp_etag ) ) ) { $status = 304; $exit_required = true; } } if ( is_singular() ) { $post = isset( $wp_query->post ) ? $wp_query->post : null; if ( $post && pings_open( $post ) ) { $headers['X-Pingback'] = get_bloginfo( 'pingback_url', 'display' ); } } $headers = apply_filters( 'wp_headers', $headers, $this ); if ( ! empty( $status ) ) { status_header( $status ); } if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) { unset( $headers['Last-Modified'] ); if ( ! headers_sent() ) { header_remove( 'Last-Modified' ); } } if ( ! headers_sent() ) { foreach ( (array) $headers as $name => $field_value ) { header( "{$name}: {$field_value}" ); } } if ( $exit_required ) { exit; } do_action_ref_array( 'send_headers', array( &$this ) ); } public function build_query_string() { $this->query_string = ''; foreach ( (array) array_keys( $this->query_vars ) as $wpvar ) { if ( '' != $this->query_vars[ $wpvar ] ) { $this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&'; if ( ! is_scalar( $this->query_vars[ $wpvar ] ) ) { continue; } $this->query_string .= $wpvar . '=' . rawurlencode( $this->query_vars[ $wpvar ] ); } } if ( has_filter( 'query_string' ) ) { $this->query_string = apply_filters_deprecated( 'query_string', array( $this->query_string ), '2.1.0', 'query_vars, request' ); parse_str( $this->query_string, $this->query_vars ); } } public function register_globals() { global $wp_query; foreach ( (array) $wp_query->query_vars as $key => $value ) { $GLOBALS[ $key ] = $value; } $GLOBALS['query_string'] = $this->query_string; $GLOBALS['posts'] = & $wp_query->posts; $GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null; $GLOBALS['request'] = $wp_query->request; if ( $wp_query->is_single() || $wp_query->is_page() ) { $GLOBALS['more'] = 1; $GLOBALS['single'] = 1; } if ( $wp_query->is_author() ) { $GLOBALS['authordata'] = get_userdata( get_queried_object_id() ); } } public function init() { wp_get_current_user(); } public function query_posts() { global $wp_the_query; $this->build_query_string(); $wp_the_query->query( $this->query_vars ); } public function handle_404() { global $wp_query; if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) { return; } if ( is_404() ) { return; } $set_404 = true; if ( is_admin() || is_robots() || is_favicon() ) { $set_404 = false; } elseif ( $wp_query->posts ) { $content_found = true; if ( is_singular() ) { $post = isset( $wp_query->post ) ? $wp_query->post : null; $next = ''; if ( $post && ! empty( $this->query_vars['page'] ) ) { if ( false !== strpos( $post->post_content, $next ) ) { $page = trim( $this->query_vars['page'], '/' ); $content_found = (int) $page <= ( substr_count( $post->post_content, $next ) + 1 ); } else { $content_found = false; } } } if ( $wp_query->is_posts_page && ! empty( $this->query_vars['page'] ) ) { $content_found = false; } if ( $content_found ) { $set_404 = false; } } elseif ( ! is_paged() ) { $author = get_query_var( 'author' ); if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author ) || ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object() || is_home() || is_search() || is_feed() ) { $set_404 = false; } } if ( $set_404 ) { $wp_query->set_404(); status_header( 404 ); nocache_headers(); } else { status_header( 200 ); } } public function main( $query_args = '' ) { $this->init(); $parsed = $this->parse_request( $query_args ); if ( $parsed ) { $this->query_posts(); $this->handle_404(); $this->register_globals(); } $this->send_headers(); do_action_ref_array( 'wp', array( &$this ) ); } } show_errors(); } if ( function_exists( 'mysqli_connect' ) ) { $this->use_mysqli = true; if ( defined( 'WP_USE_EXT_MYSQL' ) ) { $this->use_mysqli = ! WP_USE_EXT_MYSQL; } } $this->dbuser = $dbuser; $this->dbpassword = $dbpassword; $this->dbname = $dbname; $this->dbhost = $dbhost; if ( defined( 'WP_SETUP_CONFIG' ) ) { return; } $this->db_connect(); } public function __get( $name ) { if ( 'col_info' === $name ) { $this->load_col_info(); } return $this->$name; } public function __set( $name, $value ) { $protected_members = array( 'col_meta', 'table_charset', 'check_current_query', ); if ( in_array( $name, $protected_members, true ) ) { return; } $this->$name = $value; } public function __isset( $name ) { return isset( $this->$name ); } public function __unset( $name ) { unset( $this->$name ); } public function init_charset() { $charset = ''; $collate = ''; if ( function_exists( 'is_multisite' ) && is_multisite() ) { $charset = 'utf8'; if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) { $collate = DB_COLLATE; } else { $collate = 'utf8_general_ci'; } } elseif ( defined( 'DB_COLLATE' ) ) { $collate = DB_COLLATE; } if ( defined( 'DB_CHARSET' ) ) { $charset = DB_CHARSET; } $charset_collate = $this->determine_charset( $charset, $collate ); $this->charset = $charset_collate['charset']; $this->collate = $charset_collate['collate']; } public function determine_charset( $charset, $collate ) { if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) { return compact( 'charset', 'collate' ); } if ( 'utf8' === $charset && $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8mb4'; } if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8'; $collate = str_replace( 'utf8mb4_', 'utf8_', $collate ); } if ( 'utf8mb4' === $charset ) { if ( ! $collate || 'utf8_general_ci' === $collate ) { $collate = 'utf8mb4_unicode_ci'; } else { $collate = str_replace( 'utf8_', 'utf8mb4_', $collate ); } } if ( $this->has_cap( 'utf8mb4_520' ) && 'utf8mb4_unicode_ci' === $collate ) { $collate = 'utf8mb4_unicode_520_ci'; } return compact( 'charset', 'collate' ); } public function set_charset( $dbh, $charset = null, $collate = null ) { if ( ! isset( $charset ) ) { $charset = $this->charset; } if ( ! isset( $collate ) ) { $collate = $this->collate; } if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) { $set_charset_succeeded = true; if ( $this->use_mysqli ) { if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) { $set_charset_succeeded = mysqli_set_charset( $dbh, $charset ); } if ( $set_charset_succeeded ) { $query = $this->prepare( 'SET NAMES %s', $charset ); if ( ! empty( $collate ) ) { $query .= $this->prepare( ' COLLATE %s', $collate ); } mysqli_query( $dbh, $query ); } } else { if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) { $set_charset_succeeded = mysql_set_charset( $charset, $dbh ); } if ( $set_charset_succeeded ) { $query = $this->prepare( 'SET NAMES %s', $charset ); if ( ! empty( $collate ) ) { $query .= $this->prepare( ' COLLATE %s', $collate ); } mysql_query( $query, $dbh ); } } } } public function set_sql_mode( $modes = array() ) { if ( empty( $modes ) ) { if ( $this->use_mysqli ) { $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' ); } else { $res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh ); } if ( empty( $res ) ) { return; } if ( $this->use_mysqli ) { $modes_array = mysqli_fetch_array( $res ); if ( empty( $modes_array[0] ) ) { return; } $modes_str = $modes_array[0]; } else { $modes_str = mysql_result( $res, 0 ); } if ( empty( $modes_str ) ) { return; } $modes = explode( ',', $modes_str ); } $modes = array_change_key_case( $modes, CASE_UPPER ); $incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes ); foreach ( $modes as $i => $mode ) { if ( in_array( $mode, $incompatible_modes, true ) ) { unset( $modes[ $i ] ); } } $modes_str = implode( ',', $modes ); if ( $this->use_mysqli ) { mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" ); } else { mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh ); } } public function set_prefix( $prefix, $set_table_names = true ) { if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) { return new WP_Error( 'invalid_db_prefix', 'Invalid database prefix' ); } $old_prefix = is_multisite() ? '' : $prefix; if ( isset( $this->base_prefix ) ) { $old_prefix = $this->base_prefix; } $this->base_prefix = $prefix; if ( $set_table_names ) { foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } if ( is_multisite() && empty( $this->blogid ) ) { return $old_prefix; } $this->prefix = $this->get_blog_prefix(); foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } } return $old_prefix; } public function set_blog_id( $blog_id, $network_id = 0 ) { if ( ! empty( $network_id ) ) { $this->siteid = $network_id; } $old_blog_id = $this->blogid; $this->blogid = $blog_id; $this->prefix = $this->get_blog_prefix(); foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } return $old_blog_id; } public function get_blog_prefix( $blog_id = null ) { if ( is_multisite() ) { if ( null === $blog_id ) { $blog_id = $this->blogid; } $blog_id = (int) $blog_id; if ( defined( 'MULTISITE' ) && ( 0 === $blog_id || 1 === $blog_id ) ) { return $this->base_prefix; } else { return $this->base_prefix . $blog_id . '_'; } } else { return $this->base_prefix; } } public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { switch ( $scope ) { case 'all': $tables = array_merge( $this->global_tables, $this->tables ); if ( is_multisite() ) { $tables = array_merge( $tables, $this->ms_global_tables ); } break; case 'blog': $tables = $this->tables; break; case 'global': $tables = $this->global_tables; if ( is_multisite() ) { $tables = array_merge( $tables, $this->ms_global_tables ); } break; case 'ms_global': $tables = $this->ms_global_tables; break; case 'old': $tables = $this->old_tables; if ( is_multisite() ) { $tables = array_merge( $tables, $this->old_ms_global_tables ); } break; default: return array(); } if ( $prefix ) { if ( ! $blog_id ) { $blog_id = $this->blogid; } $blog_prefix = $this->get_blog_prefix( $blog_id ); $base_prefix = $this->base_prefix; $global_tables = array_merge( $this->global_tables, $this->ms_global_tables ); foreach ( $tables as $k => $table ) { if ( in_array( $table, $global_tables, true ) ) { $tables[ $table ] = $base_prefix . $table; } else { $tables[ $table ] = $blog_prefix . $table; } unset( $tables[ $k ] ); } if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) { $tables['users'] = CUSTOM_USER_TABLE; } if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) ) { $tables['usermeta'] = CUSTOM_USER_META_TABLE; } } return $tables; } public function select( $db, $dbh = null ) { if ( is_null( $dbh ) ) { $dbh = $this->dbh; } if ( $this->use_mysqli ) { $success = mysqli_select_db( $dbh, $db ); } else { $success = mysql_select_db( $db, $dbh ); } if ( ! $success ) { $this->ready = false; if ( ! did_action( 'template_redirect' ) ) { wp_load_translations_early(); $message = '

    ' . __( 'Cannot select database' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'The database server could be connected to (which means your username and password is okay) but the %s database could not be selected.' ), '' . htmlspecialchars( $db, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure it exists?' ) . "
    • \n"; $message .= '
    • ' . sprintf( __( 'Does the user %1$s have permission to use the %2$s database?' ), '' . htmlspecialchars( $this->dbuser, ENT_QUOTES ) . '', '' . htmlspecialchars( $db, ENT_QUOTES ) . '' ) . "
    • \n"; $message .= '
    • ' . sprintf( __( 'On some systems the name of your database is prefixed with your username, so it would be like username_%1$s. Could that be the problem?' ), htmlspecialchars( $db, ENT_QUOTES ) ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you do not know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_select_fail' ); } } } public function _weak_escape( $data ) { if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) { _deprecated_function( __METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()' ); } return addslashes( $data ); } public function _real_escape( $data ) { if ( ! is_scalar( $data ) ) { return ''; } if ( $this->dbh ) { if ( $this->use_mysqli ) { $escaped = mysqli_real_escape_string( $this->dbh, $data ); } else { $escaped = mysql_real_escape_string( $data, $this->dbh ); } } else { $class = get_class( $this ); wp_load_translations_early(); _doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' ); $escaped = addslashes( $data ); } return $this->add_placeholder_escape( $escaped ); } public function _escape( $data ) { if ( is_array( $data ) ) { foreach ( $data as $k => $v ) { if ( is_array( $v ) ) { $data[ $k ] = $this->_escape( $v ); } else { $data[ $k ] = $this->_real_escape( $v ); } } } else { $data = $this->_real_escape( $data ); } return $data; } public function escape( $data ) { if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) { _deprecated_function( __METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()' ); } if ( is_array( $data ) ) { foreach ( $data as $k => $v ) { if ( is_array( $v ) ) { $data[ $k ] = $this->escape( $v, 'recursive' ); } else { $data[ $k ] = $this->_weak_escape( $v, 'internal' ); } } } else { $data = $this->_weak_escape( $data, 'internal' ); } return $data; } public function escape_by_ref( &$data ) { if ( ! is_float( $data ) ) { $data = $this->_real_escape( $data ); } } public function prepare( $query, ...$args ) { if ( is_null( $query ) ) { return; } if ( strpos( $query, '%' ) === false ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9.0' ); } $passed_as_array = false; if ( isset( $args[0] ) && is_array( $args[0] ) && 1 === count( $args ) ) { $passed_as_array = true; $args = $args[0]; } foreach ( $args as $arg ) { if ( ! is_scalar( $arg ) && ! is_null( $arg ) ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'Unsupported value type (%s).' ), gettype( $arg ) ), '4.8.2' ); } } $allowed_format = '(?:[1-9][0-9]*[$])?[-+0-9]*(?: |0|\'.)?[-+0-9]*(?:\.[0-9]+)?'; $query = str_replace( "'%s'", '%s', $query ); $query = str_replace( '"%s"', '%s', $query ); $query = preg_replace( '/(?add_placeholder_escape( $query ); } public function esc_like( $text ) { return addcslashes( $text, '_%\\' ); } public function print_error( $str = '' ) { global $EZSQL_ERROR; if ( ! $str ) { if ( $this->use_mysqli ) { $str = mysqli_error( $this->dbh ); } else { $str = mysql_error( $this->dbh ); } } $EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str, ); if ( $this->suppress_errors ) { return false; } $caller = $this->get_caller(); if ( $caller ) { $error_str = sprintf( 'WordPress database error %1$s for query %2$s made by %3$s', $str, $this->last_query, $caller ); } else { $error_str = sprintf( 'WordPress database error %1$s for query %2$s', $str, $this->last_query ); } error_log( $error_str ); if ( ! $this->show_errors ) { return false; } wp_load_translations_early(); if ( is_multisite() ) { $msg = sprintf( "%s [%s]\n%s\n", __( 'WordPress database error:' ), $str, $this->last_query ); if ( defined( 'ERRORLOGFILE' ) ) { error_log( $msg, 3, ERRORLOGFILE ); } if ( defined( 'DIEONDBERROR' ) ) { wp_die( $msg ); } } else { $str = htmlspecialchars( $str, ENT_QUOTES ); $query = htmlspecialchars( $this->last_query, ENT_QUOTES ); printf( '

    %s [%s]
    %s

    ', __( 'WordPress database error:' ), $str, $query ); } } public function show_errors( $show = true ) { $errors = $this->show_errors; $this->show_errors = $show; return $errors; } public function hide_errors() { $show = $this->show_errors; $this->show_errors = false; return $show; } public function suppress_errors( $suppress = true ) { $errors = $this->suppress_errors; $this->suppress_errors = (bool) $suppress; return $errors; } public function flush() { $this->last_result = array(); $this->col_info = null; $this->last_query = null; $this->rows_affected = 0; $this->num_rows = 0; $this->last_error = ''; if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { mysqli_free_result( $this->result ); $this->result = null; if ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) { return; } while ( mysqli_more_results( $this->dbh ) ) { mysqli_next_result( $this->dbh ); } } elseif ( is_resource( $this->result ) ) { mysql_free_result( $this->result ); } } public function db_connect( $allow_bail = true ) { $this->is_mysql = true; $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true; $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; if ( $this->use_mysqli ) { mysqli_report( MYSQLI_REPORT_OFF ); $this->dbh = mysqli_init(); $host = $this->dbhost; $port = null; $socket = null; $is_ipv6 = false; $host_data = $this->parse_db_host( $this->dbhost ); if ( $host_data ) { list( $host, $port, $socket, $is_ipv6 ) = $host_data; } if ( $is_ipv6 && extension_loaded( 'mysqlnd' ) ) { $host = "[$host]"; } if ( WP_DEBUG ) { mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); } else { @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); } if ( $this->dbh->connect_errno ) { $this->dbh = null; $attempt_fallback = true; if ( $this->has_connected ) { $attempt_fallback = false; } elseif ( defined( 'WP_USE_EXT_MYSQL' ) && ! WP_USE_EXT_MYSQL ) { $attempt_fallback = false; } elseif ( ! function_exists( 'mysql_connect' ) ) { $attempt_fallback = false; } if ( $attempt_fallback ) { $this->use_mysqli = false; return $this->db_connect( $allow_bail ); } } } else { if ( WP_DEBUG ) { $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); } else { $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); } } if ( ! $this->dbh && $allow_bail ) { wp_load_translations_early(); if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once WP_CONTENT_DIR . '/db-error.php'; die(); } $message = '

    ' . __( 'Error establishing a database connection' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'This either means that the username and password information in your %1$s file is incorrect or that contact with the database server at %2$s could not be established. This could mean your host’s database server is down.' ), 'wp-config.php', '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure you have the correct username and password?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure you have typed the correct hostname?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure the database server is running?' ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_connect_fail' ); return false; } elseif ( $this->dbh ) { if ( ! $this->has_connected ) { $this->init_charset(); } $this->has_connected = true; $this->set_charset( $this->dbh ); $this->ready = true; $this->set_sql_mode(); $this->select( $this->dbname, $this->dbh ); return true; } return false; } public function parse_db_host( $host ) { $socket = null; $is_ipv6 = false; $socket_pos = strpos( $host, ':/' ); if ( false !== $socket_pos ) { $socket = substr( $host, $socket_pos + 1 ); $host = substr( $host, 0, $socket_pos ); } if ( substr_count( $host, ':' ) > 1 ) { $pattern = '#^(?:\[)?(?P[0-9a-fA-F:]+)(?:\]:(?P[\d]+))?#'; $is_ipv6 = true; } else { $pattern = '#^(?P[^:/]*)(?::(?P[\d]+))?#'; } $matches = array(); $result = preg_match( $pattern, $host, $matches ); if ( 1 !== $result ) { return false; } $host = ! empty( $matches['host'] ) ? $matches['host'] : ''; $port = ! empty( $matches['port'] ) ? absint( $matches['port'] ) : null; return array( $host, $port, $socket, $is_ipv6 ); } public function check_connection( $allow_bail = true ) { if ( $this->use_mysqli ) { if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) { return true; } } else { if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) { return true; } } $error_reporting = false; if ( WP_DEBUG ) { $error_reporting = error_reporting(); error_reporting( $error_reporting & ~E_WARNING ); } for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) { if ( $this->reconnect_retries === $tries && WP_DEBUG ) { error_reporting( $error_reporting ); } if ( $this->db_connect( false ) ) { if ( $error_reporting ) { error_reporting( $error_reporting ); } return true; } sleep( 1 ); } if ( did_action( 'template_redirect' ) ) { return false; } if ( ! $allow_bail ) { return false; } wp_load_translations_early(); $message = '

    ' . __( 'Error reconnecting to the database' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'This means that the contact with the database server at %s was lost. This could mean your host’s database server is down.' ), '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure the database server is running?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure the database server is not under particularly heavy load?' ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_connect_fail' ); dead_db(); } public function query( $query ) { if ( ! $this->ready ) { $this->check_current_query = true; return false; } $query = apply_filters( 'query', $query ); if ( ! $query ) { $this->insert_id = 0; return false; } $this->flush(); $this->func_call = "\$db->query(\"$query\")"; if ( $this->check_current_query && ! $this->check_ascii( $query ) ) { $stripped_query = $this->strip_invalid_text_from_query( $query ); $this->flush(); if ( $stripped_query !== $query ) { $this->insert_id = 0; $this->last_query = $query; wp_load_translations_early(); $this->last_error = __( 'WordPress database error: Could not perform query because it contains invalid data.' ); return false; } } $this->check_current_query = true; $this->last_query = $query; $this->_do_query( $query ); $mysql_errno = 0; if ( ! empty( $this->dbh ) ) { if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $mysql_errno = mysqli_errno( $this->dbh ); } else { $mysql_errno = 2006; } } else { if ( is_resource( $this->dbh ) ) { $mysql_errno = mysql_errno( $this->dbh ); } else { $mysql_errno = 2006; } } } if ( empty( $this->dbh ) || 2006 === $mysql_errno ) { if ( $this->check_connection() ) { $this->_do_query( $query ); } else { $this->insert_id = 0; return false; } } if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $this->last_error = mysqli_error( $this->dbh ); } else { $this->last_error = __( 'Unable to retrieve the error message from MySQL' ); } } else { if ( is_resource( $this->dbh ) ) { $this->last_error = mysql_error( $this->dbh ); } else { $this->last_error = __( 'Unable to retrieve the error message from MySQL' ); } } if ( $this->last_error ) { if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { $this->insert_id = 0; } $this->print_error(); return false; } if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) { $return_val = $this->result; } elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) { if ( $this->use_mysqli ) { $this->rows_affected = mysqli_affected_rows( $this->dbh ); } else { $this->rows_affected = mysql_affected_rows( $this->dbh ); } if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { if ( $this->use_mysqli ) { $this->insert_id = mysqli_insert_id( $this->dbh ); } else { $this->insert_id = mysql_insert_id( $this->dbh ); } } $return_val = $this->rows_affected; } else { $num_rows = 0; if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { while ( $row = mysqli_fetch_object( $this->result ) ) { $this->last_result[ $num_rows ] = $row; $num_rows++; } } elseif ( is_resource( $this->result ) ) { while ( $row = mysql_fetch_object( $this->result ) ) { $this->last_result[ $num_rows ] = $row; $num_rows++; } } $this->num_rows = $num_rows; $return_val = $num_rows; } return $return_val; } private function _do_query( $query ) { if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { $this->timer_start(); } if ( ! empty( $this->dbh ) && $this->use_mysqli ) { $this->result = mysqli_query( $this->dbh, $query ); } elseif ( ! empty( $this->dbh ) ) { $this->result = mysql_query( $query, $this->dbh ); } $this->num_queries++; if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { $this->log_query( $query, $this->timer_stop(), $this->get_caller(), $this->time_start, array() ); } } public function log_query( $query, $query_time, $query_callstack, $query_start, $query_data ) { $query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start ); $this->queries[] = array( $query, $query_time, $query_callstack, $query_start, $query_data, ); } public function placeholder_escape() { static $placeholder; if ( ! $placeholder ) { $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand(); $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}'; } if ( false === has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) { add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 ); } return $placeholder; } public function add_placeholder_escape( $query ) { return str_replace( '%', $this->placeholder_escape(), $query ); } public function remove_placeholder_escape( $query ) { return str_replace( $this->placeholder_escape(), '%', $query ); } public function insert( $table, $data, $format = null ) { return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' ); } public function replace( $table, $data, $format = null ) { return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' ); } public function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) { $this->insert_id = 0; if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ), true ) ) { return false; } $data = $this->process_fields( $table, $data, $format ); if ( false === $data ) { return false; } $formats = array(); $values = array(); foreach ( $data as $value ) { if ( is_null( $value['value'] ) ) { $formats[] = 'NULL'; continue; } $formats[] = $value['format']; $values[] = $value['value']; } $fields = '`' . implode( '`, `', array_keys( $data ) ) . '`'; $formats = implode( ', ', $formats ); $sql = "$type INTO `$table` ($fields) VALUES ($formats)"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } public function update( $table, $data, $where, $format = null, $where_format = null ) { if ( ! is_array( $data ) || ! is_array( $where ) ) { return false; } $data = $this->process_fields( $table, $data, $format ); if ( false === $data ) { return false; } $where = $this->process_fields( $table, $where, $where_format ); if ( false === $where ) { return false; } $fields = array(); $conditions = array(); $values = array(); foreach ( $data as $field => $value ) { if ( is_null( $value['value'] ) ) { $fields[] = "`$field` = NULL"; continue; } $fields[] = "`$field` = " . $value['format']; $values[] = $value['value']; } foreach ( $where as $field => $value ) { if ( is_null( $value['value'] ) ) { $conditions[] = "`$field` IS NULL"; continue; } $conditions[] = "`$field` = " . $value['format']; $values[] = $value['value']; } $fields = implode( ', ', $fields ); $conditions = implode( ' AND ', $conditions ); $sql = "UPDATE `$table` SET $fields WHERE $conditions"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } public function delete( $table, $where, $where_format = null ) { if ( ! is_array( $where ) ) { return false; } $where = $this->process_fields( $table, $where, $where_format ); if ( false === $where ) { return false; } $conditions = array(); $values = array(); foreach ( $where as $field => $value ) { if ( is_null( $value['value'] ) ) { $conditions[] = "`$field` IS NULL"; continue; } $conditions[] = "`$field` = " . $value['format']; $values[] = $value['value']; } $conditions = implode( ' AND ', $conditions ); $sql = "DELETE FROM `$table` WHERE $conditions"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } protected function process_fields( $table, $data, $format ) { $data = $this->process_field_formats( $data, $format ); if ( false === $data ) { return false; } $data = $this->process_field_charsets( $data, $table ); if ( false === $data ) { return false; } $data = $this->process_field_lengths( $data, $table ); if ( false === $data ) { return false; } $converted_data = $this->strip_invalid_text( $data ); if ( $data !== $converted_data ) { $problem_fields = array(); foreach ( $data as $field => $value ) { if ( $value !== $converted_data[ $field ] ) { $problem_fields[] = $field; } } wp_load_translations_early(); if ( 1 === count( $problem_fields ) ) { $this->last_error = sprintf( __( 'WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.' ), reset( $problem_fields ) ); } else { $this->last_error = sprintf( __( 'WordPress database error: Processing the values for the following fields failed: %s. The supplied values may be too long or contain invalid data.' ), implode( ', ', $problem_fields ) ); } return false; } return $data; } protected function process_field_formats( $data, $format ) { $formats = (array) $format; $original_formats = $formats; foreach ( $data as $field => $value ) { $value = array( 'value' => $value, 'format' => '%s', ); if ( ! empty( $format ) ) { $value['format'] = array_shift( $formats ); if ( ! $value['format'] ) { $value['format'] = reset( $original_formats ); } } elseif ( isset( $this->field_types[ $field ] ) ) { $value['format'] = $this->field_types[ $field ]; } $data[ $field ] = $value; } return $data; } protected function process_field_charsets( $data, $table ) { foreach ( $data as $field => $value ) { if ( '%d' === $value['format'] || '%f' === $value['format'] ) { $value['charset'] = false; } else { $value['charset'] = $this->get_col_charset( $table, $field ); if ( is_wp_error( $value['charset'] ) ) { return false; } } $data[ $field ] = $value; } return $data; } protected function process_field_lengths( $data, $table ) { foreach ( $data as $field => $value ) { if ( '%d' === $value['format'] || '%f' === $value['format'] ) { $value['length'] = false; } else { $value['length'] = $this->get_col_length( $table, $field ); if ( is_wp_error( $value['length'] ) ) { return false; } } $data[ $field ] = $value; } return $data; } public function get_var( $query = null, $x = 0, $y = 0 ) { $this->func_call = "\$db->get_var(\"$query\", $x, $y)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } if ( ! empty( $this->last_result[ $y ] ) ) { $values = array_values( get_object_vars( $this->last_result[ $y ] ) ); } return ( isset( $values[ $x ] ) && '' !== $values[ $x ] ) ? $values[ $x ] : null; } public function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } else { return null; } if ( ! isset( $this->last_result[ $y ] ) ) { return null; } if ( OBJECT === $output ) { return $this->last_result[ $y ] ? $this->last_result[ $y ] : null; } elseif ( ARRAY_A === $output ) { return $this->last_result[ $y ] ? get_object_vars( $this->last_result[ $y ] ) : null; } elseif ( ARRAY_N === $output ) { return $this->last_result[ $y ] ? array_values( get_object_vars( $this->last_result[ $y ] ) ) : null; } elseif ( OBJECT === strtoupper( $output ) ) { return $this->last_result[ $y ] ? $this->last_result[ $y ] : null; } else { $this->print_error( ' $db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N' ); } } public function get_col( $query = null, $x = 0 ) { if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } $new_array = array(); if ( $this->last_result ) { for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { $new_array[ $i ] = $this->get_var( null, $x, $i ); } } return $new_array; } public function get_results( $query = null, $output = OBJECT ) { $this->func_call = "\$db->get_results(\"$query\", $output)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } else { return null; } $new_array = array(); if ( OBJECT === $output ) { return $this->last_result; } elseif ( OBJECT_K === $output ) { if ( $this->last_result ) { foreach ( $this->last_result as $row ) { $var_by_ref = get_object_vars( $row ); $key = array_shift( $var_by_ref ); if ( ! isset( $new_array[ $key ] ) ) { $new_array[ $key ] = $row; } } } return $new_array; } elseif ( ARRAY_A === $output || ARRAY_N === $output ) { if ( $this->last_result ) { foreach ( (array) $this->last_result as $row ) { if ( ARRAY_N === $output ) { $new_array[] = array_values( get_object_vars( $row ) ); } else { $new_array[] = get_object_vars( $row ); } } } return $new_array; } elseif ( strtoupper( $output ) === OBJECT ) { return $this->last_result; } return null; } protected function get_table_charset( $table ) { $tablekey = strtolower( $table ); $charset = apply_filters( 'pre_get_table_charset', null, $table ); if ( null !== $charset ) { return $charset; } if ( isset( $this->table_charset[ $tablekey ] ) ) { return $this->table_charset[ $tablekey ]; } $charsets = array(); $columns = array(); $table_parts = explode( '.', $table ); $table = '`' . implode( '`.`', $table_parts ) . '`'; $results = $this->get_results( "SHOW FULL COLUMNS FROM $table" ); if ( ! $results ) { return new WP_Error( 'wpdb_get_table_charset_failure', __( 'Could not retrieve table charset.' ) ); } foreach ( $results as $column ) { $columns[ strtolower( $column->Field ) ] = $column; } $this->col_meta[ $tablekey ] = $columns; foreach ( $columns as $column ) { if ( ! empty( $column->Collation ) ) { list( $charset ) = explode( '_', $column->Collation ); if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8'; } $charsets[ strtolower( $charset ) ] = true; } list( $type ) = explode( '(', $column->Type ); if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ), true ) ) { $this->table_charset[ $tablekey ] = 'binary'; return 'binary'; } } if ( isset( $charsets['utf8mb3'] ) ) { $charsets['utf8'] = true; unset( $charsets['utf8mb3'] ); } $count = count( $charsets ); if ( 1 === $count ) { $charset = key( $charsets ); } elseif ( 0 === $count ) { $charset = false; } else { unset( $charsets['latin1'] ); $count = count( $charsets ); if ( 1 === $count ) { $charset = key( $charsets ); } elseif ( 2 === $count && isset( $charsets['utf8'], $charsets['utf8mb4'] ) ) { $charset = 'utf8'; } else { $charset = 'ascii'; } } $this->table_charset[ $tablekey ] = $charset; return $charset; } public function get_col_charset( $table, $column ) { $tablekey = strtolower( $table ); $columnkey = strtolower( $column ); $charset = apply_filters( 'pre_get_col_charset', null, $table, $column ); if ( null !== $charset ) { return $charset; } if ( empty( $this->is_mysql ) ) { return false; } if ( empty( $this->table_charset[ $tablekey ] ) ) { $table_charset = $this->get_table_charset( $table ); if ( is_wp_error( $table_charset ) ) { return $table_charset; } } if ( empty( $this->col_meta[ $tablekey ] ) ) { return $this->table_charset[ $tablekey ]; } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) { return $this->table_charset[ $tablekey ]; } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ]->Collation ) ) { return false; } list( $charset ) = explode( '_', $this->col_meta[ $tablekey ][ $columnkey ]->Collation ); return $charset; } public function get_col_length( $table, $column ) { $tablekey = strtolower( $table ); $columnkey = strtolower( $column ); if ( empty( $this->is_mysql ) ) { return false; } if ( empty( $this->col_meta[ $tablekey ] ) ) { $table_charset = $this->get_table_charset( $table ); if ( is_wp_error( $table_charset ) ) { return $table_charset; } } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) { return false; } $typeinfo = explode( '(', $this->col_meta[ $tablekey ][ $columnkey ]->Type ); $type = strtolower( $typeinfo[0] ); if ( ! empty( $typeinfo[1] ) ) { $length = trim( $typeinfo[1], ')' ); } else { $length = false; } switch ( $type ) { case 'char': case 'varchar': return array( 'type' => 'char', 'length' => (int) $length, ); case 'binary': case 'varbinary': return array( 'type' => 'byte', 'length' => (int) $length, ); case 'tinyblob': case 'tinytext': return array( 'type' => 'byte', 'length' => 255, ); case 'blob': case 'text': return array( 'type' => 'byte', 'length' => 65535, ); case 'mediumblob': case 'mediumtext': return array( 'type' => 'byte', 'length' => 16777215, ); case 'longblob': case 'longtext': return array( 'type' => 'byte', 'length' => 4294967295, ); default: return false; } } protected function check_ascii( $input_string ) { if ( function_exists( 'mb_check_encoding' ) ) { if ( mb_check_encoding( $input_string, 'ASCII' ) ) { return true; } } elseif ( ! preg_match( '/[^\x00-\x7F]/', $input_string ) ) { return true; } return false; } protected function check_safe_collation( $query ) { if ( $this->checking_collation ) { return true; } $query = ltrim( $query, "\r\n\t (" ); if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $query ) ) { return true; } if ( $this->check_ascii( $query ) ) { return true; } $table = $this->get_table_from_query( $query ); if ( ! $table ) { return false; } $this->checking_collation = true; $collation = $this->get_table_charset( $table ); $this->checking_collation = false; if ( false === $collation || 'latin1' === $collation ) { return true; } $table = strtolower( $table ); if ( empty( $this->col_meta[ $table ] ) ) { return false; } $safe_collations = array( 'utf8_bin', 'utf8_general_ci', 'utf8mb3_bin', 'utf8mb3_general_ci', 'utf8mb4_bin', 'utf8mb4_general_ci', ); foreach ( $this->col_meta[ $table ] as $col ) { if ( empty( $col->Collation ) ) { continue; } if ( ! in_array( $col->Collation, $safe_collations, true ) ) { return false; } } return true; } protected function strip_invalid_text( $data ) { $db_check_string = false; foreach ( $data as &$value ) { $charset = $value['charset']; if ( is_array( $value['length'] ) ) { $length = $value['length']['length']; $truncate_by_byte_length = 'byte' === $value['length']['type']; } else { $length = false; $truncate_by_byte_length = false; } if ( false === $charset ) { continue; } if ( ! is_string( $value['value'] ) ) { continue; } $needs_validation = true; if ( 'latin1' === $charset || ( ! isset( $value['ascii'] ) && $this->check_ascii( $value['value'] ) ) ) { $truncate_by_byte_length = true; $needs_validation = false; } if ( $truncate_by_byte_length ) { mbstring_binary_safe_encoding(); if ( false !== $length && strlen( $value['value'] ) > $length ) { $value['value'] = substr( $value['value'], 0, $length ); } reset_mbstring_encoding(); if ( ! $needs_validation ) { continue; } } if ( ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) && function_exists( 'mb_strlen' ) ) { $regex = '/ + define( 'EZSQL_VERSION', 'WP1.25' ); define( 'OBJECT', 'OBJECT' ); define( 'object', 'OBJECT' ); define( 'OBJECT_K', 'OBJECT_K' ); define( 'ARRAY_A', 'ARRAY_A' ); define( 'ARRAY_N', 'ARRAY_N' ); class wpdb { public $show_errors = false; public $suppress_errors = false; public $last_error = ''; public $num_queries = 0; public $num_rows = 0; public $rows_affected = 0; public $insert_id = 0; public $last_query; public $last_result; protected $result; protected $col_meta = array(); protected $table_charset = array(); protected $check_current_query = true; private $checking_collation = false; protected $col_info; public $queries; protected $reconnect_retries = 5; public $prefix = ''; public $base_prefix; public $ready = false; public $blogid = 0; public $siteid = 0; public $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'termmeta', 'commentmeta', ); public $old_tables = array( 'categories', 'post2cat', 'link2cat' ); public $global_tables = array( 'users', 'usermeta' ); public $ms_global_tables = array( 'blogs', 'blogmeta', 'signups', 'site', 'sitemeta', 'registration_log', ); public $old_ms_global_tables = array( 'sitecategories' ); public $comments; public $commentmeta; public $links; public $options; public $postmeta; public $posts; public $terms; public $term_relationships; public $term_taxonomy; public $termmeta; public $usermeta; public $users; public $blogs; public $blogmeta; public $registration_log; public $signups; public $site; public $sitecategories; public $sitemeta; public $field_types = array(); public $charset; public $collate; protected $dbuser; protected $dbpassword; protected $dbname; protected $dbhost; protected $dbh; public $func_call; public $is_mysql = null; protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL', 'ANSI', ); private $allow_unsafe_unquoted_parameters = true; private $use_mysqli = false; private $has_connected = false; public $time_start = null; public $error = null; public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) { if ( WP_DEBUG && WP_DEBUG_DISPLAY ) { $this->show_errors(); } if ( function_exists( 'mysqli_connect' ) ) { $this->use_mysqli = true; if ( defined( 'WP_USE_EXT_MYSQL' ) ) { $this->use_mysqli = ! WP_USE_EXT_MYSQL; } } $this->dbuser = $dbuser; $this->dbpassword = $dbpassword; $this->dbname = $dbname; $this->dbhost = $dbhost; if ( defined( 'WP_SETUP_CONFIG' ) ) { return; } $this->db_connect(); } public function __get( $name ) { if ( 'col_info' === $name ) { $this->load_col_info(); } return $this->$name; } public function __set( $name, $value ) { $protected_members = array( 'col_meta', 'table_charset', 'check_current_query', 'allow_unsafe_unquoted_parameters', ); if ( in_array( $name, $protected_members, true ) ) { return; } $this->$name = $value; } public function __isset( $name ) { return isset( $this->$name ); } public function __unset( $name ) { unset( $this->$name ); } public function init_charset() { $charset = ''; $collate = ''; if ( function_exists( 'is_multisite' ) && is_multisite() ) { $charset = 'utf8'; if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) { $collate = DB_COLLATE; } else { $collate = 'utf8_general_ci'; } } elseif ( defined( 'DB_COLLATE' ) ) { $collate = DB_COLLATE; } if ( defined( 'DB_CHARSET' ) ) { $charset = DB_CHARSET; } $charset_collate = $this->determine_charset( $charset, $collate ); $this->charset = $charset_collate['charset']; $this->collate = $charset_collate['collate']; } public function determine_charset( $charset, $collate ) { if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) { return compact( 'charset', 'collate' ); } if ( 'utf8' === $charset && $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8mb4'; } if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8'; $collate = str_replace( 'utf8mb4_', 'utf8_', $collate ); } if ( 'utf8mb4' === $charset ) { if ( ! $collate || 'utf8_general_ci' === $collate ) { $collate = 'utf8mb4_unicode_ci'; } else { $collate = str_replace( 'utf8_', 'utf8mb4_', $collate ); } } if ( $this->has_cap( 'utf8mb4_520' ) && 'utf8mb4_unicode_ci' === $collate ) { $collate = 'utf8mb4_unicode_520_ci'; } return compact( 'charset', 'collate' ); } public function set_charset( $dbh, $charset = null, $collate = null ) { if ( ! isset( $charset ) ) { $charset = $this->charset; } if ( ! isset( $collate ) ) { $collate = $this->collate; } if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) { $set_charset_succeeded = true; if ( $this->use_mysqli ) { if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) { $set_charset_succeeded = mysqli_set_charset( $dbh, $charset ); } if ( $set_charset_succeeded ) { $query = $this->prepare( 'SET NAMES %s', $charset ); if ( ! empty( $collate ) ) { $query .= $this->prepare( ' COLLATE %s', $collate ); } mysqli_query( $dbh, $query ); } } else { if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) { $set_charset_succeeded = mysql_set_charset( $charset, $dbh ); } if ( $set_charset_succeeded ) { $query = $this->prepare( 'SET NAMES %s', $charset ); if ( ! empty( $collate ) ) { $query .= $this->prepare( ' COLLATE %s', $collate ); } mysql_query( $query, $dbh ); } } } } public function set_sql_mode( $modes = array() ) { if ( empty( $modes ) ) { if ( $this->use_mysqli ) { $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' ); } else { $res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh ); } if ( empty( $res ) ) { return; } if ( $this->use_mysqli ) { $modes_array = mysqli_fetch_array( $res ); if ( empty( $modes_array[0] ) ) { return; } $modes_str = $modes_array[0]; } else { $modes_str = mysql_result( $res, 0 ); } if ( empty( $modes_str ) ) { return; } $modes = explode( ',', $modes_str ); } $modes = array_change_key_case( $modes, CASE_UPPER ); $incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes ); foreach ( $modes as $i => $mode ) { if ( in_array( $mode, $incompatible_modes, true ) ) { unset( $modes[ $i ] ); } } $modes_str = implode( ',', $modes ); if ( $this->use_mysqli ) { mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" ); } else { mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh ); } } public function set_prefix( $prefix, $set_table_names = true ) { if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) { return new WP_Error( 'invalid_db_prefix', 'Invalid database prefix' ); } $old_prefix = is_multisite() ? '' : $prefix; if ( isset( $this->base_prefix ) ) { $old_prefix = $this->base_prefix; } $this->base_prefix = $prefix; if ( $set_table_names ) { foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } if ( is_multisite() && empty( $this->blogid ) ) { return $old_prefix; } $this->prefix = $this->get_blog_prefix(); foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } } return $old_prefix; } public function set_blog_id( $blog_id, $network_id = 0 ) { if ( ! empty( $network_id ) ) { $this->siteid = $network_id; } $old_blog_id = $this->blogid; $this->blogid = $blog_id; $this->prefix = $this->get_blog_prefix(); foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) { $this->$table = $prefixed_table; } return $old_blog_id; } public function get_blog_prefix( $blog_id = null ) { if ( is_multisite() ) { if ( null === $blog_id ) { $blog_id = $this->blogid; } $blog_id = (int) $blog_id; if ( defined( 'MULTISITE' ) && ( 0 === $blog_id || 1 === $blog_id ) ) { return $this->base_prefix; } else { return $this->base_prefix . $blog_id . '_'; } } else { return $this->base_prefix; } } public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { switch ( $scope ) { case 'all': $tables = array_merge( $this->global_tables, $this->tables ); if ( is_multisite() ) { $tables = array_merge( $tables, $this->ms_global_tables ); } break; case 'blog': $tables = $this->tables; break; case 'global': $tables = $this->global_tables; if ( is_multisite() ) { $tables = array_merge( $tables, $this->ms_global_tables ); } break; case 'ms_global': $tables = $this->ms_global_tables; break; case 'old': $tables = $this->old_tables; if ( is_multisite() ) { $tables = array_merge( $tables, $this->old_ms_global_tables ); } break; default: return array(); } if ( $prefix ) { if ( ! $blog_id ) { $blog_id = $this->blogid; } $blog_prefix = $this->get_blog_prefix( $blog_id ); $base_prefix = $this->base_prefix; $global_tables = array_merge( $this->global_tables, $this->ms_global_tables ); foreach ( $tables as $k => $table ) { if ( in_array( $table, $global_tables, true ) ) { $tables[ $table ] = $base_prefix . $table; } else { $tables[ $table ] = $blog_prefix . $table; } unset( $tables[ $k ] ); } if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) { $tables['users'] = CUSTOM_USER_TABLE; } if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) ) { $tables['usermeta'] = CUSTOM_USER_META_TABLE; } } return $tables; } public function select( $db, $dbh = null ) { if ( is_null( $dbh ) ) { $dbh = $this->dbh; } if ( $this->use_mysqli ) { $success = mysqli_select_db( $dbh, $db ); } else { $success = mysql_select_db( $db, $dbh ); } if ( ! $success ) { $this->ready = false; if ( ! did_action( 'template_redirect' ) ) { wp_load_translations_early(); $message = '

    ' . __( 'Cannot select database' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'The database server could be connected to (which means your username and password is okay) but the %s database could not be selected.' ), '' . htmlspecialchars( $db, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure it exists?' ) . "
    • \n"; $message .= '
    • ' . sprintf( __( 'Does the user %1$s have permission to use the %2$s database?' ), '' . htmlspecialchars( $this->dbuser, ENT_QUOTES ) . '', '' . htmlspecialchars( $db, ENT_QUOTES ) . '' ) . "
    • \n"; $message .= '
    • ' . sprintf( __( 'On some systems the name of your database is prefixed with your username, so it would be like username_%1$s. Could that be the problem?' ), htmlspecialchars( $db, ENT_QUOTES ) ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you do not know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_select_fail' ); } } } public function _weak_escape( $data ) { if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) { _deprecated_function( __METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()' ); } return addslashes( $data ); } public function _real_escape( $data ) { if ( ! is_scalar( $data ) ) { return ''; } if ( $this->dbh ) { if ( $this->use_mysqli ) { $escaped = mysqli_real_escape_string( $this->dbh, $data ); } else { $escaped = mysql_real_escape_string( $data, $this->dbh ); } } else { $class = get_class( $this ); wp_load_translations_early(); _doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), '3.6.0' ); $escaped = addslashes( $data ); } return $this->add_placeholder_escape( $escaped ); } public function _escape( $data ) { if ( is_array( $data ) ) { foreach ( $data as $k => $v ) { if ( is_array( $v ) ) { $data[ $k ] = $this->_escape( $v ); } else { $data[ $k ] = $this->_real_escape( $v ); } } } else { $data = $this->_real_escape( $data ); } return $data; } public function escape( $data ) { if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) { _deprecated_function( __METHOD__, '3.6.0', 'wpdb::prepare() or esc_sql()' ); } if ( is_array( $data ) ) { foreach ( $data as $k => $v ) { if ( is_array( $v ) ) { $data[ $k ] = $this->escape( $v, 'recursive' ); } else { $data[ $k ] = $this->_weak_escape( $v, 'internal' ); } } } else { $data = $this->_weak_escape( $data, 'internal' ); } return $data; } public function escape_by_ref( &$data ) { if ( ! is_float( $data ) ) { $data = $this->_real_escape( $data ); } } public function quote_identifier( $identifier ) { return '`' . $this->_escape_identifier_value( $identifier ) . '`'; } private function _escape_identifier_value( $identifier ) { return str_replace( '`', '``', $identifier ); } public function prepare( $query, ...$args ) { if ( is_null( $query ) ) { return; } if ( strpos( $query, '%' ) === false ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9.0' ); } $allowed_format = '(?:[1-9][0-9]*[$])?[-+0-9]*(?: |0|\'.)?[-+0-9]*(?:\.[0-9]+)?'; $query = str_replace( "'%s'", '%s', $query ); $query = str_replace( '"%s"', '%s', $query ); $query = preg_replace( "/%(?:%|$|(?!($allowed_format)?[sdfFi]))/", '%%\\1', $query ); $split_query = preg_split( "/(^|[^%]|(?:%%)+)(%(?:$allowed_format)?[sdfFi])/", $query, -1, PREG_SPLIT_DELIM_CAPTURE ); $split_query_count = count( $split_query ); $placeholder_count = ( ( $split_query_count - 1 ) / 3 ); $passed_as_array = ( isset( $args[0] ) && is_array( $args[0] ) && 1 === count( $args ) ); if ( $passed_as_array ) { $args = $args[0]; } $new_query = ''; $key = 2; $arg_id = 0; $arg_identifiers = array(); $arg_strings = array(); while ( $key < $split_query_count ) { $placeholder = $split_query[ $key ]; $format = substr( $placeholder, 1, -1 ); $type = substr( $placeholder, -1 ); if ( 'f' === $type && true === $this->allow_unsafe_unquoted_parameters && '%' === substr( $split_query[ $key - 1 ], -1, 1 ) ) { $s = $split_query[ $key - 2 ] . $split_query[ $key - 1 ]; $k = 1; $l = strlen( $s ); while ( $k <= $l && '%' === $s[ $l - $k ] ) { $k++; } $placeholder = '%' . ( $k % 2 ? '%' : '' ) . $format . $type; --$placeholder_count; } else { if ( 'f' === $type ) { $type = 'F'; $placeholder = '%' . $format . $type; } if ( 'i' === $type ) { $placeholder = '`%' . $format . 's`'; $argnum_pos = strpos( $format, '$' ); if ( false !== $argnum_pos ) { $arg_identifiers[] = ( ( (int) substr( $format, 0, $argnum_pos ) ) - 1 ); } else { $arg_identifiers[] = $arg_id; } } elseif ( 'd' !== $type && 'F' !== $type ) { $argnum_pos = strpos( $format, '$' ); if ( false !== $argnum_pos ) { $arg_strings[] = ( ( (int) substr( $format, 0, $argnum_pos ) ) - 1 ); } else { $arg_strings[] = $arg_id; } if ( true !== $this->allow_unsafe_unquoted_parameters || ( '' === $format && '%' !== substr( $split_query[ $key - 1 ], -1, 1 ) ) ) { $placeholder = "'%" . $format . "s'"; } } } $new_query .= $split_query[ $key - 2 ] . $split_query[ $key - 1 ] . $placeholder; $key += 3; $arg_id++; } $query = $new_query . $split_query[ $key - 2 ]; $dual_use = array_intersect( $arg_identifiers, $arg_strings ); if ( count( $dual_use ) > 0 ) { wp_load_translations_early(); $used_placeholders = array(); $key = 2; $arg_id = 0; while ( $key < $split_query_count ) { $placeholder = $split_query[ $key ]; $format = substr( $placeholder, 1, -1 ); $argnum_pos = strpos( $format, '$' ); if ( false !== $argnum_pos ) { $arg_pos = ( ( (int) substr( $format, 0, $argnum_pos ) ) - 1 ); } else { $arg_pos = $arg_id; } $used_placeholders[ $arg_pos ][] = $placeholder; $key += 3; $arg_id++; } $conflicts = array(); foreach ( $dual_use as $arg_pos ) { $conflicts[] = implode( ' and ', $used_placeholders[ $arg_pos ] ); } _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'Arguments cannot be prepared as both an Identifier and Value. Found the following conflicts: %s' ), implode( ', ', $conflicts ) ), '6.2.0' ); return; } $args_count = count( $args ); if ( $args_count !== $placeholder_count ) { if ( 1 === $placeholder_count && $passed_as_array ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', __( 'The query only expected one placeholder, but an array of multiple placeholders was sent.' ), '4.9.0' ); return; } else { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query does not contain the correct number of placeholders (%1$d) for the number of arguments passed (%2$d).' ), $placeholder_count, $args_count ), '4.8.3' ); if ( $args_count < $placeholder_count ) { $max_numbered_placeholder = 0; for ( $i = 2, $l = $split_query_count; $i < $l; $i += 3 ) { $argnum = (int) substr( $split_query[ $i ], 1 ); if ( $max_numbered_placeholder < $argnum ) { $max_numbered_placeholder = $argnum; } } if ( ! $max_numbered_placeholder || $args_count < $max_numbered_placeholder ) { return ''; } } } } $args_escaped = array(); foreach ( $args as $i => $value ) { if ( in_array( $i, $arg_identifiers, true ) ) { $args_escaped[] = $this->_escape_identifier_value( $value ); } elseif ( is_int( $value ) || is_float( $value ) ) { $args_escaped[] = $value; } else { if ( ! is_scalar( $value ) && ! is_null( $value ) ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'Unsupported value type (%s).' ), gettype( $value ) ), '4.8.2' ); $value = ''; } $args_escaped[] = $this->_real_escape( $value ); } } $query = vsprintf( $query, $args_escaped ); return $this->add_placeholder_escape( $query ); } public function esc_like( $text ) { return addcslashes( $text, '_%\\' ); } public function print_error( $str = '' ) { global $EZSQL_ERROR; if ( ! $str ) { if ( $this->use_mysqli ) { $str = mysqli_error( $this->dbh ); } else { $str = mysql_error( $this->dbh ); } } $EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str, ); if ( $this->suppress_errors ) { return false; } $caller = $this->get_caller(); if ( $caller ) { $error_str = sprintf( 'WordPress database error %1$s for query %2$s made by %3$s', $str, $this->last_query, $caller ); } else { $error_str = sprintf( 'WordPress database error %1$s for query %2$s', $str, $this->last_query ); } error_log( $error_str ); if ( ! $this->show_errors ) { return false; } wp_load_translations_early(); if ( is_multisite() ) { $msg = sprintf( "%s [%s]\n%s\n", __( 'WordPress database error:' ), $str, $this->last_query ); if ( defined( 'ERRORLOGFILE' ) ) { error_log( $msg, 3, ERRORLOGFILE ); } if ( defined( 'DIEONDBERROR' ) ) { wp_die( $msg ); } } else { $str = htmlspecialchars( $str, ENT_QUOTES ); $query = htmlspecialchars( $this->last_query, ENT_QUOTES ); printf( '

    %s [%s]
    %s

    ', __( 'WordPress database error:' ), $str, $query ); } } public function show_errors( $show = true ) { $errors = $this->show_errors; $this->show_errors = $show; return $errors; } public function hide_errors() { $show = $this->show_errors; $this->show_errors = false; return $show; } public function suppress_errors( $suppress = true ) { $errors = $this->suppress_errors; $this->suppress_errors = (bool) $suppress; return $errors; } public function flush() { $this->last_result = array(); $this->col_info = null; $this->last_query = null; $this->rows_affected = 0; $this->num_rows = 0; $this->last_error = ''; if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { mysqli_free_result( $this->result ); $this->result = null; if ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) { return; } while ( mysqli_more_results( $this->dbh ) ) { mysqli_next_result( $this->dbh ); } } elseif ( is_resource( $this->result ) ) { mysql_free_result( $this->result ); } } public function db_connect( $allow_bail = true ) { $this->is_mysql = true; $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true; $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; if ( $this->use_mysqli ) { mysqli_report( MYSQLI_REPORT_OFF ); $this->dbh = mysqli_init(); $host = $this->dbhost; $port = null; $socket = null; $is_ipv6 = false; $host_data = $this->parse_db_host( $this->dbhost ); if ( $host_data ) { list( $host, $port, $socket, $is_ipv6 ) = $host_data; } if ( $is_ipv6 && extension_loaded( 'mysqlnd' ) ) { $host = "[$host]"; } if ( WP_DEBUG ) { mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); } else { @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); } if ( $this->dbh->connect_errno ) { $this->dbh = null; $attempt_fallback = true; if ( $this->has_connected ) { $attempt_fallback = false; } elseif ( defined( 'WP_USE_EXT_MYSQL' ) && ! WP_USE_EXT_MYSQL ) { $attempt_fallback = false; } elseif ( ! function_exists( 'mysql_connect' ) ) { $attempt_fallback = false; } if ( $attempt_fallback ) { $this->use_mysqli = false; return $this->db_connect( $allow_bail ); } } } else { if ( WP_DEBUG ) { $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); } else { $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); } } if ( ! $this->dbh && $allow_bail ) { wp_load_translations_early(); if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once WP_CONTENT_DIR . '/db-error.php'; die(); } $message = '

    ' . __( 'Error establishing a database connection' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'This either means that the username and password information in your %1$s file is incorrect or that contact with the database server at %2$s could not be established. This could mean your host’s database server is down.' ), 'wp-config.php', '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure you have the correct username and password?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure you have typed the correct hostname?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure the database server is running?' ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_connect_fail' ); return false; } elseif ( $this->dbh ) { if ( ! $this->has_connected ) { $this->init_charset(); } $this->has_connected = true; $this->set_charset( $this->dbh ); $this->ready = true; $this->set_sql_mode(); $this->select( $this->dbname, $this->dbh ); return true; } return false; } public function parse_db_host( $host ) { $socket = null; $is_ipv6 = false; $socket_pos = strpos( $host, ':/' ); if ( false !== $socket_pos ) { $socket = substr( $host, $socket_pos + 1 ); $host = substr( $host, 0, $socket_pos ); } if ( substr_count( $host, ':' ) > 1 ) { $pattern = '#^(?:\[)?(?P[0-9a-fA-F:]+)(?:\]:(?P[\d]+))?#'; $is_ipv6 = true; } else { $pattern = '#^(?P[^:/]*)(?::(?P[\d]+))?#'; } $matches = array(); $result = preg_match( $pattern, $host, $matches ); if ( 1 !== $result ) { return false; } $host = ! empty( $matches['host'] ) ? $matches['host'] : ''; $port = ! empty( $matches['port'] ) ? absint( $matches['port'] ) : null; return array( $host, $port, $socket, $is_ipv6 ); } public function check_connection( $allow_bail = true ) { if ( $this->use_mysqli ) { if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) { return true; } } else { if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) { return true; } } $error_reporting = false; if ( WP_DEBUG ) { $error_reporting = error_reporting(); error_reporting( $error_reporting & ~E_WARNING ); } for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) { if ( $this->reconnect_retries === $tries && WP_DEBUG ) { error_reporting( $error_reporting ); } if ( $this->db_connect( false ) ) { if ( $error_reporting ) { error_reporting( $error_reporting ); } return true; } sleep( 1 ); } if ( did_action( 'template_redirect' ) ) { return false; } if ( ! $allow_bail ) { return false; } wp_load_translations_early(); $message = '

    ' . __( 'Error reconnecting to the database' ) . "

    \n"; $message .= '

    ' . sprintf( __( 'This means that the contact with the database server at %s was lost. This could mean your host’s database server is down.' ), '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' ) . "

    \n"; $message .= "
      \n"; $message .= '
    • ' . __( 'Are you sure the database server is running?' ) . "
    • \n"; $message .= '
    • ' . __( 'Are you sure the database server is not under particularly heavy load?' ) . "
    • \n"; $message .= "
    \n"; $message .= '

    ' . sprintf( __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), __( 'https://wordpress.org/support/forums/' ) ) . "

    \n"; $this->bail( $message, 'db_connect_fail' ); dead_db(); } public function query( $query ) { if ( ! $this->ready ) { $this->check_current_query = true; return false; } $query = apply_filters( 'query', $query ); if ( ! $query ) { $this->insert_id = 0; return false; } $this->flush(); $this->func_call = "\$db->query(\"$query\")"; if ( $this->check_current_query && ! $this->check_ascii( $query ) ) { $stripped_query = $this->strip_invalid_text_from_query( $query ); $this->flush(); if ( $stripped_query !== $query ) { $this->insert_id = 0; $this->last_query = $query; wp_load_translations_early(); $this->last_error = __( 'WordPress database error: Could not perform query because it contains invalid data.' ); return false; } } $this->check_current_query = true; $this->last_query = $query; $this->_do_query( $query ); $mysql_errno = 0; if ( ! empty( $this->dbh ) ) { if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $mysql_errno = mysqli_errno( $this->dbh ); } else { $mysql_errno = 2006; } } else { if ( is_resource( $this->dbh ) ) { $mysql_errno = mysql_errno( $this->dbh ); } else { $mysql_errno = 2006; } } } if ( empty( $this->dbh ) || 2006 === $mysql_errno ) { if ( $this->check_connection() ) { $this->_do_query( $query ); } else { $this->insert_id = 0; return false; } } if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $this->last_error = mysqli_error( $this->dbh ); } else { $this->last_error = __( 'Unable to retrieve the error message from MySQL' ); } } else { if ( is_resource( $this->dbh ) ) { $this->last_error = mysql_error( $this->dbh ); } else { $this->last_error = __( 'Unable to retrieve the error message from MySQL' ); } } if ( $this->last_error ) { if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { $this->insert_id = 0; } $this->print_error(); return false; } if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) { $return_val = $this->result; } elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) { if ( $this->use_mysqli ) { $this->rows_affected = mysqli_affected_rows( $this->dbh ); } else { $this->rows_affected = mysql_affected_rows( $this->dbh ); } if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { if ( $this->use_mysqli ) { $this->insert_id = mysqli_insert_id( $this->dbh ); } else { $this->insert_id = mysql_insert_id( $this->dbh ); } } $return_val = $this->rows_affected; } else { $num_rows = 0; if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { while ( $row = mysqli_fetch_object( $this->result ) ) { $this->last_result[ $num_rows ] = $row; $num_rows++; } } elseif ( is_resource( $this->result ) ) { while ( $row = mysql_fetch_object( $this->result ) ) { $this->last_result[ $num_rows ] = $row; $num_rows++; } } $this->num_rows = $num_rows; $return_val = $num_rows; } return $return_val; } private function _do_query( $query ) { if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { $this->timer_start(); } if ( ! empty( $this->dbh ) && $this->use_mysqli ) { $this->result = mysqli_query( $this->dbh, $query ); } elseif ( ! empty( $this->dbh ) ) { $this->result = mysql_query( $query, $this->dbh ); } $this->num_queries++; if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { $this->log_query( $query, $this->timer_stop(), $this->get_caller(), $this->time_start, array() ); } } public function log_query( $query, $query_time, $query_callstack, $query_start, $query_data ) { $query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start ); $this->queries[] = array( $query, $query_time, $query_callstack, $query_start, $query_data, ); } public function placeholder_escape() { static $placeholder; if ( ! $placeholder ) { $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand(); $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}'; } if ( false === has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) { add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 ); } return $placeholder; } public function add_placeholder_escape( $query ) { return str_replace( '%', $this->placeholder_escape(), $query ); } public function remove_placeholder_escape( $query ) { return str_replace( $this->placeholder_escape(), '%', $query ); } public function insert( $table, $data, $format = null ) { return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' ); } public function replace( $table, $data, $format = null ) { return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' ); } public function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) { $this->insert_id = 0; if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ), true ) ) { return false; } $data = $this->process_fields( $table, $data, $format ); if ( false === $data ) { return false; } $formats = array(); $values = array(); foreach ( $data as $value ) { if ( is_null( $value['value'] ) ) { $formats[] = 'NULL'; continue; } $formats[] = $value['format']; $values[] = $value['value']; } $fields = '`' . implode( '`, `', array_keys( $data ) ) . '`'; $formats = implode( ', ', $formats ); $sql = "$type INTO `$table` ($fields) VALUES ($formats)"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } public function update( $table, $data, $where, $format = null, $where_format = null ) { if ( ! is_array( $data ) || ! is_array( $where ) ) { return false; } $data = $this->process_fields( $table, $data, $format ); if ( false === $data ) { return false; } $where = $this->process_fields( $table, $where, $where_format ); if ( false === $where ) { return false; } $fields = array(); $conditions = array(); $values = array(); foreach ( $data as $field => $value ) { if ( is_null( $value['value'] ) ) { $fields[] = "`$field` = NULL"; continue; } $fields[] = "`$field` = " . $value['format']; $values[] = $value['value']; } foreach ( $where as $field => $value ) { if ( is_null( $value['value'] ) ) { $conditions[] = "`$field` IS NULL"; continue; } $conditions[] = "`$field` = " . $value['format']; $values[] = $value['value']; } $fields = implode( ', ', $fields ); $conditions = implode( ' AND ', $conditions ); $sql = "UPDATE `$table` SET $fields WHERE $conditions"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } public function delete( $table, $where, $where_format = null ) { if ( ! is_array( $where ) ) { return false; } $where = $this->process_fields( $table, $where, $where_format ); if ( false === $where ) { return false; } $conditions = array(); $values = array(); foreach ( $where as $field => $value ) { if ( is_null( $value['value'] ) ) { $conditions[] = "`$field` IS NULL"; continue; } $conditions[] = "`$field` = " . $value['format']; $values[] = $value['value']; } $conditions = implode( ' AND ', $conditions ); $sql = "DELETE FROM `$table` WHERE $conditions"; $this->check_current_query = false; return $this->query( $this->prepare( $sql, $values ) ); } protected function process_fields( $table, $data, $format ) { $data = $this->process_field_formats( $data, $format ); if ( false === $data ) { return false; } $data = $this->process_field_charsets( $data, $table ); if ( false === $data ) { return false; } $data = $this->process_field_lengths( $data, $table ); if ( false === $data ) { return false; } $converted_data = $this->strip_invalid_text( $data ); if ( $data !== $converted_data ) { $problem_fields = array(); foreach ( $data as $field => $value ) { if ( $value !== $converted_data[ $field ] ) { $problem_fields[] = $field; } } wp_load_translations_early(); if ( 1 === count( $problem_fields ) ) { $this->last_error = sprintf( __( 'WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.' ), reset( $problem_fields ) ); } else { $this->last_error = sprintf( __( 'WordPress database error: Processing the values for the following fields failed: %s. The supplied values may be too long or contain invalid data.' ), implode( ', ', $problem_fields ) ); } return false; } return $data; } protected function process_field_formats( $data, $format ) { $formats = (array) $format; $original_formats = $formats; foreach ( $data as $field => $value ) { $value = array( 'value' => $value, 'format' => '%s', ); if ( ! empty( $format ) ) { $value['format'] = array_shift( $formats ); if ( ! $value['format'] ) { $value['format'] = reset( $original_formats ); } } elseif ( isset( $this->field_types[ $field ] ) ) { $value['format'] = $this->field_types[ $field ]; } $data[ $field ] = $value; } return $data; } protected function process_field_charsets( $data, $table ) { foreach ( $data as $field => $value ) { if ( '%d' === $value['format'] || '%f' === $value['format'] ) { $value['charset'] = false; } else { $value['charset'] = $this->get_col_charset( $table, $field ); if ( is_wp_error( $value['charset'] ) ) { return false; } } $data[ $field ] = $value; } return $data; } protected function process_field_lengths( $data, $table ) { foreach ( $data as $field => $value ) { if ( '%d' === $value['format'] || '%f' === $value['format'] ) { $value['length'] = false; } else { $value['length'] = $this->get_col_length( $table, $field ); if ( is_wp_error( $value['length'] ) ) { return false; } } $data[ $field ] = $value; } return $data; } public function get_var( $query = null, $x = 0, $y = 0 ) { $this->func_call = "\$db->get_var(\"$query\", $x, $y)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } if ( ! empty( $this->last_result[ $y ] ) ) { $values = array_values( get_object_vars( $this->last_result[ $y ] ) ); } return ( isset( $values[ $x ] ) && '' !== $values[ $x ] ) ? $values[ $x ] : null; } public function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } else { return null; } if ( ! isset( $this->last_result[ $y ] ) ) { return null; } if ( OBJECT === $output ) { return $this->last_result[ $y ] ? $this->last_result[ $y ] : null; } elseif ( ARRAY_A === $output ) { return $this->last_result[ $y ] ? get_object_vars( $this->last_result[ $y ] ) : null; } elseif ( ARRAY_N === $output ) { return $this->last_result[ $y ] ? array_values( get_object_vars( $this->last_result[ $y ] ) ) : null; } elseif ( OBJECT === strtoupper( $output ) ) { return $this->last_result[ $y ] ? $this->last_result[ $y ] : null; } else { $this->print_error( ' $db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N' ); } } public function get_col( $query = null, $x = 0 ) { if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } $new_array = array(); if ( $this->last_result ) { for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { $new_array[ $i ] = $this->get_var( null, $x, $i ); } } return $new_array; } public function get_results( $query = null, $output = OBJECT ) { $this->func_call = "\$db->get_results(\"$query\", $output)"; if ( $query ) { if ( $this->check_current_query && $this->check_safe_collation( $query ) ) { $this->check_current_query = false; } $this->query( $query ); } else { return null; } $new_array = array(); if ( OBJECT === $output ) { return $this->last_result; } elseif ( OBJECT_K === $output ) { if ( $this->last_result ) { foreach ( $this->last_result as $row ) { $var_by_ref = get_object_vars( $row ); $key = array_shift( $var_by_ref ); if ( ! isset( $new_array[ $key ] ) ) { $new_array[ $key ] = $row; } } } return $new_array; } elseif ( ARRAY_A === $output || ARRAY_N === $output ) { if ( $this->last_result ) { foreach ( (array) $this->last_result as $row ) { if ( ARRAY_N === $output ) { $new_array[] = array_values( get_object_vars( $row ) ); } else { $new_array[] = get_object_vars( $row ); } } } return $new_array; } elseif ( strtoupper( $output ) === OBJECT ) { return $this->last_result; } return null; } protected function get_table_charset( $table ) { $tablekey = strtolower( $table ); $charset = apply_filters( 'pre_get_table_charset', null, $table ); if ( null !== $charset ) { return $charset; } if ( isset( $this->table_charset[ $tablekey ] ) ) { return $this->table_charset[ $tablekey ]; } $charsets = array(); $columns = array(); $table_parts = explode( '.', $table ); $table = '`' . implode( '`.`', $table_parts ) . '`'; $results = $this->get_results( "SHOW FULL COLUMNS FROM $table" ); if ( ! $results ) { return new WP_Error( 'wpdb_get_table_charset_failure', __( 'Could not retrieve table charset.' ) ); } foreach ( $results as $column ) { $columns[ strtolower( $column->Field ) ] = $column; } $this->col_meta[ $tablekey ] = $columns; foreach ( $columns as $column ) { if ( ! empty( $column->Collation ) ) { list( $charset ) = explode( '_', $column->Collation ); if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) { $charset = 'utf8'; } $charsets[ strtolower( $charset ) ] = true; } list( $type ) = explode( '(', $column->Type ); if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ), true ) ) { $this->table_charset[ $tablekey ] = 'binary'; return 'binary'; } } if ( isset( $charsets['utf8mb3'] ) ) { $charsets['utf8'] = true; unset( $charsets['utf8mb3'] ); } $count = count( $charsets ); if ( 1 === $count ) { $charset = key( $charsets ); } elseif ( 0 === $count ) { $charset = false; } else { unset( $charsets['latin1'] ); $count = count( $charsets ); if ( 1 === $count ) { $charset = key( $charsets ); } elseif ( 2 === $count && isset( $charsets['utf8'], $charsets['utf8mb4'] ) ) { $charset = 'utf8'; } else { $charset = 'ascii'; } } $this->table_charset[ $tablekey ] = $charset; return $charset; } public function get_col_charset( $table, $column ) { $tablekey = strtolower( $table ); $columnkey = strtolower( $column ); $charset = apply_filters( 'pre_get_col_charset', null, $table, $column ); if ( null !== $charset ) { return $charset; } if ( empty( $this->is_mysql ) ) { return false; } if ( empty( $this->table_charset[ $tablekey ] ) ) { $table_charset = $this->get_table_charset( $table ); if ( is_wp_error( $table_charset ) ) { return $table_charset; } } if ( empty( $this->col_meta[ $tablekey ] ) ) { return $this->table_charset[ $tablekey ]; } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) { return $this->table_charset[ $tablekey ]; } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ]->Collation ) ) { return false; } list( $charset ) = explode( '_', $this->col_meta[ $tablekey ][ $columnkey ]->Collation ); return $charset; } public function get_col_length( $table, $column ) { $tablekey = strtolower( $table ); $columnkey = strtolower( $column ); if ( empty( $this->is_mysql ) ) { return false; } if ( empty( $this->col_meta[ $tablekey ] ) ) { $table_charset = $this->get_table_charset( $table ); if ( is_wp_error( $table_charset ) ) { return $table_charset; } } if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) { return false; } $typeinfo = explode( '(', $this->col_meta[ $tablekey ][ $columnkey ]->Type ); $type = strtolower( $typeinfo[0] ); if ( ! empty( $typeinfo[1] ) ) { $length = trim( $typeinfo[1], ')' ); } else { $length = false; } switch ( $type ) { case 'char': case 'varchar': return array( 'type' => 'char', 'length' => (int) $length, ); case 'binary': case 'varbinary': return array( 'type' => 'byte', 'length' => (int) $length, ); case 'tinyblob': case 'tinytext': return array( 'type' => 'byte', 'length' => 255, ); case 'blob': case 'text': return array( 'type' => 'byte', 'length' => 65535, ); case 'mediumblob': case 'mediumtext': return array( 'type' => 'byte', 'length' => 16777215, ); case 'longblob': case 'longtext': return array( 'type' => 'byte', 'length' => 4294967295, ); default: return false; } } protected function check_ascii( $input_string ) { if ( function_exists( 'mb_check_encoding' ) ) { if ( mb_check_encoding( $input_string, 'ASCII' ) ) { return true; } } elseif ( ! preg_match( '/[^\x00-\x7F]/', $input_string ) ) { return true; } return false; } protected function check_safe_collation( $query ) { if ( $this->checking_collation ) { return true; } $query = ltrim( $query, "\r\n\t (" ); if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $query ) ) { return true; } if ( $this->check_ascii( $query ) ) { return true; } $table = $this->get_table_from_query( $query ); if ( ! $table ) { return false; } $this->checking_collation = true; $collation = $this->get_table_charset( $table ); $this->checking_collation = false; if ( false === $collation || 'latin1' === $collation ) { return true; } $table = strtolower( $table ); if ( empty( $this->col_meta[ $table ] ) ) { return false; } $safe_collations = array( 'utf8_bin', 'utf8_general_ci', 'utf8mb3_bin', 'utf8mb3_general_ci', 'utf8mb4_bin', 'utf8mb4_general_ci', ); foreach ( $this->col_meta[ $table ] as $col ) { if ( empty( $col->Collation ) ) { continue; } if ( ! in_array( $col->Collation, $safe_collations, true ) ) { return false; } } return true; } protected function strip_invalid_text( $data ) { $db_check_string = false; foreach ( $data as &$value ) { $charset = $value['charset']; if ( is_array( $value['length'] ) ) { $length = $value['length']['length']; $truncate_by_byte_length = 'byte' === $value['length']['type']; } else { $length = false; $truncate_by_byte_length = false; } if ( false === $charset ) { continue; } if ( ! is_string( $value['value'] ) ) { continue; } $needs_validation = true; if ( 'latin1' === $charset || ( ! isset( $value['ascii'] ) && $this->check_ascii( $value['value'] ) ) ) { $truncate_by_byte_length = true; $needs_validation = false; } if ( $truncate_by_byte_length ) { mbstring_binary_safe_encoding(); if ( false !== $length && strlen( $value['value'] ) > $length ) { $value['value'] = substr( $value['value'], 0, $length ); } reset_mbstring_encoding(); if ( ! $needs_validation ) { continue; } } if ( ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) && function_exists( 'mb_strlen' ) ) { $regex = '/ ( (?: [\x00-\x7F] # single-byte sequences 0xxxxxxx | [\xC2-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx @@ -28441,7 +31124,7 @@ if ( $display ) { printf( "\n%s\n\n", '; } $regex .= '){1,40} # ...one or more times ) | . # anything else - /x'; $value['value'] = preg_replace( $regex, '$1', $value['value'] ); if ( false !== $length && mb_strlen( $value['value'], 'UTF-8' ) > $length ) { $value['value'] = mb_substr( $value['value'], 0, $length, 'UTF-8' ); } continue; } $value['db'] = true; $db_check_string = true; } unset( $value ); if ( $db_check_string ) { $queries = array(); foreach ( $data as $col => $value ) { if ( ! empty( $value['db'] ) ) { if ( isset( $value['length']['type'] ) && 'byte' === $value['length']['type'] ) { $charset = 'binary'; } else { $charset = $value['charset']; } if ( $this->charset ) { $connection_charset = $this->charset; } else { if ( $this->use_mysqli ) { $connection_charset = mysqli_character_set_name( $this->dbh ); } else { $connection_charset = mysql_client_encoding(); } } if ( is_array( $value['length'] ) ) { $length = sprintf( '%.0f', $value['length']['length'] ); $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), $length ) USING $connection_charset )", $value['value'] ); } elseif ( 'binary' !== $charset ) { $queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING $connection_charset )", $value['value'] ); } unset( $data[ $col ]['db'] ); } } $sql = array(); foreach ( $queries as $column => $query ) { if ( ! $query ) { continue; } $sql[] = $query . " AS x_$column"; } $this->check_current_query = false; $row = $this->get_row( 'SELECT ' . implode( ', ', $sql ), ARRAY_A ); if ( ! $row ) { return new WP_Error( 'wpdb_strip_invalid_text_failure', __( 'Could not strip invalid text.' ) ); } foreach ( array_keys( $data ) as $column ) { if ( isset( $row[ "x_$column" ] ) ) { $data[ $column ]['value'] = $row[ "x_$column" ]; } } } return $data; } protected function strip_invalid_text_from_query( $query ) { $trimmed_query = ltrim( $query, "\r\n\t (" ); if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $trimmed_query ) ) { return $query; } $table = $this->get_table_from_query( $query ); if ( $table ) { $charset = $this->get_table_charset( $table ); if ( is_wp_error( $charset ) ) { return $charset; } if ( 'binary' === $charset ) { return $query; } } else { $charset = $this->charset; } $data = array( 'value' => $query, 'charset' => $charset, 'ascii' => false, 'length' => false, ); $data = $this->strip_invalid_text( array( $data ) ); if ( is_wp_error( $data ) ) { return $data; } return $data[0]['value']; } public function strip_invalid_text_for_column( $table, $column, $value ) { if ( ! is_string( $value ) ) { return $value; } $charset = $this->get_col_charset( $table, $column ); if ( ! $charset ) { return $value; } elseif ( is_wp_error( $charset ) ) { return $charset; } $data = array( $column => array( 'value' => $value, 'charset' => $charset, 'length' => $this->get_col_length( $table, $column ), ), ); $data = $this->strip_invalid_text( $data ); if ( is_wp_error( $data ) ) { return $data; } return $data[ $column ]['value']; } protected function get_table_from_query( $query ) { $query = rtrim( $query, ';/-#' ); $query = ltrim( $query, "\r\n\t (" ); $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', $query ); if ( preg_match( '/^\s*(?:' . 'SELECT.*?\s+FROM' . '|INSERT(?:\s+LOW_PRIORITY|\s+DELAYED|\s+HIGH_PRIORITY)?(?:\s+IGNORE)?(?:\s+INTO)?' . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?' . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?' . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:.+?FROM)?' . ')\s+((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) { return str_replace( '`', '', $maybe[1] ); } if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES).+WHERE\s+Name\s*=\s*("|\')((?:[0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)\\1/is', $query, $maybe ) ) { return $maybe[2]; } if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES)\s+(?:WHERE\s+Name\s+)?LIKE\s*("|\')((?:[\\\\0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)%?\\1/is', $query, $maybe ) ) { return str_replace( '\\_', '_', $maybe[2] ); } if ( preg_match( '/^\s*(?:' . '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM' . '|DESCRIBE|DESC|EXPLAIN|HANDLER' . '|(?:LOCK|UNLOCK)\s+TABLE(?:S)?' . '|(?:RENAME|OPTIMIZE|BACKUP|RESTORE|CHECK|CHECKSUM|ANALYZE|REPAIR).*\s+TABLE' . '|TRUNCATE(?:\s+TABLE)?' . '|CREATE(?:\s+TEMPORARY)?\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?' . '|ALTER(?:\s+IGNORE)?\s+TABLE' . '|DROP\s+TABLE(?:\s+IF\s+EXISTS)?' . '|CREATE(?:\s+\w+)?\s+INDEX.*\s+ON' . '|DROP\s+INDEX.*\s+ON' . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE' . '|(?:GRANT|REVOKE).*ON\s+TABLE' . '|SHOW\s+(?:.*FROM|.*TABLE)' . ')\s+\(*\s*((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe ) ) { return str_replace( '`', '', $maybe[1] ); } return false; } protected function load_col_info() { if ( $this->col_info ) { return; } if ( $this->use_mysqli ) { $num_fields = mysqli_num_fields( $this->result ); for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = mysqli_fetch_field( $this->result ); } } else { $num_fields = mysql_num_fields( $this->result ); for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = mysql_fetch_field( $this->result, $i ); } } } public function get_col_info( $info_type = 'name', $col_offset = -1 ) { $this->load_col_info(); if ( $this->col_info ) { if ( -1 === $col_offset ) { $i = 0; $new_array = array(); foreach ( (array) $this->col_info as $col ) { $new_array[ $i ] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[ $col_offset ]->{$info_type}; } } } public function timer_start() { $this->time_start = microtime( true ); return true; } public function timer_stop() { return ( microtime( true ) - $this->time_start ); } public function bail( $message, $error_code = '500' ) { if ( $this->show_errors ) { $error = ''; if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $error = mysqli_error( $this->dbh ); } elseif ( mysqli_connect_errno() ) { $error = mysqli_connect_error(); } } else { if ( is_resource( $this->dbh ) ) { $error = mysql_error( $this->dbh ); } else { $error = mysql_error(); } } if ( $error ) { $message = '

    ' . $error . "

    \n" . $message; } wp_die( $message ); } else { if ( class_exists( 'WP_Error', false ) ) { $this->error = new WP_Error( $error_code, $message ); } else { $this->error = $message; } return false; } } public function close() { if ( ! $this->dbh ) { return false; } if ( $this->use_mysqli ) { $closed = mysqli_close( $this->dbh ); } else { $closed = mysql_close( $this->dbh ); } if ( $closed ) { $this->dbh = null; $this->ready = false; $this->has_connected = false; } return $closed; } public function check_database_version() { global $wp_version, $required_mysql_version; if ( version_compare( $this->db_version(), $required_mysql_version, '<' ) ) { return new WP_Error( 'database_version', sprintf( __( 'Error: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ) ); } } public function supports_collation() { _deprecated_function( __FUNCTION__, '3.5.0', 'wpdb::has_cap( \'collation\' )' ); return $this->has_cap( 'collation' ); } public function get_charset_collate() { $charset_collate = ''; if ( ! empty( $this->charset ) ) { $charset_collate = "DEFAULT CHARACTER SET $this->charset"; } if ( ! empty( $this->collate ) ) { $charset_collate .= " COLLATE $this->collate"; } return $charset_collate; } public function has_cap( $db_cap ) { $db_version = $this->db_version(); $db_server_info = $this->db_server_info(); if ( '5.5.5' === $db_version && str_contains( $db_server_info, 'MariaDB' ) && PHP_VERSION_ID < 80016 ) { $db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info ); $db_version = preg_replace( '/[^0-9.].*/', '', $db_server_info ); } switch ( strtolower( $db_cap ) ) { case 'collation': case 'group_concat': case 'subqueries': return version_compare( $db_version, '4.1', '>=' ); case 'set_charset': return version_compare( $db_version, '5.0.7', '>=' ); case 'utf8mb4': if ( version_compare( $db_version, '5.5.3', '<' ) ) { return false; } if ( $this->use_mysqli ) { $client_version = mysqli_get_client_info(); } else { $client_version = mysql_get_client_info(); } if ( false !== strpos( $client_version, 'mysqlnd' ) ) { $client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version ); return version_compare( $client_version, '5.0.9', '>=' ); } else { return version_compare( $client_version, '5.5.3', '>=' ); } case 'utf8mb4_520': return version_compare( $db_version, '5.6', '>=' ); } return false; } public function get_caller() { return wp_debug_backtrace_summary( __CLASS__ ); } public function db_version() { return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() ); } public function db_server_info() { if ( $this->use_mysqli ) { $server_info = mysqli_get_server_info( $this->dbh ); } else { $server_info = mysql_get_server_info( $this->dbh ); } return $server_info; } } $length ) { $value['value'] = mb_substr( $value['value'], 0, $length, 'UTF-8' ); } continue; } $value['db'] = true; $db_check_string = true; } unset( $value ); if ( $db_check_string ) { $queries = array(); foreach ( $data as $col => $value ) { if ( ! empty( $value['db'] ) ) { if ( isset( $value['length']['type'] ) && 'byte' === $value['length']['type'] ) { $charset = 'binary'; } else { $charset = $value['charset']; } if ( $this->charset ) { $connection_charset = $this->charset; } else { if ( $this->use_mysqli ) { $connection_charset = mysqli_character_set_name( $this->dbh ); } else { $connection_charset = mysql_client_encoding(); } } if ( is_array( $value['length'] ) ) { $length = sprintf( '%.0f', $value['length']['length'] ); $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), $length ) USING $connection_charset )", $value['value'] ); } elseif ( 'binary' !== $charset ) { $queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING $connection_charset )", $value['value'] ); } unset( $data[ $col ]['db'] ); } } $sql = array(); foreach ( $queries as $column => $query ) { if ( ! $query ) { continue; } $sql[] = $query . " AS x_$column"; } $this->check_current_query = false; $row = $this->get_row( 'SELECT ' . implode( ', ', $sql ), ARRAY_A ); if ( ! $row ) { return new WP_Error( 'wpdb_strip_invalid_text_failure', __( 'Could not strip invalid text.' ) ); } foreach ( array_keys( $data ) as $column ) { if ( isset( $row[ "x_$column" ] ) ) { $data[ $column ]['value'] = $row[ "x_$column" ]; } } } return $data; } protected function strip_invalid_text_from_query( $query ) { $trimmed_query = ltrim( $query, "\r\n\t (" ); if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $trimmed_query ) ) { return $query; } $table = $this->get_table_from_query( $query ); if ( $table ) { $charset = $this->get_table_charset( $table ); if ( is_wp_error( $charset ) ) { return $charset; } if ( 'binary' === $charset ) { return $query; } } else { $charset = $this->charset; } $data = array( 'value' => $query, 'charset' => $charset, 'ascii' => false, 'length' => false, ); $data = $this->strip_invalid_text( array( $data ) ); if ( is_wp_error( $data ) ) { return $data; } return $data[0]['value']; } public function strip_invalid_text_for_column( $table, $column, $value ) { if ( ! is_string( $value ) ) { return $value; } $charset = $this->get_col_charset( $table, $column ); if ( ! $charset ) { return $value; } elseif ( is_wp_error( $charset ) ) { return $charset; } $data = array( $column => array( 'value' => $value, 'charset' => $charset, 'length' => $this->get_col_length( $table, $column ), ), ); $data = $this->strip_invalid_text( $data ); if ( is_wp_error( $data ) ) { return $data; } return $data[ $column ]['value']; } protected function get_table_from_query( $query ) { $query = rtrim( $query, ';/-#' ); $query = ltrim( $query, "\r\n\t (" ); $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', $query ); if ( preg_match( '/^\s*(?:' . 'SELECT.*?\s+FROM' . '|INSERT(?:\s+LOW_PRIORITY|\s+DELAYED|\s+HIGH_PRIORITY)?(?:\s+IGNORE)?(?:\s+INTO)?' . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?' . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?' . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:.+?FROM)?' . ')\s+((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) { return str_replace( '`', '', $maybe[1] ); } if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES).+WHERE\s+Name\s*=\s*("|\')((?:[0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)\\1/is', $query, $maybe ) ) { return $maybe[2]; } if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES)\s+(?:WHERE\s+Name\s+)?LIKE\s*("|\')((?:[\\\\0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)%?\\1/is', $query, $maybe ) ) { return str_replace( '\\_', '_', $maybe[2] ); } if ( preg_match( '/^\s*(?:' . '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM' . '|DESCRIBE|DESC|EXPLAIN|HANDLER' . '|(?:LOCK|UNLOCK)\s+TABLE(?:S)?' . '|(?:RENAME|OPTIMIZE|BACKUP|RESTORE|CHECK|CHECKSUM|ANALYZE|REPAIR).*\s+TABLE' . '|TRUNCATE(?:\s+TABLE)?' . '|CREATE(?:\s+TEMPORARY)?\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?' . '|ALTER(?:\s+IGNORE)?\s+TABLE' . '|DROP\s+TABLE(?:\s+IF\s+EXISTS)?' . '|CREATE(?:\s+\w+)?\s+INDEX.*\s+ON' . '|DROP\s+INDEX.*\s+ON' . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE' . '|(?:GRANT|REVOKE).*ON\s+TABLE' . '|SHOW\s+(?:.*FROM|.*TABLE)' . ')\s+\(*\s*((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe ) ) { return str_replace( '`', '', $maybe[1] ); } return false; } protected function load_col_info() { if ( $this->col_info ) { return; } if ( $this->use_mysqli ) { $num_fields = mysqli_num_fields( $this->result ); for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = mysqli_fetch_field( $this->result ); } } else { $num_fields = mysql_num_fields( $this->result ); for ( $i = 0; $i < $num_fields; $i++ ) { $this->col_info[ $i ] = mysql_fetch_field( $this->result, $i ); } } } public function get_col_info( $info_type = 'name', $col_offset = -1 ) { $this->load_col_info(); if ( $this->col_info ) { if ( -1 === $col_offset ) { $i = 0; $new_array = array(); foreach ( (array) $this->col_info as $col ) { $new_array[ $i ] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[ $col_offset ]->{$info_type}; } } } public function timer_start() { $this->time_start = microtime( true ); return true; } public function timer_stop() { return ( microtime( true ) - $this->time_start ); } public function bail( $message, $error_code = '500' ) { if ( $this->show_errors ) { $error = ''; if ( $this->use_mysqli ) { if ( $this->dbh instanceof mysqli ) { $error = mysqli_error( $this->dbh ); } elseif ( mysqli_connect_errno() ) { $error = mysqli_connect_error(); } } else { if ( is_resource( $this->dbh ) ) { $error = mysql_error( $this->dbh ); } else { $error = mysql_error(); } } if ( $error ) { $message = '

    ' . $error . "

    \n" . $message; } wp_die( $message ); } else { if ( class_exists( 'WP_Error', false ) ) { $this->error = new WP_Error( $error_code, $message ); } else { $this->error = $message; } return false; } } public function close() { if ( ! $this->dbh ) { return false; } if ( $this->use_mysqli ) { $closed = mysqli_close( $this->dbh ); } else { $closed = mysql_close( $this->dbh ); } if ( $closed ) { $this->dbh = null; $this->ready = false; $this->has_connected = false; } return $closed; } public function check_database_version() { global $wp_version, $required_mysql_version; if ( version_compare( $this->db_version(), $required_mysql_version, '<' ) ) { return new WP_Error( 'database_version', sprintf( __( 'Error: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ) ); } } public function supports_collation() { _deprecated_function( __FUNCTION__, '3.5.0', 'wpdb::has_cap( \'collation\' )' ); return $this->has_cap( 'collation' ); } public function get_charset_collate() { $charset_collate = ''; if ( ! empty( $this->charset ) ) { $charset_collate = "DEFAULT CHARACTER SET $this->charset"; } if ( ! empty( $this->collate ) ) { $charset_collate .= " COLLATE $this->collate"; } return $charset_collate; } public function has_cap( $db_cap ) { $db_version = $this->db_version(); $db_server_info = $this->db_server_info(); if ( '5.5.5' === $db_version && str_contains( $db_server_info, 'MariaDB' ) && PHP_VERSION_ID < 80016 ) { $db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info ); $db_version = preg_replace( '/[^0-9.].*/', '', $db_server_info ); } switch ( strtolower( $db_cap ) ) { case 'collation': case 'group_concat': case 'subqueries': return version_compare( $db_version, '4.1', '>=' ); case 'set_charset': return version_compare( $db_version, '5.0.7', '>=' ); case 'utf8mb4': if ( version_compare( $db_version, '5.5.3', '<' ) ) { return false; } if ( $this->use_mysqli ) { $client_version = mysqli_get_client_info(); } else { $client_version = mysql_get_client_info(); } if ( false !== strpos( $client_version, 'mysqlnd' ) ) { $client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version ); return version_compare( $client_version, '5.0.9', '>=' ); } else { return version_compare( $client_version, '5.5.3', '>=' ); } case 'utf8mb4_520': return version_compare( $db_version, '5.6', '>=' ); case 'identifier_placeholders': return true; } return false; } public function get_caller() { return wp_debug_backtrace_summary( __CLASS__ ); } public function db_version() { return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() ); } public function db_server_info() { if ( $this->use_mysqli ) { $server_info = mysqli_get_server_info( $this->dbh ); } else { $server_info = mysql_get_server_info( $this->dbh ); } return $server_info; } } \n%s\n\n", class WP_Widget_Form_Customize_Control extends WP_Customize_Control { public $type = 'widget_form'; public $widget_id; public $widget_id_base; public $sidebar_id; public $is_new = false; public $width; public $height; public $is_wide = false; public function to_json() { global $wp_registered_widgets; parent::to_json(); $exported_properties = array( 'widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide' ); foreach ( $exported_properties as $key ) { $this->json[ $key ] = $this->$key; } require_once ABSPATH . 'wp-admin/includes/widgets.php'; $widget = $wp_registered_widgets[ $this->widget_id ]; if ( ! isset( $widget['params'][0] ) ) { $widget['params'][0] = array(); } $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], ); $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0], ) ); $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $args ); $this->json['widget_control'] = $widget_control_parts['control']; $this->json['widget_content'] = $widget_control_parts['content']; } public function render_content() {} public function active_callback() { return $this->manager->widgets->is_widget_rendered( $this->widget_id ); } } 268435456 ) { define( 'WP_MAX_MEMORY_LIMIT', $current_limit ); } else { define( 'WP_MAX_MEMORY_LIMIT', '256M' ); } } $wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT ); if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) { ini_set( 'memory_limit', WP_MEMORY_LIMIT ); } if ( ! isset( $blog_id ) ) { $blog_id = 1; } if ( ! defined( 'WP_CONTENT_DIR' ) ) { define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); } if ( ! defined( 'WP_DEBUG' ) ) { if ( 'development' === wp_get_environment_type() ) { define( 'WP_DEBUG', true ); } else { define( 'WP_DEBUG', false ); } } if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) { define( 'WP_DEBUG_DISPLAY', true ); } if ( ! defined( 'WP_DEBUG_LOG' ) ) { define( 'WP_DEBUG_LOG', false ); } if ( ! defined( 'WP_CACHE' ) ) { define( 'WP_CACHE', false ); } if ( ! defined( 'SCRIPT_DEBUG' ) ) { if ( ! empty( $wp_version ) ) { $develop_src = false !== strpos( $wp_version, '-src' ); } else { $develop_src = false; } define( 'SCRIPT_DEBUG', $develop_src ); } if ( ! defined( 'MEDIA_TRASH' ) ) { define( 'MEDIA_TRASH', false ); } if ( ! defined( 'SHORTINIT' ) ) { define( 'SHORTINIT', false ); } define( 'WP_FEATURE_BETTER_PASSWORDS', true ); define( 'MINUTE_IN_SECONDS', 60 ); define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS ); define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS ); define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS ); define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS ); define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS ); } function wp_plugin_directory_constants() { if ( ! defined( 'WP_CONTENT_URL' ) ) { define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); } if ( ! defined( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); } if ( ! defined( 'WP_PLUGIN_URL' ) ) { define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); } if ( ! defined( 'PLUGINDIR' ) ) { define( 'PLUGINDIR', 'wp-content/plugins' ); } if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) { define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); } if ( ! defined( 'WPMU_PLUGIN_URL' ) ) { define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); } if ( ! defined( 'MUPLUGINDIR' ) ) { define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); } } function wp_cookie_constants() { if ( ! defined( 'COOKIEHASH' ) ) { $siteurl = get_site_option( 'siteurl' ); if ( $siteurl ) { define( 'COOKIEHASH', md5( $siteurl ) ); } else { define( 'COOKIEHASH', '' ); } } if ( ! defined( 'USER_COOKIE' ) ) { define( 'USER_COOKIE', 'wordpressuser_' . COOKIEHASH ); } if ( ! defined( 'PASS_COOKIE' ) ) { define( 'PASS_COOKIE', 'wordpresspass_' . COOKIEHASH ); } if ( ! defined( 'AUTH_COOKIE' ) ) { define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH ); } if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) { define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH ); } if ( ! defined( 'LOGGED_IN_COOKIE' ) ) { define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH ); } if ( ! defined( 'TEST_COOKIE' ) ) { define( 'TEST_COOKIE', 'wordpress_test_cookie' ); } if ( ! defined( 'COOKIEPATH' ) ) { define( 'COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'home' ) . '/' ) ); } if ( ! defined( 'SITECOOKIEPATH' ) ) { define( 'SITECOOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) ); } if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) { define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' ); } if ( ! defined( 'PLUGINS_COOKIE_PATH' ) ) { define( 'PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) ); } if ( ! defined( 'COOKIE_DOMAIN' ) ) { define( 'COOKIE_DOMAIN', false ); } if ( ! defined( 'RECOVERY_MODE_COOKIE' ) ) { define( 'RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH ); } } function wp_ssl_constants() { if ( ! defined( 'FORCE_SSL_ADMIN' ) ) { if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) { define( 'FORCE_SSL_ADMIN', true ); } else { define( 'FORCE_SSL_ADMIN', false ); } } force_ssl_admin( FORCE_SSL_ADMIN ); if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) { force_ssl_admin( true ); } } function wp_functionality_constants() { if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) { define( 'AUTOSAVE_INTERVAL', MINUTE_IN_SECONDS ); } if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) { define( 'EMPTY_TRASH_DAYS', 30 ); } if ( ! defined( 'WP_POST_REVISIONS' ) ) { define( 'WP_POST_REVISIONS', true ); } if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) { define( 'WP_CRON_LOCK_TIMEOUT', MINUTE_IN_SECONDS ); } } function wp_templating_constants() { define( 'TEMPLATEPATH', get_template_directory() ); define( 'STYLESHEETPATH', get_stylesheet_directory() ); if ( ! defined( 'WP_DEFAULT_THEME' ) ) { define( 'WP_DEFAULT_THEME', 'twentytwentythree' ); } } $post->ID, 'Author_ID' => $post->post_author, 'Date' => $post->post_date, 'Content' => $post->post_content, 'Excerpt' => $post->post_excerpt, 'Title' => $post->post_title, 'Category' => $post->post_category, 'post_status' => $post->post_status, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_password' => $post->post_password, 'to_ping' => $post->to_ping, 'pinged' => $post->pinged, 'post_type' => $post->post_type, 'post_name' => $post->post_name ); return $postdata; } function start_wp() { global $wp_query; _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') ); $wp_query->next_post(); setup_postdata( get_post() ); } function the_category_ID($display = true) { _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); $categories = get_the_category(); $cat = $categories[0]->term_id; if ( $display ) echo $cat; return $cat; } function the_category_head( $before = '', $after = '' ) { global $currentcat, $previouscat; _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); $categories = get_the_category(); $currentcat = $categories[0]->category_id; if ( $currentcat != $previouscat ) { echo $before; echo get_the_category_by_ID($currentcat); echo $after; $previouscat = $currentcat; } } function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; else $in_same_cat = true; $post = get_previous_post($in_same_cat, $excluded_categories); if ( !$post ) return; $string = ''.$previous; if ( 'yes' == $title ) $string .= apply_filters('the_title', $post->post_title, $post->ID); $string .= ''; $format = str_replace('%', $string, $format); echo $format; } function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); if ( empty($in_same_cat) || 'no' == $in_same_cat ) $in_same_cat = false; else $in_same_cat = true; $post = get_next_post($in_same_cat, $excluded_categories); if ( !$post ) return; $string = ''.$next; if ( 'yes' == $title ) $string .= apply_filters('the_title', $post->post_title, $post->ID); $string .= ''; $format = str_replace('%', $string, $format); echo $format; } function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return ($author_data->user_level > 1); } function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return ($author_data->user_level >= 1); } function user_can_edit_post($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $author_data = get_userdata($user_id); $post = get_post($post_id); $post_author_data = get_userdata($post->post_author); if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) || ($author_data->user_level > $post_author_data->user_level) || ($author_data->user_level >= 10) ) { return true; } else { return false; } } function user_can_delete_post($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); return user_can_edit_post($user_id, $post_id, $blog_id); } function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); } function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $author_data = get_userdata($user_id); return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); } function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); return user_can_edit_post($user_id, $post_id, $blog_id); } function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); return user_can_edit_post_comments($user_id, $post_id, $blog_id); } function user_can_edit_user($user_id, $other_user) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); $user = get_userdata($user_id); $other = get_userdata($other_user); if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) return true; else return false; } function get_linksbyname($cat_name = "noname", $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $show_rating = false, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); if ( $cat ) $cat_id = $cat->term_id; get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); } function wp_get_linksbyname($category, $args = '') { _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); $defaults = array( 'after' => '
    ', 'before' => '', 'categorize' => 0, 'category_after' => '', 'category_before' => '', 'category_name' => $category, 'show_description' => 1, 'title_li' => '', ); $parsed_args = wp_parse_args( $args, $defaults ); return wp_list_bookmarks($parsed_args); } function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); if ( $cat ) $cat_id = $cat->term_id; return get_linkobjects($cat_id, $orderby, $limit); } function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; $links_array = array(); foreach ($links as $link) $links_array[] = $link; return $links_array; } function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); } function get_links_withrating($category = -1, $before = '', $after = '
    ', $between = " ", $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); } function get_autotoggle($id = 0) { _deprecated_function( __FUNCTION__, '2.1.0' ); return 0; } function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); return wp_list_cats($query); } function wp_list_cats($args = '') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); $parsed_args = wp_parse_args( $args ); if ( isset($parsed_args['optionall']) && isset($parsed_args['all'])) $parsed_args['show_option_all'] = $parsed_args['all']; if ( isset($parsed_args['sort_column']) ) $parsed_args['orderby'] = $parsed_args['sort_column']; if ( isset($parsed_args['sort_order']) ) $parsed_args['order'] = $parsed_args['sort_order']; if ( isset($parsed_args['optiondates']) ) $parsed_args['show_last_update'] = $parsed_args['optiondates']; if ( isset($parsed_args['optioncount']) ) $parsed_args['show_count'] = $parsed_args['optioncount']; if ( isset($parsed_args['list']) ) $parsed_args['style'] = $parsed_args['list'] ? 'list' : 'break'; $parsed_args['title_li'] = ''; return wp_list_categories($parsed_args); } function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, $selected = 0, $exclude = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); $show_option_all = ''; if ( $optionall ) $show_option_all = $all; $show_option_none = ''; if ( $optionnone ) $show_option_none = __('None'); $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); $query = add_query_arg($vars, ''); return wp_dropdown_categories($query); } function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' ); $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); return wp_list_authors($args); } function wp_get_post_cats($blogid = '1', $post_ID = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' ); return wp_get_post_categories($post_ID); } function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); return wp_set_post_categories($post_ID, $post_categories); } function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' ); $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); return wp_get_archives($args); } function get_author_link($display, $author_id, $author_nicename = '') { _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' ); $link = get_author_posts_url($author_id, $author_nicename); if ( $display ) echo $link; return $link; } function link_pages($before='
    ', $after='
    ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' ); $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); return wp_link_pages($args); } function get_settings($option) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' ); return get_option($option); } function permalink_link() { _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' ); the_permalink(); } function permalink_single_rss($deprecated = '') { _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' ); the_permalink_rss(); } function wp_get_links($args = '') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); if ( strpos( $args, '=' ) === false ) { $cat_id = $args; $args = add_query_arg( 'category', $cat_id, $args ); } $defaults = array( 'after' => '
    ', 'before' => '', 'between' => ' ', 'categorize' => 0, 'category' => '', 'echo' => true, 'limit' => -1, 'orderby' => 'name', 'show_description' => true, 'show_images' => true, 'show_rating' => false, 'show_updated' => true, 'title_li' => '', ); $parsed_args = wp_parse_args( $args, $defaults ); return wp_list_bookmarks($parsed_args); } function get_links($category = -1, $before = '', $after = '
    ', $between = ' ', $show_images = true, $orderby = 'name', $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $display = true) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); $order = 'ASC'; if ( substr($orderby, 0, 1) == '_' ) { $order = 'DESC'; $orderby = substr($orderby, 1); } if ( $category == -1 ) $category = ''; $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); if ( !$results ) return; $output = ''; foreach ( (array) $results as $row ) { if ( !isset($row->recently_updated) ) $row->recently_updated = false; $output .= $before; if ( $show_updated && $row->recently_updated ) $output .= get_option('links_recently_updated_prepend'); $the_link = '#'; if ( !empty($row->link_url) ) $the_link = esc_url($row->link_url); $rel = $row->link_rel; if ( '' != $rel ) $rel = ' rel="' . $rel . '"'; $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); $title = $desc; if ( $show_updated ) if (substr($row->link_updated_f, 0, 2) != '00') $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; if ( '' != $title ) $title = ' title="' . $title . '"'; $alt = ' alt="' . $name . '"'; $target = $row->link_target; if ( '' != $target ) $target = ' target="' . $target . '"'; $output .= ''; if ( $row->link_image != null && $show_images ) { if ( strpos($row->link_image, 'http') !== false ) $output .= "link_image\" $alt $title />"; else $output .= "link_image\" $alt $title />"; } else { $output .= $name; } $output .= ''; if ( $show_updated && $row->recently_updated ) $output .= get_option('links_recently_updated_append'); if ( $show_description && '' != $desc ) $output .= $between . $desc; if ($show_rating) { $output .= $between . get_linkrating($row); } $output .= "$after\n"; } if ( !$display ) return $output; echo $output; } function get_links_list($order = 'name') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); $order = strtolower($order); $direction = 'ASC'; if ( '_' == substr($order,0,1) ) { $direction = 'DESC'; $order = substr($order,1); } if ( !isset($direction) ) $direction = ''; $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); if ( $cats ) { foreach ( (array) $cats as $cat ) { echo '
  • ' . apply_filters('link_category', $cat->name ) . "

    \n\t
      \n"; get_links($cat->term_id, '
    • ', "
    • ", "\n", true, 'name', false); echo "\n\t
    \n
  • \n"; } } } function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { _deprecated_function( __FUNCTION__, '2.1.0' ); } function get_linkrating( $link ) { _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' ); return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); } function get_linkcatname($id = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); $id = (int) $id; if ( empty($id) ) return ''; $cats = wp_get_link_cats($id); if ( empty($cats) || ! is_array($cats) ) return ''; $cat_id = (int) $cats[0]; $cat = get_category($cat_id); return $cat->name; } function comments_rss_link($link_text = 'Comments RSS') { _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' ); post_comments_feed_link($link_text); } function get_category_rss_link($display = false, $cat_ID = 1) { _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' ); $link = get_category_feed_link($cat_ID, 'rss2'); if ( $display ) echo $link; return $link; } function get_author_rss_link($display = false, $author_id = 1) { _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); $link = get_author_feed_link($author_id); if ( $display ) echo $link; return $link; } function comments_rss() { _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' ); return esc_url( get_post_comments_feed_link() ); } function create_user($username, $password, $email) { _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' ); return wp_create_user($username, $password, $email); } function gzip_compression() { _deprecated_function( __FUNCTION__, '2.5.0' ); return false; } function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' ); return get_comment($comment_ID, ARRAY_A); } function get_catname( $cat_ID ) { _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' ); return get_cat_name( $cat_ID ); } function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); if ( 0 == $id ) return ''; $chain = ''; $cat_ids = get_all_category_ids(); foreach ( (array) $cat_ids as $cat_id ) { if ( $cat_id == $id ) continue; $category = get_category( $cat_id ); if ( is_wp_error( $category ) ) return $category; if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { $visited[] = $category->term_id; $chain .= $before.$category->term_id.$after; $chain .= get_category_children( $category->term_id, $before, $after ); } } return $chain; } function get_all_category_ids() { _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' ); $cat_ids = get_terms( array( 'taxonomy' => 'category', 'fields' => 'ids', 'get' => 'all', ) ); return $cat_ids; } function get_the_author_description() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' ); return get_the_author_meta('description'); } function the_author_description() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' ); the_author_meta('description'); } function get_the_author_login() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' ); return get_the_author_meta('login'); } function the_author_login() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' ); the_author_meta('login'); } function get_the_author_firstname() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' ); return get_the_author_meta('first_name'); } function the_author_firstname() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' ); the_author_meta('first_name'); } function get_the_author_lastname() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' ); return get_the_author_meta('last_name'); } function the_author_lastname() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' ); the_author_meta('last_name'); } function get_the_author_nickname() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' ); return get_the_author_meta('nickname'); } function the_author_nickname() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' ); the_author_meta('nickname'); } function get_the_author_email() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' ); return get_the_author_meta('email'); } function the_author_email() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' ); the_author_meta('email'); } function get_the_author_icq() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' ); return get_the_author_meta('icq'); } function the_author_icq() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' ); the_author_meta('icq'); } function get_the_author_yim() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' ); return get_the_author_meta('yim'); } function the_author_yim() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' ); the_author_meta('yim'); } function get_the_author_msn() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' ); return get_the_author_meta('msn'); } function the_author_msn() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' ); the_author_meta('msn'); } function get_the_author_aim() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' ); return get_the_author_meta('aim'); } function the_author_aim() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' ); the_author_meta('aim'); } function get_author_name( $auth_id = false ) { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' ); return get_the_author_meta('display_name', $auth_id); } function get_the_author_url() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' ); return get_the_author_meta('url'); } function the_author_url() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' ); the_author_meta('url'); } function get_the_author_ID() { _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' ); return get_the_author_meta('ID'); } function the_author_ID() { _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' ); the_author_meta('ID'); } function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' ); $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters('the_content_rss', $content); if ( $cut && !$encode_html ) $encode_html = 2; if ( 1== $encode_html ) { $content = esc_html($content); $cut = 0; } elseif ( 0 == $encode_html ) { $content = make_url_footnote($content); } elseif ( 2 == $encode_html ) { $content = strip_tags($content); } if ( $cut ) { $blah = explode(' ', $content); if ( count($blah) > $cut ) { $k = $cut; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } for ( $i=0; $i<$k; $i++ ) $excerpt .= $blah[$i].' '; $excerpt .= ($use_dotdotdot) ? '...' : ''; $content = $excerpt; } $content = str_replace(']]>', ']]>', $content); echo $content; } function make_url_footnote( $content ) { _deprecated_function( __FUNCTION__, '2.9.0', '' ); preg_match_all( '/(.+?)<\/a>/', $content, $matches ); $links_summary = "\n"; for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { $link_match = $matches[0][$i]; $link_number = '['.($i+1).']'; $link_url = $matches[2][$i]; $link_text = $matches[4][$i]; $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; $links_summary .= "\n" . $link_number . ' ' . $link_url; } $content = strip_tags( $content ); $content .= $links_summary; return $content; } function _c( $text, $domain = 'default' ) { _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); return before_last_bar( translate( $text, $domain ) ); } function translate_with_context( $text, $domain = 'default' ) { _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); return before_last_bar( translate( $text, $domain ) ); } function _nc( $single, $plural, $number, $domain = 'default' ) { _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' ); return before_last_bar( _n( $single, $plural, $number, $domain ) ); } function __ngettext( ...$args ) { _deprecated_function( __FUNCTION__, '2.8.0', '_n()' ); return _n( ...$args ); } function __ngettext_noop( ...$args ) { _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' ); return _n_noop( ...$args ); } function get_alloptions() { _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' ); return wp_load_alloptions(); } function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); $id = (int) $id; $_post = get_post($id); if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) return __('Missing Attachment'); if ( $permalink ) $url = get_attachment_link($_post->ID); $post_title = esc_attr($_post->post_title); $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); return "$innerHTML"; } function get_attachment_icon_src( $id = 0, $fullsize = false ) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; $file = get_attached_file( $post->ID ); if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { $src_file = wp_basename($src); } elseif ( wp_attachment_is_image( $post->ID ) ) { $src = wp_get_attachment_url( $post->ID ); $src_file = & $file; } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); $src_file = $icon_dir . '/' . wp_basename($src); } if ( !isset($src) || !$src ) return false; return array($src, $src_file); } function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) return false; list($src, $src_file) = $src; if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { $imagesize = wp_getimagesize($src_file); if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { $actual_aspect = $imagesize[0] / $imagesize[1]; $desired_aspect = $max_dims[0] / $max_dims[1]; if ( $actual_aspect >= $desired_aspect ) { $height = $actual_aspect * $max_dims[0]; $constraint = "width='{$max_dims[0]}' "; $post->iconsize = array($max_dims[0], $height); } else { $width = $max_dims[1] / $actual_aspect; $constraint = "height='{$max_dims[1]}' "; $post->iconsize = array($width, $max_dims[1]); } } else { $post->iconsize = array($imagesize[0], $imagesize[1]); $constraint = ''; } } else { $constraint = ''; } $post_title = esc_attr($post->post_title); $icon = "$post_title"; return apply_filters( 'attachment_icon', $icon, $post->ID ); } function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) return $innerHTML; $innerHTML = esc_attr($post->post_title); return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); } function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' ); return get_bookmark($bookmark_id, $output, $filter); } function clean_url( $url, $protocols = null, $context = 'display' ) { if ( $context == 'db' ) _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'sanitize_url()' ); else _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); return esc_url( $url, $protocols, $context ); } function js_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' ); return esc_js( $text ); } function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); if ( func_num_args() > 1 ) { return _wp_specialchars( $text, $quote_style, $charset, $double_encode ); } else { return esc_html( $text ); } } function attribute_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' ); return esc_attr( $text ); } function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); if ( is_array( $name ) ) { if ( count( $name ) === 3 ) { $name = sprintf( $name[0], $name[2] ); } else { $name = $name[0]; } } $id = sanitize_title( $name ); $options = array(); if ( ! empty( $classname ) && is_string( $classname ) ) { $options['classname'] = $classname; } wp_register_sidebar_widget( $id, $name, $output_callback, $options, ...$params ); } function unregister_sidebar_widget($id) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' ); return wp_unregister_sidebar_widget($id); } function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); if ( is_array( $name ) ) { if ( count( $name ) === 3 ) { $name = sprintf( $name[0], $name[2] ); } else { $name = $name[0]; } } $id = sanitize_title( $name ); $options = array(); if ( ! empty( $width ) ) { $options['width'] = $width; } if ( ! empty( $height ) ) { $options['height'] = $height; } wp_register_widget_control( $id, $name, $control_callback, $options, ...$params ); } function unregister_widget_control($id) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' ); return wp_unregister_widget_control($id); } function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if ( is_array($meta_value) || is_object($meta_value) ) $meta_value = serialize($meta_value); $meta_value = trim( $meta_value ); $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur && $cur->umeta_id ) do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( ! empty($meta_value) ) $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); else $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( $cur && $cur->umeta_id ) do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } function get_usermeta( $user_id, $meta_key = '' ) { _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' ); global $wpdb; $user_id = (int) $user_id; if ( !$user_id ) return false; if ( !empty($meta_key) ) { $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $user = wp_cache_get($user_id, 'users'); if ( false !== $user && isset($user->$meta_key) ) $metas = array($user->$meta_key); else $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); } else { $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); } if ( empty($metas) ) { if ( empty($meta_key) ) return array(); else return ''; } $metas = array_map('maybe_unserialize', $metas); if ( count($metas) == 1 ) return $metas[0]; else return $metas; } function update_usermeta( $user_id, $meta_key, $meta_value ) { _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if ( is_string($meta_value) ) $meta_value = stripslashes($meta_value); $meta_value = maybe_serialize($meta_value); if (empty($meta_value)) { return delete_usermeta($user_id, $meta_key); } $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur ) do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( !$cur ) $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); elseif ( $cur->meta_value != $meta_value ) $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); else return false; clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( !$cur ) do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); else do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } function get_users_of_blog( $id = '' ) { _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); global $wpdb; if ( empty( $id ) ) { $id = get_current_blog_id(); } $blog_prefix = $wpdb->get_blog_prefix($id); $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); return $users; } function automatic_feed_links( $add = true ) { _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); if ( $add ) add_theme_support( 'automatic-feed-links' ); else remove_action( 'wp_head', 'feed_links_extra', 3 ); } function get_profile( $field, $user = false ) { _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' ); if ( $user ) { $user = get_user_by( 'login', $user ); $user = $user->ID; } return get_the_author_meta( $field, $user ); } function get_usernumposts( $userid ) { _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); return count_user_posts( $userid ); } function funky_javascript_callback($matches) { return "&#".base_convert($matches[1],16,10).";"; } function funky_javascript_fix($text) { _deprecated_function( __FUNCTION__, '3.0.0' ); global $is_macIE, $is_winIE; if ( $is_winIE || $is_macIE ) $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", "funky_javascript_callback", $text); return $text; } function is_taxonomy( $taxonomy ) { _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' ); return taxonomy_exists( $taxonomy ); } function is_term( $term, $taxonomy = '', $parent = 0 ) { _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' ); return term_exists( $term, $taxonomy, $parent ); } function is_plugin_page() { _deprecated_function( __FUNCTION__, '3.1.0' ); global $plugin_page; if ( isset($plugin_page) ) return true; return false; } function update_category_cache() { _deprecated_function( __FUNCTION__, '3.1.0' ); return true; } function wp_timezone_supported() { _deprecated_function( __FUNCTION__, '3.2.0' ); return true; } function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); } function get_user_metavalues($ids) { _deprecated_function( __FUNCTION__, '3.3.0' ); $objects = array(); $ids = array_map('intval', $ids); foreach ( $ids as $id ) $objects[$id] = array(); $metas = update_meta_cache('user', $ids); foreach ( $metas as $id => $meta ) { foreach ( $meta as $key => $metavalues ) { foreach ( $metavalues as $value ) { $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); } } } return $objects; } function sanitize_user_object($user, $context = 'display') { _deprecated_function( __FUNCTION__, '3.3.0' ); if ( is_object($user) ) { if ( !isset($user->ID) ) $user->ID = 0; if ( ! ( $user instanceof WP_User ) ) { $vars = get_object_vars($user); foreach ( array_keys($vars) as $field ) { if ( is_string($user->$field) || is_numeric($user->$field) ) $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); } } $user->filter = $context; } else { if ( !isset($user['ID']) ) $user['ID'] = 0; foreach ( array_keys($user) as $field ) $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); $user['filter'] = $context; } return $user; } function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { _deprecated_function( __FUNCTION__, '3.3.0' ); $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); if ( empty($posts) ) return; $post = $posts[0]; if ( empty($post->post_title) ) $post->post_title = $start ? __('First Post') : __('Last Post'); $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); $title = apply_filters('the_title', $title, $post->ID); $link = $start ? "\n"; $boundary = $start ? 'start' : 'end'; return apply_filters( "{$boundary}_post_rel_link", $link ); } function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { _deprecated_function( __FUNCTION__, '3.3.0' ); echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); } function get_index_rel_link() { _deprecated_function( __FUNCTION__, '3.3.0' ); $link = "\n"; return apply_filters( "index_rel_link", $link ); } function index_rel_link() { _deprecated_function( __FUNCTION__, '3.3.0' ); echo get_index_rel_link(); } function get_parent_post_rel_link( $title = '%title' ) { _deprecated_function( __FUNCTION__, '3.3.0' ); if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) $post = get_post($GLOBALS['post']->post_parent); if ( empty($post) ) return; $date = mysql2date(get_option('date_format'), $post->post_date); $title = str_replace('%title', $post->post_title, $title); $title = str_replace('%date', $date, $title); $title = apply_filters('the_title', $title, $post->ID); $link = "\n"; return apply_filters( "parent_post_rel_link", $link ); } function parent_post_rel_link( $title = '%title' ) { _deprecated_function( __FUNCTION__, '3.3.0' ); echo get_parent_post_rel_link($title); } function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { _deprecated_function( __FUNCTION__, '3.3.0' ); $user_id = get_current_user_id(); if ( 0 != $user_id ) { if ( is_admin() ) $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); elseif ( is_multisite() ) $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); else $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); } } function is_blog_user( $blog_id = 0 ) { _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' ); return is_user_member_of_blog( get_current_user_id(), $blog_id ); } function debug_fopen( $filename, $mode ) { _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); return false; } function debug_fwrite( $fp, $message ) { _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); if ( ! empty( $GLOBALS['debug'] ) ) error_log( $message ); } function debug_fclose( $fp ) { _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); } function get_themes() { _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); global $wp_themes; if ( isset( $wp_themes ) ) return $wp_themes; $themes = wp_get_themes(); $wp_themes = array(); foreach ( $themes as $theme ) { $name = $theme->get('Name'); if ( isset( $wp_themes[ $name ] ) ) $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; else $wp_themes[ $name ] = $theme; } return $wp_themes; } function get_theme( $theme ) { _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); $themes = get_themes(); if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) return $themes[ $theme ]; return null; } function get_current_theme() { _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); if ( $theme = get_option( 'current_theme' ) ) return $theme; return wp_get_theme()->get('Name'); } function clean_pre($matches) { _deprecated_function( __FUNCTION__, '3.4.0' ); if ( is_array($matches) ) $text = $matches[1] . $matches[2] . ""; else $text = $matches; $text = str_replace(array('
    ', '
    ', '
    '), array('', '', ''), $text); $text = str_replace('

    ', "\n", $text); $text = str_replace('

    ', '', $text); return $text; } function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' ); $args = array( 'wp-head-callback' => $wp_head_callback, 'admin-head-callback' => $admin_head_callback, ); if ( $admin_preview_callback ) $args['admin-preview-callback'] = $admin_preview_callback; return add_theme_support( 'custom-header', $args ); } function remove_custom_image_header() { _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' ); return remove_theme_support( 'custom-header' ); } function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); $args = array(); if ( $wp_head_callback ) $args['wp-head-callback'] = $wp_head_callback; if ( $admin_head_callback ) $args['admin-head-callback'] = $admin_head_callback; if ( $admin_preview_callback ) $args['admin-preview-callback'] = $admin_preview_callback; return add_theme_support( 'custom-background', $args ); } function remove_custom_background() { _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' ); return remove_theme_support( 'custom-background' ); } function get_theme_data( $theme_file ) { _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); $theme = new WP_Theme( wp_basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); $theme_data = array( 'Name' => $theme->get('Name'), 'URI' => $theme->display('ThemeURI', true, false), 'Description' => $theme->display('Description', true, false), 'Author' => $theme->display('Author', true, false), 'AuthorURI' => $theme->display('AuthorURI', true, false), 'Version' => $theme->get('Version'), 'Template' => $theme->get('Template'), 'Status' => $theme->get('Status'), 'Tags' => $theme->get('Tags'), 'Title' => $theme->get('Name'), 'AuthorName' => $theme->get('Author'), ); foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { if ( ! isset( $theme_data[ $extra_header ] ) ) $theme_data[ $extra_header ] = $theme->get( $extra_header ); } return $theme_data; } function update_page_cache( &$pages ) { _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' ); update_post_cache( $pages ); } function clean_page_cache( $id ) { _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' ); clean_post_cache( $id ); } function wp_explain_nonce( $action ) { _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); return __( 'Are you sure you want to do this?' ); } function sticky_class( $post_id = null ) { _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); if ( is_sticky( $post_id ) ) echo ' sticky'; } function _get_post_ancestors( &$post ) { _deprecated_function( __FUNCTION__, '3.5.0' ); } function wp_load_image( $file ) { _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); if ( is_numeric( $file ) ) $file = get_attached_file( $file ); if ( ! is_file( $file ) ) { return sprintf( __( 'File “%s” does not exist?' ), $file ); } if ( ! function_exists('imagecreatefromstring') ) return __('The GD image library is not installed.'); wp_raise_memory_limit( 'image' ); $image = imagecreatefromstring( file_get_contents( $file ) ); if ( ! is_gd_image( $image ) ) { return sprintf( __( 'File “%s” is not an image.' ), $file ); } return $image; } function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); $editor = wp_get_image_editor( $file ); if ( is_wp_error( $editor ) ) return $editor; $editor->set_quality( $jpeg_quality ); $resized = $editor->resize( $max_w, $max_h, $crop ); if ( is_wp_error( $resized ) ) return $resized; $dest_file = $editor->generate_filename( $suffix, $dest_path ); $saved = $editor->save( $dest_file ); if ( is_wp_error( $saved ) ) return $saved; return $dest_file; } function wp_get_single_post( $postid = 0, $mode = OBJECT ) { _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); return get_post( $postid, $mode ); } function user_pass_ok($user_login, $user_pass) { _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); $user = wp_authenticate( $user_login, $user_pass ); if ( is_wp_error( $user ) ) return false; return true; } function _save_post_hook() {} function gd_edit_image_support($mime_type) { _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' ); if ( function_exists('imagetypes') ) { switch( $mime_type ) { case 'image/jpeg': return (imagetypes() & IMG_JPG) != 0; case 'image/png': return (imagetypes() & IMG_PNG) != 0; case 'image/gif': return (imagetypes() & IMG_GIF) != 0; case 'image/webp': return (imagetypes() & IMG_WEBP) != 0; } } else { switch( $mime_type ) { case 'image/jpeg': return function_exists('imagecreatefromjpeg'); case 'image/png': return function_exists('imagecreatefrompng'); case 'image/gif': return function_exists('imagecreatefromgif'); case 'image/webp': return function_exists('imagecreatefromwebp'); } } return false; } function wp_convert_bytes_to_hr( $bytes ) { _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); $log = log( $bytes, KB_IN_BYTES ); $power = (int) $log; $size = KB_IN_BYTES ** ( $log - $power ); if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { $unit = $units[ $power ]; } else { $size = $bytes; $unit = $units[0]; } return $size . $unit; } function _search_terms_tidy( $t ) { _deprecated_function( __FUNCTION__, '3.7.0' ); return trim( $t, "\"'\n\r " ); } function rich_edit_exists() { global $wp_rich_edit_exists; _deprecated_function( __FUNCTION__, '3.9.0' ); if ( ! isset( $wp_rich_edit_exists ) ) $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); return $wp_rich_edit_exists; } function default_topic_count_text( $count ) { return $count; } function format_to_post( $content ) { _deprecated_function( __FUNCTION__, '3.9.0' ); return $content; } function like_escape($text) { _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); } function url_is_accessable_via_ssl( $url ) { _deprecated_function( __FUNCTION__, '4.0.0' ); $response = wp_remote_get( set_url_scheme( $url, 'https' ) ); if ( !is_wp_error( $response ) ) { $status = wp_remote_retrieve_response_code( $response ); if ( 200 == $status || 401 == $status ) { return true; } } return false; } function preview_theme() { _deprecated_function( __FUNCTION__, '4.3.0' ); } function _preview_theme_template_filter() { _deprecated_function( __FUNCTION__, '4.3.0' ); return ''; } function _preview_theme_stylesheet_filter() { _deprecated_function( __FUNCTION__, '4.3.0' ); return ''; } function preview_theme_ob_filter( $content ) { _deprecated_function( __FUNCTION__, '4.3.0' ); return $content; } function preview_theme_ob_filter_callback( $matches ) { _deprecated_function( __FUNCTION__, '4.3.0' ); return ''; } function wp_richedit_pre($text) { _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); if ( empty( $text ) ) { return apply_filters( 'richedit_pre', '' ); } $output = convert_chars($text); $output = wpautop($output); $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); return apply_filters( 'richedit_pre', $output ); } function wp_htmledit_pre($output) { _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); if ( !empty($output) ) $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); return apply_filters( 'htmledit_pre', $output ); } function post_permalink( $post = 0 ) { _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' ); return get_permalink( $post ); } function wp_get_http( $url, $file_path = false, $red = 1 ) { _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' ); ; if ( $red > 5 ) return false; $options = array(); $options['redirection'] = 5; if ( false == $file_path ) $options['method'] = 'HEAD'; else $options['method'] = 'GET'; $response = wp_safe_remote_request( $url, $options ); if ( is_wp_error( $response ) ) return false; $headers = wp_remote_retrieve_headers( $response ); $headers['response'] = wp_remote_retrieve_response_code( $response ); if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { return wp_get_http( $headers['location'], $file_path, ++$red ); } if ( false == $file_path ) return $headers; $out_fp = fopen($file_path, 'w'); if ( !$out_fp ) return $headers; fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); fclose($out_fp); clearstatcache(); return $headers; } function force_ssl_login( $force = null ) { _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' ); return force_ssl_admin( $force ); } function get_comments_popup_template() { _deprecated_function( __FUNCTION__, '4.5.0' ); return ''; } function is_comments_popup() { _deprecated_function( __FUNCTION__, '4.5.0' ); return false; } function comments_popup_script() { _deprecated_function( __FUNCTION__, '4.5.0' ); } function popuplinks( $text ) { _deprecated_function( __FUNCTION__, '4.5.0' ); $text = preg_replace('//i', "", $text); return $text; } function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { _deprecated_function( __FUNCTION__, '4.6.0' ); return ''; } function get_paged_template() { _deprecated_function( __FUNCTION__, '4.7.0' ); return get_query_template( 'paged' ); } function wp_kses_js_entities( $content ) { _deprecated_function( __FUNCTION__, '4.7.0' ); return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $content ); } function _usort_terms_by_ID( $a, $b ) { _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); if ( $a->term_id > $b->term_id ) return 1; elseif ( $a->term_id < $b->term_id ) return -1; else return 0; } function _usort_terms_by_name( $a, $b ) { _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); return strcmp( $a->name, $b->name ); } function _sort_nav_menu_items( $a, $b ) { global $_menu_item_sort_prop; _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); if ( empty( $_menu_item_sort_prop ) ) return 0; if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) return 0; $_a = (int) $a->$_menu_item_sort_prop; $_b = (int) $b->$_menu_item_sort_prop; if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) return 0; elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) return $_a < $_b ? -1 : 1; else return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); } function get_shortcut_link() { _deprecated_function( __FUNCTION__, '4.9.0' ); $link = ''; return apply_filters( 'shortcut_link', $link ); } function wp_ajax_press_this_save_post() { _deprecated_function( __FUNCTION__, '4.9.0' ); if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; $wp_press_this = new WP_Press_This_Plugin(); $wp_press_this->save_post(); } else { wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); } } function wp_ajax_press_this_add_category() { _deprecated_function( __FUNCTION__, '4.9.0' ); if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; $wp_press_this = new WP_Press_This_Plugin(); $wp_press_this->add_category(); } else { wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); } } function wp_get_user_request_data( $request_id ) { _deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' ); return wp_get_user_request( $request_id ); } function wp_make_content_images_responsive( $content ) { _deprecated_function( __FUNCTION__, '5.5.0', 'wp_filter_content_tags()' ); return wp_filter_content_tags( $content ); } function wp_unregister_GLOBALS() { _deprecated_function( __FUNCTION__, '5.5.0' ); } function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) { _deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' ); return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ); } function _wp_register_meta_args_whitelist( $args, $default_args ) { _deprecated_function( __FUNCTION__, '5.5.0', '_wp_register_meta_args_allowed_list()' ); return _wp_register_meta_args_allowed_list( $args, $default_args ); } function add_option_whitelist( $new_options, $options = '' ) { _deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' ); return add_allowed_options( $new_options, $options ); } function remove_option_whitelist( $del_options, $options = '' ) { _deprecated_function( __FUNCTION__, '5.5.0', 'remove_allowed_options()' ); return remove_allowed_options( $del_options, $options ); } function wp_slash_strings_only( $value ) { return map_deep( $value, 'addslashes_strings_only' ); } function addslashes_strings_only( $value ) { return is_string( $value ) ? addslashes( $value ) : $value; } function noindex() { _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_noindex()' ); if ( '0' == get_option( 'blog_public' ) ) { wp_no_robots(); } } function wp_no_robots() { _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' ); if ( get_option( 'blog_public' ) ) { echo "\n"; return; } echo "\n"; } function wp_sensitive_page_meta() { _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' ); ?> @@ -29787,7 +32470,7 @@ img.emoji { apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/14.0.0/72x72/' ), 'ext' => apply_filters( 'emoji_ext', '.png' ), 'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/14.0.0/svg/' ), 'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ), ); $version = 'ver=' . get_bloginfo( 'version' ); if ( SCRIPT_DEBUG ) { $settings['source'] = array( 'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ), 'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ), ); } else { $settings['source'] = array( 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ), ); } wp_print_inline_script_tag( sprintf( 'window._wpemojiSettings = %s;', wp_json_encode( $settings ) ) . "\n" . file_get_contents( sprintf( ABSPATH . WPINC . '/js/wp-emoji-loader' . wp_scripts_get_suffix() . '.js' ) ) ); } function wp_encode_emoji( $content ) { $emoji = _wp_emoji_list( 'partials' ); foreach ( $emoji as $emojum ) { $emoji_char = html_entity_decode( $emojum ); if ( false !== strpos( $content, $emoji_char ) ) { $content = preg_replace( "/$emoji_char/", $emojum, $content ); } } return $content; } function wp_staticize_emoji( $text ) { if ( false === strpos( $text, '&#x' ) ) { if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) { return $text; } else { $encoded_text = wp_encode_emoji( $text ); if ( $encoded_text === $text ) { return $encoded_text; } $text = $encoded_text; } } $emoji = _wp_emoji_list( 'entities' ); $possible_emoji = array(); foreach ( $emoji as $emojum ) { if ( false !== strpos( $text, $emojum ) ) { $possible_emoji[ $emojum ] = html_entity_decode( $emojum ); } } if ( ! $possible_emoji ) { return $text; } $cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/14.0.0/72x72/' ); $ext = apply_filters( 'emoji_ext', '.png' ); $output = ''; $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); $stop = count( $textarr ); $tags_to_ignore = 'code|pre|style|script|textarea'; $ignore_block_element = ''; for ( $i = 0; $i < $stop; $i++ ) { $content = $textarr[ $i ]; if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { $ignore_block_element = $matches[1]; } if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && false !== strpos( $content, '&#x' ) ) { foreach ( $possible_emoji as $emojum => $emoji_char ) { if ( false === strpos( $content, $emojum ) ) { continue; } $file = str_replace( ';&#x', '-', $emojum ); $file = str_replace( array( '&#x', ';' ), '', $file ); $entity = sprintf( '%s', $cdn_url . $file . $ext, $emoji_char ); $content = str_replace( $emojum, $entity, $content ); } } if ( '' !== $ignore_block_element && '' === $content ) { $ignore_block_element = ''; } $output .= $content; } $output = str_replace( '️', '', $output ); return $output; } function wp_staticize_emoji_for_email( $mail ) { if ( ! isset( $mail['message'] ) ) { return $mail; } $headers = array(); if ( isset( $mail['headers'] ) ) { if ( is_array( $mail['headers'] ) ) { $headers = $mail['headers']; } else { $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); } } foreach ( $headers as $header ) { if ( strpos( $header, ':' ) === false ) { continue; } list( $name, $content ) = explode( ':', trim( $header ), 2 ); $name = trim( $name ); $content = trim( $content ); if ( 'content-type' === strtolower( $name ) ) { if ( strpos( $content, ';' ) !== false ) { list( $type, $charset ) = explode( ';', $content ); $content_type = trim( $type ); } else { $content_type = trim( $content ); } break; } } if ( ! isset( $content_type ) ) { $content_type = 'text/plain'; } $content_type = apply_filters( 'wp_mail_content_type', $content_type ); if ( 'text/html' === $content_type ) { $mail['message'] = wp_staticize_emoji( $mail['message'] ); } return $mail; } function _wp_emoji_list( $type = 'entities' ) { $entities = array( '👨🏻‍❤️‍💋‍👨🏻', '👨🏻‍❤️‍💋‍👨🏼', '👨🏻‍❤️‍💋‍👨🏽', '👨🏻‍❤️‍💋‍👨🏾', '👨🏻‍❤️‍💋‍👨🏿', '👨🏼‍❤️‍💋‍👨🏻', '👨🏼‍❤️‍💋‍👨🏼', '👨🏼‍❤️‍💋‍👨🏽', '👨🏼‍❤️‍💋‍👨🏾', '👨🏼‍❤️‍💋‍👨🏿', '👨🏽‍❤️‍💋‍👨🏻', '👨🏽‍❤️‍💋‍👨🏼', '👨🏽‍❤️‍💋‍👨🏽', '👨🏽‍❤️‍💋‍👨🏾', '👨🏽‍❤️‍💋‍👨🏿', '👨🏾‍❤️‍💋‍👨🏻', '👨🏾‍❤️‍💋‍👨🏼', '👨🏾‍❤️‍💋‍👨🏽', '👨🏾‍❤️‍💋‍👨🏾', '👨🏾‍❤️‍💋‍👨🏿', '👨🏿‍❤️‍💋‍👨🏻', '👨🏿‍❤️‍💋‍👨🏼', '👨🏿‍❤️‍💋‍👨🏽', '👨🏿‍❤️‍💋‍👨🏾', '👨🏿‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👨🏻', '👩🏻‍❤️‍💋‍👨🏼', '👩🏻‍❤️‍💋‍👨🏽', '👩🏻‍❤️‍💋‍👨🏾', '👩🏻‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👩🏻', '👩🏻‍❤️‍💋‍👩🏼', '👩🏻‍❤️‍💋‍👩🏽', '👩🏻‍❤️‍💋‍👩🏾', '👩🏻‍❤️‍💋‍👩🏿', '👩🏼‍❤️‍💋‍👨🏻', '👩🏼‍❤️‍💋‍👨🏼', '👩🏼‍❤️‍💋‍👨🏽', '👩🏼‍❤️‍💋‍👨🏾', '👩🏼‍❤️‍💋‍👨🏿', '👩🏼‍❤️‍💋‍👩🏻', '👩🏼‍❤️‍💋‍👩🏼', '👩🏼‍❤️‍💋‍👩🏽', '👩🏼‍❤️‍💋‍👩🏾', '👩🏼‍❤️‍💋‍👩🏿', '👩🏽‍❤️‍💋‍👨🏻', '👩🏽‍❤️‍💋‍👨🏼', '👩🏽‍❤️‍💋‍👨🏽', '👩🏽‍❤️‍💋‍👨🏾', '👩🏽‍❤️‍💋‍👨🏿', '👩🏽‍❤️‍💋‍👩🏻', '👩🏽‍❤️‍💋‍👩🏼', '👩🏽‍❤️‍💋‍👩🏽', '👩🏽‍❤️‍💋‍👩🏾', '👩🏽‍❤️‍💋‍👩🏿', '👩🏾‍❤️‍💋‍👨🏻', '👩🏾‍❤️‍💋‍👨🏼', '👩🏾‍❤️‍💋‍👨🏽', '👩🏾‍❤️‍💋‍👨🏾', '👩🏾‍❤️‍💋‍👨🏿', '👩🏾‍❤️‍💋‍👩🏻', '👩🏾‍❤️‍💋‍👩🏼', '👩🏾‍❤️‍💋‍👩🏽', '👩🏾‍❤️‍💋‍👩🏾', '👩🏾‍❤️‍💋‍👩🏿', '👩🏿‍❤️‍💋‍👨🏻', '👩🏿‍❤️‍💋‍👨🏼', '👩🏿‍❤️‍💋‍👨🏽', '👩🏿‍❤️‍💋‍👨🏾', '👩🏿‍❤️‍💋‍👨🏿', '👩🏿‍❤️‍💋‍👩🏻', '👩🏿‍❤️‍💋‍👩🏼', '👩🏿‍❤️‍💋‍👩🏽', '👩🏿‍❤️‍💋‍👩🏾', '👩🏿‍❤️‍💋‍👩🏿', '🧑🏻‍❤️‍💋‍🧑🏼', '🧑🏻‍❤️‍💋‍🧑🏽', '🧑🏻‍❤️‍💋‍🧑🏾', '🧑🏻‍❤️‍💋‍🧑🏿', '🧑🏼‍❤️‍💋‍🧑🏻', '🧑🏼‍❤️‍💋‍🧑🏽', '🧑🏼‍❤️‍💋‍🧑🏾', '🧑🏼‍❤️‍💋‍🧑🏿', '🧑🏽‍❤️‍💋‍🧑🏻', '🧑🏽‍❤️‍💋‍🧑🏼', '🧑🏽‍❤️‍💋‍🧑🏾', '🧑🏽‍❤️‍💋‍🧑🏿', '🧑🏾‍❤️‍💋‍🧑🏻', '🧑🏾‍❤️‍💋‍🧑🏼', '🧑🏾‍❤️‍💋‍🧑🏽', '🧑🏾‍❤️‍💋‍🧑🏿', '🧑🏿‍❤️‍💋‍🧑🏻', '🧑🏿‍❤️‍💋‍🧑🏼', '🧑🏿‍❤️‍💋‍🧑🏽', '🧑🏿‍❤️‍💋‍🧑🏾', '👨🏻‍❤️‍👨🏻', '👨🏻‍❤️‍👨🏼', '👨🏻‍❤️‍👨🏽', '👨🏻‍❤️‍👨🏾', '👨🏻‍❤️‍👨🏿', '👨🏼‍❤️‍👨🏻', '👨🏼‍❤️‍👨🏼', '👨🏼‍❤️‍👨🏽', '👨🏼‍❤️‍👨🏾', '👨🏼‍❤️‍👨🏿', '👨🏽‍❤️‍👨🏻', '👨🏽‍❤️‍👨🏼', '👨🏽‍❤️‍👨🏽', '👨🏽‍❤️‍👨🏾', '👨🏽‍❤️‍👨🏿', '👨🏾‍❤️‍👨🏻', '👨🏾‍❤️‍👨🏼', '👨🏾‍❤️‍👨🏽', '👨🏾‍❤️‍👨🏾', '👨🏾‍❤️‍👨🏿', '👨🏿‍❤️‍👨🏻', '👨🏿‍❤️‍👨🏼', '👨🏿‍❤️‍👨🏽', '👨🏿‍❤️‍👨🏾', '👨🏿‍❤️‍👨🏿', '👩🏻‍❤️‍👨🏻', '👩🏻‍❤️‍👨🏼', '👩🏻‍❤️‍👨🏽', '👩🏻‍❤️‍👨🏾', '👩🏻‍❤️‍👨🏿', '👩🏻‍❤️‍👩🏻', '👩🏻‍❤️‍👩🏼', '👩🏻‍❤️‍👩🏽', '👩🏻‍❤️‍👩🏾', '👩🏻‍❤️‍👩🏿', '👩🏼‍❤️‍👨🏻', '👩🏼‍❤️‍👨🏼', '👩🏼‍❤️‍👨🏽', '👩🏼‍❤️‍👨🏾', '👩🏼‍❤️‍👨🏿', '👩🏼‍❤️‍👩🏻', '👩🏼‍❤️‍👩🏼', '👩🏼‍❤️‍👩🏽', '👩🏼‍❤️‍👩🏾', '👩🏼‍❤️‍👩🏿', '👩🏽‍❤️‍👨🏻', '👩🏽‍❤️‍👨🏼', '👩🏽‍❤️‍👨🏽', '👩🏽‍❤️‍👨🏾', '👩🏽‍❤️‍👨🏿', '👩🏽‍❤️‍👩🏻', '👩🏽‍❤️‍👩🏼', '👩🏽‍❤️‍👩🏽', '👩🏽‍❤️‍👩🏾', '👩🏽‍❤️‍👩🏿', '👩🏾‍❤️‍👨🏻', '👩🏾‍❤️‍👨🏼', '👩🏾‍❤️‍👨🏽', '👩🏾‍❤️‍👨🏾', '👩🏾‍❤️‍👨🏿', '👩🏾‍❤️‍👩🏻', '👩🏾‍❤️‍👩🏼', '👩🏾‍❤️‍👩🏽', '👩🏾‍❤️‍👩🏾', '👩🏾‍❤️‍👩🏿', '👩🏿‍❤️‍👨🏻', '👩🏿‍❤️‍👨🏼', '👩🏿‍❤️‍👨🏽', '👩🏿‍❤️‍👨🏾', '👩🏿‍❤️‍👨🏿', '👩🏿‍❤️‍👩🏻', '👩🏿‍❤️‍👩🏼', '👩🏿‍❤️‍👩🏽', '👩🏿‍❤️‍👩🏾', '👩🏿‍❤️‍👩🏿', '🧑🏻‍❤️‍🧑🏼', '🧑🏻‍❤️‍🧑🏽', '🧑🏻‍❤️‍🧑🏾', '🧑🏻‍❤️‍🧑🏿', '🧑🏼‍❤️‍🧑🏻', '🧑🏼‍❤️‍🧑🏽', '🧑🏼‍❤️‍🧑🏾', '🧑🏼‍❤️‍🧑🏿', '🧑🏽‍❤️‍🧑🏻', '🧑🏽‍❤️‍🧑🏼', '🧑🏽‍❤️‍🧑🏾', '🧑🏽‍❤️‍🧑🏿', '🧑🏾‍❤️‍🧑🏻', '🧑🏾‍❤️‍🧑🏼', '🧑🏾‍❤️‍🧑🏽', '🧑🏾‍❤️‍🧑🏿', '🧑🏿‍❤️‍🧑🏻', '🧑🏿‍❤️‍🧑🏼', '🧑🏿‍❤️‍🧑🏽', '🧑🏿‍❤️‍🧑🏾', '👨‍❤️‍💋‍👨', '👩‍❤️‍💋‍👨', '👩‍❤️‍💋‍👩', '🏴󠁧󠁢󠁥󠁮󠁧󠁿', '🏴󠁧󠁢󠁳󠁣󠁴󠁿', '🏴󠁧󠁢󠁷󠁬󠁳󠁿', '👨🏻‍🤝‍👨🏼', '👨🏻‍🤝‍👨🏽', '👨🏻‍🤝‍👨🏾', '👨🏻‍🤝‍👨🏿', '👨🏼‍🤝‍👨🏻', '👨🏼‍🤝‍👨🏽', '👨🏼‍🤝‍👨🏾', '👨🏼‍🤝‍👨🏿', '👨🏽‍🤝‍👨🏻', '👨🏽‍🤝‍👨🏼', '👨🏽‍🤝‍👨🏾', '👨🏽‍🤝‍👨🏿', '👨🏾‍🤝‍👨🏻', '👨🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏽', '👨🏾‍🤝‍👨🏿', '👨🏿‍🤝‍👨🏻', '👨🏿‍🤝‍👨🏼', '👨🏿‍🤝‍👨🏽', '👨🏿‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏼', '👩🏻‍🤝‍👨🏽', '👩🏻‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏿', '👩🏻‍🤝‍👩🏼', '👩🏻‍🤝‍👩🏽', '👩🏻‍🤝‍👩🏾', '👩🏻‍🤝‍👩🏿', '👩🏼‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏽', '👩🏼‍🤝‍👨🏾', '👩🏼‍🤝‍👨🏿', '👩🏼‍🤝‍👩🏻', '👩🏼‍🤝‍👩🏽', '👩🏼‍🤝‍👩🏾', '👩🏼‍🤝‍👩🏿', '👩🏽‍🤝‍👨🏻', '👩🏽‍🤝‍👨🏼', '👩🏽‍🤝‍👨🏾', '👩🏽‍🤝‍👨🏿', '👩🏽‍🤝‍👩🏻', '👩🏽‍🤝‍👩🏼', '👩🏽‍🤝‍👩🏾', '👩🏽‍🤝‍👩🏿', '👩🏾‍🤝‍👨🏻', '👩🏾‍🤝‍👨🏼', '👩🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏿', '👩🏾‍🤝‍👩🏻', '👩🏾‍🤝‍👩🏼', '👩🏾‍🤝‍👩🏽', '👩🏾‍🤝‍👩🏿', '👩🏿‍🤝‍👨🏻', '👩🏿‍🤝‍👨🏼', '👩🏿‍🤝‍👨🏽', '👩🏿‍🤝‍👨🏾', '👩🏿‍🤝‍👩🏻', '👩🏿‍🤝‍👩🏼', '👩🏿‍🤝‍👩🏽', '👩🏿‍🤝‍👩🏾', '🧑🏻‍🤝‍🧑🏻', '🧑🏻‍🤝‍🧑🏼', '🧑🏻‍🤝‍🧑🏽', '🧑🏻‍🤝‍🧑🏾', '🧑🏻‍🤝‍🧑🏿', '🧑🏼‍🤝‍🧑🏻', '🧑🏼‍🤝‍🧑🏼', '🧑🏼‍🤝‍🧑🏽', '🧑🏼‍🤝‍🧑🏾', '🧑🏼‍🤝‍🧑🏿', '🧑🏽‍🤝‍🧑🏻', '🧑🏽‍🤝‍🧑🏼', '🧑🏽‍🤝‍🧑🏽', '🧑🏽‍🤝‍🧑🏾', '🧑🏽‍🤝‍🧑🏿', '🧑🏾‍🤝‍🧑🏻', '🧑🏾‍🤝‍🧑🏼', '🧑🏾‍🤝‍🧑🏽', '🧑🏾‍🤝‍🧑🏾', '🧑🏾‍🤝‍🧑🏿', '🧑🏿‍🤝‍🧑🏻', '🧑🏿‍🤝‍🧑🏼', '🧑🏿‍🤝‍🧑🏽', '🧑🏿‍🤝‍🧑🏾', '🧑🏿‍🤝‍🧑🏿', '👨‍👨‍👦‍👦', '👨‍👨‍👧‍👦', '👨‍👨‍👧‍👧', '👨‍👩‍👦‍👦', '👨‍👩‍👧‍👦', '👨‍👩‍👧‍👧', '👩‍👩‍👦‍👦', '👩‍👩‍👧‍👦', '👩‍👩‍👧‍👧', '👨‍❤️‍👨', '👩‍❤️‍👨', '👩‍❤️‍👩', '🫱🏻‍🫲🏼', '🫱🏻‍🫲🏽', '🫱🏻‍🫲🏾', '🫱🏻‍🫲🏿', '🫱🏼‍🫲🏻', '🫱🏼‍🫲🏽', '🫱🏼‍🫲🏾', '🫱🏼‍🫲🏿', '🫱🏽‍🫲🏻', '🫱🏽‍🫲🏼', '🫱🏽‍🫲🏾', '🫱🏽‍🫲🏿', '🫱🏾‍🫲🏻', '🫱🏾‍🫲🏼', '🫱🏾‍🫲🏽', '🫱🏾‍🫲🏿', '🫱🏿‍🫲🏻', '🫱🏿‍🫲🏼', '🫱🏿‍🫲🏽', '🫱🏿‍🫲🏾', '👨‍👦‍👦', '👨‍👧‍👦', '👨‍👧‍👧', '👨‍👨‍👦', '👨‍👨‍👧', '👨‍👩‍👦', '👨‍👩‍👧', '👩‍👦‍👦', '👩‍👧‍👦', '👩‍👧‍👧', '👩‍👩‍👦', '👩‍👩‍👧', '🧑‍🤝‍🧑', '🏃🏻‍♀️', '🏃🏻‍♂️', '🏃🏼‍♀️', '🏃🏼‍♂️', '🏃🏽‍♀️', '🏃🏽‍♂️', '🏃🏾‍♀️', '🏃🏾‍♂️', '🏃🏿‍♀️', '🏃🏿‍♂️', '🏄🏻‍♀️', '🏄🏻‍♂️', '🏄🏼‍♀️', '🏄🏼‍♂️', '🏄🏽‍♀️', '🏄🏽‍♂️', '🏄🏾‍♀️', '🏄🏾‍♂️', '🏄🏿‍♀️', '🏄🏿‍♂️', '🏊🏻‍♀️', '🏊🏻‍♂️', '🏊🏼‍♀️', '🏊🏼‍♂️', '🏊🏽‍♀️', '🏊🏽‍♂️', '🏊🏾‍♀️', '🏊🏾‍♂️', '🏊🏿‍♀️', '🏊🏿‍♂️', '🏋🏻‍♀️', '🏋🏻‍♂️', '🏋🏼‍♀️', '🏋🏼‍♂️', '🏋🏽‍♀️', '🏋🏽‍♂️', '🏋🏾‍♀️', '🏋🏾‍♂️', '🏋🏿‍♀️', '🏋🏿‍♂️', '🏌🏻‍♀️', '🏌🏻‍♂️', '🏌🏼‍♀️', '🏌🏼‍♂️', '🏌🏽‍♀️', '🏌🏽‍♂️', '🏌🏾‍♀️', '🏌🏾‍♂️', '🏌🏿‍♀️', '🏌🏿‍♂️', '👨🏻‍⚕️', '👨🏻‍⚖️', '👨🏻‍✈️', '👨🏼‍⚕️', '👨🏼‍⚖️', '👨🏼‍✈️', '👨🏽‍⚕️', '👨🏽‍⚖️', '👨🏽‍✈️', '👨🏾‍⚕️', '👨🏾‍⚖️', '👨🏾‍✈️', '👨🏿‍⚕️', '👨🏿‍⚖️', '👨🏿‍✈️', '👩🏻‍⚕️', '👩🏻‍⚖️', '👩🏻‍✈️', '👩🏼‍⚕️', '👩🏼‍⚖️', '👩🏼‍✈️', '👩🏽‍⚕️', '👩🏽‍⚖️', '👩🏽‍✈️', '👩🏾‍⚕️', '👩🏾‍⚖️', '👩🏾‍✈️', '👩🏿‍⚕️', '👩🏿‍⚖️', '👩🏿‍✈️', '👮🏻‍♀️', '👮🏻‍♂️', '👮🏼‍♀️', '👮🏼‍♂️', '👮🏽‍♀️', '👮🏽‍♂️', '👮🏾‍♀️', '👮🏾‍♂️', '👮🏿‍♀️', '👮🏿‍♂️', '👰🏻‍♀️', '👰🏻‍♂️', '👰🏼‍♀️', '👰🏼‍♂️', '👰🏽‍♀️', '👰🏽‍♂️', '👰🏾‍♀️', '👰🏾‍♂️', '👰🏿‍♀️', '👰🏿‍♂️', '👱🏻‍♀️', '👱🏻‍♂️', '👱🏼‍♀️', '👱🏼‍♂️', '👱🏽‍♀️', '👱🏽‍♂️', '👱🏾‍♀️', '👱🏾‍♂️', '👱🏿‍♀️', '👱🏿‍♂️', '👳🏻‍♀️', '👳🏻‍♂️', '👳🏼‍♀️', '👳🏼‍♂️', '👳🏽‍♀️', '👳🏽‍♂️', '👳🏾‍♀️', '👳🏾‍♂️', '👳🏿‍♀️', '👳🏿‍♂️', '👷🏻‍♀️', '👷🏻‍♂️', '👷🏼‍♀️', '👷🏼‍♂️', '👷🏽‍♀️', '👷🏽‍♂️', '👷🏾‍♀️', '👷🏾‍♂️', '👷🏿‍♀️', '👷🏿‍♂️', '💁🏻‍♀️', '💁🏻‍♂️', '💁🏼‍♀️', '💁🏼‍♂️', '💁🏽‍♀️', '💁🏽‍♂️', '💁🏾‍♀️', '💁🏾‍♂️', '💁🏿‍♀️', '💁🏿‍♂️', '💂🏻‍♀️', '💂🏻‍♂️', '💂🏼‍♀️', '💂🏼‍♂️', '💂🏽‍♀️', '💂🏽‍♂️', '💂🏾‍♀️', '💂🏾‍♂️', '💂🏿‍♀️', '💂🏿‍♂️', '💆🏻‍♀️', '💆🏻‍♂️', '💆🏼‍♀️', '💆🏼‍♂️', '💆🏽‍♀️', '💆🏽‍♂️', '💆🏾‍♀️', '💆🏾‍♂️', '💆🏿‍♀️', '💆🏿‍♂️', '💇🏻‍♀️', '💇🏻‍♂️', '💇🏼‍♀️', '💇🏼‍♂️', '💇🏽‍♀️', '💇🏽‍♂️', '💇🏾‍♀️', '💇🏾‍♂️', '💇🏿‍♀️', '💇🏿‍♂️', '🕴🏻‍♀️', '🕴🏻‍♂️', '🕴🏼‍♀️', '🕴🏼‍♂️', '🕴🏽‍♀️', '🕴🏽‍♂️', '🕴🏾‍♀️', '🕴🏾‍♂️', '🕴🏿‍♀️', '🕴🏿‍♂️', '🕵🏻‍♀️', '🕵🏻‍♂️', '🕵🏼‍♀️', '🕵🏼‍♂️', '🕵🏽‍♀️', '🕵🏽‍♂️', '🕵🏾‍♀️', '🕵🏾‍♂️', '🕵🏿‍♀️', '🕵🏿‍♂️', '🙅🏻‍♀️', '🙅🏻‍♂️', '🙅🏼‍♀️', '🙅🏼‍♂️', '🙅🏽‍♀️', '🙅🏽‍♂️', '🙅🏾‍♀️', '🙅🏾‍♂️', '🙅🏿‍♀️', '🙅🏿‍♂️', '🙆🏻‍♀️', '🙆🏻‍♂️', '🙆🏼‍♀️', '🙆🏼‍♂️', '🙆🏽‍♀️', '🙆🏽‍♂️', '🙆🏾‍♀️', '🙆🏾‍♂️', '🙆🏿‍♀️', '🙆🏿‍♂️', '🙇🏻‍♀️', '🙇🏻‍♂️', '🙇🏼‍♀️', '🙇🏼‍♂️', '🙇🏽‍♀️', '🙇🏽‍♂️', '🙇🏾‍♀️', '🙇🏾‍♂️', '🙇🏿‍♀️', '🙇🏿‍♂️', '🙋🏻‍♀️', '🙋🏻‍♂️', '🙋🏼‍♀️', '🙋🏼‍♂️', '🙋🏽‍♀️', '🙋🏽‍♂️', '🙋🏾‍♀️', '🙋🏾‍♂️', '🙋🏿‍♀️', '🙋🏿‍♂️', '🙍🏻‍♀️', '🙍🏻‍♂️', '🙍🏼‍♀️', '🙍🏼‍♂️', '🙍🏽‍♀️', '🙍🏽‍♂️', '🙍🏾‍♀️', '🙍🏾‍♂️', '🙍🏿‍♀️', '🙍🏿‍♂️', '🙎🏻‍♀️', '🙎🏻‍♂️', '🙎🏼‍♀️', '🙎🏼‍♂️', '🙎🏽‍♀️', '🙎🏽‍♂️', '🙎🏾‍♀️', '🙎🏾‍♂️', '🙎🏿‍♀️', '🙎🏿‍♂️', '🚣🏻‍♀️', '🚣🏻‍♂️', '🚣🏼‍♀️', '🚣🏼‍♂️', '🚣🏽‍♀️', '🚣🏽‍♂️', '🚣🏾‍♀️', '🚣🏾‍♂️', '🚣🏿‍♀️', '🚣🏿‍♂️', '🚴🏻‍♀️', '🚴🏻‍♂️', '🚴🏼‍♀️', '🚴🏼‍♂️', '🚴🏽‍♀️', '🚴🏽‍♂️', '🚴🏾‍♀️', '🚴🏾‍♂️', '🚴🏿‍♀️', '🚴🏿‍♂️', '🚵🏻‍♀️', '🚵🏻‍♂️', '🚵🏼‍♀️', '🚵🏼‍♂️', '🚵🏽‍♀️', '🚵🏽‍♂️', '🚵🏾‍♀️', '🚵🏾‍♂️', '🚵🏿‍♀️', '🚵🏿‍♂️', '🚶🏻‍♀️', '🚶🏻‍♂️', '🚶🏼‍♀️', '🚶🏼‍♂️', '🚶🏽‍♀️', '🚶🏽‍♂️', '🚶🏾‍♀️', '🚶🏾‍♂️', '🚶🏿‍♀️', '🚶🏿‍♂️', '🤦🏻‍♀️', '🤦🏻‍♂️', '🤦🏼‍♀️', '🤦🏼‍♂️', '🤦🏽‍♀️', '🤦🏽‍♂️', '🤦🏾‍♀️', '🤦🏾‍♂️', '🤦🏿‍♀️', '🤦🏿‍♂️', '🤵🏻‍♀️', '🤵🏻‍♂️', '🤵🏼‍♀️', '🤵🏼‍♂️', '🤵🏽‍♀️', '🤵🏽‍♂️', '🤵🏾‍♀️', '🤵🏾‍♂️', '🤵🏿‍♀️', '🤵🏿‍♂️', '🤷🏻‍♀️', '🤷🏻‍♂️', '🤷🏼‍♀️', '🤷🏼‍♂️', '🤷🏽‍♀️', '🤷🏽‍♂️', '🤷🏾‍♀️', '🤷🏾‍♂️', '🤷🏿‍♀️', '🤷🏿‍♂️', '🤸🏻‍♀️', '🤸🏻‍♂️', '🤸🏼‍♀️', '🤸🏼‍♂️', '🤸🏽‍♀️', '🤸🏽‍♂️', '🤸🏾‍♀️', '🤸🏾‍♂️', '🤸🏿‍♀️', '🤸🏿‍♂️', '🤹🏻‍♀️', '🤹🏻‍♂️', '🤹🏼‍♀️', '🤹🏼‍♂️', '🤹🏽‍♀️', '🤹🏽‍♂️', '🤹🏾‍♀️', '🤹🏾‍♂️', '🤹🏿‍♀️', '🤹🏿‍♂️', '🤽🏻‍♀️', '🤽🏻‍♂️', '🤽🏼‍♀️', '🤽🏼‍♂️', '🤽🏽‍♀️', '🤽🏽‍♂️', '🤽🏾‍♀️', '🤽🏾‍♂️', '🤽🏿‍♀️', '🤽🏿‍♂️', '🤾🏻‍♀️', '🤾🏻‍♂️', '🤾🏼‍♀️', '🤾🏼‍♂️', '🤾🏽‍♀️', '🤾🏽‍♂️', '🤾🏾‍♀️', '🤾🏾‍♂️', '🤾🏿‍♀️', '🤾🏿‍♂️', '🦸🏻‍♀️', '🦸🏻‍♂️', '🦸🏼‍♀️', '🦸🏼‍♂️', '🦸🏽‍♀️', '🦸🏽‍♂️', '🦸🏾‍♀️', '🦸🏾‍♂️', '🦸🏿‍♀️', '🦸🏿‍♂️', '🦹🏻‍♀️', '🦹🏻‍♂️', '🦹🏼‍♀️', '🦹🏼‍♂️', '🦹🏽‍♀️', '🦹🏽‍♂️', '🦹🏾‍♀️', '🦹🏾‍♂️', '🦹🏿‍♀️', '🦹🏿‍♂️', '🧍🏻‍♀️', '🧍🏻‍♂️', '🧍🏼‍♀️', '🧍🏼‍♂️', '🧍🏽‍♀️', '🧍🏽‍♂️', '🧍🏾‍♀️', '🧍🏾‍♂️', '🧍🏿‍♀️', '🧍🏿‍♂️', '🧎🏻‍♀️', '🧎🏻‍♂️', '🧎🏼‍♀️', '🧎🏼‍♂️', '🧎🏽‍♀️', '🧎🏽‍♂️', '🧎🏾‍♀️', '🧎🏾‍♂️', '🧎🏿‍♀️', '🧎🏿‍♂️', '🧏🏻‍♀️', '🧏🏻‍♂️', '🧏🏼‍♀️', '🧏🏼‍♂️', '🧏🏽‍♀️', '🧏🏽‍♂️', '🧏🏾‍♀️', '🧏🏾‍♂️', '🧏🏿‍♀️', '🧏🏿‍♂️', '🧑🏻‍⚕️', '🧑🏻‍⚖️', '🧑🏻‍✈️', '🧑🏼‍⚕️', '🧑🏼‍⚖️', '🧑🏼‍✈️', '🧑🏽‍⚕️', '🧑🏽‍⚖️', '🧑🏽‍✈️', '🧑🏾‍⚕️', '🧑🏾‍⚖️', '🧑🏾‍✈️', '🧑🏿‍⚕️', '🧑🏿‍⚖️', '🧑🏿‍✈️', '🧔🏻‍♀️', '🧔🏻‍♂️', '🧔🏼‍♀️', '🧔🏼‍♂️', '🧔🏽‍♀️', '🧔🏽‍♂️', '🧔🏾‍♀️', '🧔🏾‍♂️', '🧔🏿‍♀️', '🧔🏿‍♂️', '🧖🏻‍♀️', '🧖🏻‍♂️', '🧖🏼‍♀️', '🧖🏼‍♂️', '🧖🏽‍♀️', '🧖🏽‍♂️', '🧖🏾‍♀️', '🧖🏾‍♂️', '🧖🏿‍♀️', '🧖🏿‍♂️', '🧗🏻‍♀️', '🧗🏻‍♂️', '🧗🏼‍♀️', '🧗🏼‍♂️', '🧗🏽‍♀️', '🧗🏽‍♂️', '🧗🏾‍♀️', '🧗🏾‍♂️', '🧗🏿‍♀️', '🧗🏿‍♂️', '🧘🏻‍♀️', '🧘🏻‍♂️', '🧘🏼‍♀️', '🧘🏼‍♂️', '🧘🏽‍♀️', '🧘🏽‍♂️', '🧘🏾‍♀️', '🧘🏾‍♂️', '🧘🏿‍♀️', '🧘🏿‍♂️', '🧙🏻‍♀️', '🧙🏻‍♂️', '🧙🏼‍♀️', '🧙🏼‍♂️', '🧙🏽‍♀️', '🧙🏽‍♂️', '🧙🏾‍♀️', '🧙🏾‍♂️', '🧙🏿‍♀️', '🧙🏿‍♂️', '🧚🏻‍♀️', '🧚🏻‍♂️', '🧚🏼‍♀️', '🧚🏼‍♂️', '🧚🏽‍♀️', '🧚🏽‍♂️', '🧚🏾‍♀️', '🧚🏾‍♂️', '🧚🏿‍♀️', '🧚🏿‍♂️', '🧛🏻‍♀️', '🧛🏻‍♂️', '🧛🏼‍♀️', '🧛🏼‍♂️', '🧛🏽‍♀️', '🧛🏽‍♂️', '🧛🏾‍♀️', '🧛🏾‍♂️', '🧛🏿‍♀️', '🧛🏿‍♂️', '🧜🏻‍♀️', '🧜🏻‍♂️', '🧜🏼‍♀️', '🧜🏼‍♂️', '🧜🏽‍♀️', '🧜🏽‍♂️', '🧜🏾‍♀️', '🧜🏾‍♂️', '🧜🏿‍♀️', '🧜🏿‍♂️', '🧝🏻‍♀️', '🧝🏻‍♂️', '🧝🏼‍♀️', '🧝🏼‍♂️', '🧝🏽‍♀️', '🧝🏽‍♂️', '🧝🏾‍♀️', '🧝🏾‍♂️', '🧝🏿‍♀️', '🧝🏿‍♂️', '🏋️‍♀️', '🏋️‍♂️', '🏌️‍♀️', '🏌️‍♂️', '🏳️‍⚧️', '🕴️‍♀️', '🕴️‍♂️', '🕵️‍♀️', '🕵️‍♂️', '⛹🏻‍♀️', '⛹🏻‍♂️', '⛹🏼‍♀️', '⛹🏼‍♂️', '⛹🏽‍♀️', '⛹🏽‍♂️', '⛹🏾‍♀️', '⛹🏾‍♂️', '⛹🏿‍♀️', '⛹🏿‍♂️', '⛹️‍♀️', '⛹️‍♂️', '👨🏻‍🌾', '👨🏻‍🍳', '👨🏻‍🍼', '👨🏻‍🎄', '👨🏻‍🎓', '👨🏻‍🎤', '👨🏻‍🎨', '👨🏻‍🏫', '👨🏻‍🏭', '👨🏻‍💻', '👨🏻‍💼', '👨🏻‍🔧', '👨🏻‍🔬', '👨🏻‍🚀', '👨🏻‍🚒', '👨🏻‍🦯', '👨🏻‍🦰', '👨🏻‍🦱', '👨🏻‍🦲', '👨🏻‍🦳', '👨🏻‍🦼', '👨🏻‍🦽', '👨🏼‍🌾', '👨🏼‍🍳', '👨🏼‍🍼', '👨🏼‍🎄', '👨🏼‍🎓', '👨🏼‍🎤', '👨🏼‍🎨', '👨🏼‍🏫', '👨🏼‍🏭', '👨🏼‍💻', '👨🏼‍💼', '👨🏼‍🔧', '👨🏼‍🔬', '👨🏼‍🚀', '👨🏼‍🚒', '👨🏼‍🦯', '👨🏼‍🦰', '👨🏼‍🦱', '👨🏼‍🦲', '👨🏼‍🦳', '👨🏼‍🦼', '👨🏼‍🦽', '👨🏽‍🌾', '👨🏽‍🍳', '👨🏽‍🍼', '👨🏽‍🎄', '👨🏽‍🎓', '👨🏽‍🎤', '👨🏽‍🎨', '👨🏽‍🏫', '👨🏽‍🏭', '👨🏽‍💻', '👨🏽‍💼', '👨🏽‍🔧', '👨🏽‍🔬', '👨🏽‍🚀', '👨🏽‍🚒', '👨🏽‍🦯', '👨🏽‍🦰', '👨🏽‍🦱', '👨🏽‍🦲', '👨🏽‍🦳', '👨🏽‍🦼', '👨🏽‍🦽', '👨🏾‍🌾', '👨🏾‍🍳', '👨🏾‍🍼', '👨🏾‍🎄', '👨🏾‍🎓', '👨🏾‍🎤', '👨🏾‍🎨', '👨🏾‍🏫', '👨🏾‍🏭', '👨🏾‍💻', '👨🏾‍💼', '👨🏾‍🔧', '👨🏾‍🔬', '👨🏾‍🚀', '👨🏾‍🚒', '👨🏾‍🦯', '👨🏾‍🦰', '👨🏾‍🦱', '👨🏾‍🦲', '👨🏾‍🦳', '👨🏾‍🦼', '👨🏾‍🦽', '👨🏿‍🌾', '👨🏿‍🍳', '👨🏿‍🍼', '👨🏿‍🎄', '👨🏿‍🎓', '👨🏿‍🎤', '👨🏿‍🎨', '👨🏿‍🏫', '👨🏿‍🏭', '👨🏿‍💻', '👨🏿‍💼', '👨🏿‍🔧', '👨🏿‍🔬', '👨🏿‍🚀', '👨🏿‍🚒', '👨🏿‍🦯', '👨🏿‍🦰', '👨🏿‍🦱', '👨🏿‍🦲', '👨🏿‍🦳', '👨🏿‍🦼', '👨🏿‍🦽', '👩🏻‍🌾', '👩🏻‍🍳', '👩🏻‍🍼', '👩🏻‍🎄', '👩🏻‍🎓', '👩🏻‍🎤', '👩🏻‍🎨', '👩🏻‍🏫', '👩🏻‍🏭', '👩🏻‍💻', '👩🏻‍💼', '👩🏻‍🔧', '👩🏻‍🔬', '👩🏻‍🚀', '👩🏻‍🚒', '👩🏻‍🦯', '👩🏻‍🦰', '👩🏻‍🦱', '👩🏻‍🦲', '👩🏻‍🦳', '👩🏻‍🦼', '👩🏻‍🦽', '👩🏼‍🌾', '👩🏼‍🍳', '👩🏼‍🍼', '👩🏼‍🎄', '👩🏼‍🎓', '👩🏼‍🎤', '👩🏼‍🎨', '👩🏼‍🏫', '👩🏼‍🏭', '👩🏼‍💻', '👩🏼‍💼', '👩🏼‍🔧', '👩🏼‍🔬', '👩🏼‍🚀', '👩🏼‍🚒', '👩🏼‍🦯', '👩🏼‍🦰', '👩🏼‍🦱', '👩🏼‍🦲', '👩🏼‍🦳', '👩🏼‍🦼', '👩🏼‍🦽', '👩🏽‍🌾', '👩🏽‍🍳', '👩🏽‍🍼', '👩🏽‍🎄', '👩🏽‍🎓', '👩🏽‍🎤', '👩🏽‍🎨', '👩🏽‍🏫', '👩🏽‍🏭', '👩🏽‍💻', '👩🏽‍💼', '👩🏽‍🔧', '👩🏽‍🔬', '👩🏽‍🚀', '👩🏽‍🚒', '👩🏽‍🦯', '👩🏽‍🦰', '👩🏽‍🦱', '👩🏽‍🦲', '👩🏽‍🦳', '👩🏽‍🦼', '👩🏽‍🦽', '👩🏾‍🌾', '👩🏾‍🍳', '👩🏾‍🍼', '👩🏾‍🎄', '👩🏾‍🎓', '👩🏾‍🎤', '👩🏾‍🎨', '👩🏾‍🏫', '👩🏾‍🏭', '👩🏾‍💻', '👩🏾‍💼', '👩🏾‍🔧', '👩🏾‍🔬', '👩🏾‍🚀', '👩🏾‍🚒', '👩🏾‍🦯', '👩🏾‍🦰', '👩🏾‍🦱', '👩🏾‍🦲', '👩🏾‍🦳', '👩🏾‍🦼', '👩🏾‍🦽', '👩🏿‍🌾', '👩🏿‍🍳', '👩🏿‍🍼', '👩🏿‍🎄', '👩🏿‍🎓', '👩🏿‍🎤', '👩🏿‍🎨', '👩🏿‍🏫', '👩🏿‍🏭', '👩🏿‍💻', '👩🏿‍💼', '👩🏿‍🔧', '👩🏿‍🔬', '👩🏿‍🚀', '👩🏿‍🚒', '👩🏿‍🦯', '👩🏿‍🦰', '👩🏿‍🦱', '👩🏿‍🦲', '👩🏿‍🦳', '👩🏿‍🦼', '👩🏿‍🦽', '🧑🏻‍🌾', '🧑🏻‍🍳', '🧑🏻‍🍼', '🧑🏻‍🎄', '🧑🏻‍🎓', '🧑🏻‍🎤', '🧑🏻‍🎨', '🧑🏻‍🏫', '🧑🏻‍🏭', '🧑🏻‍💻', '🧑🏻‍💼', '🧑🏻‍🔧', '🧑🏻‍🔬', '🧑🏻‍🚀', '🧑🏻‍🚒', '🧑🏻‍🦯', '🧑🏻‍🦰', '🧑🏻‍🦱', '🧑🏻‍🦲', '🧑🏻‍🦳', '🧑🏻‍🦼', '🧑🏻‍🦽', '🧑🏼‍🌾', '🧑🏼‍🍳', '🧑🏼‍🍼', '🧑🏼‍🎄', '🧑🏼‍🎓', '🧑🏼‍🎤', '🧑🏼‍🎨', '🧑🏼‍🏫', '🧑🏼‍🏭', '🧑🏼‍💻', '🧑🏼‍💼', '🧑🏼‍🔧', '🧑🏼‍🔬', '🧑🏼‍🚀', '🧑🏼‍🚒', '🧑🏼‍🦯', '🧑🏼‍🦰', '🧑🏼‍🦱', '🧑🏼‍🦲', '🧑🏼‍🦳', '🧑🏼‍🦼', '🧑🏼‍🦽', '🧑🏽‍🌾', '🧑🏽‍🍳', '🧑🏽‍🍼', '🧑🏽‍🎄', '🧑🏽‍🎓', '🧑🏽‍🎤', '🧑🏽‍🎨', '🧑🏽‍🏫', '🧑🏽‍🏭', '🧑🏽‍💻', '🧑🏽‍💼', '🧑🏽‍🔧', '🧑🏽‍🔬', '🧑🏽‍🚀', '🧑🏽‍🚒', '🧑🏽‍🦯', '🧑🏽‍🦰', '🧑🏽‍🦱', '🧑🏽‍🦲', '🧑🏽‍🦳', '🧑🏽‍🦼', '🧑🏽‍🦽', '🧑🏾‍🌾', '🧑🏾‍🍳', '🧑🏾‍🍼', '🧑🏾‍🎄', '🧑🏾‍🎓', '🧑🏾‍🎤', '🧑🏾‍🎨', '🧑🏾‍🏫', '🧑🏾‍🏭', '🧑🏾‍💻', '🧑🏾‍💼', '🧑🏾‍🔧', '🧑🏾‍🔬', '🧑🏾‍🚀', '🧑🏾‍🚒', '🧑🏾‍🦯', '🧑🏾‍🦰', '🧑🏾‍🦱', '🧑🏾‍🦲', '🧑🏾‍🦳', '🧑🏾‍🦼', '🧑🏾‍🦽', '🧑🏿‍🌾', '🧑🏿‍🍳', '🧑🏿‍🍼', '🧑🏿‍🎄', '🧑🏿‍🎓', '🧑🏿‍🎤', '🧑🏿‍🎨', '🧑🏿‍🏫', '🧑🏿‍🏭', '🧑🏿‍💻', '🧑🏿‍💼', '🧑🏿‍🔧', '🧑🏿‍🔬', '🧑🏿‍🚀', '🧑🏿‍🚒', '🧑🏿‍🦯', '🧑🏿‍🦰', '🧑🏿‍🦱', '🧑🏿‍🦲', '🧑🏿‍🦳', '🧑🏿‍🦼', '🧑🏿‍🦽', '🏳️‍🌈', '😶‍🌫️', '🏃‍♀️', '🏃‍♂️', '🏄‍♀️', '🏄‍♂️', '🏊‍♀️', '🏊‍♂️', '🏴‍☠️', '🐻‍❄️', '👨‍⚕️', '👨‍⚖️', '👨‍✈️', '👩‍⚕️', '👩‍⚖️', '👩‍✈️', '👮‍♀️', '👮‍♂️', '👯‍♀️', '👯‍♂️', '👰‍♀️', '👰‍♂️', '👱‍♀️', '👱‍♂️', '👳‍♀️', '👳‍♂️', '👷‍♀️', '👷‍♂️', '💁‍♀️', '💁‍♂️', '💂‍♀️', '💂‍♂️', '💆‍♀️', '💆‍♂️', '💇‍♀️', '💇‍♂️', '🙅‍♀️', '🙅‍♂️', '🙆‍♀️', '🙆‍♂️', '🙇‍♀️', '🙇‍♂️', '🙋‍♀️', '🙋‍♂️', '🙍‍♀️', '🙍‍♂️', '🙎‍♀️', '🙎‍♂️', '🚣‍♀️', '🚣‍♂️', '🚴‍♀️', '🚴‍♂️', '🚵‍♀️', '🚵‍♂️', '🚶‍♀️', '🚶‍♂️', '🤦‍♀️', '🤦‍♂️', '🤵‍♀️', '🤵‍♂️', '🤷‍♀️', '🤷‍♂️', '🤸‍♀️', '🤸‍♂️', '🤹‍♀️', '🤹‍♂️', '🤼‍♀️', '🤼‍♂️', '🤽‍♀️', '🤽‍♂️', '🤾‍♀️', '🤾‍♂️', '🦸‍♀️', '🦸‍♂️', '🦹‍♀️', '🦹‍♂️', '🧍‍♀️', '🧍‍♂️', '🧎‍♀️', '🧎‍♂️', '🧏‍♀️', '🧏‍♂️', '🧑‍⚕️', '🧑‍⚖️', '🧑‍✈️', '🧔‍♀️', '🧔‍♂️', '🧖‍♀️', '🧖‍♂️', '🧗‍♀️', '🧗‍♂️', '🧘‍♀️', '🧘‍♂️', '🧙‍♀️', '🧙‍♂️', '🧚‍♀️', '🧚‍♂️', '🧛‍♀️', '🧛‍♂️', '🧜‍♀️', '🧜‍♂️', '🧝‍♀️', '🧝‍♂️', '🧞‍♀️', '🧞‍♂️', '🧟‍♀️', '🧟‍♂️', '❤️‍🔥', '❤️‍🩹', '🐕‍🦺', '👁‍🗨', '👨‍🌾', '👨‍🍳', '👨‍🍼', '👨‍🎄', '👨‍🎓', '👨‍🎤', '👨‍🎨', '👨‍🏫', '👨‍🏭', '👨‍👦', '👨‍👧', '👨‍💻', '👨‍💼', '👨‍🔧', '👨‍🔬', '👨‍🚀', '👨‍🚒', '👨‍🦯', '👨‍🦰', '👨‍🦱', '👨‍🦲', '👨‍🦳', '👨‍🦼', '👨‍🦽', '👩‍🌾', '👩‍🍳', '👩‍🍼', '👩‍🎄', '👩‍🎓', '👩‍🎤', '👩‍🎨', '👩‍🏫', '👩‍🏭', '👩‍👦', '👩‍👧', '👩‍💻', '👩‍💼', '👩‍🔧', '👩‍🔬', '👩‍🚀', '👩‍🚒', '👩‍🦯', '👩‍🦰', '👩‍🦱', '👩‍🦲', '👩‍🦳', '👩‍🦼', '👩‍🦽', '😮‍💨', '😵‍💫', '🧑‍🌾', '🧑‍🍳', '🧑‍🍼', '🧑‍🎄', '🧑‍🎓', '🧑‍🎤', '🧑‍🎨', '🧑‍🏫', '🧑‍🏭', '🧑‍💻', '🧑‍💼', '🧑‍🔧', '🧑‍🔬', '🧑‍🚀', '🧑‍🚒', '🧑‍🦯', '🧑‍🦰', '🧑‍🦱', '🧑‍🦲', '🧑‍🦳', '🧑‍🦼', '🧑‍🦽', '🐈‍⬛', '🇦🇨', '🇦🇩', '🇦🇪', '🇦🇫', '🇦🇬', '🇦🇮', '🇦🇱', '🇦🇲', '🇦🇴', '🇦🇶', '🇦🇷', '🇦🇸', '🇦🇹', '🇦🇺', '🇦🇼', '🇦🇽', '🇦🇿', '🇧🇦', '🇧🇧', '🇧🇩', '🇧🇪', '🇧🇫', '🇧🇬', '🇧🇭', '🇧🇮', '🇧🇯', '🇧🇱', '🇧🇲', '🇧🇳', '🇧🇴', '🇧🇶', '🇧🇷', '🇧🇸', '🇧🇹', '🇧🇻', '🇧🇼', '🇧🇾', '🇧🇿', '🇨🇦', '🇨🇨', '🇨🇩', '🇨🇫', '🇨🇬', '🇨🇭', '🇨🇮', '🇨🇰', '🇨🇱', '🇨🇲', '🇨🇳', '🇨🇴', '🇨🇵', '🇨🇷', '🇨🇺', '🇨🇻', '🇨🇼', '🇨🇽', '🇨🇾', '🇨🇿', '🇩🇪', '🇩🇬', '🇩🇯', '🇩🇰', '🇩🇲', '🇩🇴', '🇩🇿', '🇪🇦', '🇪🇨', '🇪🇪', '🇪🇬', '🇪🇭', '🇪🇷', '🇪🇸', '🇪🇹', '🇪🇺', '🇫🇮', '🇫🇯', '🇫🇰', '🇫🇲', '🇫🇴', '🇫🇷', '🇬🇦', '🇬🇧', '🇬🇩', '🇬🇪', '🇬🇫', '🇬🇬', '🇬🇭', '🇬🇮', '🇬🇱', '🇬🇲', '🇬🇳', '🇬🇵', '🇬🇶', '🇬🇷', '🇬🇸', '🇬🇹', '🇬🇺', '🇬🇼', '🇬🇾', '🇭🇰', '🇭🇲', '🇭🇳', '🇭🇷', '🇭🇹', '🇭🇺', '🇮🇨', '🇮🇩', '🇮🇪', '🇮🇱', '🇮🇲', '🇮🇳', '🇮🇴', '🇮🇶', '🇮🇷', '🇮🇸', '🇮🇹', '🇯🇪', '🇯🇲', '🇯🇴', '🇯🇵', '🇰🇪', '🇰🇬', '🇰🇭', '🇰🇮', '🇰🇲', '🇰🇳', '🇰🇵', '🇰🇷', '🇰🇼', '🇰🇾', '🇰🇿', '🇱🇦', '🇱🇧', '🇱🇨', '🇱🇮', '🇱🇰', '🇱🇷', '🇱🇸', '🇱🇹', '🇱🇺', '🇱🇻', '🇱🇾', '🇲🇦', '🇲🇨', '🇲🇩', '🇲🇪', '🇲🇫', '🇲🇬', '🇲🇭', '🇲🇰', '🇲🇱', '🇲🇲', '🇲🇳', '🇲🇴', '🇲🇵', '🇲🇶', '🇲🇷', '🇲🇸', '🇲🇹', '🇲🇺', '🇲🇻', '🇲🇼', '🇲🇽', '🇲🇾', '🇲🇿', '🇳🇦', '🇳🇨', '🇳🇪', '🇳🇫', '🇳🇬', '🇳🇮', '🇳🇱', '🇳🇴', '🇳🇵', '🇳🇷', '🇳🇺', '🇳🇿', '🇴🇲', '🇵🇦', '🇵🇪', '🇵🇫', '🇵🇬', '🇵🇭', '🇵🇰', '🇵🇱', '🇵🇲', '🇵🇳', '🇵🇷', '🇵🇸', '🇵🇹', '🇵🇼', '🇵🇾', '🇶🇦', '🇷🇪', '🇷🇴', '🇷🇸', '🇷🇺', '🇷🇼', '🇸🇦', '🇸🇧', '🇸🇨', '🇸🇩', '🇸🇪', '🇸🇬', '🇸🇭', '🇸🇮', '🇸🇯', '🇸🇰', '🇸🇱', '🇸🇲', '🇸🇳', '🇸🇴', '🇸🇷', '🇸🇸', '🇸🇹', '🇸🇻', '🇸🇽', '🇸🇾', '🇸🇿', '🇹🇦', '🇹🇨', '🇹🇩', '🇹🇫', '🇹🇬', '🇹🇭', '🇹🇯', '🇹🇰', '🇹🇱', '🇹🇲', '🇹🇳', '🇹🇴', '🇹🇷', '🇹🇹', '🇹🇻', '🇹🇼', '🇹🇿', '🇺🇦', '🇺🇬', '🇺🇲', '🇺🇳', '🇺🇸', '🇺🇾', '🇺🇿', '🇻🇦', '🇻🇨', '🇻🇪', '🇻🇬', '🇻🇮', '🇻🇳', '🇻🇺', '🇼🇫', '🇼🇸', '🇽🇰', '🇾🇪', '🇾🇹', '🇿🇦', '🇿🇲', '🇿🇼', '🎅🏻', '🎅🏼', '🎅🏽', '🎅🏾', '🎅🏿', '🏂🏻', '🏂🏼', '🏂🏽', '🏂🏾', '🏂🏿', '🏃🏻', '🏃🏼', '🏃🏽', '🏃🏾', '🏃🏿', '🏄🏻', '🏄🏼', '🏄🏽', '🏄🏾', '🏄🏿', '🏇🏻', '🏇🏼', '🏇🏽', '🏇🏾', '🏇🏿', '🏊🏻', '🏊🏼', '🏊🏽', '🏊🏾', '🏊🏿', '🏋🏻', '🏋🏼', '🏋🏽', '🏋🏾', '🏋🏿', '🏌🏻', '🏌🏼', '🏌🏽', '🏌🏾', '🏌🏿', '👂🏻', '👂🏼', '👂🏽', '👂🏾', '👂🏿', '👃🏻', '👃🏼', '👃🏽', '👃🏾', '👃🏿', '👆🏻', '👆🏼', '👆🏽', '👆🏾', '👆🏿', '👇🏻', '👇🏼', '👇🏽', '👇🏾', '👇🏿', '👈🏻', '👈🏼', '👈🏽', '👈🏾', '👈🏿', '👉🏻', '👉🏼', '👉🏽', '👉🏾', '👉🏿', '👊🏻', '👊🏼', '👊🏽', '👊🏾', '👊🏿', '👋🏻', '👋🏼', '👋🏽', '👋🏾', '👋🏿', '👌🏻', '👌🏼', '👌🏽', '👌🏾', '👌🏿', '👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿', '👎🏻', '👎🏼', '👎🏽', '👎🏾', '👎🏿', '👏🏻', '👏🏼', '👏🏽', '👏🏾', '👏🏿', '👐🏻', '👐🏼', '👐🏽', '👐🏾', '👐🏿', '👦🏻', '👦🏼', '👦🏽', '👦🏾', '👦🏿', '👧🏻', '👧🏼', '👧🏽', '👧🏾', '👧🏿', '👨🏻', '👨🏼', '👨🏽', '👨🏾', '👨🏿', '👩🏻', '👩🏼', '👩🏽', '👩🏾', '👩🏿', '👫🏻', '👫🏼', '👫🏽', '👫🏾', '👫🏿', '👬🏻', '👬🏼', '👬🏽', '👬🏾', '👬🏿', '👭🏻', '👭🏼', '👭🏽', '👭🏾', '👭🏿', '👮🏻', '👮🏼', '👮🏽', '👮🏾', '👮🏿', '👰🏻', '👰🏼', '👰🏽', '👰🏾', '👰🏿', '👱🏻', '👱🏼', '👱🏽', '👱🏾', '👱🏿', '👲🏻', '👲🏼', '👲🏽', '👲🏾', '👲🏿', '👳🏻', '👳🏼', '👳🏽', '👳🏾', '👳🏿', '👴🏻', '👴🏼', '👴🏽', '👴🏾', '👴🏿', '👵🏻', '👵🏼', '👵🏽', '👵🏾', '👵🏿', '👶🏻', '👶🏼', '👶🏽', '👶🏾', '👶🏿', '👷🏻', '👷🏼', '👷🏽', '👷🏾', '👷🏿', '👸🏻', '👸🏼', '👸🏽', '👸🏾', '👸🏿', '👼🏻', '👼🏼', '👼🏽', '👼🏾', '👼🏿', '💁🏻', '💁🏼', '💁🏽', '💁🏾', '💁🏿', '💂🏻', '💂🏼', '💂🏽', '💂🏾', '💂🏿', '💃🏻', '💃🏼', '💃🏽', '💃🏾', '💃🏿', '💅🏻', '💅🏼', '💅🏽', '💅🏾', '💅🏿', '💆🏻', '💆🏼', '💆🏽', '💆🏾', '💆🏿', '💇🏻', '💇🏼', '💇🏽', '💇🏾', '💇🏿', '💏🏻', '💏🏼', '💏🏽', '💏🏾', '💏🏿', '💑🏻', '💑🏼', '💑🏽', '💑🏾', '💑🏿', '💪🏻', '💪🏼', '💪🏽', '💪🏾', '💪🏿', '🕴🏻', '🕴🏼', '🕴🏽', '🕴🏾', '🕴🏿', '🕵🏻', '🕵🏼', '🕵🏽', '🕵🏾', '🕵🏿', '🕺🏻', '🕺🏼', '🕺🏽', '🕺🏾', '🕺🏿', '🖐🏻', '🖐🏼', '🖐🏽', '🖐🏾', '🖐🏿', '🖕🏻', '🖕🏼', '🖕🏽', '🖕🏾', '🖕🏿', '🖖🏻', '🖖🏼', '🖖🏽', '🖖🏾', '🖖🏿', '🙅🏻', '🙅🏼', '🙅🏽', '🙅🏾', '🙅🏿', '🙆🏻', '🙆🏼', '🙆🏽', '🙆🏾', '🙆🏿', '🙇🏻', '🙇🏼', '🙇🏽', '🙇🏾', '🙇🏿', '🙋🏻', '🙋🏼', '🙋🏽', '🙋🏾', '🙋🏿', '🙌🏻', '🙌🏼', '🙌🏽', '🙌🏾', '🙌🏿', '🙍🏻', '🙍🏼', '🙍🏽', '🙍🏾', '🙍🏿', '🙎🏻', '🙎🏼', '🙎🏽', '🙎🏾', '🙎🏿', '🙏🏻', '🙏🏼', '🙏🏽', '🙏🏾', '🙏🏿', '🚣🏻', '🚣🏼', '🚣🏽', '🚣🏾', '🚣🏿', '🚴🏻', '🚴🏼', '🚴🏽', '🚴🏾', '🚴🏿', '🚵🏻', '🚵🏼', '🚵🏽', '🚵🏾', '🚵🏿', '🚶🏻', '🚶🏼', '🚶🏽', '🚶🏾', '🚶🏿', '🛀🏻', '🛀🏼', '🛀🏽', '🛀🏾', '🛀🏿', '🛌🏻', '🛌🏼', '🛌🏽', '🛌🏾', '🛌🏿', '🤌🏻', '🤌🏼', '🤌🏽', '🤌🏾', '🤌🏿', '🤏🏻', '🤏🏼', '🤏🏽', '🤏🏾', '🤏🏿', '🤘🏻', '🤘🏼', '🤘🏽', '🤘🏾', '🤘🏿', '🤙🏻', '🤙🏼', '🤙🏽', '🤙🏾', '🤙🏿', '🤚🏻', '🤚🏼', '🤚🏽', '🤚🏾', '🤚🏿', '🤛🏻', '🤛🏼', '🤛🏽', '🤛🏾', '🤛🏿', '🤜🏻', '🤜🏼', '🤜🏽', '🤜🏾', '🤜🏿', '🤝🏻', '🤝🏼', '🤝🏽', '🤝🏾', '🤝🏿', '🤞🏻', '🤞🏼', '🤞🏽', '🤞🏾', '🤞🏿', '🤟🏻', '🤟🏼', '🤟🏽', '🤟🏾', '🤟🏿', '🤦🏻', '🤦🏼', '🤦🏽', '🤦🏾', '🤦🏿', '🤰🏻', '🤰🏼', '🤰🏽', '🤰🏾', '🤰🏿', '🤱🏻', '🤱🏼', '🤱🏽', '🤱🏾', '🤱🏿', '🤲🏻', '🤲🏼', '🤲🏽', '🤲🏾', '🤲🏿', '🤳🏻', '🤳🏼', '🤳🏽', '🤳🏾', '🤳🏿', '🤴🏻', '🤴🏼', '🤴🏽', '🤴🏾', '🤴🏿', '🤵🏻', '🤵🏼', '🤵🏽', '🤵🏾', '🤵🏿', '🤶🏻', '🤶🏼', '🤶🏽', '🤶🏾', '🤶🏿', '🤷🏻', '🤷🏼', '🤷🏽', '🤷🏾', '🤷🏿', '🤸🏻', '🤸🏼', '🤸🏽', '🤸🏾', '🤸🏿', '🤹🏻', '🤹🏼', '🤹🏽', '🤹🏾', '🤹🏿', '🤽🏻', '🤽🏼', '🤽🏽', '🤽🏾', '🤽🏿', '🤾🏻', '🤾🏼', '🤾🏽', '🤾🏾', '🤾🏿', '🥷🏻', '🥷🏼', '🥷🏽', '🥷🏾', '🥷🏿', '🦵🏻', '🦵🏼', '🦵🏽', '🦵🏾', '🦵🏿', '🦶🏻', '🦶🏼', '🦶🏽', '🦶🏾', '🦶🏿', '🦸🏻', '🦸🏼', '🦸🏽', '🦸🏾', '🦸🏿', '🦹🏻', '🦹🏼', '🦹🏽', '🦹🏾', '🦹🏿', '🦻🏻', '🦻🏼', '🦻🏽', '🦻🏾', '🦻🏿', '🧍🏻', '🧍🏼', '🧍🏽', '🧍🏾', '🧍🏿', '🧎🏻', '🧎🏼', '🧎🏽', '🧎🏾', '🧎🏿', '🧏🏻', '🧏🏼', '🧏🏽', '🧏🏾', '🧏🏿', '🧑🏻', '🧑🏼', '🧑🏽', '🧑🏾', '🧑🏿', '🧒🏻', '🧒🏼', '🧒🏽', '🧒🏾', '🧒🏿', '🧓🏻', '🧓🏼', '🧓🏽', '🧓🏾', '🧓🏿', '🧔🏻', '🧔🏼', '🧔🏽', '🧔🏾', '🧔🏿', '🧕🏻', '🧕🏼', '🧕🏽', '🧕🏾', '🧕🏿', '🧖🏻', '🧖🏼', '🧖🏽', '🧖🏾', '🧖🏿', '🧗🏻', '🧗🏼', '🧗🏽', '🧗🏾', '🧗🏿', '🧘🏻', '🧘🏼', '🧘🏽', '🧘🏾', '🧘🏿', '🧙🏻', '🧙🏼', '🧙🏽', '🧙🏾', '🧙🏿', '🧚🏻', '🧚🏼', '🧚🏽', '🧚🏾', '🧚🏿', '🧛🏻', '🧛🏼', '🧛🏽', '🧛🏾', '🧛🏿', '🧜🏻', '🧜🏼', '🧜🏽', '🧜🏾', '🧜🏿', '🧝🏻', '🧝🏼', '🧝🏽', '🧝🏾', '🧝🏿', '🫃🏻', '🫃🏼', '🫃🏽', '🫃🏾', '🫃🏿', '🫄🏻', '🫄🏼', '🫄🏽', '🫄🏾', '🫄🏿', '🫅🏻', '🫅🏼', '🫅🏽', '🫅🏾', '🫅🏿', '🫰🏻', '🫰🏼', '🫰🏽', '🫰🏾', '🫰🏿', '🫱🏻', '🫱🏼', '🫱🏽', '🫱🏾', '🫱🏿', '🫲🏻', '🫲🏼', '🫲🏽', '🫲🏾', '🫲🏿', '🫳🏻', '🫳🏼', '🫳🏽', '🫳🏾', '🫳🏿', '🫴🏻', '🫴🏼', '🫴🏽', '🫴🏾', '🫴🏿', '🫵🏻', '🫵🏼', '🫵🏽', '🫵🏾', '🫵🏿', '🫶🏻', '🫶🏼', '🫶🏽', '🫶🏾', '🫶🏿', '☝🏻', '☝🏼', '☝🏽', '☝🏾', '☝🏿', '⛷🏻', '⛷🏼', '⛷🏽', '⛷🏾', '⛷🏿', '⛹🏻', '⛹🏼', '⛹🏽', '⛹🏾', '⛹🏿', '✊🏻', '✊🏼', '✊🏽', '✊🏾', '✊🏿', '✋🏻', '✋🏼', '✋🏽', '✋🏾', '✋🏿', '✌🏻', '✌🏼', '✌🏽', '✌🏾', '✌🏿', '✍🏻', '✍🏼', '✍🏽', '✍🏾', '✍🏿', '#⃣', '*⃣', '0⃣', '1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮', '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷', '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '🏴', '🏵', '🏷', '🏸', '🏹', '🏺', '🏻', '🏼', '🏽', '🏾', '🏿', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💋', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💻', '💼', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔧', '🔨', '🔩', '🔪', '🔫', '🔬', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗨', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚀', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚒', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤝', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦯', '🦰', '🦱', '🦲', '🦳', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦺', '🦻', '🦼', '🦽', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩴', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☠', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♀', '♂', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚕', '⚖', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚧', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✈', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '❤', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); $partials = array( '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇨', '🇩', '🇪', '🇫', '🇬', '🇮', '🇱', '🇲', '🇴', '🇶', '🇷', '🇸', '🇹', '🇺', '🇼', '🇽', '🇿', '🇧', '🇭', '🇯', '🇳', '🇻', '🇾', '🇰', '🇵', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🏻', '🏼', '🏽', '🏾', '🏿', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '‍', '♀', '️', '♂', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '⚧', '🏴', '☠', '󠁧', '󠁢', '󠁥', '󠁮', '󠁿', '󠁳', '󠁣', '󠁴', '󠁷', '󠁬', '🏵', '🏷', '🏸', '🏹', '🏺', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '⬛', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🦺', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '❄', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '🗨', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '💻', '💼', '🔧', '🔬', '🚀', '🚒', '🤝', '🦯', '🦰', '🦱', '🦲', '🦳', '🦼', '🦽', '⚕', '⚖', '✈', '❤', '💋', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔨', '🔩', '🔪', '🔫', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦻', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩴', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⃣', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); if ( 'entities' === $type ) { return $entities; } return $partials; } function url_shorten( $url, $length = 35 ) { $stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url ); $short_url = untrailingslashit( $stripped ); if ( strlen( $short_url ) > $length ) { $short_url = substr( $short_url, 0, $length - 3 ) . '…'; } return $short_url; } function sanitize_hex_color( $color ) { if ( '' === $color ) { return ''; } if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { return $color; } } function sanitize_hex_color_no_hash( $color ) { $color = ltrim( $color, '#' ); if ( '' === $color ) { return ''; } return sanitize_hex_color( '#' . $color ) ? $color : null; } function maybe_hash_hex_color( $color ) { $unhashed = sanitize_hex_color_no_hash( $color ); if ( $unhashed ) { return '#' . $unhashed; } return $color; } getTimestamp() + $datetime->getOffset(); } if ( $translate ) { return wp_date( $format, $datetime->getTimestamp() ); } return $datetime->format( $format ); } function current_time( $type, $gmt = 0 ) { if ( 'timestamp' === $type || 'U' === $type ) { return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); } if ( 'mysql' === $type ) { $type = 'Y-m-d H:i:s'; } $timezone = $gmt ? new DateTimeZone( 'UTC' ) : wp_timezone(); $datetime = new DateTime( 'now', $timezone ); return $datetime->format( $type ); } function current_datetime() { return new DateTimeImmutable( 'now', wp_timezone() ); } function wp_timezone_string() { $timezone_string = get_option( 'timezone_string' ); if ( $timezone_string ) { return $timezone_string; } $offset = (float) get_option( 'gmt_offset' ); $hours = (int) $offset; $minutes = ( $offset - $hours ); $sign = ( $offset < 0 ) ? '-' : '+'; $abs_hour = abs( $hours ); $abs_mins = abs( $minutes * 60 ); $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins ); return $tz_offset; } function wp_timezone() { return new DateTimeZone( wp_timezone_string() ); } function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) { $timestamp = $timestamp_with_offset; if ( ! is_numeric( $timestamp ) ) { $timestamp = current_time( 'timestamp', $gmt ); } if ( 'U' === $format ) { $date = $timestamp; } elseif ( $gmt && false === $timestamp_with_offset ) { $date = wp_date( $format, null, new DateTimeZone( 'UTC' ) ); } elseif ( false === $timestamp_with_offset ) { $date = wp_date( $format ); } else { $local_time = gmdate( 'Y-m-d H:i:s', $timestamp ); $timezone = wp_timezone(); $datetime = date_create( $local_time, $timezone ); $date = wp_date( $format, $datetime->getTimestamp(), $timezone ); } $date = apply_filters( 'date_i18n', $date, $format, $timestamp, $gmt ); return $date; } function wp_date( $format, $timestamp = null, $timezone = null ) { global $wp_locale; if ( null === $timestamp ) { $timestamp = time(); } elseif ( ! is_numeric( $timestamp ) ) { return false; } if ( ! $timezone ) { $timezone = wp_timezone(); } $datetime = date_create( '@' . $timestamp ); $datetime->setTimezone( $timezone ); if ( empty( $wp_locale->month ) || empty( $wp_locale->weekday ) ) { $date = $datetime->format( $format ); } else { $format = preg_replace( '/(?get_month( $datetime->format( 'm' ) ); $weekday = $wp_locale->get_weekday( $datetime->format( 'w' ) ); for ( $i = 0; $i < $format_length; $i++ ) { switch ( $format[ $i ] ) { case 'D': $new_format .= addcslashes( $wp_locale->get_weekday_abbrev( $weekday ), '\\A..Za..z' ); break; case 'F': $new_format .= addcslashes( $month, '\\A..Za..z' ); break; case 'l': $new_format .= addcslashes( $weekday, '\\A..Za..z' ); break; case 'M': $new_format .= addcslashes( $wp_locale->get_month_abbrev( $month ), '\\A..Za..z' ); break; case 'a': $new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'a' ) ), '\\A..Za..z' ); break; case 'A': $new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'A' ) ), '\\A..Za..z' ); break; case '\\': $new_format .= $format[ $i ]; if ( $i < $format_length ) { $new_format .= $format[ ++$i ]; } break; default: $new_format .= $format[ $i ]; break; } } $date = $datetime->format( $new_format ); $date = wp_maybe_decline_date( $date, $format ); } $date = apply_filters( 'wp_date', $date, $format, $timestamp, $timezone ); return $date; } function wp_maybe_decline_date( $date, $format = '' ) { global $wp_locale; if ( ! function_exists( '_x' ) ) { return $date; } if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) { $months = $wp_locale->month; $months_genitive = $wp_locale->month_genitive; if ( $format ) { $decline = preg_match( '#[dj]\.? F#', $format ); } else { $decline = preg_match( '#\b\d{1,2}\.? [^\d ]+\b#u', $date ); } if ( $decline ) { foreach ( $months as $key => $month ) { $months[ $key ] = '# ' . preg_quote( $month, '#' ) . '\b#u'; } foreach ( $months_genitive as $key => $month ) { $months_genitive[ $key ] = ' ' . $month; } $date = preg_replace( $months, $months_genitive, $date ); } if ( $format ) { $decline = preg_match( '#F [dj]#', $format ); } else { $decline = preg_match( '#\b[^\d ]+ \d{1,2}(st|nd|rd|th)?\b#u', trim( $date ) ); } if ( $decline ) { foreach ( $months as $key => $month ) { $months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?([-–]\d{1,2})?(st|nd|rd|th)?\b#u'; } foreach ( $months_genitive as $key => $month ) { $months_genitive[ $key ] = '$1$3 ' . $month; } $date = preg_replace( $months, $months_genitive, $date ); } } $locale = get_locale(); if ( 'ca' === $locale ) { $date = preg_replace( '# de ([ao])#i', " d'\\1", $date ); } return $date; } function number_format_i18n( $number, $decimals = 0 ) { global $wp_locale; if ( isset( $wp_locale ) ) { $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); } else { $formatted = number_format( $number, absint( $decimals ) ); } return apply_filters( 'number_format_i18n', $formatted, $number, $decimals ); } function size_format( $bytes, $decimals = 0 ) { $quant = array( _x( 'YB', 'unit symbol' ) => YB_IN_BYTES, _x( 'ZB', 'unit symbol' ) => ZB_IN_BYTES, _x( 'EB', 'unit symbol' ) => EB_IN_BYTES, _x( 'PB', 'unit symbol' ) => PB_IN_BYTES, _x( 'TB', 'unit symbol' ) => TB_IN_BYTES, _x( 'GB', 'unit symbol' ) => GB_IN_BYTES, _x( 'MB', 'unit symbol' ) => MB_IN_BYTES, _x( 'KB', 'unit symbol' ) => KB_IN_BYTES, _x( 'B', 'unit symbol' ) => 1, ); if ( 0 === $bytes ) { return number_format_i18n( 0, $decimals ) . ' ' . _x( 'B', 'unit symbol' ); } foreach ( $quant as $unit => $mag ) { if ( (float) $bytes >= $mag ) { return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; } } return false; } function human_readable_duration( $duration = '' ) { if ( ( empty( $duration ) || ! is_string( $duration ) ) ) { return false; } $duration = trim( $duration ); if ( '-' === substr( $duration, 0, 1 ) ) { $duration = substr( $duration, 1 ); } $duration_parts = array_reverse( explode( ':', $duration ) ); $duration_count = count( $duration_parts ); $hour = null; $minute = null; $second = null; if ( 3 === $duration_count ) { if ( ! ( (bool) preg_match( '/^([0-9]+):([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) { return false; } list( $second, $minute, $hour ) = $duration_parts; } elseif ( 2 === $duration_count ) { if ( ! ( (bool) preg_match( '/^([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) { return false; } list( $second, $minute ) = $duration_parts; } else { return false; } $human_readable_duration = array(); if ( is_numeric( $hour ) ) { $human_readable_duration[] = sprintf( _n( '%s hour', '%s hours', $hour ), (int) $hour ); } if ( is_numeric( $minute ) ) { $human_readable_duration[] = sprintf( _n( '%s minute', '%s minutes', $minute ), (int) $minute ); } if ( is_numeric( $second ) ) { $human_readable_duration[] = sprintf( _n( '%s second', '%s seconds', $second ), (int) $second ); } return implode( ', ', $human_readable_duration ); } function get_weekstartend( $mysqlstring, $start_of_week = '' ) { $my = substr( $mysqlstring, 0, 4 ); $mm = substr( $mysqlstring, 8, 2 ); $md = substr( $mysqlstring, 5, 2 ); $day = mktime( 0, 0, 0, $md, $mm, $my ); $weekday = gmdate( 'w', $day ); if ( ! is_numeric( $start_of_week ) ) { $start_of_week = get_option( 'start_of_week' ); } if ( $weekday < $start_of_week ) { $weekday += 7; } $start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); $end = $start + WEEK_IN_SECONDS - 1; return compact( 'start', 'end' ); } function maybe_serialize( $data ) { if ( is_array( $data ) || is_object( $data ) ) { return serialize( $data ); } if ( is_serialized( $data, false ) ) { return serialize( $data ); } return $data; } function maybe_unserialize( $data ) { if ( is_serialized( $data ) ) { return @unserialize( trim( $data ) ); } return $data; } function is_serialized( $data, $strict = true ) { if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( 'N;' === $data ) { return true; } if ( strlen( $data ) < 4 ) { return false; } if ( ':' !== $data[1] ) { return false; } if ( $strict ) { $lastc = substr( $data, -1 ); if ( ';' !== $lastc && '}' !== $lastc ) { return false; } } else { $semicolon = strpos( $data, ';' ); $brace = strpos( $data, '}' ); if ( false === $semicolon && false === $brace ) { return false; } if ( false !== $semicolon && $semicolon < 3 ) { return false; } if ( false !== $brace && $brace < 4 ) { return false; } } $token = $data[0]; switch ( $token ) { case 's': if ( $strict ) { if ( '"' !== substr( $data, -2, 1 ) ) { return false; } } elseif ( false === strpos( $data, '"' ) ) { return false; } case 'a': case 'O': case 'E': return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); case 'b': case 'i': case 'd': $end = $strict ? '$' : ''; return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data ); } return false; } function is_serialized_string( $data ) { if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( strlen( $data ) < 4 ) { return false; } elseif ( ':' !== $data[1] ) { return false; } elseif ( ';' !== substr( $data, -1 ) ) { return false; } elseif ( 's' !== $data[0] ) { return false; } elseif ( '"' !== substr( $data, -2, 1 ) ) { return false; } else { return true; } } function xmlrpc_getposttitle( $content ) { global $post_default_title; if ( preg_match( '/(.+?)<\/title>/is', $content, $matchtitle ) ) { $post_title = $matchtitle[1]; } else { $post_title = $post_default_title; } return $post_title; } function xmlrpc_getpostcategory( $content ) { global $post_default_category; if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { $post_category = trim( $matchcat[1], ',' ); $post_category = explode( ',', $post_category ); } else { $post_category = $post_default_category; } return $post_category; } function xmlrpc_removepostdata( $content ) { $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); $content = trim( $content ); return $content; } function wp_extract_urls( $content ) { preg_match_all( "#([\"']?)(" . '(?:([\w-]+:)?//?)' . '[^\s()<>]+' . '[.]' . '(?:' . '\([\w\d]+\)|' . '(?:' . "[^`!()\[\]{}:'\".,<>«»“”‘’\s]|" . '(?:[:]\d+)?/?' . ')+' . ')' . ")\\1#", $content, $post_links ); $post_links = array_unique( array_map( static function( $link ) { $link = html_entity_decode( $link ); return str_replace( ';', '', $link ); }, $post_links[2] ) ); return array_values( $post_links ); } function do_enclose( $content, $post ) { global $wpdb; include_once ABSPATH . WPINC . '/class-IXR.php'; $post = get_post( $post ); if ( ! $post ) { return false; } if ( null === $content ) { $content = $post->post_content; } $post_links = array(); $pung = get_enclosed( $post->ID ); $post_links_temp = wp_extract_urls( $content ); foreach ( $pung as $link_test ) { if ( ! in_array( $link_test, $post_links_temp, true ) ) { $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) ); foreach ( $mids as $mid ) { delete_metadata_by_mid( 'post', $mid ); } } } foreach ( (array) $post_links_temp as $link_test ) { if ( ! in_array( $link_test, $pung, true ) ) { $test = parse_url( $link_test ); if ( false === $test ) { continue; } if ( isset( $test['query'] ) ) { $post_links[] = $link_test; } elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) { $post_links[] = $link_test; } } } $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); foreach ( (array) $post_links as $url ) { $url = strip_fragment_from_url( $url ); if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) { $headers = wp_get_http_headers( $url ); if ( $headers ) { $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; $allowed_types = array( 'video', 'audio' ); $url_parts = parse_url( $url ); if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) { $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); if ( ! empty( $extension ) ) { foreach ( wp_get_mime_types() as $exts => $mime ) { if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { $type = $mime; break; } } } } if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types, true ) ) { add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" ); } } } } } function wp_get_http_headers( $url, $deprecated = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.7.0' ); } $response = wp_safe_remote_head( $url ); if ( is_wp_error( $response ) ) { return false; } return wp_remote_retrieve_headers( $response ); } function is_new_day() { global $currentday, $previousday; if ( $currentday !== $previousday ) { return 1; } else { return 0; } } function build_query( $data ) { return _http_build_query( $data, null, '&', '', false ); } function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) { $ret = array(); foreach ( (array) $data as $k => $v ) { if ( $urlencode ) { $k = urlencode( $k ); } if ( is_int( $k ) && null != $prefix ) { $k = $prefix . $k; } if ( ! empty( $key ) ) { $k = $key . '%5B' . $k . '%5D'; } if ( null === $v ) { continue; } elseif ( false === $v ) { $v = '0'; } if ( is_array( $v ) || is_object( $v ) ) { array_push( $ret, _http_build_query( $v, '', $sep, $k, $urlencode ) ); } elseif ( $urlencode ) { array_push( $ret, $k . '=' . urlencode( $v ) ); } else { array_push( $ret, $k . '=' . $v ); } } if ( null === $sep ) { $sep = ini_get( 'arg_separator.output' ); } return implode( $sep, $ret ); } function add_query_arg( ...$args ) { if ( is_array( $args[0] ) ) { if ( count( $args ) < 2 || false === $args[1] ) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $args[1]; } } else { if ( count( $args ) < 3 || false === $args[2] ) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $args[2]; } } $frag = strstr( $uri, '#' ); if ( $frag ) { $uri = substr( $uri, 0, -strlen( $frag ) ); } else { $frag = ''; } if ( 0 === stripos( $uri, 'http://' ) ) { $protocol = 'http://'; $uri = substr( $uri, 7 ); } elseif ( 0 === stripos( $uri, 'https://' ) ) { $protocol = 'https://'; $uri = substr( $uri, 8 ); } else { $protocol = ''; } if ( strpos( $uri, '?' ) !== false ) { list( $base, $query ) = explode( '?', $uri, 2 ); $base .= '?'; } elseif ( $protocol || strpos( $uri, '=' ) === false ) { $base = $uri . '?'; $query = ''; } else { $base = ''; $query = $uri; } wp_parse_str( $query, $qs ); $qs = urlencode_deep( $qs ); if ( is_array( $args[0] ) ) { foreach ( $args[0] as $k => $v ) { $qs[ $k ] = $v; } } else { $qs[ $args[0] ] = $args[1]; } foreach ( $qs as $k => $v ) { if ( false === $v ) { unset( $qs[ $k ] ); } } $ret = build_query( $qs ); $ret = trim( $ret, '?' ); $ret = preg_replace( '#=(&|$)#', '$1', $ret ); $ret = $protocol . $base . $ret . $frag; $ret = rtrim( $ret, '?' ); $ret = str_replace( '?#', '#', $ret ); return $ret; } function remove_query_arg( $key, $query = false ) { if ( is_array( $key ) ) { foreach ( $key as $k ) { $query = add_query_arg( $k, false, $query ); } return $query; } return add_query_arg( $key, false, $query ); } function wp_removable_query_args() { $removable_query_args = array( 'activate', 'activated', 'admin_email_remind_later', 'approved', 'core-major-auto-updates-saved', 'deactivate', 'delete_count', 'deleted', 'disabled', 'doing_wp_cron', 'enabled', 'error', 'hotkeys_highlight_first', 'hotkeys_highlight_last', 'ids', 'locked', 'message', 'same', 'saved', 'settings-updated', 'skipped', 'spammed', 'trashed', 'unspammed', 'untrashed', 'update', 'updated', 'wp-post-new-reload', ); return apply_filters( 'removable_query_args', $removable_query_args ); } function add_magic_quotes( $input_array ) { foreach ( (array) $input_array as $k => $v ) { if ( is_array( $v ) ) { $input_array[ $k ] = add_magic_quotes( $v ); } elseif ( is_string( $v ) ) { $input_array[ $k ] = addslashes( $v ); } else { continue; } } return $input_array; } function wp_remote_fopen( $uri ) { $parsed_url = parse_url( $uri ); if ( ! $parsed_url || ! is_array( $parsed_url ) ) { return false; } $options = array(); $options['timeout'] = 10; $response = wp_safe_remote_get( $uri, $options ); if ( is_wp_error( $response ) ) { return false; } return wp_remote_retrieve_body( $response ); } function wp( $query_vars = '' ) { global $wp, $wp_query, $wp_the_query; $wp->main( $query_vars ); if ( ! isset( $wp_the_query ) ) { $wp_the_query = $wp_query; } } function get_status_header_desc( $code ) { global $wp_header_to_desc; $code = absint( $code ); if ( ! isset( $wp_header_to_desc ) ) { $wp_header_to_desc = array( 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 103 => 'Early Hints', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 421 => 'Misdirected Request', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 510 => 'Not Extended', 511 => 'Network Authentication Required', ); } if ( isset( $wp_header_to_desc[ $code ] ) ) { return $wp_header_to_desc[ $code ]; } else { return ''; } } function status_header( $code, $description = '' ) { if ( ! $description ) { $description = get_status_header_desc( $code ); } if ( empty( $description ) ) { return; } $protocol = wp_get_server_protocol(); $status_header = "$protocol $code $description"; if ( function_exists( 'apply_filters' ) ) { $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); } if ( ! headers_sent() ) { header( $status_header, true, $code ); } } function wp_get_nocache_headers() { $headers = array( 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', ); if ( function_exists( 'apply_filters' ) ) { $headers = (array) apply_filters( 'nocache_headers', $headers ); } $headers['Last-Modified'] = false; return $headers; } function nocache_headers() { if ( headers_sent() ) { return; } $headers = wp_get_nocache_headers(); unset( $headers['Last-Modified'] ); header_remove( 'Last-Modified' ); foreach ( $headers as $name => $field_value ) { header( "{$name}: {$field_value}" ); } } function cache_javascript_headers() { $expiresOffset = 10 * DAY_IN_SECONDS; header( 'Content-Type: text/javascript; charset=' . get_bloginfo( 'charset' ) ); header( 'Vary: Accept-Encoding' ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiresOffset ) . ' GMT' ); } function get_num_queries() { global $wpdb; return $wpdb->num_queries; } function bool_from_yn( $yn ) { return ( 'y' === strtolower( $yn ) ); } function do_feed() { global $wp_query; $feed = get_query_var( 'feed' ); $feed = preg_replace( '/^_+/', '', $feed ); if ( '' === $feed || 'feed' === $feed ) { $feed = get_default_feed(); } if ( ! has_action( "do_feed_{$feed}" ) ) { wp_die( __( '<strong>Error:</strong> This is not a valid feed template.' ), '', array( 'response' => 404 ) ); } do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed ); } function do_feed_rdf() { load_template( ABSPATH . WPINC . '/feed-rdf.php' ); } function do_feed_rss() { load_template( ABSPATH . WPINC . '/feed-rss.php' ); } function do_feed_rss2( $for_comments ) { if ( $for_comments ) { load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); } else { load_template( ABSPATH . WPINC . '/feed-rss2.php' ); } } function do_feed_atom( $for_comments ) { if ( $for_comments ) { load_template( ABSPATH . WPINC . '/feed-atom-comments.php' ); } else { load_template( ABSPATH . WPINC . '/feed-atom.php' ); } } function do_robots() { header( 'Content-Type: text/plain; charset=utf-8' ); do_action( 'do_robotstxt' ); $output = "User-agent: *\n"; $public = get_option( 'blog_public' ); $site_url = parse_url( site_url() ); $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : ''; $output .= "Disallow: $path/wp-admin/\n"; $output .= "Allow: $path/wp-admin/admin-ajax.php\n"; echo apply_filters( 'robots_txt', $output, $public ); } function do_favicon() { do_action( 'do_faviconico' ); wp_redirect( get_site_icon_url( 32, includes_url( 'images/w-logo-blue-white-bg.png' ) ) ); exit; } function is_blog_installed() { global $wpdb; if ( wp_cache_get( 'is_blog_installed' ) ) { return true; } $suppress = $wpdb->suppress_errors(); if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); } if ( ! isset( $alloptions['siteurl'] ) ) { $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); } else { $installed = $alloptions['siteurl']; } $wpdb->suppress_errors( $suppress ); $installed = ! empty( $installed ); wp_cache_set( 'is_blog_installed', $installed ); if ( $installed ) { return true; } if ( defined( 'WP_REPAIRING' ) ) { return true; } $suppress = $wpdb->suppress_errors(); $wp_tables = $wpdb->tables(); foreach ( $wp_tables as $table ) { if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) { continue; } if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) { continue; } $described_table = $wpdb->get_results( "DESCRIBE $table;" ); if ( ( ! $described_table && empty( $wpdb->last_error ) ) || ( is_array( $described_table ) && 0 === count( $described_table ) ) ) { continue; } wp_load_translations_early(); $wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' ); dead_db(); } $wpdb->suppress_errors( $suppress ); wp_cache_set( 'is_blog_installed', false ); return false; } function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { $actionurl = str_replace( '&', '&', $actionurl ); return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) ); } function wp_nonce_field( $action = -1, $name = '_wpnonce', $referer = true, $display = true ) { $name = esc_attr( $name ); $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; if ( $referer ) { $nonce_field .= wp_referer_field( false ); } if ( $display ) { echo $nonce_field; } return $nonce_field; } function wp_referer_field( $display = true ) { $request_url = remove_query_arg( '_wp_http_referer' ); $referer_field = '<input type="hidden" name="_wp_http_referer" value="' . esc_url( $request_url ) . '" />'; if ( $display ) { echo $referer_field; } return $referer_field; } function wp_original_referer_field( $display = true, $jump_back_to = 'current' ) { $ref = wp_get_original_referer(); if ( ! $ref ) { $ref = ( 'previous' === $jump_back_to ) ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); } $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; if ( $display ) { echo $orig_referer_field; } return $orig_referer_field; } function wp_get_referer() { if ( ! function_exists( 'wp_validate_redirect' ) ) { return false; } $ref = wp_get_raw_referer(); if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref && home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref ) { return wp_validate_redirect( $ref, false ); } return false; } function wp_get_raw_referer() { if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { return wp_unslash( $_REQUEST['_wp_http_referer'] ); } elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { return wp_unslash( $_SERVER['HTTP_REFERER'] ); } return false; } function wp_get_original_referer() { if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) { return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); } return false; } function wp_mkdir_p( $target ) { $wrapper = null; if ( wp_is_stream( $target ) ) { list( $wrapper, $target ) = explode( '://', $target, 2 ); } $target = str_replace( '//', '/', $target ); if ( null !== $wrapper ) { $target = $wrapper . '://' . $target; } $target = rtrim( $target, '/' ); if ( empty( $target ) ) { $target = '/'; } if ( file_exists( $target ) ) { return @is_dir( $target ); } if ( false !== strpos( $target, '../' ) || false !== strpos( $target, '..' . DIRECTORY_SEPARATOR ) ) { return false; } $target_parent = dirname( $target ); while ( '.' !== $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) { $target_parent = dirname( $target_parent ); } $stat = @stat( $target_parent ); if ( $stat ) { $dir_perms = $stat['mode'] & 0007777; } else { $dir_perms = 0777; } if ( @mkdir( $target, $dir_perms, true ) ) { if ( ( $dir_perms & ~umask() ) != $dir_perms ) { $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) { chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms ); } } return true; } return false; } function path_is_absolute( $path ) { if ( wp_is_stream( $path ) && ( is_dir( $path ) || is_file( $path ) ) ) { return true; } if ( realpath( $path ) === $path ) { return true; } if ( strlen( $path ) === 0 || '.' === $path[0] ) { return false; } if ( preg_match( '#^[a-zA-Z]:\\\\#', $path ) ) { return true; } return ( '/' === $path[0] || '\\' === $path[0] ); } function path_join( $base, $path ) { if ( path_is_absolute( $path ) ) { return $path; } return rtrim( $base, '/' ) . '/' . $path; } function wp_normalize_path( $path ) { $wrapper = ''; if ( wp_is_stream( $path ) ) { list( $wrapper, $path ) = explode( '://', $path, 2 ); $wrapper .= '://'; } $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); if ( ':' === substr( $path, 1, 1 ) ) { $path = ucfirst( $path ); } return $wrapper . $path; } function get_temp_dir() { static $temp = ''; if ( defined( 'WP_TEMP_DIR' ) ) { return trailingslashit( WP_TEMP_DIR ); } if ( $temp ) { return trailingslashit( $temp ); } if ( function_exists( 'sys_get_temp_dir' ) ) { $temp = sys_get_temp_dir(); if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { return trailingslashit( $temp ); } } $temp = ini_get( 'upload_tmp_dir' ); if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { return trailingslashit( $temp ); } $temp = WP_CONTENT_DIR . '/'; if ( is_dir( $temp ) && wp_is_writable( $temp ) ) { return $temp; } return '/tmp/'; } function wp_is_writable( $path ) { if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) { return win_is_writable( $path ); } else { return @is_writable( $path ); } } function win_is_writable( $path ) { if ( '/' === $path[ strlen( $path ) - 1 ] ) { return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' ); } elseif ( is_dir( $path ) ) { return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); } $should_delete_tmp_file = ! file_exists( $path ); $f = @fopen( $path, 'a' ); if ( false === $f ) { return false; } fclose( $f ); if ( $should_delete_tmp_file ) { unlink( $path ); } return true; } function wp_get_upload_dir() { return wp_upload_dir( null, false ); } function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) { static $cache = array(), $tested_paths = array(); $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time ); if ( $refresh_cache || empty( $cache[ $key ] ) ) { $cache[ $key ] = _wp_upload_dir( $time ); } $uploads = apply_filters( 'upload_dir', $cache[ $key ] ); if ( $create_dir ) { $path = $uploads['path']; if ( array_key_exists( $path, $tested_paths ) ) { $uploads['error'] = $tested_paths[ $path ]; } else { if ( ! wp_mkdir_p( $path ) ) { if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; } else { $error_path = wp_basename( $uploads['basedir'] ) . $uploads['subdir']; } $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) ); } $tested_paths[ $path ] = $uploads['error']; } } return $uploads; } function _wp_upload_dir( $time = null ) { $siteurl = get_option( 'siteurl' ); $upload_path = trim( get_option( 'upload_path' ) ); if ( empty( $upload_path ) || 'wp-content/uploads' === $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { $dir = path_join( ABSPATH, $upload_path ); } else { $dir = $upload_path; } $url = get_option( 'upload_url_path' ); if ( ! $url ) { if ( empty( $upload_path ) || ( 'wp-content/uploads' === $upload_path ) || ( $upload_path == $dir ) ) { $url = WP_CONTENT_URL . '/uploads'; } else { $url = trailingslashit( $siteurl ) . $upload_path; } } if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) { $dir = ABSPATH . UPLOADS; $url = trailingslashit( $siteurl ) . UPLOADS; } if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { if ( defined( 'MULTISITE' ) ) { $ms_dir = '/sites/' . get_current_blog_id(); } else { $ms_dir = '/' . get_current_blog_id(); } $dir .= $ms_dir; $url .= $ms_dir; } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { if ( defined( 'BLOGUPLOADDIR' ) ) { $dir = untrailingslashit( BLOGUPLOADDIR ); } else { $dir = ABSPATH . UPLOADS; } $url = trailingslashit( $siteurl ) . 'files'; } } $basedir = $dir; $baseurl = $url; $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { if ( ! $time ) { $time = current_time( 'mysql' ); } $y = substr( $time, 0, 4 ); $m = substr( $time, 5, 2 ); $subdir = "/$y/$m"; } $dir .= $subdir; $url .= $subdir; return array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $basedir, 'baseurl' => $baseurl, 'error' => false, ); } function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { $filename = sanitize_file_name( $filename ); $ext2 = null; $number = ''; $alt_filenames = array(); $ext = pathinfo( $filename, PATHINFO_EXTENSION ); $name = pathinfo( $filename, PATHINFO_BASENAME ); if ( $ext ) { $ext = '.' . $ext; } if ( $name === $ext ) { $name = ''; } if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); } else { $fname = pathinfo( $filename, PATHINFO_FILENAME ); if ( $fname && preg_match( '/-(?:\d+x\d+|scaled|rotated)$/', $fname ) ) { $number = 1; $filename = str_replace( "{$fname}{$ext}", "{$fname}-{$number}{$ext}", $filename ); } $file_type = wp_check_filetype( $filename ); $mime_type = $file_type['type']; $is_image = ( ! empty( $mime_type ) && 0 === strpos( $mime_type, 'image/' ) ); $upload_dir = wp_get_upload_dir(); $lc_filename = null; $lc_ext = strtolower( $ext ); $_dir = trailingslashit( $dir ); if ( $ext && $lc_ext !== $ext ) { $lc_filename = preg_replace( '|' . preg_quote( $ext ) . '$|', $lc_ext, $filename ); } while ( file_exists( $_dir . $filename ) || ( $lc_filename && file_exists( $_dir . $lc_filename ) ) ) { $new_number = (int) $number + 1; if ( $lc_filename ) { $lc_filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $lc_filename ); } if ( '' === "{$number}{$ext}" ) { $filename = "{$filename}-{$new_number}"; } else { $filename = str_replace( array( "-{$number}{$ext}", "{$number}{$ext}" ), "-{$new_number}{$ext}", $filename ); } $number = $new_number; } if ( $lc_filename ) { $filename = $lc_filename; } $files = array(); $count = 10000; if ( $name && $ext && @is_dir( $dir ) && false !== strpos( $dir, $upload_dir['basedir'] ) ) { $files = apply_filters( 'pre_wp_unique_filename_file_list', null, $dir, $filename ); if ( null === $files ) { $files = @scandir( $dir ); } if ( ! empty( $files ) ) { $files = array_diff( $files, array( '.', '..' ) ); } if ( ! empty( $files ) ) { $count = count( $files ); $i = 0; while ( $i <= $count && _wp_check_existing_file_names( $filename, $files ) ) { $new_number = (int) $number + 1; $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename ); $number = $new_number; $i++; } } } if ( $is_image ) { $output_formats = apply_filters( 'image_editor_output_format', array(), $_dir . $filename, $mime_type ); $alt_types = array(); if ( ! empty( $output_formats[ $mime_type ] ) ) { $alt_mime_type = $output_formats[ $mime_type ]; $alt_types = array_keys( array_intersect( $output_formats, array( $mime_type, $alt_mime_type ) ) ); $alt_types[] = $alt_mime_type; } elseif ( ! empty( $output_formats ) ) { $alt_types = array_keys( array_intersect( $output_formats, array( $mime_type ) ) ); } $alt_types = array_unique( array_diff( $alt_types, array( $mime_type ) ) ); foreach ( $alt_types as $alt_type ) { $alt_ext = wp_get_default_extension_for_mime_type( $alt_type ); if ( ! $alt_ext ) { continue; } $alt_ext = ".{$alt_ext}"; $alt_filename = preg_replace( '|' . preg_quote( $lc_ext ) . '$|', $alt_ext, $filename ); $alt_filenames[ $alt_ext ] = $alt_filename; } if ( ! empty( $alt_filenames ) ) { $alt_filenames[ $lc_ext ] = $filename; $i = 0; while ( $i <= $count && _wp_check_alternate_file_names( $alt_filenames, $_dir, $files ) ) { $new_number = (int) $number + 1; foreach ( $alt_filenames as $alt_ext => $alt_filename ) { $alt_filenames[ $alt_ext ] = str_replace( array( "-{$number}{$alt_ext}", "{$number}{$alt_ext}" ), "-{$new_number}{$alt_ext}", $alt_filename ); } $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename ); $number = $new_number; $i++; } } } } return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback, $alt_filenames, $number ); } function _wp_check_alternate_file_names( $filenames, $dir, $files ) { foreach ( $filenames as $filename ) { if ( file_exists( $dir . $filename ) ) { return true; } if ( ! empty( $files ) && _wp_check_existing_file_names( $filename, $files ) ) { return true; } } return false; } function _wp_check_existing_file_names( $filename, $files ) { $fname = pathinfo( $filename, PATHINFO_FILENAME ); $ext = pathinfo( $filename, PATHINFO_EXTENSION ); if ( empty( $fname ) ) { return false; } if ( $ext ) { $ext = ".$ext"; } $regex = '/^' . preg_quote( $fname ) . '-(?:\d+x\d+|scaled|rotated)' . preg_quote( $ext ) . '$/i'; foreach ( $files as $file ) { if ( preg_match( $regex, $file ) ) { return true; } } return false; } function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.0.0' ); } if ( empty( $name ) ) { return array( 'error' => __( 'Empty filename' ) ); } $wp_filetype = wp_check_filetype( $name ); if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) { return array( 'error' => __( 'Sorry, you are not allowed to upload this file type.' ) ); } $upload = wp_upload_dir( $time ); if ( false !== $upload['error'] ) { return $upload; } $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time, ) ); if ( ! is_array( $upload_bits_error ) ) { $upload['error'] = $upload_bits_error; return $upload; } $filename = wp_unique_filename( $upload['path'], $name ); $new_file = $upload['path'] . "/$filename"; if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) { $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; } else { $error_path = wp_basename( $upload['basedir'] ) . $upload['subdir']; } $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); return array( 'error' => $message ); } $ifp = @fopen( $new_file, 'wb' ); if ( ! $ifp ) { return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ), ); } fwrite( $ifp, $bits ); fclose( $ifp ); clearstatcache(); $stat = @ stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0007777; $perms = $perms & 0000666; chmod( $new_file, $perms ); clearstatcache(); $url = $upload['url'] . "/$filename"; if ( is_multisite() ) { clean_dirsize_cache( $new_file ); } return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false, ), 'sideload' ); } function wp_ext2type( $ext ) { $ext = strtolower( $ext ); $ext2type = wp_get_ext_types(); foreach ( $ext2type as $type => $exts ) { if ( in_array( $ext, $exts, true ) ) { return $type; } } } function wp_get_default_extension_for_mime_type( $mime_type ) { $extensions = explode( '|', array_search( $mime_type, wp_get_mime_types(), true ) ); if ( empty( $extensions[0] ) ) { return false; } return $extensions[0]; } function wp_check_filetype( $filename, $mimes = null ) { if ( empty( $mimes ) ) { $mimes = get_allowed_mime_types(); } $type = false; $ext = false; foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { $type = $mime_match; $ext = $ext_matches[1]; break; } } return compact( 'ext', 'type' ); } function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $proper_filename = false; $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; if ( ! file_exists( $file ) ) { return compact( 'ext', 'type', 'proper_filename' ); } $real_mime = false; if ( $type && 0 === strpos( $type, 'image/' ) ) { $real_mime = wp_get_image_mime( $file ); if ( $real_mime && $real_mime != $type ) { $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/tiff' => 'tif', 'image/webp' => 'webp', ) ); if ( ! empty( $mime_to_ext[ $real_mime ] ) ) { $filename_parts = explode( '.', $filename ); array_pop( $filename_parts ); $filename_parts[] = $mime_to_ext[ $real_mime ]; $new_filename = implode( '.', $filename_parts ); if ( $new_filename != $filename ) { $proper_filename = $new_filename; } $wp_filetype = wp_check_filetype( $new_filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; } else { $real_mime = false; } } } if ( $type && ! $real_mime && extension_loaded( 'fileinfo' ) ) { $finfo = finfo_open( FILEINFO_MIME_TYPE ); $real_mime = finfo_file( $finfo, $file ); finfo_close( $finfo ); $nonspecific_types = array( 'application/octet-stream', 'application/encrypted', 'application/CDFV2-encrypted', 'application/zip', ); if ( in_array( $real_mime, $nonspecific_types, true ) ) { if ( ! in_array( substr( $type, 0, strcspn( $type, '/' ) ), array( 'application', 'video', 'audio' ), true ) ) { $type = false; $ext = false; } } elseif ( 0 === strpos( $real_mime, 'video/' ) || 0 === strpos( $real_mime, 'audio/' ) ) { if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) { $type = false; $ext = false; } } elseif ( 'text/plain' === $real_mime ) { if ( ! in_array( $type, array( 'text/plain', 'text/csv', 'application/csv', 'text/richtext', 'text/tsv', 'text/vtt', ), true ) ) { $type = false; $ext = false; } } elseif ( 'application/csv' === $real_mime ) { if ( ! in_array( $type, array( 'text/csv', 'text/plain', 'application/csv', ), true ) ) { $type = false; $ext = false; } } elseif ( 'text/rtf' === $real_mime ) { if ( ! in_array( $type, array( 'text/rtf', 'text/plain', 'application/rtf', ), true ) ) { $type = false; $ext = false; } } else { if ( $type !== $real_mime ) { $type = false; $ext = false; } } } if ( $type ) { $allowed = get_allowed_mime_types(); if ( ! in_array( $type, $allowed, true ) ) { $type = false; $ext = false; } } return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime ); } function wp_get_image_mime( $file ) { try { if ( is_callable( 'exif_imagetype' ) ) { $imagetype = exif_imagetype( $file ); $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; } elseif ( function_exists( 'getimagesize' ) ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! defined( 'WP_RUN_CORE_TESTS' ) ) { $imagesize = getimagesize( $file ); } else { $imagesize = @getimagesize( $file ); } $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; } else { $mime = false; } if ( false !== $mime ) { return $mime; } $magic = file_get_contents( $file, false, null, 0, 12 ); if ( false === $magic ) { return false; } $magic = bin2hex( $magic ); if ( ( 0 === strpos( $magic, '52494646' ) ) && ( 16 === strpos( $magic, '57454250' ) ) ) { $mime = 'image/webp'; } } catch ( Exception $e ) { $mime = false; } return $mime; } function wp_get_mime_types() { return apply_filters( 'mime_types', array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tiff|tif' => 'image/tiff', 'webp' => 'image/webp', 'ico' => 'image/x-icon', 'heic' => 'image/heic', 'asf|asx' => 'video/x-ms-asf', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wm' => 'video/x-ms-wm', 'avi' => 'video/avi', 'divx' => 'video/divx', 'flv' => 'video/x-flv', 'mov|qt' => 'video/quicktime', 'mpeg|mpg|mpe' => 'video/mpeg', 'mp4|m4v' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'mkv' => 'video/x-matroska', '3gp|3gpp' => 'video/3gpp', '3g2|3gp2' => 'video/3gpp2', 'txt|asc|c|cc|h|srt' => 'text/plain', 'csv' => 'text/csv', 'tsv' => 'text/tab-separated-values', 'ics' => 'text/calendar', 'rtx' => 'text/richtext', 'css' => 'text/css', 'htm|html' => 'text/html', 'vtt' => 'text/vtt', 'dfxp' => 'application/ttaf+xml', 'mp3|m4a|m4b' => 'audio/mpeg', 'aac' => 'audio/aac', 'ra|ram' => 'audio/x-realaudio', 'wav' => 'audio/wav', 'ogg|oga' => 'audio/ogg', 'flac' => 'audio/flac', 'mid|midi' => 'audio/midi', 'wma' => 'audio/x-ms-wma', 'wax' => 'audio/x-ms-wax', 'mka' => 'audio/x-matroska', 'rtf' => 'application/rtf', 'js' => 'application/javascript', 'pdf' => 'application/pdf', 'swf' => 'application/x-shockwave-flash', 'class' => 'application/java', 'tar' => 'application/x-tar', 'zip' => 'application/zip', 'gz|gzip' => 'application/x-gzip', 'rar' => 'application/rar', '7z' => 'application/x-7z-compressed', 'exe' => 'application/x-msdownload', 'psd' => 'application/octet-stream', 'xcf' => 'application/octet-stream', 'doc' => 'application/msword', 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 'wri' => 'application/vnd.ms-write', 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 'mdb' => 'application/vnd.ms-access', 'mpp' => 'application/vnd.ms-project', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 'oxps' => 'application/oxps', 'xps' => 'application/vnd.ms-xpsdocument', 'odt' => 'application/vnd.oasis.opendocument.text', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odb' => 'application/vnd.oasis.opendocument.database', 'odf' => 'application/vnd.oasis.opendocument.formula', 'wp|wpd' => 'application/wordperfect', 'key' => 'application/vnd.apple.keynote', 'numbers' => 'application/vnd.apple.numbers', 'pages' => 'application/vnd.apple.pages', ) ); } function wp_get_ext_types() { return apply_filters( 'ext2type', array( 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp' ), 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ), 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), ) ); } function wp_filesize( $path ) { $size = apply_filters( 'pre_wp_filesize', null, $path ); if ( is_int( $size ) ) { return $size; } $size = file_exists( $path ) ? (int) filesize( $path ) : 0; return (int) apply_filters( 'wp_filesize', $size, $path ); } function get_allowed_mime_types( $user = null ) { $t = wp_get_mime_types(); unset( $t['swf'], $t['exe'] ); if ( function_exists( 'current_user_can' ) ) { $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); } if ( empty( $unfiltered ) ) { unset( $t['htm|html'], $t['js'] ); } return apply_filters( 'upload_mimes', $t, $user ); } function wp_nonce_ays( $action ) { $title = __( 'Something went wrong.' ); $response_code = 403; if ( 'log-out' === $action ) { $title = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ); $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; $html = $title; $html .= '</p><p>'; $html .= sprintf( __( 'Do you really want to <a href="%s">log out</a>?' ), wp_logout_url( $redirect_to ) ); } else { $html = __( 'The link you followed has expired.' ); if ( wp_get_referer() ) { $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() ); $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) ); $html .= '</p><p>'; $html .= sprintf( '<a href="%s">%s</a>', esc_url( $wp_http_referer ), __( 'Please try again.' ) ); } } wp_die( $html, $title, $response_code ); } function wp_die( $message = '', $title = '', $args = array() ) { global $wp_query; if ( is_int( $args ) ) { $args = array( 'response' => $args ); } elseif ( is_int( $title ) ) { $args = array( 'response' => $title ); $title = ''; } if ( wp_doing_ajax() ) { $callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); } elseif ( wp_is_json_request() ) { $callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); } elseif ( defined( 'REST_REQUEST' ) && REST_REQUEST && wp_is_jsonp_request() ) { $callback = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' ); } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { $callback = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); } elseif ( wp_is_xml_request() || isset( $wp_query ) && ( function_exists( 'is_feed' ) && is_feed() || function_exists( 'is_comment_feed' ) && is_comment_feed() || function_exists( 'is_trackback' ) && is_trackback() ) ) { $callback = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' ); } else { $callback = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); } call_user_func( $callback, $message, $title, $args ); } function _default_wp_die_handler( $message, $title = '', $args = array() ) { list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args ); if ( is_string( $message ) ) { if ( ! empty( $parsed_args['additional_errors'] ) ) { $message = array_merge( array( $message ), wp_list_pluck( $parsed_args['additional_errors'], 'message' ) ); $message = "<ul>\n\t\t<li>" . implode( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>"; } $message = sprintf( '<div class="wp-die-message">%s</div>', $message ); } $have_gettext = function_exists( '__' ); if ( ! empty( $parsed_args['link_url'] ) && ! empty( $parsed_args['link_text'] ) ) { $link_url = $parsed_args['link_url']; if ( function_exists( 'esc_url' ) ) { $link_url = esc_url( $link_url ); } $link_text = $parsed_args['link_text']; $message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>"; } if ( isset( $parsed_args['back_link'] ) && $parsed_args['back_link'] ) { $back_text = $have_gettext ? __( '« Back' ) : '« Back'; $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>"; } if ( ! did_action( 'admin_head' ) ) : if ( ! headers_sent() ) { header( "Content-Type: text/html; charset={$parsed_args['charset']}" ); status_header( $parsed_args['response'] ); nocache_headers(); } $text_direction = $parsed_args['text_direction']; $dir_attr = "dir='$text_direction'"; if ( empty( $args['text_direction'] ) && function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { $dir_attr = get_language_attributes(); } ?> + require ABSPATH . WPINC . '/option.php'; function mysql2date( $format, $date, $translate = true ) { if ( empty( $date ) ) { return false; } $datetime = date_create( $date, wp_timezone() ); if ( false === $datetime ) { return false; } if ( 'G' === $format || 'U' === $format ) { return $datetime->getTimestamp() + $datetime->getOffset(); } if ( $translate ) { return wp_date( $format, $datetime->getTimestamp() ); } return $datetime->format( $format ); } function current_time( $type, $gmt = 0 ) { if ( 'timestamp' === $type || 'U' === $type ) { return $gmt ? time() : time() + ( (int) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); } if ( 'mysql' === $type ) { $type = 'Y-m-d H:i:s'; } $timezone = $gmt ? new DateTimeZone( 'UTC' ) : wp_timezone(); $datetime = new DateTime( 'now', $timezone ); return $datetime->format( $type ); } function current_datetime() { return new DateTimeImmutable( 'now', wp_timezone() ); } function wp_timezone_string() { $timezone_string = get_option( 'timezone_string' ); if ( $timezone_string ) { return $timezone_string; } $offset = (float) get_option( 'gmt_offset' ); $hours = (int) $offset; $minutes = ( $offset - $hours ); $sign = ( $offset < 0 ) ? '-' : '+'; $abs_hour = abs( $hours ); $abs_mins = abs( $minutes * 60 ); $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins ); return $tz_offset; } function wp_timezone() { return new DateTimeZone( wp_timezone_string() ); } function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) { $timestamp = $timestamp_with_offset; if ( ! is_numeric( $timestamp ) ) { $timestamp = current_time( 'timestamp', $gmt ); } if ( 'U' === $format ) { $date = $timestamp; } elseif ( $gmt && false === $timestamp_with_offset ) { $date = wp_date( $format, null, new DateTimeZone( 'UTC' ) ); } elseif ( false === $timestamp_with_offset ) { $date = wp_date( $format ); } else { $local_time = gmdate( 'Y-m-d H:i:s', $timestamp ); $timezone = wp_timezone(); $datetime = date_create( $local_time, $timezone ); $date = wp_date( $format, $datetime->getTimestamp(), $timezone ); } $date = apply_filters( 'date_i18n', $date, $format, $timestamp, $gmt ); return $date; } function wp_date( $format, $timestamp = null, $timezone = null ) { global $wp_locale; if ( null === $timestamp ) { $timestamp = time(); } elseif ( ! is_numeric( $timestamp ) ) { return false; } if ( ! $timezone ) { $timezone = wp_timezone(); } $datetime = date_create( '@' . $timestamp ); $datetime->setTimezone( $timezone ); if ( empty( $wp_locale->month ) || empty( $wp_locale->weekday ) ) { $date = $datetime->format( $format ); } else { $format = preg_replace( '/(?<!\\\\)r/', DATE_RFC2822, $format ); $new_format = ''; $format_length = strlen( $format ); $month = $wp_locale->get_month( $datetime->format( 'm' ) ); $weekday = $wp_locale->get_weekday( $datetime->format( 'w' ) ); for ( $i = 0; $i < $format_length; $i++ ) { switch ( $format[ $i ] ) { case 'D': $new_format .= addcslashes( $wp_locale->get_weekday_abbrev( $weekday ), '\\A..Za..z' ); break; case 'F': $new_format .= addcslashes( $month, '\\A..Za..z' ); break; case 'l': $new_format .= addcslashes( $weekday, '\\A..Za..z' ); break; case 'M': $new_format .= addcslashes( $wp_locale->get_month_abbrev( $month ), '\\A..Za..z' ); break; case 'a': $new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'a' ) ), '\\A..Za..z' ); break; case 'A': $new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'A' ) ), '\\A..Za..z' ); break; case '\\': $new_format .= $format[ $i ]; if ( $i < $format_length ) { $new_format .= $format[ ++$i ]; } break; default: $new_format .= $format[ $i ]; break; } } $date = $datetime->format( $new_format ); $date = wp_maybe_decline_date( $date, $format ); } $date = apply_filters( 'wp_date', $date, $format, $timestamp, $timezone ); return $date; } function wp_maybe_decline_date( $date, $format = '' ) { global $wp_locale; if ( ! function_exists( '_x' ) ) { return $date; } if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) { $months = $wp_locale->month; $months_genitive = $wp_locale->month_genitive; if ( $format ) { $decline = preg_match( '#[dj]\.? F#', $format ); } else { $decline = preg_match( '#\b\d{1,2}\.? [^\d ]+\b#u', $date ); } if ( $decline ) { foreach ( $months as $key => $month ) { $months[ $key ] = '# ' . preg_quote( $month, '#' ) . '\b#u'; } foreach ( $months_genitive as $key => $month ) { $months_genitive[ $key ] = ' ' . $month; } $date = preg_replace( $months, $months_genitive, $date ); } if ( $format ) { $decline = preg_match( '#F [dj]#', $format ); } else { $decline = preg_match( '#\b[^\d ]+ \d{1,2}(st|nd|rd|th)?\b#u', trim( $date ) ); } if ( $decline ) { foreach ( $months as $key => $month ) { $months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?([-–]\d{1,2})?(st|nd|rd|th)?\b#u'; } foreach ( $months_genitive as $key => $month ) { $months_genitive[ $key ] = '$1$3 ' . $month; } $date = preg_replace( $months, $months_genitive, $date ); } } $locale = get_locale(); if ( 'ca' === $locale ) { $date = preg_replace( '# de ([ao])#i', " d'\\1", $date ); } return $date; } function number_format_i18n( $number, $decimals = 0 ) { global $wp_locale; if ( isset( $wp_locale ) ) { $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); } else { $formatted = number_format( $number, absint( $decimals ) ); } return apply_filters( 'number_format_i18n', $formatted, $number, $decimals ); } function size_format( $bytes, $decimals = 0 ) { $quant = array( _x( 'YB', 'unit symbol' ) => YB_IN_BYTES, _x( 'ZB', 'unit symbol' ) => ZB_IN_BYTES, _x( 'EB', 'unit symbol' ) => EB_IN_BYTES, _x( 'PB', 'unit symbol' ) => PB_IN_BYTES, _x( 'TB', 'unit symbol' ) => TB_IN_BYTES, _x( 'GB', 'unit symbol' ) => GB_IN_BYTES, _x( 'MB', 'unit symbol' ) => MB_IN_BYTES, _x( 'KB', 'unit symbol' ) => KB_IN_BYTES, _x( 'B', 'unit symbol' ) => 1, ); if ( 0 === $bytes ) { return number_format_i18n( 0, $decimals ) . ' ' . _x( 'B', 'unit symbol' ); } foreach ( $quant as $unit => $mag ) { if ( (float) $bytes >= $mag ) { return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; } } return false; } function human_readable_duration( $duration = '' ) { if ( ( empty( $duration ) || ! is_string( $duration ) ) ) { return false; } $duration = trim( $duration ); if ( '-' === substr( $duration, 0, 1 ) ) { $duration = substr( $duration, 1 ); } $duration_parts = array_reverse( explode( ':', $duration ) ); $duration_count = count( $duration_parts ); $hour = null; $minute = null; $second = null; if ( 3 === $duration_count ) { if ( ! ( (bool) preg_match( '/^([0-9]+):([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) { return false; } list( $second, $minute, $hour ) = $duration_parts; } elseif ( 2 === $duration_count ) { if ( ! ( (bool) preg_match( '/^([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) { return false; } list( $second, $minute ) = $duration_parts; } else { return false; } $human_readable_duration = array(); if ( is_numeric( $hour ) ) { $human_readable_duration[] = sprintf( _n( '%s hour', '%s hours', $hour ), (int) $hour ); } if ( is_numeric( $minute ) ) { $human_readable_duration[] = sprintf( _n( '%s minute', '%s minutes', $minute ), (int) $minute ); } if ( is_numeric( $second ) ) { $human_readable_duration[] = sprintf( _n( '%s second', '%s seconds', $second ), (int) $second ); } return implode( ', ', $human_readable_duration ); } function get_weekstartend( $mysqlstring, $start_of_week = '' ) { $my = substr( $mysqlstring, 0, 4 ); $mm = substr( $mysqlstring, 8, 2 ); $md = substr( $mysqlstring, 5, 2 ); $day = mktime( 0, 0, 0, $md, $mm, $my ); $weekday = gmdate( 'w', $day ); if ( ! is_numeric( $start_of_week ) ) { $start_of_week = get_option( 'start_of_week' ); } if ( $weekday < $start_of_week ) { $weekday += 7; } $start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); $end = $start + WEEK_IN_SECONDS - 1; return compact( 'start', 'end' ); } function maybe_serialize( $data ) { if ( is_array( $data ) || is_object( $data ) ) { return serialize( $data ); } if ( is_serialized( $data, false ) ) { return serialize( $data ); } return $data; } function maybe_unserialize( $data ) { if ( is_serialized( $data ) ) { return @unserialize( trim( $data ) ); } return $data; } function is_serialized( $data, $strict = true ) { if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( 'N;' === $data ) { return true; } if ( strlen( $data ) < 4 ) { return false; } if ( ':' !== $data[1] ) { return false; } if ( $strict ) { $lastc = substr( $data, -1 ); if ( ';' !== $lastc && '}' !== $lastc ) { return false; } } else { $semicolon = strpos( $data, ';' ); $brace = strpos( $data, '}' ); if ( false === $semicolon && false === $brace ) { return false; } if ( false !== $semicolon && $semicolon < 3 ) { return false; } if ( false !== $brace && $brace < 4 ) { return false; } } $token = $data[0]; switch ( $token ) { case 's': if ( $strict ) { if ( '"' !== substr( $data, -2, 1 ) ) { return false; } } elseif ( false === strpos( $data, '"' ) ) { return false; } case 'a': case 'O': case 'E': return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); case 'b': case 'i': case 'd': $end = $strict ? '$' : ''; return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data ); } return false; } function is_serialized_string( $data ) { if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( strlen( $data ) < 4 ) { return false; } elseif ( ':' !== $data[1] ) { return false; } elseif ( ';' !== substr( $data, -1 ) ) { return false; } elseif ( 's' !== $data[0] ) { return false; } elseif ( '"' !== substr( $data, -2, 1 ) ) { return false; } else { return true; } } function xmlrpc_getposttitle( $content ) { global $post_default_title; if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) { $post_title = $matchtitle[1]; } else { $post_title = $post_default_title; } return $post_title; } function xmlrpc_getpostcategory( $content ) { global $post_default_category; if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { $post_category = trim( $matchcat[1], ',' ); $post_category = explode( ',', $post_category ); } else { $post_category = $post_default_category; } return $post_category; } function xmlrpc_removepostdata( $content ) { $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); $content = trim( $content ); return $content; } function wp_extract_urls( $content ) { preg_match_all( "#([\"']?)(" . '(?:([\w-]+:)?//?)' . '[^\s()<>]+' . '[.]' . '(?:' . '\([\w\d]+\)|' . '(?:' . "[^`!()\[\]{}:'\".,<>«»“”‘’\s]|" . '(?:[:]\d+)?/?' . ')+' . ')' . ")\\1#", $content, $post_links ); $post_links = array_unique( array_map( static function( $link ) { $link = html_entity_decode( $link ); return str_replace( ';', '', $link ); }, $post_links[2] ) ); return array_values( $post_links ); } function do_enclose( $content, $post ) { global $wpdb; include_once ABSPATH . WPINC . '/class-IXR.php'; $post = get_post( $post ); if ( ! $post ) { return false; } if ( null === $content ) { $content = $post->post_content; } $post_links = array(); $pung = get_enclosed( $post->ID ); $post_links_temp = wp_extract_urls( $content ); foreach ( $pung as $link_test ) { if ( ! in_array( $link_test, $post_links_temp, true ) ) { $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) ); foreach ( $mids as $mid ) { delete_metadata_by_mid( 'post', $mid ); } } } foreach ( (array) $post_links_temp as $link_test ) { if ( ! in_array( $link_test, $pung, true ) ) { $test = parse_url( $link_test ); if ( false === $test ) { continue; } if ( isset( $test['query'] ) ) { $post_links[] = $link_test; } elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) { $post_links[] = $link_test; } } } $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); foreach ( (array) $post_links as $url ) { $url = strip_fragment_from_url( $url ); if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) { $headers = wp_get_http_headers( $url ); if ( $headers ) { $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; $allowed_types = array( 'video', 'audio' ); $url_parts = parse_url( $url ); if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) { $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); if ( ! empty( $extension ) ) { foreach ( wp_get_mime_types() as $exts => $mime ) { if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { $type = $mime; break; } } } } if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types, true ) ) { add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" ); } } } } } function wp_get_http_headers( $url, $deprecated = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.7.0' ); } $response = wp_safe_remote_head( $url ); if ( is_wp_error( $response ) ) { return false; } return wp_remote_retrieve_headers( $response ); } function is_new_day() { global $currentday, $previousday; if ( $currentday !== $previousday ) { return 1; } else { return 0; } } function build_query( $data ) { return _http_build_query( $data, null, '&', '', false ); } function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) { $ret = array(); foreach ( (array) $data as $k => $v ) { if ( $urlencode ) { $k = urlencode( $k ); } if ( is_int( $k ) && null != $prefix ) { $k = $prefix . $k; } if ( ! empty( $key ) ) { $k = $key . '%5B' . $k . '%5D'; } if ( null === $v ) { continue; } elseif ( false === $v ) { $v = '0'; } if ( is_array( $v ) || is_object( $v ) ) { array_push( $ret, _http_build_query( $v, '', $sep, $k, $urlencode ) ); } elseif ( $urlencode ) { array_push( $ret, $k . '=' . urlencode( $v ) ); } else { array_push( $ret, $k . '=' . $v ); } } if ( null === $sep ) { $sep = ini_get( 'arg_separator.output' ); } return implode( $sep, $ret ); } function add_query_arg( ...$args ) { if ( is_array( $args[0] ) ) { if ( count( $args ) < 2 || false === $args[1] ) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $args[1]; } } else { if ( count( $args ) < 3 || false === $args[2] ) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $args[2]; } } $frag = strstr( $uri, '#' ); if ( $frag ) { $uri = substr( $uri, 0, -strlen( $frag ) ); } else { $frag = ''; } if ( 0 === stripos( $uri, 'http://' ) ) { $protocol = 'http://'; $uri = substr( $uri, 7 ); } elseif ( 0 === stripos( $uri, 'https://' ) ) { $protocol = 'https://'; $uri = substr( $uri, 8 ); } else { $protocol = ''; } if ( strpos( $uri, '?' ) !== false ) { list( $base, $query ) = explode( '?', $uri, 2 ); $base .= '?'; } elseif ( $protocol || strpos( $uri, '=' ) === false ) { $base = $uri . '?'; $query = ''; } else { $base = ''; $query = $uri; } wp_parse_str( $query, $qs ); $qs = urlencode_deep( $qs ); if ( is_array( $args[0] ) ) { foreach ( $args[0] as $k => $v ) { $qs[ $k ] = $v; } } else { $qs[ $args[0] ] = $args[1]; } foreach ( $qs as $k => $v ) { if ( false === $v ) { unset( $qs[ $k ] ); } } $ret = build_query( $qs ); $ret = trim( $ret, '?' ); $ret = preg_replace( '#=(&|$)#', '$1', $ret ); $ret = $protocol . $base . $ret . $frag; $ret = rtrim( $ret, '?' ); $ret = str_replace( '?#', '#', $ret ); return $ret; } function remove_query_arg( $key, $query = false ) { if ( is_array( $key ) ) { foreach ( $key as $k ) { $query = add_query_arg( $k, false, $query ); } return $query; } return add_query_arg( $key, false, $query ); } function wp_removable_query_args() { $removable_query_args = array( 'activate', 'activated', 'admin_email_remind_later', 'approved', 'core-major-auto-updates-saved', 'deactivate', 'delete_count', 'deleted', 'disabled', 'doing_wp_cron', 'enabled', 'error', 'hotkeys_highlight_first', 'hotkeys_highlight_last', 'ids', 'locked', 'message', 'same', 'saved', 'settings-updated', 'skipped', 'spammed', 'trashed', 'unspammed', 'untrashed', 'update', 'updated', 'wp-post-new-reload', ); return apply_filters( 'removable_query_args', $removable_query_args ); } function add_magic_quotes( $input_array ) { foreach ( (array) $input_array as $k => $v ) { if ( is_array( $v ) ) { $input_array[ $k ] = add_magic_quotes( $v ); } elseif ( is_string( $v ) ) { $input_array[ $k ] = addslashes( $v ); } else { continue; } } return $input_array; } function wp_remote_fopen( $uri ) { $parsed_url = parse_url( $uri ); if ( ! $parsed_url || ! is_array( $parsed_url ) ) { return false; } $options = array(); $options['timeout'] = 10; $response = wp_safe_remote_get( $uri, $options ); if ( is_wp_error( $response ) ) { return false; } return wp_remote_retrieve_body( $response ); } function wp( $query_vars = '' ) { global $wp, $wp_query, $wp_the_query; $wp->main( $query_vars ); if ( ! isset( $wp_the_query ) ) { $wp_the_query = $wp_query; } } function get_status_header_desc( $code ) { global $wp_header_to_desc; $code = absint( $code ); if ( ! isset( $wp_header_to_desc ) ) { $wp_header_to_desc = array( 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 103 => 'Early Hints', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 421 => 'Misdirected Request', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 510 => 'Not Extended', 511 => 'Network Authentication Required', ); } if ( isset( $wp_header_to_desc[ $code ] ) ) { return $wp_header_to_desc[ $code ]; } else { return ''; } } function status_header( $code, $description = '' ) { if ( ! $description ) { $description = get_status_header_desc( $code ); } if ( empty( $description ) ) { return; } $protocol = wp_get_server_protocol(); $status_header = "$protocol $code $description"; if ( function_exists( 'apply_filters' ) ) { $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); } if ( ! headers_sent() ) { header( $status_header, true, $code ); } } function wp_get_nocache_headers() { $headers = array( 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', ); if ( function_exists( 'apply_filters' ) ) { $headers = (array) apply_filters( 'nocache_headers', $headers ); } $headers['Last-Modified'] = false; return $headers; } function nocache_headers() { if ( headers_sent() ) { return; } $headers = wp_get_nocache_headers(); unset( $headers['Last-Modified'] ); header_remove( 'Last-Modified' ); foreach ( $headers as $name => $field_value ) { header( "{$name}: {$field_value}" ); } } function cache_javascript_headers() { $expiresOffset = 10 * DAY_IN_SECONDS; header( 'Content-Type: text/javascript; charset=' . get_bloginfo( 'charset' ) ); header( 'Vary: Accept-Encoding' ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiresOffset ) . ' GMT' ); } function get_num_queries() { global $wpdb; return $wpdb->num_queries; } function bool_from_yn( $yn ) { return ( 'y' === strtolower( $yn ) ); } function do_feed() { global $wp_query; $feed = get_query_var( 'feed' ); $feed = preg_replace( '/^_+/', '', $feed ); if ( '' === $feed || 'feed' === $feed ) { $feed = get_default_feed(); } if ( ! has_action( "do_feed_{$feed}" ) ) { wp_die( __( '<strong>Error:</strong> This is not a valid feed template.' ), '', array( 'response' => 404 ) ); } do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed ); } function do_feed_rdf() { load_template( ABSPATH . WPINC . '/feed-rdf.php' ); } function do_feed_rss() { load_template( ABSPATH . WPINC . '/feed-rss.php' ); } function do_feed_rss2( $for_comments ) { if ( $for_comments ) { load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); } else { load_template( ABSPATH . WPINC . '/feed-rss2.php' ); } } function do_feed_atom( $for_comments ) { if ( $for_comments ) { load_template( ABSPATH . WPINC . '/feed-atom-comments.php' ); } else { load_template( ABSPATH . WPINC . '/feed-atom.php' ); } } function do_robots() { header( 'Content-Type: text/plain; charset=utf-8' ); do_action( 'do_robotstxt' ); $output = "User-agent: *\n"; $public = get_option( 'blog_public' ); $site_url = parse_url( site_url() ); $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : ''; $output .= "Disallow: $path/wp-admin/\n"; $output .= "Allow: $path/wp-admin/admin-ajax.php\n"; echo apply_filters( 'robots_txt', $output, $public ); } function do_favicon() { do_action( 'do_faviconico' ); wp_redirect( get_site_icon_url( 32, includes_url( 'images/w-logo-blue-white-bg.png' ) ) ); exit; } function is_blog_installed() { global $wpdb; if ( wp_cache_get( 'is_blog_installed' ) ) { return true; } $suppress = $wpdb->suppress_errors(); if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); } if ( ! isset( $alloptions['siteurl'] ) ) { $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); } else { $installed = $alloptions['siteurl']; } $wpdb->suppress_errors( $suppress ); $installed = ! empty( $installed ); wp_cache_set( 'is_blog_installed', $installed ); if ( $installed ) { return true; } if ( defined( 'WP_REPAIRING' ) ) { return true; } $suppress = $wpdb->suppress_errors(); $wp_tables = $wpdb->tables(); foreach ( $wp_tables as $table ) { if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) { continue; } if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) { continue; } $described_table = $wpdb->get_results( "DESCRIBE $table;" ); if ( ( ! $described_table && empty( $wpdb->last_error ) ) || ( is_array( $described_table ) && 0 === count( $described_table ) ) ) { continue; } wp_load_translations_early(); $wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' ); dead_db(); } $wpdb->suppress_errors( $suppress ); wp_cache_set( 'is_blog_installed', false ); return false; } function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { $actionurl = str_replace( '&', '&', $actionurl ); return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) ); } function wp_nonce_field( $action = -1, $name = '_wpnonce', $referer = true, $display = true ) { $name = esc_attr( $name ); $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; if ( $referer ) { $nonce_field .= wp_referer_field( false ); } if ( $display ) { echo $nonce_field; } return $nonce_field; } function wp_referer_field( $display = true ) { $request_url = remove_query_arg( '_wp_http_referer' ); $referer_field = '<input type="hidden" name="_wp_http_referer" value="' . esc_url( $request_url ) . '" />'; if ( $display ) { echo $referer_field; } return $referer_field; } function wp_original_referer_field( $display = true, $jump_back_to = 'current' ) { $ref = wp_get_original_referer(); if ( ! $ref ) { $ref = ( 'previous' === $jump_back_to ) ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); } $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; if ( $display ) { echo $orig_referer_field; } return $orig_referer_field; } function wp_get_referer() { if ( ! function_exists( 'wp_validate_redirect' ) ) { return false; } $ref = wp_get_raw_referer(); if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref && home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref ) { return wp_validate_redirect( $ref, false ); } return false; } function wp_get_raw_referer() { if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { return wp_unslash( $_REQUEST['_wp_http_referer'] ); } elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { return wp_unslash( $_SERVER['HTTP_REFERER'] ); } return false; } function wp_get_original_referer() { if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) { return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); } return false; } function wp_mkdir_p( $target ) { $wrapper = null; if ( wp_is_stream( $target ) ) { list( $wrapper, $target ) = explode( '://', $target, 2 ); } $target = str_replace( '//', '/', $target ); if ( null !== $wrapper ) { $target = $wrapper . '://' . $target; } $target = rtrim( $target, '/' ); if ( empty( $target ) ) { $target = '/'; } if ( file_exists( $target ) ) { return @is_dir( $target ); } if ( false !== strpos( $target, '../' ) || false !== strpos( $target, '..' . DIRECTORY_SEPARATOR ) ) { return false; } $target_parent = dirname( $target ); while ( '.' !== $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) { $target_parent = dirname( $target_parent ); } $stat = @stat( $target_parent ); if ( $stat ) { $dir_perms = $stat['mode'] & 0007777; } else { $dir_perms = 0777; } if ( @mkdir( $target, $dir_perms, true ) ) { if ( ( $dir_perms & ~umask() ) != $dir_perms ) { $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) { chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms ); } } return true; } return false; } function path_is_absolute( $path ) { if ( wp_is_stream( $path ) && ( is_dir( $path ) || is_file( $path ) ) ) { return true; } if ( realpath( $path ) === $path ) { return true; } if ( strlen( $path ) === 0 || '.' === $path[0] ) { return false; } if ( preg_match( '#^[a-zA-Z]:\\\\#', $path ) ) { return true; } return ( '/' === $path[0] || '\\' === $path[0] ); } function path_join( $base, $path ) { if ( path_is_absolute( $path ) ) { return $path; } return rtrim( $base, '/' ) . '/' . $path; } function wp_normalize_path( $path ) { $wrapper = ''; if ( wp_is_stream( $path ) ) { list( $wrapper, $path ) = explode( '://', $path, 2 ); $wrapper .= '://'; } $path = str_replace( '\\', '/', $path ); $path = preg_replace( '|(?<=.)/+|', '/', $path ); if ( ':' === substr( $path, 1, 1 ) ) { $path = ucfirst( $path ); } return $wrapper . $path; } function get_temp_dir() { static $temp = ''; if ( defined( 'WP_TEMP_DIR' ) ) { return trailingslashit( WP_TEMP_DIR ); } if ( $temp ) { return trailingslashit( $temp ); } if ( function_exists( 'sys_get_temp_dir' ) ) { $temp = sys_get_temp_dir(); if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { return trailingslashit( $temp ); } } $temp = ini_get( 'upload_tmp_dir' ); if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { return trailingslashit( $temp ); } $temp = WP_CONTENT_DIR . '/'; if ( is_dir( $temp ) && wp_is_writable( $temp ) ) { return $temp; } return '/tmp/'; } function wp_is_writable( $path ) { if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) { return win_is_writable( $path ); } else { return @is_writable( $path ); } } function win_is_writable( $path ) { if ( '/' === $path[ strlen( $path ) - 1 ] ) { return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' ); } elseif ( is_dir( $path ) ) { return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); } $should_delete_tmp_file = ! file_exists( $path ); $f = @fopen( $path, 'a' ); if ( false === $f ) { return false; } fclose( $f ); if ( $should_delete_tmp_file ) { unlink( $path ); } return true; } function wp_get_upload_dir() { return wp_upload_dir( null, false ); } function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) { static $cache = array(), $tested_paths = array(); $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time ); if ( $refresh_cache || empty( $cache[ $key ] ) ) { $cache[ $key ] = _wp_upload_dir( $time ); } $uploads = apply_filters( 'upload_dir', $cache[ $key ] ); if ( $create_dir ) { $path = $uploads['path']; if ( array_key_exists( $path, $tested_paths ) ) { $uploads['error'] = $tested_paths[ $path ]; } else { if ( ! wp_mkdir_p( $path ) ) { if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; } else { $error_path = wp_basename( $uploads['basedir'] ) . $uploads['subdir']; } $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) ); } $tested_paths[ $path ] = $uploads['error']; } } return $uploads; } function _wp_upload_dir( $time = null ) { $siteurl = get_option( 'siteurl' ); $upload_path = trim( get_option( 'upload_path' ) ); if ( empty( $upload_path ) || 'wp-content/uploads' === $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { $dir = path_join( ABSPATH, $upload_path ); } else { $dir = $upload_path; } $url = get_option( 'upload_url_path' ); if ( ! $url ) { if ( empty( $upload_path ) || ( 'wp-content/uploads' === $upload_path ) || ( $upload_path == $dir ) ) { $url = WP_CONTENT_URL . '/uploads'; } else { $url = trailingslashit( $siteurl ) . $upload_path; } } if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) { $dir = ABSPATH . UPLOADS; $url = trailingslashit( $siteurl ) . UPLOADS; } if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { if ( defined( 'MULTISITE' ) ) { $ms_dir = '/sites/' . get_current_blog_id(); } else { $ms_dir = '/' . get_current_blog_id(); } $dir .= $ms_dir; $url .= $ms_dir; } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { if ( defined( 'BLOGUPLOADDIR' ) ) { $dir = untrailingslashit( BLOGUPLOADDIR ); } else { $dir = ABSPATH . UPLOADS; } $url = trailingslashit( $siteurl ) . 'files'; } } $basedir = $dir; $baseurl = $url; $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { if ( ! $time ) { $time = current_time( 'mysql' ); } $y = substr( $time, 0, 4 ); $m = substr( $time, 5, 2 ); $subdir = "/$y/$m"; } $dir .= $subdir; $url .= $subdir; return array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $basedir, 'baseurl' => $baseurl, 'error' => false, ); } function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { $filename = sanitize_file_name( $filename ); $ext2 = null; $number = ''; $alt_filenames = array(); $ext = pathinfo( $filename, PATHINFO_EXTENSION ); $name = pathinfo( $filename, PATHINFO_BASENAME ); if ( $ext ) { $ext = '.' . $ext; } if ( $name === $ext ) { $name = ''; } if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); } else { $fname = pathinfo( $filename, PATHINFO_FILENAME ); if ( $fname && preg_match( '/-(?:\d+x\d+|scaled|rotated)$/', $fname ) ) { $number = 1; $filename = str_replace( "{$fname}{$ext}", "{$fname}-{$number}{$ext}", $filename ); } $file_type = wp_check_filetype( $filename ); $mime_type = $file_type['type']; $is_image = ( ! empty( $mime_type ) && 0 === strpos( $mime_type, 'image/' ) ); $upload_dir = wp_get_upload_dir(); $lc_filename = null; $lc_ext = strtolower( $ext ); $_dir = trailingslashit( $dir ); if ( $ext && $lc_ext !== $ext ) { $lc_filename = preg_replace( '|' . preg_quote( $ext ) . '$|', $lc_ext, $filename ); } while ( file_exists( $_dir . $filename ) || ( $lc_filename && file_exists( $_dir . $lc_filename ) ) ) { $new_number = (int) $number + 1; if ( $lc_filename ) { $lc_filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $lc_filename ); } if ( '' === "{$number}{$ext}" ) { $filename = "{$filename}-{$new_number}"; } else { $filename = str_replace( array( "-{$number}{$ext}", "{$number}{$ext}" ), "-{$new_number}{$ext}", $filename ); } $number = $new_number; } if ( $lc_filename ) { $filename = $lc_filename; } $files = array(); $count = 10000; if ( $name && $ext && @is_dir( $dir ) && false !== strpos( $dir, $upload_dir['basedir'] ) ) { $files = apply_filters( 'pre_wp_unique_filename_file_list', null, $dir, $filename ); if ( null === $files ) { $files = @scandir( $dir ); } if ( ! empty( $files ) ) { $files = array_diff( $files, array( '.', '..' ) ); } if ( ! empty( $files ) ) { $count = count( $files ); $i = 0; while ( $i <= $count && _wp_check_existing_file_names( $filename, $files ) ) { $new_number = (int) $number + 1; $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename ); $number = $new_number; $i++; } } } if ( $is_image ) { $output_formats = apply_filters( 'image_editor_output_format', array(), $_dir . $filename, $mime_type ); $alt_types = array(); if ( ! empty( $output_formats[ $mime_type ] ) ) { $alt_mime_type = $output_formats[ $mime_type ]; $alt_types = array_keys( array_intersect( $output_formats, array( $mime_type, $alt_mime_type ) ) ); $alt_types[] = $alt_mime_type; } elseif ( ! empty( $output_formats ) ) { $alt_types = array_keys( array_intersect( $output_formats, array( $mime_type ) ) ); } $alt_types = array_unique( array_diff( $alt_types, array( $mime_type ) ) ); foreach ( $alt_types as $alt_type ) { $alt_ext = wp_get_default_extension_for_mime_type( $alt_type ); if ( ! $alt_ext ) { continue; } $alt_ext = ".{$alt_ext}"; $alt_filename = preg_replace( '|' . preg_quote( $lc_ext ) . '$|', $alt_ext, $filename ); $alt_filenames[ $alt_ext ] = $alt_filename; } if ( ! empty( $alt_filenames ) ) { $alt_filenames[ $lc_ext ] = $filename; $i = 0; while ( $i <= $count && _wp_check_alternate_file_names( $alt_filenames, $_dir, $files ) ) { $new_number = (int) $number + 1; foreach ( $alt_filenames as $alt_ext => $alt_filename ) { $alt_filenames[ $alt_ext ] = str_replace( array( "-{$number}{$alt_ext}", "{$number}{$alt_ext}" ), "-{$new_number}{$alt_ext}", $alt_filename ); } $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename ); $number = $new_number; $i++; } } } } return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback, $alt_filenames, $number ); } function _wp_check_alternate_file_names( $filenames, $dir, $files ) { foreach ( $filenames as $filename ) { if ( file_exists( $dir . $filename ) ) { return true; } if ( ! empty( $files ) && _wp_check_existing_file_names( $filename, $files ) ) { return true; } } return false; } function _wp_check_existing_file_names( $filename, $files ) { $fname = pathinfo( $filename, PATHINFO_FILENAME ); $ext = pathinfo( $filename, PATHINFO_EXTENSION ); if ( empty( $fname ) ) { return false; } if ( $ext ) { $ext = ".$ext"; } $regex = '/^' . preg_quote( $fname ) . '-(?:\d+x\d+|scaled|rotated)' . preg_quote( $ext ) . '$/i'; foreach ( $files as $file ) { if ( preg_match( $regex, $file ) ) { return true; } } return false; } function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.0.0' ); } if ( empty( $name ) ) { return array( 'error' => __( 'Empty filename' ) ); } $wp_filetype = wp_check_filetype( $name ); if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) { return array( 'error' => __( 'Sorry, you are not allowed to upload this file type.' ) ); } $upload = wp_upload_dir( $time ); if ( false !== $upload['error'] ) { return $upload; } $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time, ) ); if ( ! is_array( $upload_bits_error ) ) { $upload['error'] = $upload_bits_error; return $upload; } $filename = wp_unique_filename( $upload['path'], $name ); $new_file = $upload['path'] . "/$filename"; if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) { $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; } else { $error_path = wp_basename( $upload['basedir'] ) . $upload['subdir']; } $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); return array( 'error' => $message ); } $ifp = @fopen( $new_file, 'wb' ); if ( ! $ifp ) { return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ), ); } fwrite( $ifp, $bits ); fclose( $ifp ); clearstatcache(); $stat = @ stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0007777; $perms = $perms & 0000666; chmod( $new_file, $perms ); clearstatcache(); $url = $upload['url'] . "/$filename"; if ( is_multisite() ) { clean_dirsize_cache( $new_file ); } return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false, ), 'sideload' ); } function wp_ext2type( $ext ) { $ext = strtolower( $ext ); $ext2type = wp_get_ext_types(); foreach ( $ext2type as $type => $exts ) { if ( in_array( $ext, $exts, true ) ) { return $type; } } } function wp_get_default_extension_for_mime_type( $mime_type ) { $extensions = explode( '|', array_search( $mime_type, wp_get_mime_types(), true ) ); if ( empty( $extensions[0] ) ) { return false; } return $extensions[0]; } function wp_check_filetype( $filename, $mimes = null ) { if ( empty( $mimes ) ) { $mimes = get_allowed_mime_types(); } $type = false; $ext = false; foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { $type = $mime_match; $ext = $ext_matches[1]; break; } } return compact( 'ext', 'type' ); } function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $proper_filename = false; $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; if ( ! file_exists( $file ) ) { return compact( 'ext', 'type', 'proper_filename' ); } $real_mime = false; if ( $type && 0 === strpos( $type, 'image/' ) ) { $real_mime = wp_get_image_mime( $file ); if ( $real_mime && $real_mime != $type ) { $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/tiff' => 'tif', 'image/webp' => 'webp', ) ); if ( ! empty( $mime_to_ext[ $real_mime ] ) ) { $filename_parts = explode( '.', $filename ); array_pop( $filename_parts ); $filename_parts[] = $mime_to_ext[ $real_mime ]; $new_filename = implode( '.', $filename_parts ); if ( $new_filename != $filename ) { $proper_filename = $new_filename; } $wp_filetype = wp_check_filetype( $new_filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; } else { $real_mime = false; } } } if ( $type && ! $real_mime && extension_loaded( 'fileinfo' ) ) { $finfo = finfo_open( FILEINFO_MIME_TYPE ); $real_mime = finfo_file( $finfo, $file ); finfo_close( $finfo ); $nonspecific_types = array( 'application/octet-stream', 'application/encrypted', 'application/CDFV2-encrypted', 'application/zip', ); if ( in_array( $real_mime, $nonspecific_types, true ) ) { if ( ! in_array( substr( $type, 0, strcspn( $type, '/' ) ), array( 'application', 'video', 'audio' ), true ) ) { $type = false; $ext = false; } } elseif ( 0 === strpos( $real_mime, 'video/' ) || 0 === strpos( $real_mime, 'audio/' ) ) { if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) { $type = false; $ext = false; } } elseif ( 'text/plain' === $real_mime ) { if ( ! in_array( $type, array( 'text/plain', 'text/csv', 'application/csv', 'text/richtext', 'text/tsv', 'text/vtt', ), true ) ) { $type = false; $ext = false; } } elseif ( 'application/csv' === $real_mime ) { if ( ! in_array( $type, array( 'text/csv', 'text/plain', 'application/csv', ), true ) ) { $type = false; $ext = false; } } elseif ( 'text/rtf' === $real_mime ) { if ( ! in_array( $type, array( 'text/rtf', 'text/plain', 'application/rtf', ), true ) ) { $type = false; $ext = false; } } else { if ( $type !== $real_mime ) { $type = false; $ext = false; } } } if ( $type ) { $allowed = get_allowed_mime_types(); if ( ! in_array( $type, $allowed, true ) ) { $type = false; $ext = false; } } return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime ); } function wp_get_image_mime( $file ) { try { if ( is_callable( 'exif_imagetype' ) ) { $imagetype = exif_imagetype( $file ); $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; } elseif ( function_exists( 'getimagesize' ) ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! defined( 'WP_RUN_CORE_TESTS' ) ) { $imagesize = getimagesize( $file ); } else { $imagesize = @getimagesize( $file ); } $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; } else { $mime = false; } if ( false !== $mime ) { return $mime; } $magic = file_get_contents( $file, false, null, 0, 12 ); if ( false === $magic ) { return false; } $magic = bin2hex( $magic ); if ( ( 0 === strpos( $magic, '52494646' ) ) && ( 16 === strpos( $magic, '57454250' ) ) ) { $mime = 'image/webp'; } } catch ( Exception $e ) { $mime = false; } return $mime; } function wp_get_mime_types() { return apply_filters( 'mime_types', array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tiff|tif' => 'image/tiff', 'webp' => 'image/webp', 'ico' => 'image/x-icon', 'heic' => 'image/heic', 'asf|asx' => 'video/x-ms-asf', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wm' => 'video/x-ms-wm', 'avi' => 'video/avi', 'divx' => 'video/divx', 'flv' => 'video/x-flv', 'mov|qt' => 'video/quicktime', 'mpeg|mpg|mpe' => 'video/mpeg', 'mp4|m4v' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'mkv' => 'video/x-matroska', '3gp|3gpp' => 'video/3gpp', '3g2|3gp2' => 'video/3gpp2', 'txt|asc|c|cc|h|srt' => 'text/plain', 'csv' => 'text/csv', 'tsv' => 'text/tab-separated-values', 'ics' => 'text/calendar', 'rtx' => 'text/richtext', 'css' => 'text/css', 'htm|html' => 'text/html', 'vtt' => 'text/vtt', 'dfxp' => 'application/ttaf+xml', 'mp3|m4a|m4b' => 'audio/mpeg', 'aac' => 'audio/aac', 'ra|ram' => 'audio/x-realaudio', 'wav' => 'audio/wav', 'ogg|oga' => 'audio/ogg', 'flac' => 'audio/flac', 'mid|midi' => 'audio/midi', 'wma' => 'audio/x-ms-wma', 'wax' => 'audio/x-ms-wax', 'mka' => 'audio/x-matroska', 'rtf' => 'application/rtf', 'js' => 'application/javascript', 'pdf' => 'application/pdf', 'swf' => 'application/x-shockwave-flash', 'class' => 'application/java', 'tar' => 'application/x-tar', 'zip' => 'application/zip', 'gz|gzip' => 'application/x-gzip', 'rar' => 'application/rar', '7z' => 'application/x-7z-compressed', 'exe' => 'application/x-msdownload', 'psd' => 'application/octet-stream', 'xcf' => 'application/octet-stream', 'doc' => 'application/msword', 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 'wri' => 'application/vnd.ms-write', 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 'mdb' => 'application/vnd.ms-access', 'mpp' => 'application/vnd.ms-project', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 'oxps' => 'application/oxps', 'xps' => 'application/vnd.ms-xpsdocument', 'odt' => 'application/vnd.oasis.opendocument.text', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odb' => 'application/vnd.oasis.opendocument.database', 'odf' => 'application/vnd.oasis.opendocument.formula', 'wp|wpd' => 'application/wordperfect', 'key' => 'application/vnd.apple.keynote', 'numbers' => 'application/vnd.apple.numbers', 'pages' => 'application/vnd.apple.pages', ) ); } function wp_get_ext_types() { return apply_filters( 'ext2type', array( 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp' ), 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ), 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), ) ); } function wp_filesize( $path ) { $size = apply_filters( 'pre_wp_filesize', null, $path ); if ( is_int( $size ) ) { return $size; } $size = file_exists( $path ) ? (int) filesize( $path ) : 0; return (int) apply_filters( 'wp_filesize', $size, $path ); } function get_allowed_mime_types( $user = null ) { $t = wp_get_mime_types(); unset( $t['swf'], $t['exe'] ); if ( function_exists( 'current_user_can' ) ) { $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); } if ( empty( $unfiltered ) ) { unset( $t['htm|html'], $t['js'] ); } return apply_filters( 'upload_mimes', $t, $user ); } function wp_nonce_ays( $action ) { $title = __( 'Something went wrong.' ); $response_code = 403; if ( 'log-out' === $action ) { $title = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ); $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; $html = $title; $html .= '</p><p>'; $html .= sprintf( __( 'Do you really want to <a href="%s">log out</a>?' ), wp_logout_url( $redirect_to ) ); } else { $html = __( 'The link you followed has expired.' ); if ( wp_get_referer() ) { $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() ); $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) ); $html .= '</p><p>'; $html .= sprintf( '<a href="%s">%s</a>', esc_url( $wp_http_referer ), __( 'Please try again.' ) ); } } wp_die( $html, $title, $response_code ); } function wp_die( $message = '', $title = '', $args = array() ) { global $wp_query; if ( is_int( $args ) ) { $args = array( 'response' => $args ); } elseif ( is_int( $title ) ) { $args = array( 'response' => $title ); $title = ''; } if ( wp_doing_ajax() ) { $callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); } elseif ( wp_is_json_request() ) { $callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); } elseif ( defined( 'REST_REQUEST' ) && REST_REQUEST && wp_is_jsonp_request() ) { $callback = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' ); } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { $callback = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); } elseif ( wp_is_xml_request() || isset( $wp_query ) && ( function_exists( 'is_feed' ) && is_feed() || function_exists( 'is_comment_feed' ) && is_comment_feed() || function_exists( 'is_trackback' ) && is_trackback() ) ) { $callback = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' ); } else { $callback = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); } call_user_func( $callback, $message, $title, $args ); } function _default_wp_die_handler( $message, $title = '', $args = array() ) { list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args ); if ( is_string( $message ) ) { if ( ! empty( $parsed_args['additional_errors'] ) ) { $message = array_merge( array( $message ), wp_list_pluck( $parsed_args['additional_errors'], 'message' ) ); $message = "<ul>\n\t\t<li>" . implode( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>"; } $message = sprintf( '<div class="wp-die-message">%s</div>', $message ); } $have_gettext = function_exists( '__' ); if ( ! empty( $parsed_args['link_url'] ) && ! empty( $parsed_args['link_text'] ) ) { $link_url = $parsed_args['link_url']; if ( function_exists( 'esc_url' ) ) { $link_url = esc_url( $link_url ); } $link_text = $parsed_args['link_text']; $message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>"; } if ( isset( $parsed_args['back_link'] ) && $parsed_args['back_link'] ) { $back_text = $have_gettext ? __( '« Back' ) : '« Back'; $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>"; } if ( ! did_action( 'admin_head' ) ) : if ( ! headers_sent() ) { header( "Content-Type: text/html; charset={$parsed_args['charset']}" ); status_header( $parsed_args['response'] ); nocache_headers(); } $text_direction = $parsed_args['text_direction']; $dir_attr = "dir='$text_direction'"; if ( empty( $args['text_direction'] ) && function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { $dir_attr = get_language_attributes(); } ?> <!DOCTYPE html> <html <?php echo $dir_attr; ?>> <head> @@ -29925,7 +32608,7 @@ img.emoji { </error> EOD; -if ( ! headers_sent() ) { header( "Content-Type: text/xml; charset={$parsed_args['charset']}" ); if ( null !== $parsed_args['response'] ) { status_header( $parsed_args['response'] ); } nocache_headers(); } echo $xml; if ( $parsed_args['exit'] ) { die(); } } function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) { list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args ); if ( $parsed_args['exit'] ) { if ( is_scalar( $message ) ) { die( (string) $message ); } die(); } if ( is_scalar( $message ) ) { echo (string) $message; } } function _wp_die_process_input( $message, $title = '', $args = array() ) { $defaults = array( 'response' => 0, 'code' => '', 'exit' => true, 'back_link' => false, 'link_url' => '', 'link_text' => '', 'text_direction' => '', 'charset' => 'utf-8', 'additional_errors' => array(), ); $args = wp_parse_args( $args, $defaults ); if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { if ( ! empty( $message->errors ) ) { $errors = array(); foreach ( (array) $message->errors as $error_code => $error_messages ) { foreach ( (array) $error_messages as $error_message ) { $errors[] = array( 'code' => $error_code, 'message' => $error_message, 'data' => $message->get_error_data( $error_code ), ); } } $message = $errors[0]['message']; if ( empty( $args['code'] ) ) { $args['code'] = $errors[0]['code']; } if ( empty( $args['response'] ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['status'] ) ) { $args['response'] = $errors[0]['data']['status']; } if ( empty( $title ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['title'] ) ) { $title = $errors[0]['data']['title']; } unset( $errors[0] ); $args['additional_errors'] = array_values( $errors ); } else { $message = ''; } } $have_gettext = function_exists( '__' ); if ( empty( $args['code'] ) ) { $args['code'] = 'wp_die'; } if ( empty( $args['response'] ) ) { $args['response'] = 500; } if ( empty( $title ) ) { $title = $have_gettext ? __( 'WordPress › Error' ) : 'WordPress › Error'; } if ( empty( $args['text_direction'] ) || ! in_array( $args['text_direction'], array( 'ltr', 'rtl' ), true ) ) { $args['text_direction'] = 'ltr'; if ( function_exists( 'is_rtl' ) && is_rtl() ) { $args['text_direction'] = 'rtl'; } } if ( ! empty( $args['charset'] ) ) { $args['charset'] = _canonical_charset( $args['charset'] ); } return array( $message, $title, $args ); } function wp_json_encode( $data, $options = 0, $depth = 512 ) { $json = json_encode( $data, $options, $depth ); if ( false !== $json ) { return $json; } try { $data = _wp_json_sanity_check( $data, $depth ); } catch ( Exception $e ) { return false; } return json_encode( $data, $options, $depth ); } function _wp_json_sanity_check( $data, $depth ) { if ( $depth < 0 ) { throw new Exception( 'Reached depth limit' ); } if ( is_array( $data ) ) { $output = array(); foreach ( $data as $id => $el ) { if ( is_string( $id ) ) { $clean_id = _wp_json_convert_string( $id ); } else { $clean_id = $id; } if ( is_array( $el ) || is_object( $el ) ) { $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 ); } elseif ( is_string( $el ) ) { $output[ $clean_id ] = _wp_json_convert_string( $el ); } else { $output[ $clean_id ] = $el; } } } elseif ( is_object( $data ) ) { $output = new stdClass(); foreach ( $data as $id => $el ) { if ( is_string( $id ) ) { $clean_id = _wp_json_convert_string( $id ); } else { $clean_id = $id; } if ( is_array( $el ) || is_object( $el ) ) { $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 ); } elseif ( is_string( $el ) ) { $output->$clean_id = _wp_json_convert_string( $el ); } else { $output->$clean_id = $el; } } } elseif ( is_string( $data ) ) { return _wp_json_convert_string( $data ); } else { return $data; } return $output; } function _wp_json_convert_string( $input_string ) { static $use_mb = null; if ( is_null( $use_mb ) ) { $use_mb = function_exists( 'mb_convert_encoding' ); } if ( $use_mb ) { $encoding = mb_detect_encoding( $input_string, mb_detect_order(), true ); if ( $encoding ) { return mb_convert_encoding( $input_string, 'UTF-8', $encoding ); } else { return mb_convert_encoding( $input_string, 'UTF-8', 'UTF-8' ); } } else { return wp_check_invalid_utf8( $input_string, true ); } } function _wp_json_prepare_data( $data ) { _deprecated_function( __FUNCTION__, '5.3.0' ); return $data; } function wp_send_json( $response, $status_code = null, $options = 0 ) { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Return a %1$s or %2$s object from your callback when using the REST API.' ), 'WP_REST_Response', 'WP_Error' ), '5.5.0' ); } if ( ! headers_sent() ) { header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); if ( null !== $status_code ) { status_header( $status_code ); } } echo wp_json_encode( $response, $options ); if ( wp_doing_ajax() ) { wp_die( '', '', array( 'response' => null, ) ); } else { die; } } function wp_send_json_success( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => true ); if ( isset( $data ) ) { $response['data'] = $data; } wp_send_json( $response, $status_code, $options ); } function wp_send_json_error( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => false ); if ( isset( $data ) ) { if ( is_wp_error( $data ) ) { $result = array(); foreach ( $data->errors as $code => $messages ) { foreach ( $messages as $message ) { $result[] = array( 'code' => $code, 'message' => $message, ); } } $response['data'] = $result; } else { $response['data'] = $data; } } wp_send_json( $response, $status_code, $options ); } function wp_check_jsonp_callback( $callback ) { if ( ! is_string( $callback ) ) { return false; } preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count ); return 0 === $illegal_char_count; } function wp_json_file_decode( $filename, $options = array() ) { $result = null; $filename = wp_normalize_path( realpath( $filename ) ); if ( ! $filename ) { trigger_error( sprintf( __( "File %s doesn't exist!" ), $filename ) ); return $result; } $options = wp_parse_args( $options, array( 'associative' => false ) ); $decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] ); if ( JSON_ERROR_NONE !== json_last_error() ) { trigger_error( sprintf( __( 'Error when decoding a JSON file at path %1$s: %2$s' ), $filename, json_last_error_msg() ) ); return $result; } return $decoded_file; } function _config_wp_home( $url = '' ) { if ( defined( 'WP_HOME' ) ) { return untrailingslashit( WP_HOME ); } return $url; } function _config_wp_siteurl( $url = '' ) { if ( defined( 'WP_SITEURL' ) ) { return untrailingslashit( WP_SITEURL ); } return $url; } function _delete_option_fresh_site() { update_option( 'fresh_site', '0' ); } function _mce_set_direction( $mce_init ) { if ( is_rtl() ) { $mce_init['directionality'] = 'rtl'; $mce_init['rtl_ui'] = true; if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) { $mce_init['plugins'] .= ',directionality'; } if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) { $mce_init['toolbar1'] .= ',ltr'; } } return $mce_init; } function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch; if ( ! get_option( 'use_smilies' ) ) { return; } if ( ! isset( $wpsmiliestrans ) ) { $wpsmiliestrans = array( ':mrgreen:' => 'mrgreen.png', ':neutral:' => "\xf0\x9f\x98\x90", ':twisted:' => "\xf0\x9f\x98\x88", ':arrow:' => "\xe2\x9e\xa1", ':shock:' => "\xf0\x9f\x98\xaf", ':smile:' => "\xf0\x9f\x99\x82", ':???:' => "\xf0\x9f\x98\x95", ':cool:' => "\xf0\x9f\x98\x8e", ':evil:' => "\xf0\x9f\x91\xbf", ':grin:' => "\xf0\x9f\x98\x80", ':idea:' => "\xf0\x9f\x92\xa1", ':oops:' => "\xf0\x9f\x98\xb3", ':razz:' => "\xf0\x9f\x98\x9b", ':roll:' => "\xf0\x9f\x99\x84", ':wink:' => "\xf0\x9f\x98\x89", ':cry:' => "\xf0\x9f\x98\xa5", ':eek:' => "\xf0\x9f\x98\xae", ':lol:' => "\xf0\x9f\x98\x86", ':mad:' => "\xf0\x9f\x98\xa1", ':sad:' => "\xf0\x9f\x99\x81", '8-)' => "\xf0\x9f\x98\x8e", '8-O' => "\xf0\x9f\x98\xaf", ':-(' => "\xf0\x9f\x99\x81", ':-)' => "\xf0\x9f\x99\x82", ':-?' => "\xf0\x9f\x98\x95", ':-D' => "\xf0\x9f\x98\x80", ':-P' => "\xf0\x9f\x98\x9b", ':-o' => "\xf0\x9f\x98\xae", ':-x' => "\xf0\x9f\x98\xa1", ':-|' => "\xf0\x9f\x98\x90", ';-)' => "\xf0\x9f\x98\x89", '8O' => "\xf0\x9f\x98\xaf", ':(' => "\xf0\x9f\x99\x81", ':)' => "\xf0\x9f\x99\x82", ':?' => "\xf0\x9f\x98\x95", ':D' => "\xf0\x9f\x98\x80", ':P' => "\xf0\x9f\x98\x9b", ':o' => "\xf0\x9f\x98\xae", ':x' => "\xf0\x9f\x98\xa1", ':|' => "\xf0\x9f\x98\x90", ';)' => "\xf0\x9f\x98\x89", ':!:' => "\xe2\x9d\x97", ':?:' => "\xe2\x9d\x93", ); } $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); if ( count( $wpsmiliestrans ) == 0 ) { return; } krsort( $wpsmiliestrans ); $spaces = wp_spaces_regexp(); $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; $subchar = ''; foreach ( (array) $wpsmiliestrans as $smiley => $img ) { $firstchar = substr( $smiley, 0, 1 ); $rest = substr( $smiley, 1 ); if ( $firstchar != $subchar ) { if ( '' !== $subchar ) { $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; } $subchar = $firstchar; $wp_smiliessearch .= preg_quote( $firstchar, '/' ) . '(?:'; } else { $wp_smiliessearch .= '|'; } $wp_smiliessearch .= preg_quote( $rest, '/' ); } $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; } function wp_parse_args( $args, $defaults = array() ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { $parsed_args =& $args; } else { wp_parse_str( $args, $parsed_args ); } if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args; } function wp_parse_list( $input_list ) { if ( ! is_array( $input_list ) ) { return preg_split( '/[\s,]+/', $input_list, -1, PREG_SPLIT_NO_EMPTY ); } $input_list = array_filter( $input_list, 'is_scalar' ); return $input_list; } function wp_parse_id_list( $input_list ) { $input_list = wp_parse_list( $input_list ); return array_unique( array_map( 'absint', $input_list ) ); } function wp_parse_slug_list( $input_list ) { $input_list = wp_parse_list( $input_list ); return array_unique( array_map( 'sanitize_title', $input_list ) ); } function wp_array_slice_assoc( $input_array, $keys ) { $slice = array(); foreach ( $keys as $key ) { if ( isset( $input_array[ $key ] ) ) { $slice[ $key ] = $input_array[ $key ]; } } return $slice; } function _wp_array_get( $input_array, $path, $default_value = null ) { if ( ! is_array( $path ) || 0 === count( $path ) ) { return $default_value; } foreach ( $path as $path_element ) { if ( ! is_array( $input_array ) || ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) || ! array_key_exists( $path_element, $input_array ) ) { return $default_value; } $input_array = $input_array[ $path_element ]; } return $input_array; } function _wp_array_set( &$input_array, $path, $value = null ) { if ( ! is_array( $input_array ) ) { return; } if ( ! is_array( $path ) ) { return; } $path_length = count( $path ); if ( 0 === $path_length ) { return; } foreach ( $path as $path_element ) { if ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) { return; } } for ( $i = 0; $i < $path_length - 1; ++$i ) { $path_element = $path[ $i ]; if ( ! array_key_exists( $path_element, $input_array ) || ! is_array( $input_array[ $path_element ] ) ) { $input_array[ $path_element ] = array(); } $input_array = &$input_array[ $path_element ]; } $input_array[ $path[ $i ] ] = $value; } function _wp_to_kebab_case( $input_string ) { $rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'; $rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'; $rsPunctuationRange = '\\x{2000}-\\x{206f}'; $rsSpaceRange = ' \\t\\x0b\\f\\xa0\\x{feff}\\n\\r\\x{2028}\\x{2029}\\x{1680}\\x{180e}\\x{2000}\\x{2001}\\x{2002}\\x{2003}\\x{2004}\\x{2005}\\x{2006}\\x{2007}\\x{2008}\\x{2009}\\x{200a}\\x{202f}\\x{205f}\\x{3000}'; $rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'; $rsBreakRange = $rsNonCharRange . $rsPunctuationRange . $rsSpaceRange; $rsBreak = '[' . $rsBreakRange . ']'; $rsDigits = '\\d+'; $rsLower = '[' . $rsLowerRange . ']'; $rsMisc = '[^' . $rsBreakRange . $rsDigits . $rsLowerRange . $rsUpperRange . ']'; $rsUpper = '[' . $rsUpperRange . ']'; $rsMiscLower = '(?:' . $rsLower . '|' . $rsMisc . ')'; $rsMiscUpper = '(?:' . $rsUpper . '|' . $rsMisc . ')'; $rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])'; $rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])'; $regexp = '/' . implode( '|', array( $rsUpper . '?' . $rsLower . '+' . '(?=' . implode( '|', array( $rsBreak, $rsUpper, '$' ) ) . ')', $rsMiscUpper . '+' . '(?=' . implode( '|', array( $rsBreak, $rsUpper . $rsMiscLower, '$' ) ) . ')', $rsUpper . '?' . $rsMiscLower . '+', $rsUpper . '+', $rsOrdUpper, $rsOrdLower, $rsDigits, ) ) . '/u'; preg_match_all( $regexp, str_replace( "'", '', $input_string ), $matches ); return strtolower( implode( '-', $matches[0] ) ); } function wp_is_numeric_array( $data ) { if ( ! is_array( $data ) ) { return false; } $keys = array_keys( $data ); $string_keys = array_filter( $keys, 'is_string' ); return count( $string_keys ) === 0; } function wp_filter_object_list( $input_list, $args = array(), $operator = 'and', $field = false ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); $util->filter( $args, $operator ); if ( $field ) { $util->pluck( $field ); } return $util->get_output(); } function wp_list_filter( $input_list, $args = array(), $operator = 'AND' ) { return wp_filter_object_list( $input_list, $args, $operator ); } function wp_list_pluck( $input_list, $field, $index_key = null ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->pluck( $field, $index_key ); } function wp_list_sort( $input_list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->sort( $orderby, $order, $preserve_keys ); } function wp_maybe_load_widgets() { if ( ! apply_filters( 'load_default_widgets', true ) ) { return; } require_once ABSPATH . WPINC . '/default-widgets.php'; add_action( '_admin_menu', 'wp_widgets_add_menu' ); } function wp_widgets_add_menu() { global $submenu; if ( ! current_theme_supports( 'widgets' ) ) { return; } $menu_name = __( 'Widgets' ); if ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) { $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); } else { $submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); } ksort( $submenu['themes.php'], SORT_NUMERIC ); } function wp_ob_end_flush_all() { $levels = ob_get_level(); for ( $i = 0; $i < $levels; $i++ ) { ob_end_flush(); } } function dead_db() { global $wpdb; wp_load_translations_early(); if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once WP_CONTENT_DIR . '/db-error.php'; die(); } if ( wp_installing() || defined( 'WP_ADMIN' ) ) { wp_die( $wpdb->error ); } wp_die( '<h1>' . __( 'Error establishing a database connection' ) . '</h1>', __( 'Database Error' ) ); } function absint( $maybeint ) { return abs( (int) $maybeint ); } function _deprecated_function( $function_name, $version, $replacement = '' ) { do_action( 'deprecated_function_run', $function_name, $replacement, $version ); if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( __( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $function_name, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function_name, $version ), E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function_name, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function_name, $version ), E_USER_DEPRECATED ); } } } } function _deprecated_constructor( $class_name, $version, $parent_class = '' ) { do_action( 'deprecated_constructor_run', $class_name, $version, $parent_class ); if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $parent_class ) { trigger_error( sprintf( __( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ), $class_name, $parent_class, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $class_name, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } } else { if ( $parent_class ) { trigger_error( sprintf( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.', $class_name, $parent_class, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class_name, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } } } } function _deprecated_file( $file, $version, $replacement = '', $message = '' ) { do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( __( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $file, $version ) . $message, E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED ); } } } } function _deprecated_argument( $function_name, $version, $message = '' ) { do_action( 'deprecated_argument_run', $function_name, $message, $version ); if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $message ) { trigger_error( sprintf( __( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function_name, $version, $message ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function_name, $version ), E_USER_DEPRECATED ); } } else { if ( $message ) { trigger_error( sprintf( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function_name, $version, $message ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function_name, $version ), E_USER_DEPRECATED ); } } } } function _deprecated_hook( $hook, $version, $replacement = '', $message = '' ) { do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( $replacement ) { trigger_error( sprintf( __( 'Hook %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Hook %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message, E_USER_DEPRECATED ); } } } function _doing_it_wrong( $function_name, $message, $version ) { do_action( 'doing_it_wrong_run', $function_name, $message, $version ); if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true, $function_name, $message, $version ) ) { if ( function_exists( '__' ) ) { if ( $version ) { $version = sprintf( __( '(This message was added in version %s.)' ), $version ); } $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), __( 'https://wordpress.org/support/article/debugging-in-wordpress/' ) ); trigger_error( sprintf( __( 'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function_name, $message, $version ), E_USER_NOTICE ); } else { if ( $version ) { $version = sprintf( '(This message was added in version %s.)', $version ); } $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', 'https://wordpress.org/support/article/debugging-in-wordpress/' ); trigger_error( sprintf( 'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function_name, $message, $version ), E_USER_NOTICE ); } } } function is_lighttpd_before_150() { $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; return ( 'lighttpd' === $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ) ); } function apache_mod_loaded( $mod, $default_value = false ) { global $is_apache; if ( ! $is_apache ) { return false; } $loaded_mods = array(); if ( function_exists( 'apache_get_modules' ) ) { $loaded_mods = apache_get_modules(); if ( in_array( $mod, $loaded_mods, true ) ) { return true; } } if ( empty( $loaded_mods ) && function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { ob_start(); phpinfo( INFO_MODULES ); $phpinfo = ob_get_clean(); if ( false !== strpos( $phpinfo, $mod ) ) { return true; } } return $default_value; } function iis7_supports_permalinks() { global $is_iis7; $supports_permalinks = false; if ( $is_iis7 ) { $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( 'cgi-fcgi' === PHP_SAPI ); } return apply_filters( 'iis7_supports_permalinks', $supports_permalinks ); } function validate_file( $file, $allowed_files = array() ) { if ( ! is_scalar( $file ) || '' === $file ) { return 0; } if ( '../' === $file ) { return 1; } if ( preg_match_all( '#\.\./#', $file, $matches, PREG_SET_ORDER ) && ( count( $matches ) > 1 ) ) { return 1; } if ( false !== strpos( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) { return 1; } if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files, true ) ) { return 3; } if ( ':' === substr( $file, 1, 1 ) ) { return 2; } return 0; } function force_ssl_admin( $force = null ) { static $forced = false; if ( ! is_null( $force ) ) { $old_forced = $forced; $forced = $force; return $old_forced; } return $forced; } function wp_guess_url() { if ( defined( 'WP_SITEURL' ) && '' !== WP_SITEURL ) { $url = WP_SITEURL; } else { $abspath_fix = str_replace( '\\', '/', ABSPATH ); $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { $path = preg_replace( '#/(wp-admin/?.*|wp-login\.php.*)#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( $script_filename_dir . '/' === $abspath_fix ) { $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); } else { if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) { $directory = str_replace( ABSPATH, '', $script_filename_dir ); $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ) . $subdirectory; } else { $path = $_SERVER['REQUEST_URI']; } } $schema = is_ssl() ? 'https://' : 'http://'; $url = $schema . $_SERVER['HTTP_HOST'] . $path; } return rtrim( $url, '/' ); } function wp_suspend_cache_addition( $suspend = null ) { static $_suspend = false; if ( is_bool( $suspend ) ) { $_suspend = $suspend; } return $_suspend; } function wp_suspend_cache_invalidation( $suspend = true ) { global $_wp_suspend_cache_invalidation; $current_suspend = $_wp_suspend_cache_invalidation; $_wp_suspend_cache_invalidation = $suspend; return $current_suspend; } function is_main_site( $site_id = null, $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( ! $site_id ) { $site_id = get_current_blog_id(); } $site_id = (int) $site_id; return get_main_site_id( $network_id ) === $site_id; } function get_main_site_id( $network_id = null ) { if ( ! is_multisite() ) { return get_current_blog_id(); } $network = get_network( $network_id ); if ( ! $network ) { return 0; } return $network->site_id; } function is_main_network( $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( null === $network_id ) { $network_id = get_current_network_id(); } $network_id = (int) $network_id; return ( get_main_network_id() === $network_id ); } function get_main_network_id() { if ( ! is_multisite() ) { return 1; } $current_network = get_network(); if ( defined( 'PRIMARY_NETWORK_ID' ) ) { $main_network_id = PRIMARY_NETWORK_ID; } elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) { $main_network_id = 1; } else { $_networks = get_networks( array( 'fields' => 'ids', 'number' => 1, ) ); $main_network_id = array_shift( $_networks ); } return (int) apply_filters( 'get_main_network_id', $main_network_id ); } function is_site_meta_supported() { global $wpdb; if ( ! is_multisite() ) { return false; } $network_id = get_main_network_id(); $supported = get_network_option( $network_id, 'site_meta_supported', false ); if ( false === $supported ) { $supported = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->blogmeta}'" ) ? 1 : 0; update_network_option( $network_id, 'site_meta_supported', $supported ); } return (bool) $supported; } function wp_timezone_override_offset() { $timezone_string = get_option( 'timezone_string' ); if ( ! $timezone_string ) { return false; } $timezone_object = timezone_open( $timezone_string ); $datetime_object = date_create(); if ( false === $timezone_object || false === $datetime_object ) { return false; } return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 ); } function _wp_timezone_choice_usort_callback( $a, $b ) { if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) { if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) { return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) ); } if ( 'UTC' === $a['city'] ) { if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) { return 1; } return -1; } if ( 'UTC' === $b['city'] ) { if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) { return -1; } return 1; } return strnatcasecmp( $a['city'], $b['city'] ); } if ( $a['t_continent'] == $b['t_continent'] ) { if ( $a['t_city'] == $b['t_city'] ) { return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] ); } return strnatcasecmp( $a['t_city'], $b['t_city'] ); } else { if ( 'Etc' === $a['continent'] ) { return 1; } if ( 'Etc' === $b['continent'] ) { return -1; } return strnatcasecmp( $a['t_continent'], $b['t_continent'] ); } } function wp_timezone_choice( $selected_zone, $locale = null ) { static $mo_loaded = false, $locale_loaded = null; $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific' ); if ( ! $mo_loaded || $locale !== $locale_loaded ) { $locale_loaded = $locale ? $locale : get_locale(); $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; unload_textdomain( 'continents-cities' ); load_textdomain( 'continents-cities', $mofile, $locale_loaded ); $mo_loaded = true; } $tz_identifiers = timezone_identifiers_list(); $zonen = array(); foreach ( $tz_identifiers as $zone ) { $zone = explode( '/', $zone ); if ( ! in_array( $zone[0], $continents, true ) ) { continue; } $exists = array( 0 => ( isset( $zone[0] ) && $zone[0] ), 1 => ( isset( $zone[1] ) && $zone[1] ), 2 => ( isset( $zone[2] ) && $zone[2] ), ); $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ); $exists[4] = ( $exists[1] && $exists[3] ); $exists[5] = ( $exists[2] && $exists[3] ); $zonen[] = array( 'continent' => ( $exists[0] ? $zone[0] : '' ), 'city' => ( $exists[1] ? $zone[1] : '' ), 'subcity' => ( $exists[2] ? $zone[2] : '' ), 't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ), 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ), ); } usort( $zonen, '_wp_timezone_choice_usort_callback' ); $structure = array(); if ( empty( $selected_zone ) ) { $structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>'; } if ( in_array( $selected_zone, $tz_identifiers, true ) === false && in_array( $selected_zone, timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) { $structure[] = '<option selected="selected" value="' . esc_attr( $selected_zone ) . '">' . esc_html( $selected_zone ) . '</option>'; } foreach ( $zonen as $key => $zone ) { $value = array( $zone['continent'] ); if ( empty( $zone['city'] ) ) { $display = $zone['t_continent']; } else { if ( ! isset( $zonen[ $key - 1 ] ) || $zonen[ $key - 1 ]['continent'] !== $zone['continent'] ) { $label = $zone['t_continent']; $structure[] = '<optgroup label="' . esc_attr( $label ) . '">'; } $value[] = $zone['city']; $display = $zone['t_city']; if ( ! empty( $zone['subcity'] ) ) { $value[] = $zone['subcity']; $display .= ' - ' . $zone['t_subcity']; } } $value = implode( '/', $value ); $selected = ''; if ( $value === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . '</option>'; if ( ! empty( $zone['city'] ) && ( ! isset( $zonen[ $key + 1 ] ) || ( isset( $zonen[ $key + 1 ] ) && $zonen[ $key + 1 ]['continent'] !== $zone['continent'] ) ) ) { $structure[] = '</optgroup>'; } } $structure[] = '<optgroup label="' . esc_attr__( 'UTC' ) . '">'; $selected = ''; if ( 'UTC' === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __( 'UTC' ) . '</option>'; $structure[] = '</optgroup>'; $structure[] = '<optgroup label="' . esc_attr__( 'Manual Offsets' ) . '">'; $offset_range = array( -12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14, ); foreach ( $offset_range as $offset ) { if ( 0 <= $offset ) { $offset_name = '+' . $offset; } else { $offset_name = (string) $offset; } $offset_value = $offset_name; $offset_name = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $offset_name ); $offset_name = 'UTC' . $offset_name; $offset_value = 'UTC' . $offset_value; $selected = ''; if ( $offset_value === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . '</option>'; } $structure[] = '</optgroup>'; return implode( "\n", $structure ); } function _cleanup_header_comment( $str ) { return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) ); } function wp_scheduled_delete() { global $wpdb; $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); $posts_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); foreach ( (array) $posts_to_delete as $post ) { $post_id = (int) $post['post_id']; if ( ! $post_id ) { continue; } $del_post = get_post( $post_id ); if ( ! $del_post || 'trash' !== $del_post->post_status ) { delete_post_meta( $post_id, '_wp_trash_meta_status' ); delete_post_meta( $post_id, '_wp_trash_meta_time' ); } else { wp_delete_post( $post_id ); } } $comments_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); foreach ( (array) $comments_to_delete as $comment ) { $comment_id = (int) $comment['comment_id']; if ( ! $comment_id ) { continue; } $del_comment = get_comment( $comment_id ); if ( ! $del_comment || 'trash' !== $del_comment->comment_approved ) { delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); } else { wp_delete_comment( $del_comment ); } } } function get_file_data( $file, $default_headers, $context = '' ) { $file_data = file_get_contents( $file, false, null, 0, 8 * KB_IN_BYTES ); if ( false === $file_data ) { $file_data = ''; } $file_data = str_replace( "\r", "\n", $file_data ); $extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array(); if ( $extra_headers ) { $extra_headers = array_combine( $extra_headers, $extra_headers ); $all_headers = array_merge( $extra_headers, (array) $default_headers ); } else { $all_headers = $default_headers; } foreach ( $all_headers as $field => $regex ) { if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); } else { $all_headers[ $field ] = ''; } } return $all_headers; } function __return_true() { return true; } function __return_false() { return false; } function __return_zero() { return 0; } function __return_empty_array() { return array(); } function __return_null() { return null; } function __return_empty_string() { return ''; } function send_nosniff_header() { header( 'X-Content-Type-Options: nosniff' ); } function _wp_mysql_week( $column ) { $start_of_week = (int) get_option( 'start_of_week' ); switch ( $start_of_week ) { case 1: return "WEEK( $column, 1 )"; case 2: case 3: case 4: case 5: case 6: return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; case 0: default: return "WEEK( $column, 0 )"; } } function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ); if ( ! $arbitrary_loop_member ) { return array(); } return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); } function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { $tortoise = $start; $hare = $start; $evanescent_hare = $start; $return = array(); while ( $tortoise && ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) && ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) ) { if ( $_return_loop ) { $return[ $tortoise ] = true; $return[ $evanescent_hare ] = true; $return[ $hare ] = true; } if ( $tortoise == $evanescent_hare || $tortoise == $hare ) { return $_return_loop ? $return : $tortoise; } $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); } return false; } function send_frame_options_header() { header( 'X-Frame-Options: SAMEORIGIN' ); } function wp_allowed_protocols() { static $protocols = array(); if ( empty( $protocols ) ) { $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'irc6', 'ircs', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'sms', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' ); } if ( ! did_action( 'wp_loaded' ) ) { $protocols = array_unique( (array) apply_filters( 'kses_allowed_protocols', $protocols ) ); } return $protocols; } function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { static $truncate_paths; $trace = debug_backtrace( false ); $caller = array(); $check_class = ! is_null( $ignore_class ); $skip_frames++; if ( ! isset( $truncate_paths ) ) { $truncate_paths = array( wp_normalize_path( WP_CONTENT_DIR ), wp_normalize_path( ABSPATH ), ); } foreach ( $trace as $call ) { if ( $skip_frames > 0 ) { $skip_frames--; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class == $call['class'] ) { continue; } $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; } else { if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) { $filename = isset( $call['args'][0] ) ? $call['args'][0] : ''; $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')"; } else { $caller[] = $call['function']; } } } if ( $pretty ) { return implode( ', ', array_reverse( $caller ) ); } else { return $caller; } } function _get_non_cached_ids( $object_ids, $cache_key ) { $non_cached_ids = array(); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); foreach ( $cache_values as $id => $value ) { if ( ! $value ) { $non_cached_ids[] = (int) $id; } } return $non_cached_ids; } function _device_can_upload() { if ( ! wp_is_mobile() ) { return true; } $ua = $_SERVER['HTTP_USER_AGENT']; if ( strpos( $ua, 'iPhone' ) !== false || strpos( $ua, 'iPad' ) !== false || strpos( $ua, 'iPod' ) !== false ) { return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' ); } return true; } function wp_is_stream( $path ) { $scheme_separator = strpos( $path, '://' ); if ( false === $scheme_separator ) { return false; } $stream = substr( $path, 0, $scheme_separator ); return in_array( $stream, stream_get_wrappers(), true ); } function wp_checkdate( $month, $day, $year, $source_date ) { return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date ); } function wp_auth_check_load() { if ( ! is_admin() && ! is_user_logged_in() ) { return; } if ( defined( 'IFRAME_REQUEST' ) ) { return; } $screen = get_current_screen(); $hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' ); $show = ! in_array( $screen->id, $hidden, true ); if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) { wp_enqueue_style( 'wp-auth-check' ); wp_enqueue_script( 'wp-auth-check' ); add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 ); add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 ); } } function wp_auth_check_html() { $login_url = wp_login_url(); $current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']; $same_domain = ( strpos( $login_url, $current_domain ) === 0 ); $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; ?> +if ( ! headers_sent() ) { header( "Content-Type: text/xml; charset={$parsed_args['charset']}" ); if ( null !== $parsed_args['response'] ) { status_header( $parsed_args['response'] ); } nocache_headers(); } echo $xml; if ( $parsed_args['exit'] ) { die(); } } function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) { list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args ); if ( $parsed_args['exit'] ) { if ( is_scalar( $message ) ) { die( (string) $message ); } die(); } if ( is_scalar( $message ) ) { echo (string) $message; } } function _wp_die_process_input( $message, $title = '', $args = array() ) { $defaults = array( 'response' => 0, 'code' => '', 'exit' => true, 'back_link' => false, 'link_url' => '', 'link_text' => '', 'text_direction' => '', 'charset' => 'utf-8', 'additional_errors' => array(), ); $args = wp_parse_args( $args, $defaults ); if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { if ( ! empty( $message->errors ) ) { $errors = array(); foreach ( (array) $message->errors as $error_code => $error_messages ) { foreach ( (array) $error_messages as $error_message ) { $errors[] = array( 'code' => $error_code, 'message' => $error_message, 'data' => $message->get_error_data( $error_code ), ); } } $message = $errors[0]['message']; if ( empty( $args['code'] ) ) { $args['code'] = $errors[0]['code']; } if ( empty( $args['response'] ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['status'] ) ) { $args['response'] = $errors[0]['data']['status']; } if ( empty( $title ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['title'] ) ) { $title = $errors[0]['data']['title']; } unset( $errors[0] ); $args['additional_errors'] = array_values( $errors ); } else { $message = ''; } } $have_gettext = function_exists( '__' ); if ( empty( $args['code'] ) ) { $args['code'] = 'wp_die'; } if ( empty( $args['response'] ) ) { $args['response'] = 500; } if ( empty( $title ) ) { $title = $have_gettext ? __( 'WordPress › Error' ) : 'WordPress › Error'; } if ( empty( $args['text_direction'] ) || ! in_array( $args['text_direction'], array( 'ltr', 'rtl' ), true ) ) { $args['text_direction'] = 'ltr'; if ( function_exists( 'is_rtl' ) && is_rtl() ) { $args['text_direction'] = 'rtl'; } } if ( ! empty( $args['charset'] ) ) { $args['charset'] = _canonical_charset( $args['charset'] ); } return array( $message, $title, $args ); } function wp_json_encode( $data, $options = 0, $depth = 512 ) { $json = json_encode( $data, $options, $depth ); if ( false !== $json ) { return $json; } try { $data = _wp_json_sanity_check( $data, $depth ); } catch ( Exception $e ) { return false; } return json_encode( $data, $options, $depth ); } function _wp_json_sanity_check( $data, $depth ) { if ( $depth < 0 ) { throw new Exception( 'Reached depth limit' ); } if ( is_array( $data ) ) { $output = array(); foreach ( $data as $id => $el ) { if ( is_string( $id ) ) { $clean_id = _wp_json_convert_string( $id ); } else { $clean_id = $id; } if ( is_array( $el ) || is_object( $el ) ) { $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 ); } elseif ( is_string( $el ) ) { $output[ $clean_id ] = _wp_json_convert_string( $el ); } else { $output[ $clean_id ] = $el; } } } elseif ( is_object( $data ) ) { $output = new stdClass(); foreach ( $data as $id => $el ) { if ( is_string( $id ) ) { $clean_id = _wp_json_convert_string( $id ); } else { $clean_id = $id; } if ( is_array( $el ) || is_object( $el ) ) { $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 ); } elseif ( is_string( $el ) ) { $output->$clean_id = _wp_json_convert_string( $el ); } else { $output->$clean_id = $el; } } } elseif ( is_string( $data ) ) { return _wp_json_convert_string( $data ); } else { return $data; } return $output; } function _wp_json_convert_string( $input_string ) { static $use_mb = null; if ( is_null( $use_mb ) ) { $use_mb = function_exists( 'mb_convert_encoding' ); } if ( $use_mb ) { $encoding = mb_detect_encoding( $input_string, mb_detect_order(), true ); if ( $encoding ) { return mb_convert_encoding( $input_string, 'UTF-8', $encoding ); } else { return mb_convert_encoding( $input_string, 'UTF-8', 'UTF-8' ); } } else { return wp_check_invalid_utf8( $input_string, true ); } } function _wp_json_prepare_data( $data ) { _deprecated_function( __FUNCTION__, '5.3.0' ); return $data; } function wp_send_json( $response, $status_code = null, $options = 0 ) { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Return a %1$s or %2$s object from your callback when using the REST API.' ), 'WP_REST_Response', 'WP_Error' ), '5.5.0' ); } if ( ! headers_sent() ) { header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); if ( null !== $status_code ) { status_header( $status_code ); } } echo wp_json_encode( $response, $options ); if ( wp_doing_ajax() ) { wp_die( '', '', array( 'response' => null, ) ); } else { die; } } function wp_send_json_success( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => true ); if ( isset( $data ) ) { $response['data'] = $data; } wp_send_json( $response, $status_code, $options ); } function wp_send_json_error( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => false ); if ( isset( $data ) ) { if ( is_wp_error( $data ) ) { $result = array(); foreach ( $data->errors as $code => $messages ) { foreach ( $messages as $message ) { $result[] = array( 'code' => $code, 'message' => $message, ); } } $response['data'] = $result; } else { $response['data'] = $data; } } wp_send_json( $response, $status_code, $options ); } function wp_check_jsonp_callback( $callback ) { if ( ! is_string( $callback ) ) { return false; } preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count ); return 0 === $illegal_char_count; } function wp_json_file_decode( $filename, $options = array() ) { $result = null; $filename = wp_normalize_path( realpath( $filename ) ); if ( ! $filename ) { trigger_error( sprintf( __( "File %s doesn't exist!" ), $filename ) ); return $result; } $options = wp_parse_args( $options, array( 'associative' => false ) ); $decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] ); if ( JSON_ERROR_NONE !== json_last_error() ) { trigger_error( sprintf( __( 'Error when decoding a JSON file at path %1$s: %2$s' ), $filename, json_last_error_msg() ) ); return $result; } return $decoded_file; } function _config_wp_home( $url = '' ) { if ( defined( 'WP_HOME' ) ) { return untrailingslashit( WP_HOME ); } return $url; } function _config_wp_siteurl( $url = '' ) { if ( defined( 'WP_SITEURL' ) ) { return untrailingslashit( WP_SITEURL ); } return $url; } function _delete_option_fresh_site() { update_option( 'fresh_site', '0' ); } function _mce_set_direction( $mce_init ) { if ( is_rtl() ) { $mce_init['directionality'] = 'rtl'; $mce_init['rtl_ui'] = true; if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) { $mce_init['plugins'] .= ',directionality'; } if ( ! empty( $mce_init['toolbar1'] ) && ! preg_match( '/\bltr\b/', $mce_init['toolbar1'] ) ) { $mce_init['toolbar1'] .= ',ltr'; } } return $mce_init; } function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch; if ( ! get_option( 'use_smilies' ) ) { return; } if ( ! isset( $wpsmiliestrans ) ) { $wpsmiliestrans = array( ':mrgreen:' => 'mrgreen.png', ':neutral:' => "\xf0\x9f\x98\x90", ':twisted:' => "\xf0\x9f\x98\x88", ':arrow:' => "\xe2\x9e\xa1", ':shock:' => "\xf0\x9f\x98\xaf", ':smile:' => "\xf0\x9f\x99\x82", ':???:' => "\xf0\x9f\x98\x95", ':cool:' => "\xf0\x9f\x98\x8e", ':evil:' => "\xf0\x9f\x91\xbf", ':grin:' => "\xf0\x9f\x98\x80", ':idea:' => "\xf0\x9f\x92\xa1", ':oops:' => "\xf0\x9f\x98\xb3", ':razz:' => "\xf0\x9f\x98\x9b", ':roll:' => "\xf0\x9f\x99\x84", ':wink:' => "\xf0\x9f\x98\x89", ':cry:' => "\xf0\x9f\x98\xa5", ':eek:' => "\xf0\x9f\x98\xae", ':lol:' => "\xf0\x9f\x98\x86", ':mad:' => "\xf0\x9f\x98\xa1", ':sad:' => "\xf0\x9f\x99\x81", '8-)' => "\xf0\x9f\x98\x8e", '8-O' => "\xf0\x9f\x98\xaf", ':-(' => "\xf0\x9f\x99\x81", ':-)' => "\xf0\x9f\x99\x82", ':-?' => "\xf0\x9f\x98\x95", ':-D' => "\xf0\x9f\x98\x80", ':-P' => "\xf0\x9f\x98\x9b", ':-o' => "\xf0\x9f\x98\xae", ':-x' => "\xf0\x9f\x98\xa1", ':-|' => "\xf0\x9f\x98\x90", ';-)' => "\xf0\x9f\x98\x89", '8O' => "\xf0\x9f\x98\xaf", ':(' => "\xf0\x9f\x99\x81", ':)' => "\xf0\x9f\x99\x82", ':?' => "\xf0\x9f\x98\x95", ':D' => "\xf0\x9f\x98\x80", ':P' => "\xf0\x9f\x98\x9b", ':o' => "\xf0\x9f\x98\xae", ':x' => "\xf0\x9f\x98\xa1", ':|' => "\xf0\x9f\x98\x90", ';)' => "\xf0\x9f\x98\x89", ':!:' => "\xe2\x9d\x97", ':?:' => "\xe2\x9d\x93", ); } $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); if ( count( $wpsmiliestrans ) == 0 ) { return; } krsort( $wpsmiliestrans ); $spaces = wp_spaces_regexp(); $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; $subchar = ''; foreach ( (array) $wpsmiliestrans as $smiley => $img ) { $firstchar = substr( $smiley, 0, 1 ); $rest = substr( $smiley, 1 ); if ( $firstchar != $subchar ) { if ( '' !== $subchar ) { $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; } $subchar = $firstchar; $wp_smiliessearch .= preg_quote( $firstchar, '/' ) . '(?:'; } else { $wp_smiliessearch .= '|'; } $wp_smiliessearch .= preg_quote( $rest, '/' ); } $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; } function wp_parse_args( $args, $defaults = array() ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { $parsed_args =& $args; } else { wp_parse_str( $args, $parsed_args ); } if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args; } function wp_parse_list( $input_list ) { if ( ! is_array( $input_list ) ) { return preg_split( '/[\s,]+/', $input_list, -1, PREG_SPLIT_NO_EMPTY ); } $input_list = array_filter( $input_list, 'is_scalar' ); return $input_list; } function wp_parse_id_list( $input_list ) { $input_list = wp_parse_list( $input_list ); return array_unique( array_map( 'absint', $input_list ) ); } function wp_parse_slug_list( $input_list ) { $input_list = wp_parse_list( $input_list ); return array_unique( array_map( 'sanitize_title', $input_list ) ); } function wp_array_slice_assoc( $input_array, $keys ) { $slice = array(); foreach ( $keys as $key ) { if ( isset( $input_array[ $key ] ) ) { $slice[ $key ] = $input_array[ $key ]; } } return $slice; } function wp_recursive_ksort( &$input_array ) { foreach ( $input_array as &$value ) { if ( is_array( $value ) ) { wp_recursive_ksort( $value ); } } ksort( $input_array ); } function _wp_array_get( $input_array, $path, $default_value = null ) { if ( ! is_array( $path ) || 0 === count( $path ) ) { return $default_value; } foreach ( $path as $path_element ) { if ( ! is_array( $input_array ) || ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) || ! array_key_exists( $path_element, $input_array ) ) { return $default_value; } $input_array = $input_array[ $path_element ]; } return $input_array; } function _wp_array_set( &$input_array, $path, $value = null ) { if ( ! is_array( $input_array ) ) { return; } if ( ! is_array( $path ) ) { return; } $path_length = count( $path ); if ( 0 === $path_length ) { return; } foreach ( $path as $path_element ) { if ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) { return; } } for ( $i = 0; $i < $path_length - 1; ++$i ) { $path_element = $path[ $i ]; if ( ! array_key_exists( $path_element, $input_array ) || ! is_array( $input_array[ $path_element ] ) ) { $input_array[ $path_element ] = array(); } $input_array = &$input_array[ $path_element ]; } $input_array[ $path[ $i ] ] = $value; } function _wp_to_kebab_case( $input_string ) { $rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'; $rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'; $rsPunctuationRange = '\\x{2000}-\\x{206f}'; $rsSpaceRange = ' \\t\\x0b\\f\\xa0\\x{feff}\\n\\r\\x{2028}\\x{2029}\\x{1680}\\x{180e}\\x{2000}\\x{2001}\\x{2002}\\x{2003}\\x{2004}\\x{2005}\\x{2006}\\x{2007}\\x{2008}\\x{2009}\\x{200a}\\x{202f}\\x{205f}\\x{3000}'; $rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'; $rsBreakRange = $rsNonCharRange . $rsPunctuationRange . $rsSpaceRange; $rsBreak = '[' . $rsBreakRange . ']'; $rsDigits = '\\d+'; $rsLower = '[' . $rsLowerRange . ']'; $rsMisc = '[^' . $rsBreakRange . $rsDigits . $rsLowerRange . $rsUpperRange . ']'; $rsUpper = '[' . $rsUpperRange . ']'; $rsMiscLower = '(?:' . $rsLower . '|' . $rsMisc . ')'; $rsMiscUpper = '(?:' . $rsUpper . '|' . $rsMisc . ')'; $rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])'; $rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])'; $regexp = '/' . implode( '|', array( $rsUpper . '?' . $rsLower . '+' . '(?=' . implode( '|', array( $rsBreak, $rsUpper, '$' ) ) . ')', $rsMiscUpper . '+' . '(?=' . implode( '|', array( $rsBreak, $rsUpper . $rsMiscLower, '$' ) ) . ')', $rsUpper . '?' . $rsMiscLower . '+', $rsUpper . '+', $rsOrdUpper, $rsOrdLower, $rsDigits, ) ) . '/u'; preg_match_all( $regexp, str_replace( "'", '', $input_string ), $matches ); return strtolower( implode( '-', $matches[0] ) ); } function wp_is_numeric_array( $data ) { if ( ! is_array( $data ) ) { return false; } $keys = array_keys( $data ); $string_keys = array_filter( $keys, 'is_string' ); return count( $string_keys ) === 0; } function wp_filter_object_list( $input_list, $args = array(), $operator = 'and', $field = false ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); $util->filter( $args, $operator ); if ( $field ) { $util->pluck( $field ); } return $util->get_output(); } function wp_list_filter( $input_list, $args = array(), $operator = 'AND' ) { return wp_filter_object_list( $input_list, $args, $operator ); } function wp_list_pluck( $input_list, $field, $index_key = null ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->pluck( $field, $index_key ); } function wp_list_sort( $input_list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->sort( $orderby, $order, $preserve_keys ); } function wp_maybe_load_widgets() { if ( ! apply_filters( 'load_default_widgets', true ) ) { return; } require_once ABSPATH . WPINC . '/default-widgets.php'; add_action( '_admin_menu', 'wp_widgets_add_menu' ); } function wp_widgets_add_menu() { global $submenu; if ( ! current_theme_supports( 'widgets' ) ) { return; } $menu_name = __( 'Widgets' ); if ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) { $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); } else { $submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); } ksort( $submenu['themes.php'], SORT_NUMERIC ); } function wp_ob_end_flush_all() { $levels = ob_get_level(); for ( $i = 0; $i < $levels; $i++ ) { ob_end_flush(); } } function dead_db() { global $wpdb; wp_load_translations_early(); if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once WP_CONTENT_DIR . '/db-error.php'; die(); } if ( wp_installing() || defined( 'WP_ADMIN' ) ) { wp_die( $wpdb->error ); } wp_die( '<h1>' . __( 'Error establishing a database connection' ) . '</h1>', __( 'Database Error' ) ); } function absint( $maybeint ) { return abs( (int) $maybeint ); } function _deprecated_function( $function_name, $version, $replacement = '' ) { do_action( 'deprecated_function_run', $function_name, $replacement, $version ); if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( __( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $function_name, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function_name, $version ), E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function_name, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function_name, $version ), E_USER_DEPRECATED ); } } } } function _deprecated_constructor( $class_name, $version, $parent_class = '' ) { do_action( 'deprecated_constructor_run', $class_name, $version, $parent_class ); if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $parent_class ) { trigger_error( sprintf( __( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ), $class_name, $parent_class, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $class_name, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } } else { if ( $parent_class ) { trigger_error( sprintf( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.', $class_name, $parent_class, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class_name, $version, '<code>__construct()</code>' ), E_USER_DEPRECATED ); } } } } function _deprecated_file( $file, $version, $replacement = '', $message = '' ) { do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( __( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $file, $version ) . $message, E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED ); } } } } function _deprecated_argument( $function_name, $version, $message = '' ) { do_action( 'deprecated_argument_run', $function_name, $message, $version ); if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $message ) { trigger_error( sprintf( __( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function_name, $version, $message ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function_name, $version ), E_USER_DEPRECATED ); } } else { if ( $message ) { trigger_error( sprintf( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function_name, $version, $message ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'Function %1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function_name, $version ), E_USER_DEPRECATED ); } } } } function _deprecated_hook( $hook, $version, $replacement = '', $message = '' ) { do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( $replacement ) { trigger_error( sprintf( __( 'Hook %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( __( 'Hook %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message, E_USER_DEPRECATED ); } } } function _doing_it_wrong( $function_name, $message, $version ) { do_action( 'doing_it_wrong_run', $function_name, $message, $version ); if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true, $function_name, $message, $version ) ) { if ( function_exists( '__' ) ) { if ( $version ) { $version = sprintf( __( '(This message was added in version %s.)' ), $version ); } $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), __( 'https://wordpress.org/support/article/debugging-in-wordpress/' ) ); trigger_error( sprintf( __( 'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function_name, $message, $version ), E_USER_NOTICE ); } else { if ( $version ) { $version = sprintf( '(This message was added in version %s.)', $version ); } $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', 'https://wordpress.org/support/article/debugging-in-wordpress/' ); trigger_error( sprintf( 'Function %1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function_name, $message, $version ), E_USER_NOTICE ); } } } function is_lighttpd_before_150() { $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; return ( 'lighttpd' === $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ) ); } function apache_mod_loaded( $mod, $default_value = false ) { global $is_apache; if ( ! $is_apache ) { return false; } $loaded_mods = array(); if ( function_exists( 'apache_get_modules' ) ) { $loaded_mods = apache_get_modules(); if ( in_array( $mod, $loaded_mods, true ) ) { return true; } } if ( empty( $loaded_mods ) && function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { ob_start(); phpinfo( INFO_MODULES ); $phpinfo = ob_get_clean(); if ( false !== strpos( $phpinfo, $mod ) ) { return true; } } return $default_value; } function iis7_supports_permalinks() { global $is_iis7; $supports_permalinks = false; if ( $is_iis7 ) { $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( 'cgi-fcgi' === PHP_SAPI ); } return apply_filters( 'iis7_supports_permalinks', $supports_permalinks ); } function validate_file( $file, $allowed_files = array() ) { if ( ! is_scalar( $file ) || '' === $file ) { return 0; } if ( '../' === $file ) { return 1; } if ( preg_match_all( '#\.\./#', $file, $matches, PREG_SET_ORDER ) && ( count( $matches ) > 1 ) ) { return 1; } if ( false !== strpos( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) { return 1; } if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files, true ) ) { return 3; } if ( ':' === substr( $file, 1, 1 ) ) { return 2; } return 0; } function force_ssl_admin( $force = null ) { static $forced = false; if ( ! is_null( $force ) ) { $old_forced = $forced; $forced = $force; return $old_forced; } return $forced; } function wp_guess_url() { if ( defined( 'WP_SITEURL' ) && '' !== WP_SITEURL ) { $url = WP_SITEURL; } else { $abspath_fix = str_replace( '\\', '/', ABSPATH ); $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { $path = preg_replace( '#/(wp-admin/?.*|wp-login\.php.*)#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( $script_filename_dir . '/' === $abspath_fix ) { $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); } else { if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) { $directory = str_replace( ABSPATH, '', $script_filename_dir ); $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ) . $subdirectory; } else { $path = $_SERVER['REQUEST_URI']; } } $schema = is_ssl() ? 'https://' : 'http://'; $url = $schema . $_SERVER['HTTP_HOST'] . $path; } return rtrim( $url, '/' ); } function wp_suspend_cache_addition( $suspend = null ) { static $_suspend = false; if ( is_bool( $suspend ) ) { $_suspend = $suspend; } return $_suspend; } function wp_suspend_cache_invalidation( $suspend = true ) { global $_wp_suspend_cache_invalidation; $current_suspend = $_wp_suspend_cache_invalidation; $_wp_suspend_cache_invalidation = $suspend; return $current_suspend; } function is_main_site( $site_id = null, $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( ! $site_id ) { $site_id = get_current_blog_id(); } $site_id = (int) $site_id; return get_main_site_id( $network_id ) === $site_id; } function get_main_site_id( $network_id = null ) { if ( ! is_multisite() ) { return get_current_blog_id(); } $network = get_network( $network_id ); if ( ! $network ) { return 0; } return $network->site_id; } function is_main_network( $network_id = null ) { if ( ! is_multisite() ) { return true; } if ( null === $network_id ) { $network_id = get_current_network_id(); } $network_id = (int) $network_id; return ( get_main_network_id() === $network_id ); } function get_main_network_id() { if ( ! is_multisite() ) { return 1; } $current_network = get_network(); if ( defined( 'PRIMARY_NETWORK_ID' ) ) { $main_network_id = PRIMARY_NETWORK_ID; } elseif ( isset( $current_network->id ) && 1 === (int) $current_network->id ) { $main_network_id = 1; } else { $_networks = get_networks( array( 'fields' => 'ids', 'number' => 1, ) ); $main_network_id = array_shift( $_networks ); } return (int) apply_filters( 'get_main_network_id', $main_network_id ); } function is_site_meta_supported() { global $wpdb; if ( ! is_multisite() ) { return false; } $network_id = get_main_network_id(); $supported = get_network_option( $network_id, 'site_meta_supported', false ); if ( false === $supported ) { $supported = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->blogmeta}'" ) ? 1 : 0; update_network_option( $network_id, 'site_meta_supported', $supported ); } return (bool) $supported; } function wp_timezone_override_offset() { $timezone_string = get_option( 'timezone_string' ); if ( ! $timezone_string ) { return false; } $timezone_object = timezone_open( $timezone_string ); $datetime_object = date_create(); if ( false === $timezone_object || false === $datetime_object ) { return false; } return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 ); } function _wp_timezone_choice_usort_callback( $a, $b ) { if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) { if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) { return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) ); } if ( 'UTC' === $a['city'] ) { if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) { return 1; } return -1; } if ( 'UTC' === $b['city'] ) { if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) { return -1; } return 1; } return strnatcasecmp( $a['city'], $b['city'] ); } if ( $a['t_continent'] == $b['t_continent'] ) { if ( $a['t_city'] == $b['t_city'] ) { return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] ); } return strnatcasecmp( $a['t_city'], $b['t_city'] ); } else { if ( 'Etc' === $a['continent'] ) { return 1; } if ( 'Etc' === $b['continent'] ) { return -1; } return strnatcasecmp( $a['t_continent'], $b['t_continent'] ); } } function wp_timezone_choice( $selected_zone, $locale = null ) { static $mo_loaded = false, $locale_loaded = null; $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific' ); if ( ! $mo_loaded || $locale !== $locale_loaded ) { $locale_loaded = $locale ? $locale : get_locale(); $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; unload_textdomain( 'continents-cities' ); load_textdomain( 'continents-cities', $mofile, $locale_loaded ); $mo_loaded = true; } $tz_identifiers = timezone_identifiers_list(); $zonen = array(); foreach ( $tz_identifiers as $zone ) { $zone = explode( '/', $zone ); if ( ! in_array( $zone[0], $continents, true ) ) { continue; } $exists = array( 0 => ( isset( $zone[0] ) && $zone[0] ), 1 => ( isset( $zone[1] ) && $zone[1] ), 2 => ( isset( $zone[2] ) && $zone[2] ), ); $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ); $exists[4] = ( $exists[1] && $exists[3] ); $exists[5] = ( $exists[2] && $exists[3] ); $zonen[] = array( 'continent' => ( $exists[0] ? $zone[0] : '' ), 'city' => ( $exists[1] ? $zone[1] : '' ), 'subcity' => ( $exists[2] ? $zone[2] : '' ), 't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ), 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ), ); } usort( $zonen, '_wp_timezone_choice_usort_callback' ); $structure = array(); if ( empty( $selected_zone ) ) { $structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>'; } if ( in_array( $selected_zone, $tz_identifiers, true ) === false && in_array( $selected_zone, timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) { $structure[] = '<option selected="selected" value="' . esc_attr( $selected_zone ) . '">' . esc_html( $selected_zone ) . '</option>'; } foreach ( $zonen as $key => $zone ) { $value = array( $zone['continent'] ); if ( empty( $zone['city'] ) ) { $display = $zone['t_continent']; } else { if ( ! isset( $zonen[ $key - 1 ] ) || $zonen[ $key - 1 ]['continent'] !== $zone['continent'] ) { $label = $zone['t_continent']; $structure[] = '<optgroup label="' . esc_attr( $label ) . '">'; } $value[] = $zone['city']; $display = $zone['t_city']; if ( ! empty( $zone['subcity'] ) ) { $value[] = $zone['subcity']; $display .= ' - ' . $zone['t_subcity']; } } $value = implode( '/', $value ); $selected = ''; if ( $value === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . '</option>'; if ( ! empty( $zone['city'] ) && ( ! isset( $zonen[ $key + 1 ] ) || ( isset( $zonen[ $key + 1 ] ) && $zonen[ $key + 1 ]['continent'] !== $zone['continent'] ) ) ) { $structure[] = '</optgroup>'; } } $structure[] = '<optgroup label="' . esc_attr__( 'UTC' ) . '">'; $selected = ''; if ( 'UTC' === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __( 'UTC' ) . '</option>'; $structure[] = '</optgroup>'; $structure[] = '<optgroup label="' . esc_attr__( 'Manual Offsets' ) . '">'; $offset_range = array( -12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14, ); foreach ( $offset_range as $offset ) { if ( 0 <= $offset ) { $offset_name = '+' . $offset; } else { $offset_name = (string) $offset; } $offset_value = $offset_name; $offset_name = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $offset_name ); $offset_name = 'UTC' . $offset_name; $offset_value = 'UTC' . $offset_value; $selected = ''; if ( $offset_value === $selected_zone ) { $selected = 'selected="selected" '; } $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . '</option>'; } $structure[] = '</optgroup>'; return implode( "\n", $structure ); } function _cleanup_header_comment( $str ) { return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) ); } function wp_scheduled_delete() { global $wpdb; $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); $posts_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); foreach ( (array) $posts_to_delete as $post ) { $post_id = (int) $post['post_id']; if ( ! $post_id ) { continue; } $del_post = get_post( $post_id ); if ( ! $del_post || 'trash' !== $del_post->post_status ) { delete_post_meta( $post_id, '_wp_trash_meta_status' ); delete_post_meta( $post_id, '_wp_trash_meta_time' ); } else { wp_delete_post( $post_id ); } } $comments_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); foreach ( (array) $comments_to_delete as $comment ) { $comment_id = (int) $comment['comment_id']; if ( ! $comment_id ) { continue; } $del_comment = get_comment( $comment_id ); if ( ! $del_comment || 'trash' !== $del_comment->comment_approved ) { delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); } else { wp_delete_comment( $del_comment ); } } } function get_file_data( $file, $default_headers, $context = '' ) { $file_data = file_get_contents( $file, false, null, 0, 8 * KB_IN_BYTES ); if ( false === $file_data ) { $file_data = ''; } $file_data = str_replace( "\r", "\n", $file_data ); $extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array(); if ( $extra_headers ) { $extra_headers = array_combine( $extra_headers, $extra_headers ); $all_headers = array_merge( $extra_headers, (array) $default_headers ); } else { $all_headers = $default_headers; } foreach ( $all_headers as $field => $regex ) { if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); } else { $all_headers[ $field ] = ''; } } return $all_headers; } function __return_true() { return true; } function __return_false() { return false; } function __return_zero() { return 0; } function __return_empty_array() { return array(); } function __return_null() { return null; } function __return_empty_string() { return ''; } function send_nosniff_header() { header( 'X-Content-Type-Options: nosniff' ); } function _wp_mysql_week( $column ) { $start_of_week = (int) get_option( 'start_of_week' ); switch ( $start_of_week ) { case 1: return "WEEK( $column, 1 )"; case 2: case 3: case 4: case 5: case 6: return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; case 0: default: return "WEEK( $column, 0 )"; } } function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ); if ( ! $arbitrary_loop_member ) { return array(); } return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); } function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { $tortoise = $start; $hare = $start; $evanescent_hare = $start; $return = array(); while ( $tortoise && ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) && ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) ) { if ( $_return_loop ) { $return[ $tortoise ] = true; $return[ $evanescent_hare ] = true; $return[ $hare ] = true; } if ( $tortoise == $evanescent_hare || $tortoise == $hare ) { return $_return_loop ? $return : $tortoise; } $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); } return false; } function send_frame_options_header() { header( 'X-Frame-Options: SAMEORIGIN' ); } function wp_allowed_protocols() { static $protocols = array(); if ( empty( $protocols ) ) { $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'irc6', 'ircs', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'sms', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' ); } if ( ! did_action( 'wp_loaded' ) ) { $protocols = array_unique( (array) apply_filters( 'kses_allowed_protocols', $protocols ) ); } return $protocols; } function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { static $truncate_paths; $trace = debug_backtrace( false ); $caller = array(); $check_class = ! is_null( $ignore_class ); $skip_frames++; if ( ! isset( $truncate_paths ) ) { $truncate_paths = array( wp_normalize_path( WP_CONTENT_DIR ), wp_normalize_path( ABSPATH ), ); } foreach ( $trace as $call ) { if ( $skip_frames > 0 ) { $skip_frames--; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class == $call['class'] ) { continue; } $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; } else { if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) { $filename = isset( $call['args'][0] ) ? $call['args'][0] : ''; $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')"; } else { $caller[] = $call['function']; } } } if ( $pretty ) { return implode( ', ', array_reverse( $caller ) ); } else { return $caller; } } function _get_non_cached_ids( $object_ids, $cache_key ) { $non_cached_ids = array(); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); foreach ( $cache_values as $id => $value ) { if ( ! $value ) { $non_cached_ids[] = (int) $id; } } return $non_cached_ids; } function _device_can_upload() { if ( ! wp_is_mobile() ) { return true; } $ua = $_SERVER['HTTP_USER_AGENT']; if ( strpos( $ua, 'iPhone' ) !== false || strpos( $ua, 'iPad' ) !== false || strpos( $ua, 'iPod' ) !== false ) { return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' ); } return true; } function wp_is_stream( $path ) { $scheme_separator = strpos( $path, '://' ); if ( false === $scheme_separator ) { return false; } $stream = substr( $path, 0, $scheme_separator ); return in_array( $stream, stream_get_wrappers(), true ); } function wp_checkdate( $month, $day, $year, $source_date ) { return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date ); } function wp_auth_check_load() { if ( ! is_admin() && ! is_user_logged_in() ) { return; } if ( defined( 'IFRAME_REQUEST' ) ) { return; } $screen = get_current_screen(); $hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' ); $show = ! in_array( $screen->id, $hidden, true ); if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) { wp_enqueue_style( 'wp-auth-check' ); wp_enqueue_script( 'wp-auth-check' ); add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 ); add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 ); } } function wp_auth_check_html() { $login_url = wp_login_url(); $current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']; $same_domain = ( strpos( $login_url, $current_domain ) === 0 ); $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; ?> <div id="wp-auth-check-wrap" class="<?php echo $wrap_class; ?>"> <div id="wp-auth-check-bg"></div> <div id="wp-auth-check"> @@ -29968,7 +32651,7 @@ This email has been sent to ###OLD_EMAIL### Regards, All at ###SITENAME### -###SITEURL###' ); $email_change_email = array( 'to' => $old_email, 'subject' => __( '[%s] Admin Email Changed' ), 'message' => $email_change_text, 'headers' => '', ); $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email ); $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $site_name ), $email_change_email['message'], $email_change_email['headers'] ); } function wp_privacy_anonymize_ip( $ip_addr, $ipv6_fallback = false ) { if ( empty( $ip_addr ) ) { return '0.0.0.0'; } $ip_prefix = ''; $is_ipv6 = substr_count( $ip_addr, ':' ) > 1; $is_ipv4 = ( 3 === substr_count( $ip_addr, '.' ) ); if ( $is_ipv6 && $is_ipv4 ) { $ip_prefix = '::ffff:'; $ip_addr = preg_replace( '/^\[?[0-9a-f:]*:/i', '', $ip_addr ); $ip_addr = str_replace( ']', '', $ip_addr ); $is_ipv6 = false; } if ( $is_ipv6 ) { $left_bracket = strpos( $ip_addr, '[' ); $right_bracket = strpos( $ip_addr, ']' ); $percent = strpos( $ip_addr, '%' ); $netmask = 'ffff:ffff:ffff:ffff:0000:0000:0000:0000'; if ( false !== $left_bracket && false !== $right_bracket ) { $ip_addr = substr( $ip_addr, $left_bracket + 1, $right_bracket - $left_bracket - 1 ); } elseif ( false !== $left_bracket || false !== $right_bracket ) { return '::'; } if ( false !== $percent ) { $ip_addr = substr( $ip_addr, 0, $percent ); } if ( preg_match( '/[^0-9a-f:]/i', $ip_addr ) ) { return '::'; } if ( function_exists( 'inet_pton' ) && function_exists( 'inet_ntop' ) ) { $ip_addr = inet_ntop( inet_pton( $ip_addr ) & inet_pton( $netmask ) ); if ( false === $ip_addr ) { return '::'; } } elseif ( ! $ipv6_fallback ) { return '::'; } } elseif ( $is_ipv4 ) { $last_octet_position = strrpos( $ip_addr, '.' ); $ip_addr = substr( $ip_addr, 0, $last_octet_position ) . '.0'; } else { return '0.0.0.0'; } return $ip_prefix . $ip_addr; } function wp_privacy_anonymize_data( $type, $data = '' ) { switch ( $type ) { case 'email': $anonymous = 'deleted@site.invalid'; break; case 'url': $anonymous = 'https://site.invalid'; break; case 'ip': $anonymous = wp_privacy_anonymize_ip( $data ); break; case 'date': $anonymous = '0000-00-00 00:00:00'; break; case 'text': $anonymous = __( '[deleted]' ); break; case 'longtext': $anonymous = __( 'This content was deleted by the author.' ); break; default: $anonymous = ''; break; } return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data ); } function wp_privacy_exports_dir() { $upload_dir = wp_upload_dir(); $exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/'; return apply_filters( 'wp_privacy_exports_dir', $exports_dir ); } function wp_privacy_exports_url() { $upload_dir = wp_upload_dir(); $exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/'; return apply_filters( 'wp_privacy_exports_url', $exports_url ); } function wp_schedule_delete_old_privacy_export_files() { if ( wp_installing() ) { return; } if ( ! wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ) { wp_schedule_event( time(), 'hourly', 'wp_privacy_delete_old_export_files' ); } } function wp_privacy_delete_old_export_files() { $exports_dir = wp_privacy_exports_dir(); if ( ! is_dir( $exports_dir ) ) { return; } require_once ABSPATH . 'wp-admin/includes/file.php'; $export_files = list_files( $exports_dir, 100, array( 'index.php' ) ); $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); foreach ( (array) $export_files as $export_file ) { $file_age_in_seconds = time() - filemtime( $export_file ); if ( $expiration < $file_age_in_seconds ) { unlink( $export_file ); } } } function wp_get_update_php_url() { $default_url = wp_get_default_update_php_url(); $update_url = $default_url; if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) { $update_url = getenv( 'WP_UPDATE_PHP_URL' ); } $update_url = apply_filters( 'wp_update_php_url', $update_url ); if ( empty( $update_url ) ) { $update_url = $default_url; } return $update_url; } function wp_get_default_update_php_url() { return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' ); } function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) { $annotation = wp_get_update_php_annotation(); if ( $annotation ) { echo $before . $annotation . $after; } } function wp_get_update_php_annotation() { $update_url = wp_get_update_php_url(); $default_url = wp_get_default_update_php_url(); if ( $update_url === $default_url ) { return ''; } $annotation = sprintf( __( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank">see the official WordPress documentation</a>.' ), esc_url( $default_url ) ); return $annotation; } function wp_get_direct_php_update_url() { $direct_update_url = ''; if ( false !== getenv( 'WP_DIRECT_UPDATE_PHP_URL' ) ) { $direct_update_url = getenv( 'WP_DIRECT_UPDATE_PHP_URL' ); } $direct_update_url = apply_filters( 'wp_direct_php_update_url', $direct_update_url ); return $direct_update_url; } function wp_direct_php_update_button() { $direct_update_url = wp_get_direct_php_update_url(); if ( empty( $direct_update_url ) ) { return; } echo '<p class="button-container">'; printf( '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', esc_url( $direct_update_url ), __( 'Update PHP' ), __( '(opens in a new tab)' ) ); echo '</p>'; } function wp_get_update_https_url() { $default_url = wp_get_default_update_https_url(); $update_url = $default_url; if ( false !== getenv( 'WP_UPDATE_HTTPS_URL' ) ) { $update_url = getenv( 'WP_UPDATE_HTTPS_URL' ); } $update_url = apply_filters( 'wp_update_https_url', $update_url ); if ( empty( $update_url ) ) { $update_url = $default_url; } return $update_url; } function wp_get_default_update_https_url() { return __( 'https://wordpress.org/support/article/why-should-i-use-https/' ); } function wp_get_direct_update_https_url() { $direct_update_url = ''; if ( false !== getenv( 'WP_DIRECT_UPDATE_HTTPS_URL' ) ) { $direct_update_url = getenv( 'WP_DIRECT_UPDATE_HTTPS_URL' ); } $direct_update_url = apply_filters( 'wp_direct_update_https_url', $direct_update_url ); return $direct_update_url; } function get_dirsize( $directory, $max_execution_time = null ) { if ( is_multisite() && is_main_site() ) { $size = recurse_dirsize( $directory, $directory . '/sites', $max_execution_time ); } else { $size = recurse_dirsize( $directory, null, $max_execution_time ); } return $size; } function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null, &$directory_cache = null ) { $directory = untrailingslashit( $directory ); $save_cache = false; if ( ! isset( $directory_cache ) ) { $directory_cache = get_transient( 'dirsize_cache' ); $save_cache = true; } if ( isset( $directory_cache[ $directory ] ) && is_int( $directory_cache[ $directory ] ) ) { return $directory_cache[ $directory ]; } if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) { return false; } if ( ( is_string( $exclude ) && $directory === $exclude ) || ( is_array( $exclude ) && in_array( $directory, $exclude, true ) ) ) { return false; } if ( null === $max_execution_time ) { if ( function_exists( 'ini_get' ) ) { $max_execution_time = ini_get( 'max_execution_time' ); } else { $max_execution_time = 0; } if ( $max_execution_time > 10 ) { $max_execution_time -= 1; } } $size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache ); if ( false === $size ) { $size = 0; $handle = opendir( $directory ); if ( $handle ) { while ( ( $file = readdir( $handle ) ) !== false ) { $path = $directory . '/' . $file; if ( '.' !== $file && '..' !== $file ) { if ( is_file( $path ) ) { $size += filesize( $path ); } elseif ( is_dir( $path ) ) { $handlesize = recurse_dirsize( $path, $exclude, $max_execution_time, $directory_cache ); if ( $handlesize > 0 ) { $size += $handlesize; } } if ( $max_execution_time > 0 && ( microtime( true ) - WP_START_TIMESTAMP ) > $max_execution_time ) { $size = null; break; } } } closedir( $handle ); } } if ( ! is_array( $directory_cache ) ) { $directory_cache = array(); } $directory_cache[ $directory ] = $size; if ( $save_cache ) { set_transient( 'dirsize_cache', $directory_cache ); } return $size; } function clean_dirsize_cache( $path ) { if ( ! is_string( $path ) || empty( $path ) ) { trigger_error( sprintf( __( '%1$s only accepts a non-empty path string, received %2$s.' ), '<code>clean_dirsize_cache()</code>', '<code>' . gettype( $path ) . '</code>' ) ); return; } $directory_cache = get_transient( 'dirsize_cache' ); if ( empty( $directory_cache ) ) { return; } if ( strpos( $path, '/' ) === false && strpos( $path, '\\' ) === false ) { unset( $directory_cache[ $path ] ); set_transient( 'dirsize_cache', $directory_cache ); return; } $last_path = null; $path = untrailingslashit( $path ); unset( $directory_cache[ $path ] ); while ( $last_path !== $path && DIRECTORY_SEPARATOR !== $path && '.' !== $path && '..' !== $path ) { $last_path = $path; $path = dirname( $path ); unset( $directory_cache[ $path ] ); } set_transient( 'dirsize_cache', $directory_cache ); } function is_wp_version_compatible( $required ) { global $wp_version; list( $version ) = explode( '-', $wp_version ); return empty( $required ) || version_compare( $version, $required, '>=' ); } function is_php_version_compatible( $required ) { return empty( $required ) || version_compare( PHP_VERSION, $required, '>=' ); } function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { return abs( (float) $expected - (float) $actual ) <= $precision; } function wp_recursive_ksort( &$array ) { foreach ( $array as &$value ) { if ( is_array( $value ) ) { wp_recursive_ksort( $value ); } } ksort( $array ); } <?php +###SITEURL###' ); $email_change_email = array( 'to' => $old_email, 'subject' => __( '[%s] Admin Email Changed' ), 'message' => $email_change_text, 'headers' => '', ); $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email ); $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] ); $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $site_name ), $email_change_email['message'], $email_change_email['headers'] ); } function wp_privacy_anonymize_ip( $ip_addr, $ipv6_fallback = false ) { if ( empty( $ip_addr ) ) { return '0.0.0.0'; } $ip_prefix = ''; $is_ipv6 = substr_count( $ip_addr, ':' ) > 1; $is_ipv4 = ( 3 === substr_count( $ip_addr, '.' ) ); if ( $is_ipv6 && $is_ipv4 ) { $ip_prefix = '::ffff:'; $ip_addr = preg_replace( '/^\[?[0-9a-f:]*:/i', '', $ip_addr ); $ip_addr = str_replace( ']', '', $ip_addr ); $is_ipv6 = false; } if ( $is_ipv6 ) { $left_bracket = strpos( $ip_addr, '[' ); $right_bracket = strpos( $ip_addr, ']' ); $percent = strpos( $ip_addr, '%' ); $netmask = 'ffff:ffff:ffff:ffff:0000:0000:0000:0000'; if ( false !== $left_bracket && false !== $right_bracket ) { $ip_addr = substr( $ip_addr, $left_bracket + 1, $right_bracket - $left_bracket - 1 ); } elseif ( false !== $left_bracket || false !== $right_bracket ) { return '::'; } if ( false !== $percent ) { $ip_addr = substr( $ip_addr, 0, $percent ); } if ( preg_match( '/[^0-9a-f:]/i', $ip_addr ) ) { return '::'; } if ( function_exists( 'inet_pton' ) && function_exists( 'inet_ntop' ) ) { $ip_addr = inet_ntop( inet_pton( $ip_addr ) & inet_pton( $netmask ) ); if ( false === $ip_addr ) { return '::'; } } elseif ( ! $ipv6_fallback ) { return '::'; } } elseif ( $is_ipv4 ) { $last_octet_position = strrpos( $ip_addr, '.' ); $ip_addr = substr( $ip_addr, 0, $last_octet_position ) . '.0'; } else { return '0.0.0.0'; } return $ip_prefix . $ip_addr; } function wp_privacy_anonymize_data( $type, $data = '' ) { switch ( $type ) { case 'email': $anonymous = 'deleted@site.invalid'; break; case 'url': $anonymous = 'https://site.invalid'; break; case 'ip': $anonymous = wp_privacy_anonymize_ip( $data ); break; case 'date': $anonymous = '0000-00-00 00:00:00'; break; case 'text': $anonymous = __( '[deleted]' ); break; case 'longtext': $anonymous = __( 'This content was deleted by the author.' ); break; default: $anonymous = ''; break; } return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data ); } function wp_privacy_exports_dir() { $upload_dir = wp_upload_dir(); $exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/'; return apply_filters( 'wp_privacy_exports_dir', $exports_dir ); } function wp_privacy_exports_url() { $upload_dir = wp_upload_dir(); $exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/'; return apply_filters( 'wp_privacy_exports_url', $exports_url ); } function wp_schedule_delete_old_privacy_export_files() { if ( wp_installing() ) { return; } if ( ! wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ) { wp_schedule_event( time(), 'hourly', 'wp_privacy_delete_old_export_files' ); } } function wp_privacy_delete_old_export_files() { $exports_dir = wp_privacy_exports_dir(); if ( ! is_dir( $exports_dir ) ) { return; } require_once ABSPATH . 'wp-admin/includes/file.php'; $export_files = list_files( $exports_dir, 100, array( 'index.php' ) ); $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); foreach ( (array) $export_files as $export_file ) { $file_age_in_seconds = time() - filemtime( $export_file ); if ( $expiration < $file_age_in_seconds ) { unlink( $export_file ); } } } function wp_get_update_php_url() { $default_url = wp_get_default_update_php_url(); $update_url = $default_url; if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) { $update_url = getenv( 'WP_UPDATE_PHP_URL' ); } $update_url = apply_filters( 'wp_update_php_url', $update_url ); if ( empty( $update_url ) ) { $update_url = $default_url; } return $update_url; } function wp_get_default_update_php_url() { return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page' ); } function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>' ) { $annotation = wp_get_update_php_annotation(); if ( $annotation ) { echo $before . $annotation . $after; } } function wp_get_update_php_annotation() { $update_url = wp_get_update_php_url(); $default_url = wp_get_default_update_php_url(); if ( $update_url === $default_url ) { return ''; } $annotation = sprintf( __( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank">see the official WordPress documentation</a>.' ), esc_url( $default_url ) ); return $annotation; } function wp_get_direct_php_update_url() { $direct_update_url = ''; if ( false !== getenv( 'WP_DIRECT_UPDATE_PHP_URL' ) ) { $direct_update_url = getenv( 'WP_DIRECT_UPDATE_PHP_URL' ); } $direct_update_url = apply_filters( 'wp_direct_php_update_url', $direct_update_url ); return $direct_update_url; } function wp_direct_php_update_button() { $direct_update_url = wp_get_direct_php_update_url(); if ( empty( $direct_update_url ) ) { return; } echo '<p class="button-container">'; printf( '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', esc_url( $direct_update_url ), __( 'Update PHP' ), __( '(opens in a new tab)' ) ); echo '</p>'; } function wp_get_update_https_url() { $default_url = wp_get_default_update_https_url(); $update_url = $default_url; if ( false !== getenv( 'WP_UPDATE_HTTPS_URL' ) ) { $update_url = getenv( 'WP_UPDATE_HTTPS_URL' ); } $update_url = apply_filters( 'wp_update_https_url', $update_url ); if ( empty( $update_url ) ) { $update_url = $default_url; } return $update_url; } function wp_get_default_update_https_url() { return __( 'https://wordpress.org/support/article/why-should-i-use-https/' ); } function wp_get_direct_update_https_url() { $direct_update_url = ''; if ( false !== getenv( 'WP_DIRECT_UPDATE_HTTPS_URL' ) ) { $direct_update_url = getenv( 'WP_DIRECT_UPDATE_HTTPS_URL' ); } $direct_update_url = apply_filters( 'wp_direct_update_https_url', $direct_update_url ); return $direct_update_url; } function get_dirsize( $directory, $max_execution_time = null ) { if ( is_multisite() && is_main_site() ) { $size = recurse_dirsize( $directory, $directory . '/sites', $max_execution_time ); } else { $size = recurse_dirsize( $directory, null, $max_execution_time ); } return $size; } function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null, &$directory_cache = null ) { $directory = untrailingslashit( $directory ); $save_cache = false; if ( ! isset( $directory_cache ) ) { $directory_cache = get_transient( 'dirsize_cache' ); $save_cache = true; } if ( isset( $directory_cache[ $directory ] ) && is_int( $directory_cache[ $directory ] ) ) { return $directory_cache[ $directory ]; } if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) { return false; } if ( ( is_string( $exclude ) && $directory === $exclude ) || ( is_array( $exclude ) && in_array( $directory, $exclude, true ) ) ) { return false; } if ( null === $max_execution_time ) { if ( function_exists( 'ini_get' ) ) { $max_execution_time = ini_get( 'max_execution_time' ); } else { $max_execution_time = 0; } if ( $max_execution_time > 10 ) { $max_execution_time -= 1; } } $size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache ); if ( false === $size ) { $size = 0; $handle = opendir( $directory ); if ( $handle ) { while ( ( $file = readdir( $handle ) ) !== false ) { $path = $directory . '/' . $file; if ( '.' !== $file && '..' !== $file ) { if ( is_file( $path ) ) { $size += filesize( $path ); } elseif ( is_dir( $path ) ) { $handlesize = recurse_dirsize( $path, $exclude, $max_execution_time, $directory_cache ); if ( $handlesize > 0 ) { $size += $handlesize; } } if ( $max_execution_time > 0 && ( microtime( true ) - WP_START_TIMESTAMP ) > $max_execution_time ) { $size = null; break; } } } closedir( $handle ); } } if ( ! is_array( $directory_cache ) ) { $directory_cache = array(); } $directory_cache[ $directory ] = $size; if ( $save_cache ) { set_transient( 'dirsize_cache', $directory_cache ); } return $size; } function clean_dirsize_cache( $path ) { if ( ! is_string( $path ) || empty( $path ) ) { trigger_error( sprintf( __( '%1$s only accepts a non-empty path string, received %2$s.' ), '<code>clean_dirsize_cache()</code>', '<code>' . gettype( $path ) . '</code>' ) ); return; } $directory_cache = get_transient( 'dirsize_cache' ); if ( empty( $directory_cache ) ) { return; } if ( strpos( $path, '/' ) === false && strpos( $path, '\\' ) === false ) { unset( $directory_cache[ $path ] ); set_transient( 'dirsize_cache', $directory_cache ); return; } $last_path = null; $path = untrailingslashit( $path ); unset( $directory_cache[ $path ] ); while ( $last_path !== $path && DIRECTORY_SEPARATOR !== $path && '.' !== $path && '..' !== $path ) { $last_path = $path; $path = dirname( $path ); unset( $directory_cache[ $path ] ); } set_transient( 'dirsize_cache', $directory_cache ); } function is_wp_version_compatible( $required ) { global $wp_version; list( $version ) = explode( '-', $wp_version ); return empty( $required ) || version_compare( $version, $required, '>=' ); } function is_php_version_compatible( $required ) { return empty( $required ) || version_compare( PHP_VERSION, $required, '>=' ); } function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { return abs( (float) $expected - (float) $actual ) <= $precision; } <?php function wp_scripts() { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { $wp_scripts = new WP_Scripts(); } return $wp_scripts; } function _wp_scripts_maybe_doing_it_wrong( $function_name, $handle = '' ) { if ( did_action( 'init' ) || did_action( 'wp_enqueue_scripts' ) || did_action( 'admin_enqueue_scripts' ) || did_action( 'login_enqueue_scripts' ) ) { return; } $message = sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ); if ( $handle ) { $message .= ' ' . sprintf( __( 'This notice was triggered by the %s handle.' ), '<code>' . $handle . '</code>' ); } _doing_it_wrong( $function_name, $message, '3.3.0' ); } function wp_print_scripts( $handles = false ) { global $wp_scripts; do_action( 'wp_print_scripts' ); if ( '' === $handles ) { $handles = false; } _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { if ( ! $handles ) { return array(); } } return wp_scripts()->do_items( $handles ); } function wp_add_inline_script( $handle, $data, $position = 'after' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); if ( false !== stripos( $data, '</script>' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Do not pass %1$s tags to %2$s.' ), '<code><script></code>', '<code>wp_add_inline_script()</code>' ), '4.5.0' ); $data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) ); } return wp_scripts()->add_inline_script( $handle, $data, $position ); } function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); $wp_scripts = wp_scripts(); $registered = $wp_scripts->add( $handle, $src, $deps, $ver ); if ( $in_footer ) { $wp_scripts->add_data( $handle, 'group', 1 ); } return $registered; } function wp_localize_script( $handle, $object_name, $l10n ) { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return false; } return $wp_scripts->localize( $handle, $object_name, $l10n ); } function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return false; } return $wp_scripts->set_translations( $handle, $domain, $path ); } function wp_deregister_script( $handle ) { global $pagenow; _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); $current_filter = current_filter(); if ( ( is_admin() && 'admin_enqueue_scripts' !== $current_filter ) || ( 'wp-login.php' === $pagenow && 'login_enqueue_scripts' !== $current_filter ) ) { $not_allowed = array( 'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone', ); if ( in_array( $handle, $not_allowed, true ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ), "<code>$handle</code>", '<code>wp_enqueue_scripts</code>' ), '3.6.0' ); return; } } wp_scripts()->remove( $handle ); } function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); $wp_scripts = wp_scripts(); if ( $src || $in_footer ) { $_handle = explode( '?', $handle ); if ( $src ) { $wp_scripts->add( $_handle[0], $src, $deps, $ver ); } if ( $in_footer ) { $wp_scripts->add_data( $_handle[0], 'group', 1 ); } } $wp_scripts->enqueue( $handle ); } function wp_dequeue_script( $handle ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); wp_scripts()->dequeue( $handle ); } function wp_script_is( $handle, $status = 'enqueued' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return (bool) wp_scripts()->query( $handle, $status ); } function wp_script_add_data( $handle, $key, $value ) { return wp_scripts()->add_data( $handle, $key, $value ); } <?php function wp_styles() { global $wp_styles; if ( ! ( $wp_styles instanceof WP_Styles ) ) { $wp_styles = new WP_Styles(); } return $wp_styles; } function wp_print_styles( $handles = false ) { global $wp_styles; if ( '' === $handles ) { $handles = false; } if ( ! $handles ) { do_action( 'wp_print_styles' ); } _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); if ( ! ( $wp_styles instanceof WP_Styles ) ) { if ( ! $handles ) { return array(); } } return wp_styles()->do_items( $handles ); } function wp_add_inline_style( $handle, $data ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); if ( false !== stripos( $data, '</style>' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Do not pass %1$s tags to %2$s.' ), '<code><style></code>', '<code>wp_add_inline_style()</code>' ), '3.7.0' ); $data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) ); } return wp_styles()->add_inline_style( $handle, $data ); } function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return wp_styles()->add( $handle, $src, $deps, $ver, $media ); } function wp_deregister_style( $handle ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); wp_styles()->remove( $handle ); } function wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); $wp_styles = wp_styles(); if ( $src ) { $_handle = explode( '?', $handle ); $wp_styles->add( $_handle[0], $src, $deps, $ver, $media ); } $wp_styles->enqueue( $handle ); } function wp_dequeue_style( $handle ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); wp_styles()->dequeue( $handle ); } function wp_style_is( $handle, $status = 'enqueued' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return (bool) wp_styles()->query( $handle, $status ); } function wp_style_add_data( $handle, $key, $value ) { return wp_styles()->add_data( $handle, $key, $value ); } <?php function get_header( $name = null, $args = array() ) { do_action( 'get_header', $name, $args ); $templates = array(); $name = (string) $name; if ( '' !== $name ) { $templates[] = "header-{$name}.php"; } $templates[] = 'header.php'; if ( ! locate_template( $templates, true, true, $args ) ) { return false; } } function get_footer( $name = null, $args = array() ) { do_action( 'get_footer', $name, $args ); $templates = array(); $name = (string) $name; if ( '' !== $name ) { $templates[] = "footer-{$name}.php"; } $templates[] = 'footer.php'; if ( ! locate_template( $templates, true, true, $args ) ) { return false; } } function get_sidebar( $name = null, $args = array() ) { do_action( 'get_sidebar', $name, $args ); $templates = array(); $name = (string) $name; if ( '' !== $name ) { $templates[] = "sidebar-{$name}.php"; } $templates[] = 'sidebar.php'; if ( ! locate_template( $templates, true, true, $args ) ) { return false; } } function get_template_part( $slug, $name = null, $args = array() ) { do_action( "get_template_part_{$slug}", $slug, $name, $args ); $templates = array(); $name = (string) $name; if ( '' !== $name ) { $templates[] = "{$slug}-{$name}.php"; } $templates[] = "{$slug}.php"; do_action( 'get_template_part', $slug, $name, $templates, $args ); if ( ! locate_template( $templates, true, false, $args ) ) { return false; } } function get_search_form( $args = array() ) { do_action( 'pre_get_search_form', $args ); $echo = true; if ( ! is_array( $args ) ) { $echo = (bool) $args; $args = array(); } $defaults = array( 'echo' => $echo, 'aria_label' => '', ); $args = wp_parse_args( $args, $defaults ); $args = apply_filters( 'search_form_args', $args ); $args = array_merge( $defaults, $args ); $format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml'; $format = apply_filters( 'search_form_format', $format, $args ); $search_form_template = locate_template( 'searchform.php' ); if ( '' !== $search_form_template ) { ob_start(); require $search_form_template; $form = ob_get_clean(); } else { if ( $args['aria_label'] ) { $aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" '; } else { $aria_label = ''; } if ( 'html5' === $format ) { $form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> @@ -29988,7 +32671,7 @@ All at ###SITENAME### <input type="text" name="log" id="%1$s" autocomplete="username" class="input" value="%3$s" size="20" /> </p>', esc_attr( $args['id_username'] ), esc_html( $args['label_username'] ), esc_attr( $args['value_username'] ) ) . sprintf( '<p class="login-password"> <label for="%1$s">%2$s</label> - <input type="password" name="pwd" id="%1$s" autocomplete="current-password" class="input" value="" size="20" /> + <input type="password" name="pwd" id="%1$s" autocomplete="current-password" spellcheck="false" class="input" value="" size="20" /> </p>', esc_attr( $args['id_password'] ), esc_html( $args['label_password'] ) ) . $login_form_middle . ( $args['remember'] ? sprintf( '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="%1$s" value="forever"%2$s /> %3$s</label></p>', esc_attr( $args['id_remember'] ), ( $args['value_remember'] ? ' checked="checked"' : '' ), esc_html( $args['label_remember'] ) ) : '' ) . sprintf( '<p class="login-submit"> <input type="submit" name="wp-submit" id="%1$s" class="button button-primary" value="%2$s" /> <input type="hidden" name="redirect_to" value="%3$s" /> @@ -30017,20 +32700,20 @@ All at ###SITENAME### <meta name='referrer' content='strict-origin-when-cross-origin' /> <?php } function wp_site_icon() { if ( ! has_site_icon() && ! is_customize_preview() ) { return; } $meta_tags = array(); $icon_32 = get_site_icon_url( 32 ); if ( empty( $icon_32 ) && is_customize_preview() ) { $icon_32 = '/favicon.ico'; } if ( $icon_32 ) { $meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) ); } $icon_192 = get_site_icon_url( 192 ); if ( $icon_192 ) { $meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) ); } $icon_180 = get_site_icon_url( 180 ); if ( $icon_180 ) { $meta_tags[] = sprintf( '<link rel="apple-touch-icon" href="%s" />', esc_url( $icon_180 ) ); } $icon_270 = get_site_icon_url( 270 ); if ( $icon_270 ) { $meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) ); } $meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags ); $meta_tags = array_filter( $meta_tags ); foreach ( $meta_tags as $meta_tag ) { echo "$meta_tag\n"; } } function wp_resource_hints() { $hints = array( 'dns-prefetch' => wp_dependencies_unique_hosts(), 'preconnect' => array(), 'prefetch' => array(), 'prerender' => array(), ); foreach ( $hints as $relation_type => $urls ) { $unique_urls = array(); $urls = apply_filters( 'wp_resource_hints', $urls, $relation_type ); foreach ( $urls as $key => $url ) { $atts = array(); if ( is_array( $url ) ) { if ( isset( $url['href'] ) ) { $atts = $url; $url = $url['href']; } else { continue; } } $url = esc_url( $url, array( 'http', 'https' ) ); if ( ! $url ) { continue; } if ( isset( $unique_urls[ $url ] ) ) { continue; } if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ), true ) ) { $parsed = wp_parse_url( $url ); if ( empty( $parsed['host'] ) ) { continue; } if ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) { $url = $parsed['scheme'] . '://' . $parsed['host']; } else { $url = '//' . $parsed['host']; } } $atts['rel'] = $relation_type; $atts['href'] = $url; $unique_urls[ $url ] = $atts; } foreach ( $unique_urls as $atts ) { $html = ''; foreach ( $atts as $attr => $value ) { if ( ! is_scalar( $value ) || ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) ) ) { continue; } $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); if ( ! is_string( $attr ) ) { $html .= " $value"; } else { $html .= " $attr='$value'"; } } $html = trim( $html ); echo "<link $html />\n"; } } } function wp_preload_resources() { $preload_resources = apply_filters( 'wp_preload_resources', array() ); if ( ! is_array( $preload_resources ) ) { return; } $unique_resources = array(); foreach ( $preload_resources as $resource ) { if ( ! is_array( $resource ) ) { continue; } $attributes = $resource; if ( isset( $resource['href'] ) ) { $href = $resource['href']; if ( isset( $unique_resources[ $href ] ) ) { continue; } $unique_resources[ $href ] = $attributes; } elseif ( ( 'image' === $resource['as'] ) && ( isset( $resource['imagesrcset'] ) || isset( $resource['imagesizes'] ) ) ) { if ( isset( $unique_resources[ $resource['imagesrcset'] ] ) ) { continue; } $unique_resources[ $resource['imagesrcset'] ] = $attributes; } else { continue; } } foreach ( $unique_resources as $unique_resource ) { $html = ''; foreach ( $unique_resource as $resource_key => $resource_value ) { if ( ! is_scalar( $resource_value ) ) { continue; } $non_supported_attributes = array( 'as', 'crossorigin', 'href', 'imagesrcset', 'imagesizes', 'type', 'media' ); if ( ! in_array( $resource_key, $non_supported_attributes, true ) && ! is_numeric( $resource_key ) ) { continue; } if ( ( 'imagesrcset' === $resource_key ) && ( ! isset( $unique_resource['as'] ) || ( 'image' !== $unique_resource['as'] ) ) ) { continue; } if ( ( 'imagesizes' === $resource_key ) && ( ! isset( $unique_resource['as'] ) || ( 'image' !== $unique_resource['as'] ) || ! isset( $unique_resource['imagesrcset'] ) ) ) { continue; } $resource_value = ( 'href' === $resource_key ) ? esc_url( $resource_value, array( 'http', 'https' ) ) : esc_attr( $resource_value ); if ( ! is_string( $resource_key ) ) { $html .= " $resource_value"; } else { $html .= " $resource_key='$resource_value'"; } } $html = trim( $html ); printf( "<link rel='preload' %s />\n", $html ); } } function wp_dependencies_unique_hosts() { global $wp_scripts, $wp_styles; $unique_hosts = array(); foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { foreach ( $dependencies->queue as $handle ) { if ( ! isset( $dependencies->registered[ $handle ] ) ) { continue; } $dependency = $dependencies->registered[ $handle ]; $parsed = wp_parse_url( $dependency->src ); if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts, true ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { $unique_hosts[] = $parsed['host']; } } } } return $unique_hosts; } function user_can_richedit() { global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge; if ( ! isset( $wp_rich_edit ) ) { $wp_rich_edit = false; if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && (int) $match[1] >= 534 ); } elseif ( $is_IE ) { $wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false ); } elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) { $wp_rich_edit = true; } } } return apply_filters( 'user_can_richedit', $wp_rich_edit ); } function wp_default_editor() { $r = user_can_richedit() ? 'tinymce' : 'html'; if ( wp_get_current_user() ) { $ed = get_user_setting( 'editor', 'tinymce' ); $r = ( in_array( $ed, array( 'tinymce', 'html', 'test' ), true ) ) ? $ed : $r; } return apply_filters( 'wp_default_editor', $r ); } function wp_editor( $content, $editor_id, $settings = array() ) { if ( ! class_exists( '_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } _WP_Editors::editor( $content, $editor_id, $settings ); } function wp_enqueue_editor() { if ( ! class_exists( '_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } _WP_Editors::enqueue_default_editor(); } function wp_enqueue_code_editor( $args ) { if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) { return false; } $settings = wp_get_code_editor_settings( $args ); if ( empty( $settings ) || empty( $settings['codemirror'] ) ) { return false; } wp_enqueue_script( 'code-editor' ); wp_enqueue_style( 'code-editor' ); if ( isset( $settings['codemirror']['mode'] ) ) { $mode = $settings['codemirror']['mode']; if ( is_string( $mode ) ) { $mode = array( 'name' => $mode, ); } if ( ! empty( $settings['codemirror']['lint'] ) ) { switch ( $mode['name'] ) { case 'css': case 'text/css': case 'text/x-scss': case 'text/x-less': wp_enqueue_script( 'csslint' ); break; case 'htmlmixed': case 'text/html': case 'php': case 'application/x-httpd-php': case 'text/x-php': wp_enqueue_script( 'htmlhint' ); wp_enqueue_script( 'csslint' ); wp_enqueue_script( 'jshint' ); if ( ! current_user_can( 'unfiltered_html' ) ) { wp_enqueue_script( 'htmlhint-kses' ); } break; case 'javascript': case 'application/ecmascript': case 'application/json': case 'application/javascript': case 'application/ld+json': case 'text/typescript': case 'application/typescript': wp_enqueue_script( 'jshint' ); wp_enqueue_script( 'jsonlint' ); break; } } } wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) ); do_action( 'wp_enqueue_code_editor', $settings ); return $settings; } function wp_get_code_editor_settings( $args ) { $settings = array( 'codemirror' => array( 'indentUnit' => 4, 'indentWithTabs' => true, 'inputStyle' => 'contenteditable', 'lineNumbers' => true, 'lineWrapping' => true, 'styleActiveLine' => true, 'continueComments' => true, 'extraKeys' => array( 'Ctrl-Space' => 'autocomplete', 'Ctrl-/' => 'toggleComment', 'Cmd-/' => 'toggleComment', 'Alt-F' => 'findPersistent', 'Ctrl-F' => 'findPersistent', 'Cmd-F' => 'findPersistent', ), 'direction' => 'ltr', 'gutters' => array(), ), 'csslint' => array( 'errors' => true, 'box-model' => true, 'display-property-grouping' => true, 'duplicate-properties' => true, 'known-properties' => true, 'outline-none' => true, ), 'jshint' => array( 'boss' => true, 'curly' => true, 'eqeqeq' => true, 'eqnull' => true, 'es3' => true, 'expr' => true, 'immed' => true, 'noarg' => true, 'nonbsp' => true, 'onevar' => true, 'quotmark' => 'single', 'trailing' => true, 'undef' => true, 'unused' => true, 'browser' => true, 'globals' => array( '_' => false, 'Backbone' => false, 'jQuery' => false, 'JSON' => false, 'wp' => false, ), ), 'htmlhint' => array( 'tagname-lowercase' => true, 'attr-lowercase' => true, 'attr-value-double-quotes' => false, 'doctype-first' => false, 'tag-pair' => true, 'spec-char-escape' => true, 'id-unique' => true, 'src-not-empty' => true, 'attr-no-duplication' => true, 'alt-require' => true, 'space-tab-mixed-disabled' => 'tab', 'attr-unsafe-chars' => true, ), ); $type = ''; if ( isset( $args['type'] ) ) { $type = $args['type']; if ( 'application/x-patch' === $type || 'text/x-patch' === $type ) { $type = 'text/x-diff'; } } elseif ( isset( $args['file'] ) && false !== strpos( basename( $args['file'] ), '.' ) ) { $extension = strtolower( pathinfo( $args['file'], PATHINFO_EXTENSION ) ); foreach ( wp_get_mime_types() as $exts => $mime ) { if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { $type = $mime; break; } } if ( empty( $type ) ) { switch ( $extension ) { case 'conf': $type = 'text/nginx'; break; case 'css': $type = 'text/css'; break; case 'diff': case 'patch': $type = 'text/x-diff'; break; case 'html': case 'htm': $type = 'text/html'; break; case 'http': $type = 'message/http'; break; case 'js': $type = 'text/javascript'; break; case 'json': $type = 'application/json'; break; case 'jsx': $type = 'text/jsx'; break; case 'less': $type = 'text/x-less'; break; case 'md': $type = 'text/x-gfm'; break; case 'php': case 'phtml': case 'php3': case 'php4': case 'php5': case 'php7': case 'phps': $type = 'application/x-httpd-php'; break; case 'scss': $type = 'text/x-scss'; break; case 'sass': $type = 'text/x-sass'; break; case 'sh': case 'bash': $type = 'text/x-sh'; break; case 'sql': $type = 'text/x-sql'; break; case 'svg': $type = 'application/svg+xml'; break; case 'xml': $type = 'text/xml'; break; case 'yml': case 'yaml': $type = 'text/x-yaml'; break; case 'txt': default: $type = 'text/plain'; break; } } } if ( in_array( $type, array( 'text/css', 'text/x-scss', 'text/x-less', 'text/x-sass' ), true ) ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => $type, 'lint' => false, 'autoCloseBrackets' => true, 'matchBrackets' => true, ) ); } elseif ( 'text/x-diff' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'diff', ) ); } elseif ( 'text/html' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'htmlmixed', 'lint' => true, 'autoCloseBrackets' => true, 'autoCloseTags' => true, 'matchTags' => array( 'bothTags' => true, ), ) ); if ( ! current_user_can( 'unfiltered_html' ) ) { $settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' ); } } elseif ( 'text/x-gfm' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'gfm', 'highlightFormatting' => true, ) ); } elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'javascript', 'lint' => true, 'autoCloseBrackets' => true, 'matchBrackets' => true, ) ); } elseif ( false !== strpos( $type, 'json' ) ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => array( 'name' => 'javascript', ), 'lint' => true, 'autoCloseBrackets' => true, 'matchBrackets' => true, ) ); if ( 'application/ld+json' === $type ) { $settings['codemirror']['mode']['jsonld'] = true; } else { $settings['codemirror']['mode']['json'] = true; } } elseif ( false !== strpos( $type, 'jsx' ) ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'jsx', 'autoCloseBrackets' => true, 'matchBrackets' => true, ) ); } elseif ( 'text/x-markdown' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'markdown', 'highlightFormatting' => true, ) ); } elseif ( 'text/nginx' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'nginx', ) ); } elseif ( 'application/x-httpd-php' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'php', 'autoCloseBrackets' => true, 'autoCloseTags' => true, 'matchBrackets' => true, 'matchTags' => array( 'bothTags' => true, ), ) ); } elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'sql', 'autoCloseBrackets' => true, 'matchBrackets' => true, ) ); } elseif ( false !== strpos( $type, 'xml' ) ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'xml', 'autoCloseBrackets' => true, 'autoCloseTags' => true, 'matchTags' => array( 'bothTags' => true, ), ) ); } elseif ( 'text/x-yaml' === $type ) { $settings['codemirror'] = array_merge( $settings['codemirror'], array( 'mode' => 'yaml', ) ); } else { $settings['codemirror']['mode'] = $type; } if ( ! empty( $settings['codemirror']['lint'] ) ) { $settings['codemirror']['gutters'][] = 'CodeMirror-lint-markers'; } foreach ( wp_array_slice_assoc( $args, array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ) ) as $key => $value ) { $settings[ $key ] = array_merge( $settings[ $key ], $value ); } return apply_filters( 'wp_code_editor_settings', $settings, $args ); } function get_search_query( $escaped = true ) { $query = apply_filters( 'get_search_query', get_query_var( 's' ) ); if ( $escaped ) { $query = esc_attr( $query ); } return $query; } function the_search_query() { echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); } function get_language_attributes( $doctype = 'html' ) { $attributes = array(); if ( function_exists( 'is_rtl' ) && is_rtl() ) { $attributes[] = 'dir="rtl"'; } $lang = get_bloginfo( 'language' ); if ( $lang ) { if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) { $attributes[] = 'lang="' . esc_attr( $lang ) . '"'; } if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) { $attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"'; } } $output = implode( ' ', $attributes ); return apply_filters( 'language_attributes', $output, $doctype ); } function language_attributes( $doctype = 'html' ) { echo get_language_attributes( $doctype ); } function paginate_links( $args = '' ) { global $wp_query, $wp_rewrite; $pagenum_link = html_entity_decode( get_pagenum_link() ); $url_parts = explode( '?', $pagenum_link ); $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1; $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%'; $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; $defaults = array( 'base' => $pagenum_link, 'format' => $format, 'total' => $total, 'current' => $current, 'aria_current' => 'page', 'show_all' => false, 'prev_next' => true, 'prev_text' => __( '« Previous' ), 'next_text' => __( 'Next »' ), 'end_size' => 1, 'mid_size' => 2, 'type' => 'plain', 'add_args' => array(), 'add_fragment' => '', 'before_page_number' => '', 'after_page_number' => '', ); $args = wp_parse_args( $args, $defaults ); if ( ! is_array( $args['add_args'] ) ) { $args['add_args'] = array(); } if ( isset( $url_parts[1] ) ) { $format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) ); $format_query = isset( $format[1] ) ? $format[1] : ''; wp_parse_str( $format_query, $format_args ); wp_parse_str( $url_parts[1], $url_query_args ); foreach ( $format_args as $format_arg => $format_arg_value ) { unset( $url_query_args[ $format_arg ] ); } $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) ); } $total = (int) $args['total']; if ( $total < 2 ) { return; } $current = (int) $args['current']; $end_size = (int) $args['end_size']; if ( $end_size < 1 ) { $end_size = 1; } $mid_size = (int) $args['mid_size']; if ( $mid_size < 0 ) { $mid_size = 2; } $add_args = $args['add_args']; $r = ''; $page_links = array(); $dots = false; if ( $args['prev_next'] && $current && 1 < $current ) : $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] ); $link = str_replace( '%#%', $current - 1, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<a class="prev page-numbers" href="%s">%s</a>', esc_url( apply_filters( 'paginate_links', $link ) ), $args['prev_text'] ); endif; for ( $n = 1; $n <= $total; $n++ ) : if ( $n == $current ) : $page_links[] = sprintf( '<span aria-current="%s" class="page-numbers current">%s</span>', esc_attr( $args['aria_current'] ), $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] ); $dots = true; else : if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); $link = str_replace( '%#%', $n, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<a class="page-numbers" href="%s">%s</a>', esc_url( apply_filters( 'paginate_links', $link ) ), $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] ); $dots = true; elseif ( $dots && ! $args['show_all'] ) : $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; $dots = false; endif; endif; endfor; if ( $args['prev_next'] && $current && $current < $total ) : $link = str_replace( '%_%', $args['format'], $args['base'] ); $link = str_replace( '%#%', $current + 1, $link ); if ( $add_args ) { $link = add_query_arg( $add_args, $link ); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<a class="next page-numbers" href="%s">%s</a>', esc_url( apply_filters( 'paginate_links', $link ) ), $args['next_text'] ); endif; switch ( $args['type'] ) { case 'array': return $page_links; case 'list': $r .= "<ul class='page-numbers'>\n\t<li>"; $r .= implode( "</li>\n\t<li>", $page_links ); $r .= "</li>\n</ul>\n"; break; default: $r = implode( "\n", $page_links ); break; } $r = apply_filters( 'paginate_links_output', $r, $args ); return $r; } function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) { global $_wp_admin_css_colors; if ( ! isset( $_wp_admin_css_colors ) ) { $_wp_admin_css_colors = array(); } $_wp_admin_css_colors[ $key ] = (object) array( 'name' => $name, 'url' => $url, 'colors' => $colors, 'icon_colors' => $icons, ); } function register_admin_color_schemes() { $suffix = is_rtl() ? '-rtl' : ''; $suffix .= SCRIPT_DEBUG ? '' : '.min'; wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), false, array( '#1d2327', '#2c3338', '#2271b1', '#72aee6' ), array( 'base' => '#a7aaad', 'focus' => '#72aee6', 'current' => '#fff', ) ); wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ), admin_url( "css/colors/light/colors$suffix.css" ), array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ), array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc', ) ); wp_admin_css_color( 'modern', _x( 'Modern', 'admin color scheme' ), admin_url( "css/colors/modern/colors$suffix.css" ), array( '#1e1e1e', '#3858e9', '#33f078' ), array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ), admin_url( "css/colors/blue/colors$suffix.css" ), array( '#096484', '#4796b3', '#52accc', '#74B6CE' ), array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ), admin_url( "css/colors/midnight/colors$suffix.css" ), array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ), array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ), admin_url( "css/colors/sunrise/colors$suffix.css" ), array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ), array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ), admin_url( "css/colors/ectoplasm/colors$suffix.css" ), array( '#413256', '#523f6d', '#a3b745', '#d46f15' ), array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ), admin_url( "css/colors/ocean/colors$suffix.css" ), array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ), array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff', ) ); wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ), admin_url( "css/colors/coffee/colors$suffix.css" ), array( '#46403c', '#59524c', '#c7a589', '#9ea476' ), array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff', ) ); } function wp_admin_css_uri( $file = 'wp-admin' ) { if ( defined( 'WP_INSTALLING' ) ) { $_file = "./$file.css"; } else { $_file = admin_url( "$file.css" ); } $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); return apply_filters( 'wp_admin_css_uri', $_file, $file ); } function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; if ( wp_styles()->query( $handle ) ) { if ( $force_echo || did_action( 'wp_print_styles' ) ) { wp_print_styles( $handle ); } else { wp_enqueue_style( $handle ); } return; } $stylesheet_link = sprintf( "<link rel='stylesheet' href='%s' type='text/css' />\n", esc_url( wp_admin_css_uri( $file ) ) ); echo apply_filters( 'wp_admin_css', $stylesheet_link, $file ); if ( function_exists( 'is_rtl' ) && is_rtl() ) { $rtl_stylesheet_link = sprintf( "<link rel='stylesheet' href='%s' type='text/css' />\n", esc_url( wp_admin_css_uri( "$file-rtl" ) ) ); echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" ); } } function add_thickbox() { wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' ); if ( is_network_admin() ) { add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); } } function wp_generator() { the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); } function the_generator( $type ) { echo apply_filters( 'the_generator', get_the_generator( $type ), $type ) . "\n"; } function get_the_generator( $type = '' ) { if ( empty( $type ) ) { $current_filter = current_filter(); if ( empty( $current_filter ) ) { return; } switch ( $current_filter ) { case 'rss2_head': case 'commentsrss2_head': $type = 'rss2'; break; case 'rss_head': case 'opml_head': $type = 'comment'; break; case 'rdf_header': $type = 'rdf'; break; case 'atom_head': case 'comments_atom_head': case 'app_head': $type = 'atom'; break; } } switch ( $type ) { case 'html': $gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '">'; break; case 'xhtml': $gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '" />'; break; case 'atom': $gen = '<generator uri="https://wordpress.org/" version="' . esc_attr( get_bloginfo_rss( 'version' ) ) . '">WordPress</generator>'; break; case 'rss2': $gen = '<generator>' . sanitize_url( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '</generator>'; break; case 'rdf': $gen = '<admin:generatorAgent rdf:resource="' . sanitize_url( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '" />'; break; case 'comment': $gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->'; break; case 'export': $gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . gmdate( 'Y-m-d H:i' ) . '" -->'; break; } return apply_filters( "get_the_generator_{$type}", $gen, $type ); } function checked( $checked, $current = true, $display = true ) { return __checked_selected_helper( $checked, $current, $display, 'checked' ); } function selected( $selected, $current = true, $display = true ) { return __checked_selected_helper( $selected, $current, $display, 'selected' ); } function disabled( $disabled, $current = true, $display = true ) { return __checked_selected_helper( $disabled, $current, $display, 'disabled' ); } function wp_readonly( $readonly_value, $current = true, $display = true ) { return __checked_selected_helper( $readonly_value, $current, $display, 'readonly' ); } if ( PHP_VERSION_ID < 80100 ) { require_once __DIR__ . '/php-compat/readonly.php'; } function __checked_selected_helper( $helper, $current, $display, $type ) { if ( (string) $helper === (string) $current ) { $result = " $type='$type'"; } else { $result = ''; } if ( $display ) { echo $result; } return $result; } function wp_required_field_indicator() { $glyph = __( '*' ); $indicator = '<span class="required">' . esc_html( $glyph ) . '</span>'; return apply_filters( 'wp_required_field_indicator', $indicator ); } function wp_required_field_message() { $message = sprintf( '<span class="required-field-message">%s</span>', sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator() ) ); return apply_filters( 'wp_required_field_message', $message ); } function wp_heartbeat_settings( $settings ) { if ( ! is_admin() ) { $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' ); } if ( is_user_logged_in() ) { $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' ); } return $settings; } <?php - function wp_get_global_settings( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $path = array_merge( array( 'blocks', $context['block_name'] ), $path ); } $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } $settings = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_settings(); return _wp_array_get( $settings, $path, $settings ); } function wp_get_global_styles( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $path = array_merge( array( 'blocks', $context['block_name'] ), $path ); } $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } $styles = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_raw_data()['styles']; return _wp_array_get( $styles, $path, $styles ); } function wp_get_global_stylesheet( $types = array() ) { $can_use_cached = ( ( empty( $types ) ) && ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && ! is_admin() ); $transient_name = 'global_styles_' . get_stylesheet(); if ( $can_use_cached ) { $cached = get_transient( $transient_name ); if ( $cached ) { return $cached; } } $tree = WP_Theme_JSON_Resolver::get_merged_data(); $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support(); if ( empty( $types ) && ! $supports_theme_json ) { $types = array( 'variables', 'presets', 'base-layout-styles' ); } elseif ( empty( $types ) ) { $types = array( 'variables', 'styles', 'presets' ); } $styles_variables = ''; if ( in_array( 'variables', $types, true ) ) { $origins = array( 'default', 'theme', 'custom' ); $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins ); $types = array_diff( $types, array( 'variables' ) ); } $styles_rest = ''; if ( ! empty( $types ) ) { $origins = array( 'default', 'theme', 'custom' ); if ( ! $supports_theme_json ) { $origins = array( 'default' ); } $styles_rest = $tree->get_stylesheet( $types, $origins ); } $stylesheet = $styles_variables . $styles_rest; if ( $can_use_cached ) { set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS ); } return $stylesheet; } function wp_get_global_styles_svg_filters() { $can_use_cached = ( ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && ! is_admin() ); $transient_name = 'global_styles_svg_filters_' . get_stylesheet(); if ( $can_use_cached ) { $cached = get_transient( $transient_name ); if ( $cached ) { return $cached; } } $supports_theme_json = WP_Theme_JSON_Resolver::theme_has_support(); $origins = array( 'default', 'theme', 'custom' ); if ( ! $supports_theme_json ) { $origins = array( 'default' ); } $tree = WP_Theme_JSON_Resolver::get_merged_data(); $svgs = $tree->get_svg_filters( $origins ); if ( $can_use_cached ) { set_transient( $transient_name, $svgs, MINUTE_IN_SECONDS ); } return $svgs; } function wp_add_global_styles_for_blocks() { $tree = WP_Theme_JSON_Resolver::get_merged_data(); $block_nodes = $tree->get_styles_block_nodes(); foreach ( $block_nodes as $metadata ) { $block_css = $tree->get_styles_for_block( $metadata ); if ( ! wp_should_load_separate_core_block_assets() ) { wp_add_inline_style( 'global-styles', $block_css ); continue; } $stylesheet_handle = 'global-styles'; if ( isset( $metadata['name'] ) ) { if ( str_starts_with( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); $stylesheet_handle = 'wp-block-' . $block_name; } wp_add_inline_style( $stylesheet_handle, $block_css ); } if ( ! isset( $metadata['name'] ) && ! empty( $metadata['path'] ) ) { $result = array_values( array_filter( $metadata['path'], function ( $item ) { if ( strpos( $item, 'core/' ) !== false ) { return true; } return false; } ) ); if ( isset( $result[0] ) ) { if ( str_starts_with( $result[0], 'core/' ) ) { $block_name = str_replace( 'core/', '', $result[0] ); $stylesheet_handle = 'wp-block-' . $block_name; } wp_add_inline_style( $stylesheet_handle, $block_css ); } } } } <?php + function wp_get_global_settings( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $new_path = array( 'blocks', $context['block_name'] ); foreach ( $path as $subpath ) { $new_path[] = $subpath; } $path = $new_path; } $origin = 'custom'; if ( ! wp_theme_has_theme_json() || ( isset( $context['origin'] ) && 'base' === $context['origin'] ) ) { $origin = 'theme'; } $cache_group = 'theme_json'; $cache_key = 'wp_get_global_settings_' . $origin; $can_use_cached = ! WP_DEBUG; $settings = false; if ( $can_use_cached ) { $settings = wp_cache_get( $cache_key, $cache_group ); } if ( false === $settings ) { $settings = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_settings(); if ( $can_use_cached ) { wp_cache_set( $cache_key, $settings, $cache_group ); } } return _wp_array_get( $settings, $path, $settings ); } function wp_get_global_styles( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $path = array_merge( array( 'blocks', $context['block_name'] ), $path ); } $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } $styles = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_raw_data()['styles']; return _wp_array_get( $styles, $path, $styles ); } function wp_get_global_stylesheet( $types = array() ) { $can_use_cached = empty( $types ) && ! WP_DEBUG; $cache_group = 'theme_json'; $cache_key = 'wp_get_global_stylesheet'; if ( $can_use_cached ) { $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { return $cached; } } $tree = WP_Theme_JSON_Resolver::get_merged_data(); $supports_theme_json = wp_theme_has_theme_json(); if ( empty( $types ) && ! $supports_theme_json ) { $types = array( 'variables', 'presets', 'base-layout-styles' ); } elseif ( empty( $types ) ) { $types = array( 'variables', 'styles', 'presets' ); } $styles_variables = ''; if ( in_array( 'variables', $types, true ) ) { $origins = array( 'default', 'theme', 'custom' ); $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins ); $types = array_diff( $types, array( 'variables' ) ); } $styles_rest = ''; if ( ! empty( $types ) ) { $origins = array( 'default', 'theme', 'custom' ); if ( ! $supports_theme_json ) { $origins = array( 'default' ); } $styles_rest = $tree->get_stylesheet( $types, $origins ); } $stylesheet = $styles_variables . $styles_rest; if ( $can_use_cached ) { wp_cache_set( $cache_key, $stylesheet, $cache_group ); } return $stylesheet; } function wp_get_global_styles_svg_filters() { $can_use_cached = ( ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && ! is_admin() ); $transient_name = 'global_styles_svg_filters_' . get_stylesheet(); if ( $can_use_cached ) { $cached = get_transient( $transient_name ); if ( $cached ) { return $cached; } } $supports_theme_json = wp_theme_has_theme_json(); $origins = array( 'default', 'theme', 'custom' ); if ( ! $supports_theme_json ) { $origins = array( 'default' ); } $tree = WP_Theme_JSON_Resolver::get_merged_data(); $svgs = $tree->get_svg_filters( $origins ); if ( $can_use_cached ) { set_transient( $transient_name, $svgs, MINUTE_IN_SECONDS ); } return $svgs; } function wp_add_global_styles_for_blocks() { $tree = WP_Theme_JSON_Resolver::get_merged_data(); $block_nodes = $tree->get_styles_block_nodes(); foreach ( $block_nodes as $metadata ) { $block_css = $tree->get_styles_for_block( $metadata ); if ( ! wp_should_load_separate_core_block_assets() ) { wp_add_inline_style( 'global-styles', $block_css ); continue; } $stylesheet_handle = 'global-styles'; if ( isset( $metadata['name'] ) ) { if ( str_starts_with( $metadata['name'], 'core/' ) ) { $block_name = str_replace( 'core/', '', $metadata['name'] ); $stylesheet_handle = 'wp-block-' . $block_name; } wp_add_inline_style( $stylesheet_handle, $block_css ); } if ( ! isset( $metadata['name'] ) && ! empty( $metadata['path'] ) ) { $result = array_values( array_filter( $metadata['path'], function ( $item ) { if ( strpos( $item, 'core/' ) !== false ) { return true; } return false; } ) ); if ( isset( $result[0] ) ) { if ( str_starts_with( $result[0], 'core/' ) ) { $block_name = str_replace( 'core/', '', $result[0] ); $stylesheet_handle = 'wp-block-' . $block_name; } wp_add_inline_style( $stylesheet_handle, $block_css ); } } } } function wp_theme_has_theme_json() { static $theme_has_support = null; if ( null !== $theme_has_support && ! WP_DEBUG && ! ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) ) { return $theme_has_support; } $theme_has_support = is_readable( get_stylesheet_directory() . '/theme.json' ); if ( ! $theme_has_support ) { $theme_has_support = is_readable( get_template_directory() . '/theme.json' ); } return $theme_has_support; } function wp_clean_theme_json_cache() { wp_cache_delete( 'wp_get_global_stylesheet', 'theme_json' ); wp_cache_delete( 'wp_get_global_settings_custom', 'theme_json' ); wp_cache_delete( 'wp_get_global_settings_theme', 'theme_json' ); WP_Theme_JSON_Resolver::clean_cached_data(); } <?php function _wp_http_get_object() { static $http = null; if ( is_null( $http ) ) { $http = new WP_Http(); } return $http; } function wp_safe_remote_request( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->request( $url, $args ); } function wp_safe_remote_get( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->get( $url, $args ); } function wp_safe_remote_post( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->post( $url, $args ); } function wp_safe_remote_head( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->head( $url, $args ); } function wp_remote_request( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->request( $url, $args ); } function wp_remote_get( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->get( $url, $args ); } function wp_remote_post( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->post( $url, $args ); } function wp_remote_head( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->head( $url, $args ); } function wp_remote_retrieve_headers( $response ) { if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) { return array(); } return $response['headers']; } function wp_remote_retrieve_header( $response, $header ) { if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) { return ''; } if ( isset( $response['headers'][ $header ] ) ) { return $response['headers'][ $header ]; } return ''; } function wp_remote_retrieve_response_code( $response ) { if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) { return ''; } return $response['response']['code']; } function wp_remote_retrieve_response_message( $response ) { if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) { return ''; } return $response['response']['message']; } function wp_remote_retrieve_body( $response ) { if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) { return ''; } return $response['body']; } function wp_remote_retrieve_cookies( $response ) { if ( is_wp_error( $response ) || empty( $response['cookies'] ) ) { return array(); } return $response['cookies']; } function wp_remote_retrieve_cookie( $response, $name ) { $cookies = wp_remote_retrieve_cookies( $response ); if ( empty( $cookies ) ) { return ''; } foreach ( $cookies as $cookie ) { if ( $cookie->name === $name ) { return $cookie; } } return ''; } function wp_remote_retrieve_cookie_value( $response, $name ) { $cookie = wp_remote_retrieve_cookie( $response, $name ); if ( ! is_a( $cookie, 'WP_Http_Cookie' ) ) { return ''; } return $cookie->value; } function wp_http_supports( $capabilities = array(), $url = null ) { $http = _wp_http_get_object(); $capabilities = wp_parse_args( $capabilities ); $count = count( $capabilities ); if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) == $count ) { $capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) ); } if ( $url && ! isset( $capabilities['ssl'] ) ) { $scheme = parse_url( $url, PHP_URL_SCHEME ); if ( 'https' === $scheme || 'ssl' === $scheme ) { $capabilities['ssl'] = true; } } return (bool) $http->_get_first_available_transport( $capabilities ); } function get_http_origin() { $origin = ''; if ( ! empty( $_SERVER['HTTP_ORIGIN'] ) ) { $origin = $_SERVER['HTTP_ORIGIN']; } return apply_filters( 'http_origin', $origin ); } function get_allowed_http_origins() { $admin_origin = parse_url( admin_url() ); $home_origin = parse_url( home_url() ); $allowed_origins = array_unique( array( 'http://' . $admin_origin['host'], 'https://' . $admin_origin['host'], 'http://' . $home_origin['host'], 'https://' . $home_origin['host'], ) ); return apply_filters( 'allowed_http_origins', $allowed_origins ); } function is_allowed_http_origin( $origin = null ) { $origin_arg = $origin; if ( null === $origin ) { $origin = get_http_origin(); } if ( $origin && ! in_array( $origin, get_allowed_http_origins(), true ) ) { $origin = ''; } return apply_filters( 'allowed_http_origin', $origin, $origin_arg ); } function send_origin_headers() { $origin = get_http_origin(); if ( is_allowed_http_origin( $origin ) ) { header( 'Access-Control-Allow-Origin: ' . $origin ); header( 'Access-Control-Allow-Credentials: true' ); if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) { exit; } return $origin; } if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) { status_header( 403 ); exit; } return false; } function wp_http_validate_url( $url ) { if ( ! is_string( $url ) || '' === $url || is_numeric( $url ) ) { return false; } $original_url = $url; $url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) ); if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) ) { return false; } $parsed_url = parse_url( $url ); if ( ! $parsed_url || empty( $parsed_url['host'] ) ) { return false; } if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) ) { return false; } if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) ) { return false; } $parsed_home = parse_url( get_option( 'home' ) ); $same_host = isset( $parsed_home['host'] ) && strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ); $host = trim( $parsed_url['host'], '.' ); if ( ! $same_host ) { if ( preg_match( '#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', $host ) ) { $ip = $host; } else { $ip = gethostbyname( $host ); if ( $ip === $host ) { return false; } } if ( $ip ) { $parts = array_map( 'intval', explode( '.', $ip ) ); if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0] || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] ) || ( 192 === $parts[0] && 168 === $parts[1] ) ) { if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) ) { return false; } } } } if ( empty( $parsed_url['port'] ) ) { return $url; } $port = $parsed_url['port']; $allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ); if ( is_array( $allowed_ports ) && in_array( $port, $allowed_ports, true ) ) { return $url; } if ( $parsed_home && $same_host && isset( $parsed_home['port'] ) && $parsed_home['port'] === $port ) { return $url; } return false; } function allowed_http_request_hosts( $is_external, $host ) { if ( ! $is_external && wp_validate_redirect( 'http://' . $host ) ) { $is_external = true; } return $is_external; } function ms_allowed_http_request_hosts( $is_external, $host ) { global $wpdb; static $queried = array(); if ( $is_external ) { return $is_external; } if ( get_network()->domain === $host ) { return true; } if ( isset( $queried[ $host ] ) ) { return $queried[ $host ]; } $queried[ $host ] = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host ) ); return $queried[ $host ]; } function wp_parse_url( $url, $component = -1 ) { $to_unset = array(); $url = (string) $url; if ( '//' === substr( $url, 0, 2 ) ) { $to_unset[] = 'scheme'; $url = 'placeholder:' . $url; } elseif ( '/' === substr( $url, 0, 1 ) ) { $to_unset[] = 'scheme'; $to_unset[] = 'host'; $url = 'placeholder://placeholder' . $url; } $parts = parse_url( $url ); if ( false === $parts ) { return $parts; } foreach ( $to_unset as $key ) { unset( $parts[ $key ] ); } return _get_component_from_parsed_url_array( $parts, $component ); } function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) { if ( -1 === $component ) { return $url_parts; } $key = _wp_translate_php_url_constant_to_key( $component ); if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) { return $url_parts[ $key ]; } else { return null; } } function _wp_translate_php_url_constant_to_key( $constant ) { $translation = array( PHP_URL_SCHEME => 'scheme', PHP_URL_HOST => 'host', PHP_URL_PORT => 'port', PHP_URL_USER => 'user', PHP_URL_PASS => 'pass', PHP_URL_PATH => 'path', PHP_URL_QUERY => 'query', PHP_URL_FRAGMENT => 'fragment', ); if ( isset( $translation[ $constant ] ) ) { return $translation[ $constant ]; } else { return false; } } <?php function wp_is_using_https() { if ( ! wp_is_home_url_using_https() ) { return false; } return wp_is_site_url_using_https(); } function wp_is_home_url_using_https() { return 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME ); } function wp_is_site_url_using_https() { $site_url = apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null ); return 'https' === wp_parse_url( $site_url, PHP_URL_SCHEME ); } function wp_is_https_supported() { $https_detection_errors = get_option( 'https_detection_errors' ); if ( false === $https_detection_errors ) { wp_update_https_detection_errors(); $https_detection_errors = get_option( 'https_detection_errors' ); } return empty( $https_detection_errors ); } function wp_update_https_detection_errors() { $support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null ); if ( is_wp_error( $support_errors ) ) { update_option( 'https_detection_errors', $support_errors->errors ); return; } $support_errors = new WP_Error(); $response = wp_remote_request( home_url( '/', 'https' ), array( 'headers' => array( 'Cache-Control' => 'no-cache', ), 'sslverify' => true, ) ); if ( is_wp_error( $response ) ) { $unverified_response = wp_remote_request( home_url( '/', 'https' ), array( 'headers' => array( 'Cache-Control' => 'no-cache', ), 'sslverify' => false, ) ); if ( is_wp_error( $unverified_response ) ) { $support_errors->add( 'https_request_failed', __( 'HTTPS request failed.' ) ); } else { $support_errors->add( 'ssl_verification_failed', __( 'SSL verification failed.' ) ); } $response = $unverified_response; } if ( ! is_wp_error( $response ) ) { if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { $support_errors->add( 'bad_response_code', wp_remote_retrieve_response_message( $response ) ); } elseif ( false === wp_is_local_html_output( wp_remote_retrieve_body( $response ) ) ) { $support_errors->add( 'bad_response_source', __( 'It looks like the response did not come from this site.' ) ); } } update_option( 'https_detection_errors', $support_errors->errors ); } function wp_schedule_https_detection() { if ( wp_installing() ) { return; } if ( ! wp_next_scheduled( 'wp_https_detection' ) ) { wp_schedule_event( time(), 'twicedaily', 'wp_https_detection' ); } } function wp_cron_conditionally_prevent_sslverify( $request ) { if ( 'https' === wp_parse_url( $request['url'], PHP_URL_SCHEME ) ) { $request['args']['sslverify'] = false; } return $request; } function wp_is_local_html_output( $html ) { if ( has_action( 'wp_head', 'rsd_link' ) ) { $pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) ); return false !== strpos( $html, $pattern ); } if ( has_action( 'wp_head', 'wlwmanifest_link' ) ) { $pattern = preg_replace( '#^https?:(?=//)#', '', includes_url( 'wlwmanifest.xml' ) ); return false !== strpos( $html, $pattern ); } if ( has_action( 'wp_head', 'rest_output_link_wp_head' ) ) { $pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( get_rest_url() ) ); return false !== strpos( $html, $pattern ); } return null; } <?php function wp_should_replace_insecure_home_url() { $should_replace_insecure_home_url = wp_is_using_https() && get_option( 'https_migration_required' ) && wp_parse_url( home_url(), PHP_URL_HOST ) === wp_parse_url( site_url(), PHP_URL_HOST ); return apply_filters( 'wp_should_replace_insecure_home_url', $should_replace_insecure_home_url ); } function wp_replace_insecure_home_url( $content ) { if ( ! wp_should_replace_insecure_home_url() ) { return $content; } $https_url = home_url( '', 'https' ); $http_url = str_replace( 'https://', 'http://', $https_url ); $escaped_https_url = str_replace( '/', '\/', $https_url ); $escaped_http_url = str_replace( '/', '\/', $http_url ); return str_replace( array( $http_url, $escaped_http_url, ), array( $https_url, $escaped_https_url, ), $content ); } function wp_update_urls_to_https() { $orig_home = get_option( 'home' ); $orig_siteurl = get_option( 'siteurl' ); $home = str_replace( 'http://', 'https://', $orig_home ); $siteurl = str_replace( 'http://', 'https://', $orig_siteurl ); update_option( 'home', $home ); update_option( 'siteurl', $siteurl ); if ( ! wp_is_using_https() ) { update_option( 'home', $orig_home ); update_option( 'siteurl', $orig_siteurl ); return false; } return true; } function wp_update_https_migration_required( $old_url, $new_url ) { if ( wp_installing() ) { return; } if ( untrailingslashit( (string) $old_url ) !== str_replace( 'https://', 'http://', untrailingslashit( (string) $new_url ) ) ) { delete_option( 'https_migration_required' ); return; } $https_migration_required = get_option( 'fresh_site' ) ? false : true; update_option( 'https_migration_required', $https_migration_required ); } <?php error_reporting( 0 ); $basepath = __DIR__; function get_file( $path ) { if ( function_exists( 'realpath' ) ) { $path = realpath( $path ); } if ( ! $path || ! @is_file( $path ) ) { return false; } return @file_get_contents( $path ); } $expires_offset = 31536000; header( 'Content-Type: application/javascript; charset=UTF-8' ); header( 'Vary: Accept-Encoding' ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); header( "Cache-Control: public, max-age=$expires_offset" ); $file = get_file( $basepath . '/wp-tinymce.js' ); if ( isset( $_GET['c'] ) && $file ) { echo $file; } else { echo get_file( $basepath . '/tinymce.min.js' ); echo get_file( $basepath . '/plugins/compat3x/plugin.min.js' ); } exit; /*! This file is auto-generated */ !function(e,a,t){var n,r,o,i=a.createElement("canvas"),p=i.getContext&&i.getContext("2d");function s(e,t){var a=String.fromCharCode,e=(p.clearRect(0,0,i.width,i.height),p.fillText(a.apply(this,e),0,0),i.toDataURL());return p.clearRect(0,0,i.width,i.height),p.fillText(a.apply(this,t),0,0),e===i.toDataURL()}function c(e){var t=a.createElement("script");t.src=e,t.defer=t.type="text/javascript",a.getElementsByTagName("head")[0].appendChild(t)}for(o=Array("flag","emoji"),t.supports={everything:!0,everythingExceptFlag:!0},r=0;r<o.length;r++)t.supports[o[r]]=function(e){if(p&&p.fillText)switch(p.textBaseline="top",p.font="600 32px Arial",e){case"flag":return s([127987,65039,8205,9895,65039],[127987,65039,8203,9895,65039])?!1:!s([55356,56826,55356,56819],[55356,56826,8203,55356,56819])&&!s([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]);case"emoji":return!s([129777,127995,8205,129778,127999],[129777,127995,8203,129778,127999])}return!1}(o[r]),t.supports.everything=t.supports.everything&&t.supports[o[r]],"flag"!==o[r]&&(t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&t.supports[o[r]]);t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&!t.supports.flag,t.DOMReady=!1,t.readyCallback=function(){t.DOMReady=!0},t.supports.everything||(n=function(){t.readyCallback()},a.addEventListener?(a.addEventListener("DOMContentLoaded",n,!1),e.addEventListener("load",n,!1)):(e.attachEvent("onload",n),a.attachEvent("onreadystatechange",function(){"complete"===a.readyState&&t.readyCallback()})),(e=t.source||{}).concatemoji?c(e.concatemoji):e.wpemoji&&e.twemoji&&(c(e.twemoji),c(e.wpemoji)))}(window,document,window._wpemojiSettings);<?php - if ( ! defined( 'CUSTOM_TAGS' ) ) { define( 'CUSTOM_TAGS', false ); } global $allowedposttags, $allowedtags, $allowedentitynames, $allowedxmlentitynames; if ( ! CUSTOM_TAGS ) { $allowedposttags = array( 'address' => array(), 'a' => array( 'href' => true, 'rel' => true, 'rev' => true, 'name' => true, 'target' => true, 'download' => array( 'valueless' => 'y', ), ), 'abbr' => array(), 'acronym' => array(), 'area' => array( 'alt' => true, 'coords' => true, 'href' => true, 'nohref' => true, 'shape' => true, 'target' => true, ), 'article' => array( 'align' => true, ), 'aside' => array( 'align' => true, ), 'audio' => array( 'autoplay' => true, 'controls' => true, 'loop' => true, 'muted' => true, 'preload' => true, 'src' => true, ), 'b' => array(), 'bdo' => array(), 'big' => array(), 'blockquote' => array( 'cite' => true, ), 'br' => array(), 'button' => array( 'disabled' => true, 'name' => true, 'type' => true, 'value' => true, ), 'caption' => array( 'align' => true, ), 'cite' => array(), 'code' => array(), 'col' => array( 'align' => true, 'char' => true, 'charoff' => true, 'span' => true, 'valign' => true, 'width' => true, ), 'colgroup' => array( 'align' => true, 'char' => true, 'charoff' => true, 'span' => true, 'valign' => true, 'width' => true, ), 'del' => array( 'datetime' => true, ), 'dd' => array(), 'dfn' => array(), 'details' => array( 'align' => true, 'open' => true, ), 'div' => array( 'align' => true, ), 'dl' => array(), 'dt' => array(), 'em' => array(), 'fieldset' => array(), 'figure' => array( 'align' => true, ), 'figcaption' => array( 'align' => true, ), 'font' => array( 'color' => true, 'face' => true, 'size' => true, ), 'footer' => array( 'align' => true, ), 'h1' => array( 'align' => true, ), 'h2' => array( 'align' => true, ), 'h3' => array( 'align' => true, ), 'h4' => array( 'align' => true, ), 'h5' => array( 'align' => true, ), 'h6' => array( 'align' => true, ), 'header' => array( 'align' => true, ), 'hgroup' => array( 'align' => true, ), 'hr' => array( 'align' => true, 'noshade' => true, 'size' => true, 'width' => true, ), 'i' => array(), 'img' => array( 'alt' => true, 'align' => true, 'border' => true, 'height' => true, 'hspace' => true, 'loading' => true, 'longdesc' => true, 'vspace' => true, 'src' => true, 'usemap' => true, 'width' => true, ), 'ins' => array( 'datetime' => true, 'cite' => true, ), 'kbd' => array(), 'label' => array( 'for' => true, ), 'legend' => array( 'align' => true, ), 'li' => array( 'align' => true, 'value' => true, ), 'main' => array( 'align' => true, ), 'map' => array( 'name' => true, ), 'mark' => array(), 'menu' => array( 'type' => true, ), 'nav' => array( 'align' => true, ), 'object' => array( 'data' => array( 'required' => true, 'value_callback' => '_wp_kses_allow_pdf_objects', ), 'type' => array( 'required' => true, 'values' => array( 'application/pdf' ), ), ), 'p' => array( 'align' => true, ), 'pre' => array( 'width' => true, ), 'q' => array( 'cite' => true, ), 'rb' => array(), 'rp' => array(), 'rt' => array(), 'rtc' => array(), 'ruby' => array(), 's' => array(), 'samp' => array(), 'span' => array( 'align' => true, ), 'section' => array( 'align' => true, ), 'small' => array(), 'strike' => array(), 'strong' => array(), 'sub' => array(), 'summary' => array( 'align' => true, ), 'sup' => array(), 'table' => array( 'align' => true, 'bgcolor' => true, 'border' => true, 'cellpadding' => true, 'cellspacing' => true, 'rules' => true, 'summary' => true, 'width' => true, ), 'tbody' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'td' => array( 'abbr' => true, 'align' => true, 'axis' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'colspan' => true, 'headers' => true, 'height' => true, 'nowrap' => true, 'rowspan' => true, 'scope' => true, 'valign' => true, 'width' => true, ), 'textarea' => array( 'cols' => true, 'rows' => true, 'disabled' => true, 'name' => true, 'readonly' => true, ), 'tfoot' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'th' => array( 'abbr' => true, 'align' => true, 'axis' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'colspan' => true, 'headers' => true, 'height' => true, 'nowrap' => true, 'rowspan' => true, 'scope' => true, 'valign' => true, 'width' => true, ), 'thead' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'title' => array(), 'tr' => array( 'align' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'track' => array( 'default' => true, 'kind' => true, 'label' => true, 'src' => true, 'srclang' => true, ), 'tt' => array(), 'u' => array(), 'ul' => array( 'type' => true, ), 'ol' => array( 'start' => true, 'type' => true, 'reversed' => true, ), 'var' => array(), 'video' => array( 'autoplay' => true, 'controls' => true, 'height' => true, 'loop' => true, 'muted' => true, 'playsinline' => true, 'poster' => true, 'preload' => true, 'src' => true, 'width' => true, ), ); $allowedtags = array( 'a' => array( 'href' => true, 'title' => true, ), 'abbr' => array( 'title' => true, ), 'acronym' => array( 'title' => true, ), 'b' => array(), 'blockquote' => array( 'cite' => true, ), 'cite' => array(), 'code' => array(), 'del' => array( 'datetime' => true, ), 'em' => array(), 'i' => array(), 'q' => array( 'cite' => true, ), 's' => array(), 'strike' => array(), 'strong' => array(), ); $allowedentitynames = array( 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', 'radic', 'prop', 'infin', 'ang', 'and', 'or', 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', 'sup1', 'sup2', 'sup3', 'frac14', 'frac12', 'frac34', 'there4', ); $allowedxmlentitynames = array( 'amp', 'lt', 'gt', 'apos', 'quot', ); $allowedposttags = array_map( '_wp_add_global_attributes', $allowedposttags ); } else { $required_kses_globals = array( 'allowedposttags', 'allowedtags', 'allowedentitynames', 'allowedxmlentitynames', ); $missing_kses_globals = array(); foreach ( $required_kses_globals as $global_name ) { if ( ! isset( $GLOBALS[ $global_name ] ) || ! is_array( $GLOBALS[ $global_name ] ) ) { $missing_kses_globals[] = '<code>$' . $global_name . '</code>'; } } if ( $missing_kses_globals ) { _doing_it_wrong( 'wp_kses_allowed_html', sprintf( __( 'When using the %1$s constant, make sure to set these globals to an array: %2$s.' ), '<code>CUSTOM_TAGS</code>', implode( ', ', $missing_kses_globals ) ), '6.2.0' ); } $allowedtags = wp_kses_array_lc( $allowedtags ); $allowedposttags = wp_kses_array_lc( $allowedposttags ); } function wp_kses( $content, $allowed_html, $allowed_protocols = array() ) { if ( empty( $allowed_protocols ) ) { $allowed_protocols = wp_allowed_protocols(); } $content = wp_kses_no_null( $content, array( 'slash_zero' => 'keep' ) ); $content = wp_kses_normalize_entities( $content ); $content = wp_kses_hook( $content, $allowed_html, $allowed_protocols ); return wp_kses_split( $content, $allowed_html, $allowed_protocols ); } function wp_kses_one_attr( $attr, $element ) { $uris = wp_kses_uri_attributes(); $allowed_html = wp_kses_allowed_html( 'post' ); $allowed_protocols = wp_allowed_protocols(); $attr = wp_kses_no_null( $attr, array( 'slash_zero' => 'keep' ) ); $matches = array(); preg_match( '/^\s*/', $attr, $matches ); $lead = $matches[0]; preg_match( '/\s*$/', $attr, $matches ); $trail = $matches[0]; if ( empty( $trail ) ) { $attr = substr( $attr, strlen( $lead ) ); } else { $attr = substr( $attr, strlen( $lead ), -strlen( $trail ) ); } $split = preg_split( '/\s*=\s*/', $attr, 2 ); $name = $split[0]; if ( count( $split ) == 2 ) { $value = $split[1]; if ( '' === $value ) { $quote = ''; } else { $quote = $value[0]; } if ( '"' === $quote || "'" === $quote ) { if ( substr( $value, -1 ) != $quote ) { return ''; } $value = substr( $value, 1, -1 ); } else { $quote = '"'; } $value = esc_attr( $value ); if ( in_array( strtolower( $name ), $uris, true ) ) { $value = wp_kses_bad_protocol( $value, $allowed_protocols ); } $attr = "$name=$quote$value$quote"; $vless = 'n'; } else { $value = ''; $vless = 'y'; } wp_kses_attr_check( $name, $value, $attr, $vless, $element, $allowed_html ); return $lead . $attr . $trail; } function wp_kses_allowed_html( $context = '' ) { global $allowedposttags, $allowedtags, $allowedentitynames; if ( is_array( $context ) ) { $html = $context; $context = 'explicit'; return apply_filters( 'wp_kses_allowed_html', $html, $context ); } switch ( $context ) { case 'post': $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context ); if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) { $tags = $allowedposttags; $tags['form'] = array( 'action' => true, 'accept' => true, 'accept-charset' => true, 'enctype' => true, 'method' => true, 'name' => true, 'target' => true, ); $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context ); } return $tags; case 'user_description': case 'pre_user_description': $tags = $allowedtags; $tags['a']['rel'] = true; return apply_filters( 'wp_kses_allowed_html', $tags, $context ); case 'strip': return apply_filters( 'wp_kses_allowed_html', array(), $context ); case 'entities': return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context ); case 'data': default: return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context ); } } function wp_kses_hook( $content, $allowed_html, $allowed_protocols ) { return apply_filters( 'pre_kses', $content, $allowed_html, $allowed_protocols ); } function wp_kses_version() { return '0.2.2'; } function wp_kses_split( $content, $allowed_html, $allowed_protocols ) { global $pass_allowed_html, $pass_allowed_protocols; $pass_allowed_html = $allowed_html; $pass_allowed_protocols = $allowed_protocols; return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $content ); } function wp_kses_uri_attributes() { $uri_attributes = array( 'action', 'archive', 'background', 'cite', 'classid', 'codebase', 'data', 'formaction', 'href', 'icon', 'longdesc', 'manifest', 'poster', 'profile', 'src', 'usemap', 'xmlns', ); $uri_attributes = apply_filters( 'wp_kses_uri_attributes', $uri_attributes ); return $uri_attributes; } function _wp_kses_split_callback( $matches ) { global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2( $matches[0], $pass_allowed_html, $pass_allowed_protocols ); } function wp_kses_split2( $content, $allowed_html, $allowed_protocols ) { $content = wp_kses_stripslashes( $content ); if ( '<' !== substr( $content, 0, 1 ) ) { return '>'; } if ( '<!--' === substr( $content, 0, 4 ) ) { $content = str_replace( array( '<!--', '-->' ), '', $content ); while ( ( $newstring = wp_kses( $content, $allowed_html, $allowed_protocols ) ) != $content ) { $content = $newstring; } if ( '' === $content ) { return ''; } $content = preg_replace( '/--+/', '-', $content ); $content = preg_replace( '/-$/', '', $content ); return "<!--{$content}-->"; } if ( ! preg_match( '%^<\s*(/\s*)?([a-zA-Z0-9-]+)([^>]*)>?$%', $content, $matches ) ) { return ''; } $slash = trim( $matches[1] ); $elem = $matches[2]; $attrlist = $matches[3]; if ( ! is_array( $allowed_html ) ) { $allowed_html = wp_kses_allowed_html( $allowed_html ); } if ( ! isset( $allowed_html[ strtolower( $elem ) ] ) ) { return ''; } if ( '' !== $slash ) { return "</$elem>"; } return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); } function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { if ( ! is_array( $allowed_html ) ) { $allowed_html = wp_kses_allowed_html( $allowed_html ); } $xhtml_slash = ''; if ( preg_match( '%\s*/\s*$%', $attr ) ) { $xhtml_slash = ' /'; } $element_low = strtolower( $element ); if ( empty( $allowed_html[ $element_low ] ) || true === $allowed_html[ $element_low ] ) { return "<$element$xhtml_slash>"; } $attrarr = wp_kses_hair( $attr, $allowed_protocols ); $required_attrs = array_filter( $allowed_html[ $element_low ], function( $required_attr_limits ) { return isset( $required_attr_limits['required'] ) && true === $required_attr_limits['required']; } ); $stripped_tag = ''; if ( empty( $xhtml_slash ) ) { $stripped_tag = "<$element>"; } $attr2 = ''; foreach ( $attrarr as $arreach ) { $required = isset( $required_attrs[ strtolower( $arreach['name'] ) ] ); if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { $attr2 .= ' ' . $arreach['whole']; if ( $required ) { unset( $required_attrs[ strtolower( $arreach['name'] ) ] ); } } elseif ( $required ) { return $stripped_tag; } } if ( ! empty( $required_attrs ) ) { return $stripped_tag; } $attr2 = preg_replace( '/[<>]/', '', $attr2 ); return "<$element$attr2$xhtml_slash>"; } function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) { $name_low = strtolower( $name ); $element_low = strtolower( $element ); if ( ! isset( $allowed_html[ $element_low ] ) ) { $name = ''; $value = ''; $whole = ''; return false; } $allowed_attr = $allowed_html[ $element_low ]; if ( ! isset( $allowed_attr[ $name_low ] ) || '' === $allowed_attr[ $name_low ] ) { if ( strpos( $name_low, 'data-' ) === 0 && ! empty( $allowed_attr['data-*'] ) && preg_match( '/^data(?:-[a-z0-9_]+)+$/', $name_low, $match ) ) { $allowed_attr[ $match[0] ] = $allowed_attr['data-*']; } else { $name = ''; $value = ''; $whole = ''; return false; } } if ( 'style' === $name_low ) { $new_value = safecss_filter_attr( $value ); if ( empty( $new_value ) ) { $name = ''; $value = ''; $whole = ''; return false; } $whole = str_replace( $value, $new_value, $whole ); $value = $new_value; } if ( is_array( $allowed_attr[ $name_low ] ) ) { foreach ( $allowed_attr[ $name_low ] as $currkey => $currval ) { if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) { $name = ''; $value = ''; $whole = ''; return false; } } } return true; } function wp_kses_hair( $attr, $allowed_protocols ) { $attrarr = array(); $mode = 0; $attrname = ''; $uris = wp_kses_uri_attributes(); while ( strlen( $attr ) != 0 ) { $working = 0; switch ( $mode ) { case 0: if ( preg_match( '/^([_a-zA-Z][-_a-zA-Z0-9:.]*)/', $attr, $match ) ) { $attrname = $match[1]; $working = 1; $mode = 1; $attr = preg_replace( '/^[_a-zA-Z][-_a-zA-Z0-9:.]*/', '', $attr ); } break; case 1: if ( preg_match( '/^\s*=\s*/', $attr ) ) { $working = 1; $mode = 2; $attr = preg_replace( '/^\s*=\s*/', '', $attr ); break; } if ( preg_match( '/^\s+/', $attr ) ) { $working = 1; $mode = 0; if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y', ); } $attr = preg_replace( '/^\s+/', '', $attr ); } break; case 2: if ( preg_match( '%^"([^"]*)"(\s+|/?$)%', $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( '/^"[^"]*"(\s+|$)/', '', $attr ); break; } if ( preg_match( "%^'([^']*)'(\s+|/?$)%", $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( "/^'[^']*'(\s+|$)/", '', $attr ); break; } if ( preg_match( "%^([^\s\"']+)(\s+|/?$)%", $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( "%^[^\s\"']+(\s+|$)%", '', $attr ); } break; } if ( 0 == $working ) { $attr = wp_kses_html_error( $attr ); $mode = 0; } } if ( 1 == $mode && false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y', ); } return $attrarr; } function wp_kses_attr_parse( $element ) { $valid = preg_match( '%^(<\s*)(/\s*)?([a-zA-Z0-9]+\s*)([^>]*)(>?)$%', $element, $matches ); if ( 1 !== $valid ) { return false; } $begin = $matches[1]; $slash = $matches[2]; $elname = $matches[3]; $attr = $matches[4]; $end = $matches[5]; if ( '' !== $slash ) { return false; } if ( 1 === preg_match( '%\s*/\s*$%', $attr, $matches ) ) { $xhtml_slash = $matches[0]; $attr = substr( $attr, 0, -strlen( $xhtml_slash ) ); } else { $xhtml_slash = ''; } $attrarr = wp_kses_hair_parse( $attr ); if ( false === $attrarr ) { return false; } array_unshift( $attrarr, $begin . $slash . $elname ); array_push( $attrarr, $xhtml_slash . $end ); return $attrarr; } function wp_kses_hair_parse( $attr ) { if ( '' === $attr ) { return array(); } $regex = '(?:' . '[_a-zA-Z][-_a-zA-Z0-9:.]*' . '|' . '\[\[?[^\[\]]+\]\]?' . ')' . '(?:' . '\s*=\s*' . '(?:' . '"[^"]*"' . '|' . "'[^']*'" . '|' . '[^\s"\']+' . '(?:\s|$)' . ')' . '|' . '(?:\s|$)' . ')' . '\s*'; $validation = "%^($regex)+$%"; $extraction = "%$regex%"; if ( 1 === preg_match( $validation, $attr ) ) { preg_match_all( $extraction, $attr, $attrarr ); return $attrarr[0]; } else { return false; } } function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { $ok = true; switch ( strtolower( $checkname ) ) { case 'maxlen': if ( strlen( $value ) > $checkvalue ) { $ok = false; } break; case 'minlen': if ( strlen( $value ) < $checkvalue ) { $ok = false; } break; case 'maxval': if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; } if ( $value > $checkvalue ) { $ok = false; } break; case 'minval': if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; } if ( $value < $checkvalue ) { $ok = false; } break; case 'valueless': if ( strtolower( $checkvalue ) != $vless ) { $ok = false; } break; case 'values': if ( false === array_search( strtolower( $value ), $checkvalue, true ) ) { $ok = false; } break; case 'value_callback': if ( ! call_user_func( $checkvalue, $value ) ) { $ok = false; } break; } return $ok; } function wp_kses_bad_protocol( $content, $allowed_protocols ) { $content = wp_kses_no_null( $content ); $iterations = 0; do { $original_content = $content; $content = wp_kses_bad_protocol_once( $content, $allowed_protocols ); } while ( $original_content != $content && ++$iterations < 6 ); if ( $original_content != $content ) { return ''; } return $content; } function wp_kses_no_null( $content, $options = null ) { if ( ! isset( $options['slash_zero'] ) ) { $options = array( 'slash_zero' => 'remove' ); } $content = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $content ); if ( 'remove' === $options['slash_zero'] ) { $content = preg_replace( '/\\\\+0+/', '', $content ); } return $content; } function wp_kses_stripslashes( $content ) { return preg_replace( '%\\\\"%', '"', $content ); } function wp_kses_array_lc( $inarray ) { $outarray = array(); foreach ( (array) $inarray as $inkey => $inval ) { $outkey = strtolower( $inkey ); $outarray[ $outkey ] = array(); foreach ( (array) $inval as $inkey2 => $inval2 ) { $outkey2 = strtolower( $inkey2 ); $outarray[ $outkey ][ $outkey2 ] = $inval2; } } return $outarray; } function wp_kses_html_error( $attr ) { return preg_replace( '/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $attr ); } function wp_kses_bad_protocol_once( $content, $allowed_protocols, $count = 1 ) { $content = preg_replace( '/(�*58(?![;0-9])|�*3a(?![;a-f0-9]))/i', '$1;', $content ); $content2 = preg_split( '/:|�*58;|�*3a;|:/i', $content, 2 ); if ( isset( $content2[1] ) && ! preg_match( '%/\?%', $content2[0] ) ) { $content = trim( $content2[1] ); $protocol = wp_kses_bad_protocol_once2( $content2[0], $allowed_protocols ); if ( 'feed:' === $protocol ) { if ( $count > 2 ) { return ''; } $content = wp_kses_bad_protocol_once( $content, $allowed_protocols, ++$count ); if ( empty( $content ) ) { return $content; } } $content = $protocol . $content; } return $content; } function wp_kses_bad_protocol_once2( $scheme, $allowed_protocols ) { $scheme = wp_kses_decode_entities( $scheme ); $scheme = preg_replace( '/\s/', '', $scheme ); $scheme = wp_kses_no_null( $scheme ); $scheme = strtolower( $scheme ); $allowed = false; foreach ( (array) $allowed_protocols as $one_protocol ) { if ( strtolower( $one_protocol ) == $scheme ) { $allowed = true; break; } } if ( $allowed ) { return "$scheme:"; } else { return ''; } } function wp_kses_normalize_entities( $content, $context = 'html' ) { $content = str_replace( '&', '&', $content ); if ( 'xml' === $context ) { $content = preg_replace_callback( '/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_xml_named_entities', $content ); } else { $content = preg_replace_callback( '/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $content ); } $content = preg_replace_callback( '/&#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $content ); $content = preg_replace_callback( '/&#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $content ); return $content; } function wp_kses_named_entities( $matches ) { global $allowedentitynames; if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; return ( ! in_array( $i, $allowedentitynames, true ) ) ? "&$i;" : "&$i;"; } function wp_kses_xml_named_entities( $matches ) { global $allowedentitynames, $allowedxmlentitynames; if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; if ( in_array( $i, $allowedxmlentitynames, true ) ) { return "&$i;"; } elseif ( in_array( $i, $allowedentitynames, true ) ) { return html_entity_decode( "&$i;", ENT_HTML5 ); } return "&$i;"; } function wp_kses_normalize_entities2( $matches ) { if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; if ( valid_unicode( $i ) ) { $i = str_pad( ltrim( $i, '0' ), 3, '0', STR_PAD_LEFT ); $i = "&#$i;"; } else { $i = "&#$i;"; } return $i; } function wp_kses_normalize_entities3( $matches ) { if ( empty( $matches[1] ) ) { return ''; } $hexchars = $matches[1]; return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&#x$hexchars;" : '&#x' . ltrim( $hexchars, '0' ) . ';'; } function valid_unicode( $i ) { return ( 0x9 == $i || 0xa == $i || 0xd == $i || ( 0x20 <= $i && $i <= 0xd7ff ) || ( 0xe000 <= $i && $i <= 0xfffd ) || ( 0x10000 <= $i && $i <= 0x10ffff ) ); } function wp_kses_decode_entities( $content ) { $content = preg_replace_callback( '/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $content ); $content = preg_replace_callback( '/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $content ); return $content; } function _wp_kses_decode_entities_chr( $matches ) { return chr( $matches[1] ); } function _wp_kses_decode_entities_chr_hexdec( $matches ) { return chr( hexdec( $matches[1] ) ); } function wp_filter_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), current_filter() ) ); } function wp_kses_data( $data ) { return wp_kses( $data, current_filter() ); } function wp_filter_post_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), 'post' ) ); } function wp_filter_global_styles_post( $data ) { $decoded_data = json_decode( wp_unslash( $data ), true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE === $json_decoding_error && is_array( $decoded_data ) && isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && $decoded_data['isGlobalStylesUserThemeJSON'] ) { unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data ); $data_to_encode['isGlobalStylesUserThemeJSON'] = true; return wp_slash( wp_json_encode( $data_to_encode ) ); } return $data; } function wp_kses_post( $data ) { return wp_kses( $data, 'post' ); } function wp_kses_post_deep( $data ) { return map_deep( $data, 'wp_kses_post' ); } function wp_filter_nohtml_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), 'strip' ) ); } function kses_init_filters() { add_filter( 'title_save_pre', 'wp_filter_kses' ); if ( current_user_can( 'unfiltered_html' ) ) { add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); } else { add_filter( 'pre_comment_content', 'wp_filter_kses' ); } add_filter( 'content_save_pre', 'wp_filter_global_styles_post', 9 ); add_filter( 'content_filtered_save_pre', 'wp_filter_global_styles_post', 9 ); add_filter( 'content_save_pre', 'wp_filter_post_kses' ); add_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); add_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); } function kses_remove_filters() { remove_filter( 'title_save_pre', 'wp_filter_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_kses' ); remove_filter( 'content_save_pre', 'wp_filter_global_styles_post', 9 ); remove_filter( 'content_filtered_save_pre', 'wp_filter_global_styles_post', 9 ); remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); remove_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); } function kses_init() { kses_remove_filters(); if ( ! current_user_can( 'unfiltered_html' ) ) { kses_init_filters(); } } function safecss_filter_attr( $css, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.8.1' ); } $css = wp_kses_no_null( $css ); $css = str_replace( array( "\n", "\r", "\t" ), '', $css ); $allowed_protocols = wp_allowed_protocols(); $css_array = explode( ';', trim( $css ) ); $allowed_attr = apply_filters( 'safe_style_css', array( 'background', 'background-color', 'background-image', 'background-position', 'background-size', 'background-attachment', 'background-blend-mode', 'border', 'border-radius', 'border-width', 'border-color', 'border-style', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-bottom', 'border-bottom-color', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-style', 'border-bottom-width', 'border-bottom-right-radius', 'border-bottom-left-radius', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-top', 'border-top-color', 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', 'border-top-width', 'border-top-left-radius', 'border-top-right-radius', 'border-spacing', 'border-collapse', 'caption-side', 'columns', 'column-count', 'column-fill', 'column-gap', 'column-rule', 'column-span', 'column-width', 'color', 'filter', 'font', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'letter-spacing', 'line-height', 'text-align', 'text-decoration', 'text-indent', 'text-transform', 'height', 'min-height', 'max-height', 'width', 'min-width', 'max-width', 'margin', 'margin-right', 'margin-bottom', 'margin-left', 'margin-top', 'margin-block-start', 'margin-block-end', 'margin-inline-start', 'margin-inline-end', 'padding', 'padding-right', 'padding-bottom', 'padding-left', 'padding-top', 'padding-block-start', 'padding-block-end', 'padding-inline-start', 'padding-inline-end', 'flex', 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', 'flex-wrap', 'gap', 'column-gap', 'row-gap', 'grid-template-columns', 'grid-auto-columns', 'grid-column-start', 'grid-column-end', 'grid-column-gap', 'grid-template-rows', 'grid-auto-rows', 'grid-row-start', 'grid-row-end', 'grid-row-gap', 'grid-gap', 'justify-content', 'justify-items', 'justify-self', 'align-content', 'align-items', 'align-self', 'clear', 'cursor', 'direction', 'float', 'list-style-type', 'object-fit', 'object-position', 'overflow', 'vertical-align', '--*', ) ); $css_url_data_types = array( 'background', 'background-image', 'cursor', 'list-style', 'list-style-image', ); $css_gradient_data_types = array( 'background', 'background-image', ); if ( empty( $allowed_attr ) ) { return $css; } $css = ''; foreach ( $css_array as $css_item ) { if ( '' === $css_item ) { continue; } $css_item = trim( $css_item ); $css_test_string = $css_item; $found = false; $url_attr = false; $gradient_attr = false; $is_custom_var = false; if ( strpos( $css_item, ':' ) === false ) { $found = true; } else { $parts = explode( ':', $css_item, 2 ); $css_selector = trim( $parts[0] ); if ( in_array( '--*', $allowed_attr, true ) && preg_match( '/^--[a-zA-Z0-9-_]+$/', $css_selector ) ) { $allowed_attr[] = $css_selector; $is_custom_var = true; } if ( in_array( $css_selector, $allowed_attr, true ) ) { $found = true; $url_attr = in_array( $css_selector, $css_url_data_types, true ); $gradient_attr = in_array( $css_selector, $css_gradient_data_types, true ); } if ( $is_custom_var ) { $css_value = trim( $parts[1] ); $url_attr = str_starts_with( $css_value, 'url(' ); $gradient_attr = str_contains( $css_value, '-gradient(' ); } } if ( $found && $url_attr ) { preg_match_all( '/url\([^)]+\)/', $parts[1], $url_matches ); foreach ( $url_matches[0] as $url_match ) { preg_match( '/^url\(\s*([\'\"]?)(.*)(\g1)\s*\)$/', $url_match, $url_pieces ); if ( empty( $url_pieces[2] ) ) { $found = false; break; } $url = trim( $url_pieces[2] ); if ( empty( $url ) || wp_kses_bad_protocol( $url, $allowed_protocols ) !== $url ) { $found = false; break; } else { $css_test_string = str_replace( $url_match, '', $css_test_string ); } } } if ( $found && $gradient_attr ) { $css_value = trim( $parts[1] ); if ( preg_match( '/^(repeating-)?(linear|radial|conic)-gradient\(([^()]|rgb[a]?\([^()]*\))*\)$/', $css_value ) ) { $css_test_string = str_replace( $css_value, '', $css_test_string ); } } if ( $found ) { $css_test_string = preg_replace( '/\b(?:var|calc|min|max|minmax|clamp)(\((?:[^()]|(?1))*\))/', '', $css_test_string ); $allow_css = ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ); $allow_css = apply_filters( 'safecss_filter_attr_allow_css', $allow_css, $css_test_string ); if ( $allow_css ) { if ( '' !== $css ) { $css .= ';'; } $css .= $css_item; } } } return $css; } function _wp_add_global_attributes( $value ) { $global_attributes = array( 'aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'data-*' => true, 'dir' => true, 'id' => true, 'lang' => true, 'style' => true, 'title' => true, 'role' => true, 'xml:lang' => true, ); if ( true === $value ) { $value = array(); } if ( is_array( $value ) ) { return array_merge( $value, $global_attributes ); } return $value; } function _wp_kses_allow_pdf_objects( $url ) { if ( str_contains( $url, '?' ) || str_contains( $url, '#' ) ) { return false; } if ( ! str_ends_with( $url, '.pdf' ) ) { return false; } $upload_info = wp_upload_dir( null, false ); $parsed_url = wp_parse_url( $upload_info['url'] ); $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : ''; $upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : ''; if ( str_starts_with( $url, "http://$upload_host$upload_port/" ) || str_starts_with( $url, "https://$upload_host$upload_port/" ) ) { return true; } return false; } <?php + if ( ! defined( 'CUSTOM_TAGS' ) ) { define( 'CUSTOM_TAGS', false ); } global $allowedposttags, $allowedtags, $allowedentitynames, $allowedxmlentitynames; if ( ! CUSTOM_TAGS ) { $allowedposttags = array( 'address' => array(), 'a' => array( 'href' => true, 'rel' => true, 'rev' => true, 'name' => true, 'target' => true, 'download' => array( 'valueless' => 'y', ), ), 'abbr' => array(), 'acronym' => array(), 'area' => array( 'alt' => true, 'coords' => true, 'href' => true, 'nohref' => true, 'shape' => true, 'target' => true, ), 'article' => array( 'align' => true, ), 'aside' => array( 'align' => true, ), 'audio' => array( 'autoplay' => true, 'controls' => true, 'loop' => true, 'muted' => true, 'preload' => true, 'src' => true, ), 'b' => array(), 'bdo' => array(), 'big' => array(), 'blockquote' => array( 'cite' => true, ), 'br' => array(), 'button' => array( 'disabled' => true, 'name' => true, 'type' => true, 'value' => true, ), 'caption' => array( 'align' => true, ), 'cite' => array(), 'code' => array(), 'col' => array( 'align' => true, 'char' => true, 'charoff' => true, 'span' => true, 'valign' => true, 'width' => true, ), 'colgroup' => array( 'align' => true, 'char' => true, 'charoff' => true, 'span' => true, 'valign' => true, 'width' => true, ), 'del' => array( 'datetime' => true, ), 'dd' => array(), 'dfn' => array(), 'details' => array( 'align' => true, 'open' => true, ), 'div' => array( 'align' => true, ), 'dl' => array(), 'dt' => array(), 'em' => array(), 'fieldset' => array(), 'figure' => array( 'align' => true, ), 'figcaption' => array( 'align' => true, ), 'font' => array( 'color' => true, 'face' => true, 'size' => true, ), 'footer' => array( 'align' => true, ), 'h1' => array( 'align' => true, ), 'h2' => array( 'align' => true, ), 'h3' => array( 'align' => true, ), 'h4' => array( 'align' => true, ), 'h5' => array( 'align' => true, ), 'h6' => array( 'align' => true, ), 'header' => array( 'align' => true, ), 'hgroup' => array( 'align' => true, ), 'hr' => array( 'align' => true, 'noshade' => true, 'size' => true, 'width' => true, ), 'i' => array(), 'img' => array( 'alt' => true, 'align' => true, 'border' => true, 'height' => true, 'hspace' => true, 'loading' => true, 'longdesc' => true, 'vspace' => true, 'src' => true, 'usemap' => true, 'width' => true, ), 'ins' => array( 'datetime' => true, 'cite' => true, ), 'kbd' => array(), 'label' => array( 'for' => true, ), 'legend' => array( 'align' => true, ), 'li' => array( 'align' => true, 'value' => true, ), 'main' => array( 'align' => true, ), 'map' => array( 'name' => true, ), 'mark' => array(), 'menu' => array( 'type' => true, ), 'nav' => array( 'align' => true, ), 'object' => array( 'data' => array( 'required' => true, 'value_callback' => '_wp_kses_allow_pdf_objects', ), 'type' => array( 'required' => true, 'values' => array( 'application/pdf' ), ), ), 'p' => array( 'align' => true, ), 'pre' => array( 'width' => true, ), 'q' => array( 'cite' => true, ), 'rb' => array(), 'rp' => array(), 'rt' => array(), 'rtc' => array(), 'ruby' => array(), 's' => array(), 'samp' => array(), 'span' => array( 'align' => true, ), 'section' => array( 'align' => true, ), 'small' => array(), 'strike' => array(), 'strong' => array(), 'sub' => array(), 'summary' => array( 'align' => true, ), 'sup' => array(), 'table' => array( 'align' => true, 'bgcolor' => true, 'border' => true, 'cellpadding' => true, 'cellspacing' => true, 'rules' => true, 'summary' => true, 'width' => true, ), 'tbody' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'td' => array( 'abbr' => true, 'align' => true, 'axis' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'colspan' => true, 'headers' => true, 'height' => true, 'nowrap' => true, 'rowspan' => true, 'scope' => true, 'valign' => true, 'width' => true, ), 'textarea' => array( 'cols' => true, 'rows' => true, 'disabled' => true, 'name' => true, 'readonly' => true, ), 'tfoot' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'th' => array( 'abbr' => true, 'align' => true, 'axis' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'colspan' => true, 'headers' => true, 'height' => true, 'nowrap' => true, 'rowspan' => true, 'scope' => true, 'valign' => true, 'width' => true, ), 'thead' => array( 'align' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'title' => array(), 'tr' => array( 'align' => true, 'bgcolor' => true, 'char' => true, 'charoff' => true, 'valign' => true, ), 'track' => array( 'default' => true, 'kind' => true, 'label' => true, 'src' => true, 'srclang' => true, ), 'tt' => array(), 'u' => array(), 'ul' => array( 'type' => true, ), 'ol' => array( 'start' => true, 'type' => true, 'reversed' => true, ), 'var' => array(), 'video' => array( 'autoplay' => true, 'controls' => true, 'height' => true, 'loop' => true, 'muted' => true, 'playsinline' => true, 'poster' => true, 'preload' => true, 'src' => true, 'width' => true, ), ); $allowedtags = array( 'a' => array( 'href' => true, 'title' => true, ), 'abbr' => array( 'title' => true, ), 'acronym' => array( 'title' => true, ), 'b' => array(), 'blockquote' => array( 'cite' => true, ), 'cite' => array(), 'code' => array(), 'del' => array( 'datetime' => true, ), 'em' => array(), 'i' => array(), 'q' => array( 'cite' => true, ), 's' => array(), 'strike' => array(), 'strong' => array(), ); $allowedentitynames = array( 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm', 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute', 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave', 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig', 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde', 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil', 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime', 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr', 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', 'radic', 'prop', 'infin', 'ang', 'and', 'or', 'cap', 'cup', 'int', 'sim', 'cong', 'asymp', 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams', 'sup1', 'sup2', 'sup3', 'frac14', 'frac12', 'frac34', 'there4', ); $allowedxmlentitynames = array( 'amp', 'lt', 'gt', 'apos', 'quot', ); $allowedposttags = array_map( '_wp_add_global_attributes', $allowedposttags ); } else { $required_kses_globals = array( 'allowedposttags', 'allowedtags', 'allowedentitynames', 'allowedxmlentitynames', ); $missing_kses_globals = array(); foreach ( $required_kses_globals as $global_name ) { if ( ! isset( $GLOBALS[ $global_name ] ) || ! is_array( $GLOBALS[ $global_name ] ) ) { $missing_kses_globals[] = '<code>$' . $global_name . '</code>'; } } if ( $missing_kses_globals ) { _doing_it_wrong( 'wp_kses_allowed_html', sprintf( __( 'When using the %1$s constant, make sure to set these globals to an array: %2$s.' ), '<code>CUSTOM_TAGS</code>', implode( ', ', $missing_kses_globals ) ), '6.2.0' ); } $allowedtags = wp_kses_array_lc( $allowedtags ); $allowedposttags = wp_kses_array_lc( $allowedposttags ); } function wp_kses( $content, $allowed_html, $allowed_protocols = array() ) { if ( empty( $allowed_protocols ) ) { $allowed_protocols = wp_allowed_protocols(); } $content = wp_kses_no_null( $content, array( 'slash_zero' => 'keep' ) ); $content = wp_kses_normalize_entities( $content ); $content = wp_kses_hook( $content, $allowed_html, $allowed_protocols ); return wp_kses_split( $content, $allowed_html, $allowed_protocols ); } function wp_kses_one_attr( $attr, $element ) { $uris = wp_kses_uri_attributes(); $allowed_html = wp_kses_allowed_html( 'post' ); $allowed_protocols = wp_allowed_protocols(); $attr = wp_kses_no_null( $attr, array( 'slash_zero' => 'keep' ) ); $matches = array(); preg_match( '/^\s*/', $attr, $matches ); $lead = $matches[0]; preg_match( '/\s*$/', $attr, $matches ); $trail = $matches[0]; if ( empty( $trail ) ) { $attr = substr( $attr, strlen( $lead ) ); } else { $attr = substr( $attr, strlen( $lead ), -strlen( $trail ) ); } $split = preg_split( '/\s*=\s*/', $attr, 2 ); $name = $split[0]; if ( count( $split ) == 2 ) { $value = $split[1]; if ( '' === $value ) { $quote = ''; } else { $quote = $value[0]; } if ( '"' === $quote || "'" === $quote ) { if ( substr( $value, -1 ) != $quote ) { return ''; } $value = substr( $value, 1, -1 ); } else { $quote = '"'; } $value = esc_attr( $value ); if ( in_array( strtolower( $name ), $uris, true ) ) { $value = wp_kses_bad_protocol( $value, $allowed_protocols ); } $attr = "$name=$quote$value$quote"; $vless = 'n'; } else { $value = ''; $vless = 'y'; } wp_kses_attr_check( $name, $value, $attr, $vless, $element, $allowed_html ); return $lead . $attr . $trail; } function wp_kses_allowed_html( $context = '' ) { global $allowedposttags, $allowedtags, $allowedentitynames; if ( is_array( $context ) ) { $html = $context; $context = 'explicit'; return apply_filters( 'wp_kses_allowed_html', $html, $context ); } switch ( $context ) { case 'post': $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context ); if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) { $tags = $allowedposttags; $tags['form'] = array( 'action' => true, 'accept' => true, 'accept-charset' => true, 'enctype' => true, 'method' => true, 'name' => true, 'target' => true, ); $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context ); } return $tags; case 'user_description': case 'pre_user_description': $tags = $allowedtags; $tags['a']['rel'] = true; return apply_filters( 'wp_kses_allowed_html', $tags, $context ); case 'strip': return apply_filters( 'wp_kses_allowed_html', array(), $context ); case 'entities': return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context ); case 'data': default: return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context ); } } function wp_kses_hook( $content, $allowed_html, $allowed_protocols ) { return apply_filters( 'pre_kses', $content, $allowed_html, $allowed_protocols ); } function wp_kses_version() { return '0.2.2'; } function wp_kses_split( $content, $allowed_html, $allowed_protocols ) { global $pass_allowed_html, $pass_allowed_protocols; $pass_allowed_html = $allowed_html; $pass_allowed_protocols = $allowed_protocols; return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $content ); } function wp_kses_uri_attributes() { $uri_attributes = array( 'action', 'archive', 'background', 'cite', 'classid', 'codebase', 'data', 'formaction', 'href', 'icon', 'longdesc', 'manifest', 'poster', 'profile', 'src', 'usemap', 'xmlns', ); $uri_attributes = apply_filters( 'wp_kses_uri_attributes', $uri_attributes ); return $uri_attributes; } function _wp_kses_split_callback( $matches ) { global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2( $matches[0], $pass_allowed_html, $pass_allowed_protocols ); } function wp_kses_split2( $content, $allowed_html, $allowed_protocols ) { $content = wp_kses_stripslashes( $content ); if ( '<' !== substr( $content, 0, 1 ) ) { return '>'; } if ( '<!--' === substr( $content, 0, 4 ) ) { $content = str_replace( array( '<!--', '-->' ), '', $content ); while ( ( $newstring = wp_kses( $content, $allowed_html, $allowed_protocols ) ) != $content ) { $content = $newstring; } if ( '' === $content ) { return ''; } $content = preg_replace( '/--+/', '-', $content ); $content = preg_replace( '/-$/', '', $content ); return "<!--{$content}-->"; } if ( ! preg_match( '%^<\s*(/\s*)?([a-zA-Z0-9-]+)([^>]*)>?$%', $content, $matches ) ) { return ''; } $slash = trim( $matches[1] ); $elem = $matches[2]; $attrlist = $matches[3]; if ( ! is_array( $allowed_html ) ) { $allowed_html = wp_kses_allowed_html( $allowed_html ); } if ( ! isset( $allowed_html[ strtolower( $elem ) ] ) ) { return ''; } if ( '' !== $slash ) { return "</$elem>"; } return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); } function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { if ( ! is_array( $allowed_html ) ) { $allowed_html = wp_kses_allowed_html( $allowed_html ); } $xhtml_slash = ''; if ( preg_match( '%\s*/\s*$%', $attr ) ) { $xhtml_slash = ' /'; } $element_low = strtolower( $element ); if ( empty( $allowed_html[ $element_low ] ) || true === $allowed_html[ $element_low ] ) { return "<$element$xhtml_slash>"; } $attrarr = wp_kses_hair( $attr, $allowed_protocols ); $required_attrs = array_filter( $allowed_html[ $element_low ], function( $required_attr_limits ) { return isset( $required_attr_limits['required'] ) && true === $required_attr_limits['required']; } ); $stripped_tag = ''; if ( empty( $xhtml_slash ) ) { $stripped_tag = "<$element>"; } $attr2 = ''; foreach ( $attrarr as $arreach ) { $required = isset( $required_attrs[ strtolower( $arreach['name'] ) ] ); if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { $attr2 .= ' ' . $arreach['whole']; if ( $required ) { unset( $required_attrs[ strtolower( $arreach['name'] ) ] ); } } elseif ( $required ) { return $stripped_tag; } } if ( ! empty( $required_attrs ) ) { return $stripped_tag; } $attr2 = preg_replace( '/[<>]/', '', $attr2 ); return "<$element$attr2$xhtml_slash>"; } function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) { $name_low = strtolower( $name ); $element_low = strtolower( $element ); if ( ! isset( $allowed_html[ $element_low ] ) ) { $name = ''; $value = ''; $whole = ''; return false; } $allowed_attr = $allowed_html[ $element_low ]; if ( ! isset( $allowed_attr[ $name_low ] ) || '' === $allowed_attr[ $name_low ] ) { if ( strpos( $name_low, 'data-' ) === 0 && ! empty( $allowed_attr['data-*'] ) && preg_match( '/^data(?:-[a-z0-9_]+)+$/', $name_low, $match ) ) { $allowed_attr[ $match[0] ] = $allowed_attr['data-*']; } else { $name = ''; $value = ''; $whole = ''; return false; } } if ( 'style' === $name_low ) { $new_value = safecss_filter_attr( $value ); if ( empty( $new_value ) ) { $name = ''; $value = ''; $whole = ''; return false; } $whole = str_replace( $value, $new_value, $whole ); $value = $new_value; } if ( is_array( $allowed_attr[ $name_low ] ) ) { foreach ( $allowed_attr[ $name_low ] as $currkey => $currval ) { if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) { $name = ''; $value = ''; $whole = ''; return false; } } } return true; } function wp_kses_hair( $attr, $allowed_protocols ) { $attrarr = array(); $mode = 0; $attrname = ''; $uris = wp_kses_uri_attributes(); while ( strlen( $attr ) != 0 ) { $working = 0; switch ( $mode ) { case 0: if ( preg_match( '/^([_a-zA-Z][-_a-zA-Z0-9:.]*)/', $attr, $match ) ) { $attrname = $match[1]; $working = 1; $mode = 1; $attr = preg_replace( '/^[_a-zA-Z][-_a-zA-Z0-9:.]*/', '', $attr ); } break; case 1: if ( preg_match( '/^\s*=\s*/', $attr ) ) { $working = 1; $mode = 2; $attr = preg_replace( '/^\s*=\s*/', '', $attr ); break; } if ( preg_match( '/^\s+/', $attr ) ) { $working = 1; $mode = 0; if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y', ); } $attr = preg_replace( '/^\s+/', '', $attr ); } break; case 2: if ( preg_match( '%^"([^"]*)"(\s+|/?$)%', $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( '/^"[^"]*"(\s+|$)/', '', $attr ); break; } if ( preg_match( "%^'([^']*)'(\s+|/?$)%", $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( "/^'[^']*'(\s+|$)/", '', $attr ); break; } if ( preg_match( "%^([^\s\"']+)(\s+|/?$)%", $attr, $match ) ) { $thisval = $match[1]; if ( in_array( strtolower( $attrname ), $uris, true ) ) { $thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols ); } if ( false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n', ); } $working = 1; $mode = 0; $attr = preg_replace( "%^[^\s\"']+(\s+|$)%", '', $attr ); } break; } if ( 0 == $working ) { $attr = wp_kses_html_error( $attr ); $mode = 0; } } if ( 1 == $mode && false === array_key_exists( $attrname, $attrarr ) ) { $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y', ); } return $attrarr; } function wp_kses_attr_parse( $element ) { $valid = preg_match( '%^(<\s*)(/\s*)?([a-zA-Z0-9]+\s*)([^>]*)(>?)$%', $element, $matches ); if ( 1 !== $valid ) { return false; } $begin = $matches[1]; $slash = $matches[2]; $elname = $matches[3]; $attr = $matches[4]; $end = $matches[5]; if ( '' !== $slash ) { return false; } if ( 1 === preg_match( '%\s*/\s*$%', $attr, $matches ) ) { $xhtml_slash = $matches[0]; $attr = substr( $attr, 0, -strlen( $xhtml_slash ) ); } else { $xhtml_slash = ''; } $attrarr = wp_kses_hair_parse( $attr ); if ( false === $attrarr ) { return false; } array_unshift( $attrarr, $begin . $slash . $elname ); array_push( $attrarr, $xhtml_slash . $end ); return $attrarr; } function wp_kses_hair_parse( $attr ) { if ( '' === $attr ) { return array(); } $regex = '(?:' . '[_a-zA-Z][-_a-zA-Z0-9:.]*' . '|' . '\[\[?[^\[\]]+\]\]?' . ')' . '(?:' . '\s*=\s*' . '(?:' . '"[^"]*"' . '|' . "'[^']*'" . '|' . '[^\s"\']+' . '(?:\s|$)' . ')' . '|' . '(?:\s|$)' . ')' . '\s*'; $validation = "%^($regex)+$%"; $extraction = "%$regex%"; if ( 1 === preg_match( $validation, $attr ) ) { preg_match_all( $extraction, $attr, $attrarr ); return $attrarr[0]; } else { return false; } } function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { $ok = true; switch ( strtolower( $checkname ) ) { case 'maxlen': if ( strlen( $value ) > $checkvalue ) { $ok = false; } break; case 'minlen': if ( strlen( $value ) < $checkvalue ) { $ok = false; } break; case 'maxval': if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; } if ( $value > $checkvalue ) { $ok = false; } break; case 'minval': if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; } if ( $value < $checkvalue ) { $ok = false; } break; case 'valueless': if ( strtolower( $checkvalue ) != $vless ) { $ok = false; } break; case 'values': if ( false === array_search( strtolower( $value ), $checkvalue, true ) ) { $ok = false; } break; case 'value_callback': if ( ! call_user_func( $checkvalue, $value ) ) { $ok = false; } break; } return $ok; } function wp_kses_bad_protocol( $content, $allowed_protocols ) { $content = wp_kses_no_null( $content ); if ( ( str_starts_with( $content, 'https://' ) && in_array( 'https', $allowed_protocols, true ) ) || ( str_starts_with( $content, 'http://' ) && in_array( 'http', $allowed_protocols, true ) ) ) { return $content; } $iterations = 0; do { $original_content = $content; $content = wp_kses_bad_protocol_once( $content, $allowed_protocols ); } while ( $original_content != $content && ++$iterations < 6 ); if ( $original_content != $content ) { return ''; } return $content; } function wp_kses_no_null( $content, $options = null ) { if ( ! isset( $options['slash_zero'] ) ) { $options = array( 'slash_zero' => 'remove' ); } $content = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $content ); if ( 'remove' === $options['slash_zero'] ) { $content = preg_replace( '/\\\\+0+/', '', $content ); } return $content; } function wp_kses_stripslashes( $content ) { return preg_replace( '%\\\\"%', '"', $content ); } function wp_kses_array_lc( $inarray ) { $outarray = array(); foreach ( (array) $inarray as $inkey => $inval ) { $outkey = strtolower( $inkey ); $outarray[ $outkey ] = array(); foreach ( (array) $inval as $inkey2 => $inval2 ) { $outkey2 = strtolower( $inkey2 ); $outarray[ $outkey ][ $outkey2 ] = $inval2; } } return $outarray; } function wp_kses_html_error( $attr ) { return preg_replace( '/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $attr ); } function wp_kses_bad_protocol_once( $content, $allowed_protocols, $count = 1 ) { $content = preg_replace( '/(�*58(?![;0-9])|�*3a(?![;a-f0-9]))/i', '$1;', $content ); $content2 = preg_split( '/:|�*58;|�*3a;|:/i', $content, 2 ); if ( isset( $content2[1] ) && ! preg_match( '%/\?%', $content2[0] ) ) { $content = trim( $content2[1] ); $protocol = wp_kses_bad_protocol_once2( $content2[0], $allowed_protocols ); if ( 'feed:' === $protocol ) { if ( $count > 2 ) { return ''; } $content = wp_kses_bad_protocol_once( $content, $allowed_protocols, ++$count ); if ( empty( $content ) ) { return $content; } } $content = $protocol . $content; } return $content; } function wp_kses_bad_protocol_once2( $scheme, $allowed_protocols ) { $scheme = wp_kses_decode_entities( $scheme ); $scheme = preg_replace( '/\s/', '', $scheme ); $scheme = wp_kses_no_null( $scheme ); $scheme = strtolower( $scheme ); $allowed = false; foreach ( (array) $allowed_protocols as $one_protocol ) { if ( strtolower( $one_protocol ) == $scheme ) { $allowed = true; break; } } if ( $allowed ) { return "$scheme:"; } else { return ''; } } function wp_kses_normalize_entities( $content, $context = 'html' ) { $content = str_replace( '&', '&', $content ); if ( 'xml' === $context ) { $content = preg_replace_callback( '/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_xml_named_entities', $content ); } else { $content = preg_replace_callback( '/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $content ); } $content = preg_replace_callback( '/&#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $content ); $content = preg_replace_callback( '/&#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $content ); return $content; } function wp_kses_named_entities( $matches ) { global $allowedentitynames; if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; return ( ! in_array( $i, $allowedentitynames, true ) ) ? "&$i;" : "&$i;"; } function wp_kses_xml_named_entities( $matches ) { global $allowedentitynames, $allowedxmlentitynames; if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; if ( in_array( $i, $allowedxmlentitynames, true ) ) { return "&$i;"; } elseif ( in_array( $i, $allowedentitynames, true ) ) { return html_entity_decode( "&$i;", ENT_HTML5 ); } return "&$i;"; } function wp_kses_normalize_entities2( $matches ) { if ( empty( $matches[1] ) ) { return ''; } $i = $matches[1]; if ( valid_unicode( $i ) ) { $i = str_pad( ltrim( $i, '0' ), 3, '0', STR_PAD_LEFT ); $i = "&#$i;"; } else { $i = "&#$i;"; } return $i; } function wp_kses_normalize_entities3( $matches ) { if ( empty( $matches[1] ) ) { return ''; } $hexchars = $matches[1]; return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&#x$hexchars;" : '&#x' . ltrim( $hexchars, '0' ) . ';'; } function valid_unicode( $i ) { return ( 0x9 == $i || 0xa == $i || 0xd == $i || ( 0x20 <= $i && $i <= 0xd7ff ) || ( 0xe000 <= $i && $i <= 0xfffd ) || ( 0x10000 <= $i && $i <= 0x10ffff ) ); } function wp_kses_decode_entities( $content ) { $content = preg_replace_callback( '/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $content ); $content = preg_replace_callback( '/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $content ); return $content; } function _wp_kses_decode_entities_chr( $matches ) { return chr( $matches[1] ); } function _wp_kses_decode_entities_chr_hexdec( $matches ) { return chr( hexdec( $matches[1] ) ); } function wp_filter_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), current_filter() ) ); } function wp_kses_data( $data ) { return wp_kses( $data, current_filter() ); } function wp_filter_post_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), 'post' ) ); } function wp_filter_global_styles_post( $data ) { $decoded_data = json_decode( wp_unslash( $data ), true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE === $json_decoding_error && is_array( $decoded_data ) && isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) && $decoded_data['isGlobalStylesUserThemeJSON'] ) { unset( $decoded_data['isGlobalStylesUserThemeJSON'] ); $data_to_encode = WP_Theme_JSON::remove_insecure_properties( $decoded_data ); $data_to_encode['isGlobalStylesUserThemeJSON'] = true; return wp_slash( wp_json_encode( $data_to_encode ) ); } return $data; } function wp_kses_post( $data ) { return wp_kses( $data, 'post' ); } function wp_kses_post_deep( $data ) { return map_deep( $data, 'wp_kses_post' ); } function wp_filter_nohtml_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), 'strip' ) ); } function kses_init_filters() { add_filter( 'title_save_pre', 'wp_filter_kses' ); if ( current_user_can( 'unfiltered_html' ) ) { add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); } else { add_filter( 'pre_comment_content', 'wp_filter_kses' ); } add_filter( 'content_save_pre', 'wp_filter_global_styles_post', 9 ); add_filter( 'content_filtered_save_pre', 'wp_filter_global_styles_post', 9 ); add_filter( 'content_save_pre', 'wp_filter_post_kses' ); add_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); add_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); } function kses_remove_filters() { remove_filter( 'title_save_pre', 'wp_filter_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_kses' ); remove_filter( 'content_save_pre', 'wp_filter_global_styles_post', 9 ); remove_filter( 'content_filtered_save_pre', 'wp_filter_global_styles_post', 9 ); remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); remove_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); } function kses_init() { kses_remove_filters(); if ( ! current_user_can( 'unfiltered_html' ) ) { kses_init_filters(); } } function safecss_filter_attr( $css, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.8.1' ); } $css = wp_kses_no_null( $css ); $css = str_replace( array( "\n", "\r", "\t" ), '', $css ); $allowed_protocols = wp_allowed_protocols(); $css_array = explode( ';', trim( $css ) ); $allowed_attr = apply_filters( 'safe_style_css', array( 'background', 'background-color', 'background-image', 'background-position', 'background-size', 'background-attachment', 'background-blend-mode', 'border', 'border-radius', 'border-width', 'border-color', 'border-style', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-bottom', 'border-bottom-color', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-style', 'border-bottom-width', 'border-bottom-right-radius', 'border-bottom-left-radius', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-top', 'border-top-color', 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', 'border-top-width', 'border-top-left-radius', 'border-top-right-radius', 'border-spacing', 'border-collapse', 'caption-side', 'columns', 'column-count', 'column-fill', 'column-gap', 'column-rule', 'column-span', 'column-width', 'color', 'filter', 'font', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'letter-spacing', 'line-height', 'text-align', 'text-decoration', 'text-indent', 'text-transform', 'height', 'min-height', 'max-height', 'width', 'min-width', 'max-width', 'margin', 'margin-right', 'margin-bottom', 'margin-left', 'margin-top', 'margin-block-start', 'margin-block-end', 'margin-inline-start', 'margin-inline-end', 'padding', 'padding-right', 'padding-bottom', 'padding-left', 'padding-top', 'padding-block-start', 'padding-block-end', 'padding-inline-start', 'padding-inline-end', 'flex', 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', 'flex-wrap', 'gap', 'column-gap', 'row-gap', 'grid-template-columns', 'grid-auto-columns', 'grid-column-start', 'grid-column-end', 'grid-column-gap', 'grid-template-rows', 'grid-auto-rows', 'grid-row-start', 'grid-row-end', 'grid-row-gap', 'grid-gap', 'justify-content', 'justify-items', 'justify-self', 'align-content', 'align-items', 'align-self', 'clear', 'cursor', 'direction', 'float', 'list-style-type', 'object-fit', 'object-position', 'overflow', 'vertical-align', '--*', ) ); $css_url_data_types = array( 'background', 'background-image', 'cursor', 'list-style', 'list-style-image', ); $css_gradient_data_types = array( 'background', 'background-image', ); if ( empty( $allowed_attr ) ) { return $css; } $css = ''; foreach ( $css_array as $css_item ) { if ( '' === $css_item ) { continue; } $css_item = trim( $css_item ); $css_test_string = $css_item; $found = false; $url_attr = false; $gradient_attr = false; $is_custom_var = false; if ( strpos( $css_item, ':' ) === false ) { $found = true; } else { $parts = explode( ':', $css_item, 2 ); $css_selector = trim( $parts[0] ); if ( in_array( '--*', $allowed_attr, true ) && preg_match( '/^--[a-zA-Z0-9-_]+$/', $css_selector ) ) { $allowed_attr[] = $css_selector; $is_custom_var = true; } if ( in_array( $css_selector, $allowed_attr, true ) ) { $found = true; $url_attr = in_array( $css_selector, $css_url_data_types, true ); $gradient_attr = in_array( $css_selector, $css_gradient_data_types, true ); } if ( $is_custom_var ) { $css_value = trim( $parts[1] ); $url_attr = str_starts_with( $css_value, 'url(' ); $gradient_attr = str_contains( $css_value, '-gradient(' ); } } if ( $found && $url_attr ) { preg_match_all( '/url\([^)]+\)/', $parts[1], $url_matches ); foreach ( $url_matches[0] as $url_match ) { preg_match( '/^url\(\s*([\'\"]?)(.*)(\g1)\s*\)$/', $url_match, $url_pieces ); if ( empty( $url_pieces[2] ) ) { $found = false; break; } $url = trim( $url_pieces[2] ); if ( empty( $url ) || wp_kses_bad_protocol( $url, $allowed_protocols ) !== $url ) { $found = false; break; } else { $css_test_string = str_replace( $url_match, '', $css_test_string ); } } } if ( $found && $gradient_attr ) { $css_value = trim( $parts[1] ); if ( preg_match( '/^(repeating-)?(linear|radial|conic)-gradient\(([^()]|rgb[a]?\([^()]*\))*\)$/', $css_value ) ) { $css_test_string = str_replace( $css_value, '', $css_test_string ); } } if ( $found ) { $css_test_string = preg_replace( '/\b(?:var|calc|min|max|minmax|clamp)(\((?:[^()]|(?1))*\))/', '', $css_test_string ); $allow_css = ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ); $allow_css = apply_filters( 'safecss_filter_attr_allow_css', $allow_css, $css_test_string ); if ( $allow_css ) { if ( '' !== $css ) { $css .= ';'; } $css .= $css_item; } } } return $css; } function _wp_add_global_attributes( $value ) { $global_attributes = array( 'aria-describedby' => true, 'aria-details' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-hidden' => true, 'class' => true, 'data-*' => true, 'dir' => true, 'id' => true, 'lang' => true, 'style' => true, 'title' => true, 'role' => true, 'xml:lang' => true, ); if ( true === $value ) { $value = array(); } if ( is_array( $value ) ) { return array_merge( $value, $global_attributes ); } return $value; } function _wp_kses_allow_pdf_objects( $url ) { if ( str_contains( $url, '?' ) || str_contains( $url, '#' ) ) { return false; } if ( ! str_ends_with( $url, '.pdf' ) ) { return false; } $upload_info = wp_upload_dir( null, false ); $parsed_url = wp_parse_url( $upload_info['url'] ); $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : ''; $upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : ''; if ( str_starts_with( $url, "http://$upload_host$upload_port/" ) || str_starts_with( $url, "https://$upload_host$upload_port/" ) ) { return true; } return false; } <?php function get_locale() { global $locale, $wp_local_package; if ( isset( $locale ) ) { return apply_filters( 'locale', $locale ); } if ( isset( $wp_local_package ) ) { $locale = $wp_local_package; } if ( defined( 'WPLANG' ) ) { $locale = WPLANG; } if ( is_multisite() ) { if ( wp_installing() ) { $ms_locale = get_site_option( 'WPLANG' ); } else { $ms_locale = get_option( 'WPLANG' ); if ( false === $ms_locale ) { $ms_locale = get_site_option( 'WPLANG' ); } } if ( false !== $ms_locale ) { $locale = $ms_locale; } } else { $db_locale = get_option( 'WPLANG' ); if ( false !== $db_locale ) { $locale = $db_locale; } } if ( empty( $locale ) ) { $locale = 'en_US'; } return apply_filters( 'locale', $locale ); } function get_user_locale( $user = 0 ) { $user_object = false; if ( 0 === $user && function_exists( 'wp_get_current_user' ) ) { $user_object = wp_get_current_user(); } elseif ( $user instanceof WP_User ) { $user_object = $user; } elseif ( $user && is_numeric( $user ) ) { $user_object = get_user_by( 'id', $user ); } if ( ! $user_object ) { return get_locale(); } $locale = $user_object->locale; return $locale ? $locale : get_locale(); } function determine_locale() { $determined_locale = apply_filters( 'pre_determine_locale', null ); if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) { return $determined_locale; } $determined_locale = get_locale(); if ( is_admin() ) { $determined_locale = get_user_locale(); } if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) { $determined_locale = get_user_locale(); } $wp_lang = ''; if ( ! empty( $_GET['wp_lang'] ) ) { $wp_lang = sanitize_text_field( $_GET['wp_lang'] ); } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { $wp_lang = sanitize_text_field( $_COOKIE['wp_lang'] ); } if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { $determined_locale = $wp_lang; } return apply_filters( 'determine_locale', $determined_locale ); } function translate( $text, $domain = 'default' ) { $translations = get_translations_for_domain( $domain ); $translation = $translations->translate( $text ); $translation = apply_filters( 'gettext', $translation, $text, $domain ); $translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain ); return $translation; } function before_last_bar( $text ) { $last_bar = strrpos( $text, '|' ); if ( false === $last_bar ) { return $text; } else { return substr( $text, 0, $last_bar ); } } function translate_with_gettext_context( $text, $context, $domain = 'default' ) { $translations = get_translations_for_domain( $domain ); $translation = $translations->translate( $text, $context ); $translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain ); $translation = apply_filters( "gettext_with_context_{$domain}", $translation, $text, $context, $domain ); return $translation; } function __( $text, $domain = 'default' ) { return translate( $text, $domain ); } function esc_attr__( $text, $domain = 'default' ) { return esc_attr( translate( $text, $domain ) ); } function esc_html__( $text, $domain = 'default' ) { return esc_html( translate( $text, $domain ) ); } function _e( $text, $domain = 'default' ) { echo translate( $text, $domain ); } function esc_attr_e( $text, $domain = 'default' ) { echo esc_attr( translate( $text, $domain ) ); } function esc_html_e( $text, $domain = 'default' ) { echo esc_html( translate( $text, $domain ) ); } function _x( $text, $context, $domain = 'default' ) { return translate_with_gettext_context( $text, $context, $domain ); } function _ex( $text, $context, $domain = 'default' ) { echo _x( $text, $context, $domain ); } function esc_attr_x( $text, $context, $domain = 'default' ) { return esc_attr( translate_with_gettext_context( $text, $context, $domain ) ); } function esc_html_x( $text, $context, $domain = 'default' ) { return esc_html( translate_with_gettext_context( $text, $context, $domain ) ); } function _n( $single, $plural, $number, $domain = 'default' ) { $translations = get_translations_for_domain( $domain ); $translation = $translations->translate_plural( $single, $plural, $number ); $translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); $translation = apply_filters( "ngettext_{$domain}", $translation, $single, $plural, $number, $domain ); return $translation; } function _nx( $single, $plural, $number, $context, $domain = 'default' ) { $translations = get_translations_for_domain( $domain ); $translation = $translations->translate_plural( $single, $plural, $number, $context ); $translation = apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); $translation = apply_filters( "ngettext_with_context_{$domain}", $translation, $single, $plural, $number, $context, $domain ); return $translation; } function _n_noop( $singular, $plural, $domain = null ) { return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain, ); } function _nx_noop( $singular, $plural, $context, $domain = null ) { return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain, ); } function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { if ( $nooped_plural['domain'] ) { $domain = $nooped_plural['domain']; } if ( $nooped_plural['context'] ) { return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); } else { return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain ); } } function load_textdomain( $domain, $mofile, $locale = null ) { global $l10n, $l10n_unloaded, $wp_textdomain_registry; $l10n_unloaded = (array) $l10n_unloaded; $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile ); if ( true === (bool) $plugin_override ) { unset( $l10n_unloaded[ $domain ] ); return true; } do_action( 'load_textdomain', $domain, $mofile ); $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); if ( ! is_readable( $mofile ) ) { return false; } if ( ! $locale ) { $locale = determine_locale(); } $mo = new MO(); if ( ! $mo->import_from_file( $mofile ) ) { $wp_textdomain_registry->set( $domain, $locale, false ); return false; } if ( isset( $l10n[ $domain ] ) ) { $mo->merge_with( $l10n[ $domain ] ); } unset( $l10n_unloaded[ $domain ] ); $l10n[ $domain ] = &$mo; $wp_textdomain_registry->set( $domain, $locale, dirname( $mofile ) ); return true; } function unload_textdomain( $domain, $reloadable = false ) { global $l10n, $l10n_unloaded; $l10n_unloaded = (array) $l10n_unloaded; $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain, $reloadable ); if ( $plugin_override ) { if ( ! $reloadable ) { $l10n_unloaded[ $domain ] = true; } return true; } do_action( 'unload_textdomain', $domain, $reloadable ); if ( isset( $l10n[ $domain ] ) ) { unset( $l10n[ $domain ] ); if ( ! $reloadable ) { $l10n_unloaded[ $domain ] = true; } return true; } return false; } function load_default_textdomain( $locale = null ) { if ( null === $locale ) { $locale = determine_locale(); } unload_textdomain( 'default' ); $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo", $locale ); if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) { load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo", $locale ); return $return; } if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo", $locale ); } if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) { load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo", $locale ); } return $return; } function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { global $wp_textdomain_registry; $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); $mofile = $domain . '-' . $locale . '.mo'; if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) { return true; } if ( false !== $plugin_rel_path ) { $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); } elseif ( false !== $deprecated ) { _deprecated_argument( __FUNCTION__, '2.7.0' ); $path = ABSPATH . trim( $deprecated, '/' ); } else { $path = WP_PLUGIN_DIR; } $wp_textdomain_registry->set_custom_path( $domain, $path ); return load_textdomain( $domain, $path . '/' . $mofile, $locale ); } function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { global $wp_textdomain_registry; $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); $mofile = $domain . '-' . $locale . '.mo'; if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) { return true; } $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ); $wp_textdomain_registry->set_custom_path( $domain, $path ); return load_textdomain( $domain, $path . '/' . $mofile, $locale ); } function load_theme_textdomain( $domain, $path = false ) { global $wp_textdomain_registry; $locale = apply_filters( 'theme_locale', determine_locale(), $domain ); $mofile = $domain . '-' . $locale . '.mo'; if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile, $locale ) ) { return true; } if ( ! $path ) { $path = get_template_directory(); } $wp_textdomain_registry->set_custom_path( $domain, $path ); return load_textdomain( $domain, $path . '/' . $locale . '.mo', $locale ); } function load_child_theme_textdomain( $domain, $path = false ) { if ( ! $path ) { $path = get_stylesheet_directory(); } return load_theme_textdomain( $domain, $path ); } function load_script_textdomain( $handle, $domain = 'default', $path = '' ) { $wp_scripts = wp_scripts(); if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { return false; } $path = untrailingslashit( $path ); $locale = determine_locale(); $file_base = 'default' === $domain ? $locale : $domain . '-' . $locale; $handle_filename = $file_base . '-' . $handle . '.json'; if ( $path ) { $translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain ); if ( $translations ) { return $translations; } } $src = $wp_scripts->registered[ $handle ]->src; if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $wp_scripts->content_url && 0 === strpos( $src, $wp_scripts->content_url ) ) ) { $src = $wp_scripts->base_url . $src; } $relative = false; $languages_path = WP_LANG_DIR; $src_url = wp_parse_url( $src ); $content_url = wp_parse_url( content_url() ); $plugins_url = wp_parse_url( plugins_url() ); $site_url = wp_parse_url( site_url() ); if ( ( ! isset( $content_url['path'] ) || strpos( $src_url['path'], $content_url['path'] ) === 0 ) && ( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] ) ) { if ( isset( $content_url['path'] ) ) { $relative = substr( $src_url['path'], strlen( $content_url['path'] ) ); } else { $relative = $src_url['path']; } $relative = trim( $relative, '/' ); $relative = explode( '/', $relative ); $languages_path = WP_LANG_DIR . '/' . $relative[0]; $relative = array_slice( $relative, 2 ); $relative = implode( '/', $relative ); } elseif ( ( ! isset( $plugins_url['path'] ) || strpos( $src_url['path'], $plugins_url['path'] ) === 0 ) && ( ! isset( $src_url['host'] ) || ! isset( $plugins_url['host'] ) || $src_url['host'] === $plugins_url['host'] ) ) { if ( isset( $plugins_url['path'] ) ) { $relative = substr( $src_url['path'], strlen( $plugins_url['path'] ) ); } else { $relative = $src_url['path']; } $relative = trim( $relative, '/' ); $relative = explode( '/', $relative ); $languages_path = WP_LANG_DIR . '/plugins'; $relative = array_slice( $relative, 1 ); $relative = implode( '/', $relative ); } elseif ( ! isset( $src_url['host'] ) || ! isset( $site_url['host'] ) || $src_url['host'] === $site_url['host'] ) { if ( ! isset( $site_url['path'] ) ) { $relative = trim( $src_url['path'], '/' ); } elseif ( ( strpos( $src_url['path'], trailingslashit( $site_url['path'] ) ) === 0 ) ) { $relative = substr( $src_url['path'], strlen( $site_url['path'] ) ); $relative = trim( $relative, '/' ); } } $relative = apply_filters( 'load_script_textdomain_relative_path', $relative, $src ); if ( false === $relative ) { return load_script_translations( false, $handle, $domain ); } if ( substr( $relative, -7 ) === '.min.js' ) { $relative = substr( $relative, 0, -7 ) . '.js'; } $md5_filename = $file_base . '-' . md5( $relative ) . '.json'; if ( $path ) { $translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain ); if ( $translations ) { return $translations; } } $translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain ); if ( $translations ) { return $translations; } return load_script_translations( false, $handle, $domain ); } function load_script_translations( $file, $handle, $domain ) { $translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain ); if ( null !== $translations ) { return $translations; } $file = apply_filters( 'load_script_translation_file', $file, $handle, $domain ); if ( ! $file || ! is_readable( $file ) ) { return false; } $translations = file_get_contents( $file ); return apply_filters( 'load_script_translations', $translations, $file, $handle, $domain ); } function _load_textdomain_just_in_time( $domain ) { global $l10n_unloaded, $wp_textdomain_registry; $l10n_unloaded = (array) $l10n_unloaded; if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) { return false; } if ( ! $wp_textdomain_registry->has( $domain ) ) { return false; } $locale = determine_locale(); $path = $wp_textdomain_registry->get( $domain, $locale ); if ( ! $path ) { return false; } $template_directory = trailingslashit( get_template_directory() ); $stylesheet_directory = trailingslashit( get_stylesheet_directory() ); if ( str_starts_with( $path, $template_directory ) || str_starts_with( $path, $stylesheet_directory ) ) { $mofile = "{$path}{$locale}.mo"; } else { $mofile = "{$path}{$domain}-{$locale}.mo"; } return load_textdomain( $domain, $mofile, $locale ); } function get_translations_for_domain( $domain ) { global $l10n; if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) { return $l10n[ $domain ]; } static $noop_translations = null; if ( null === $noop_translations ) { $noop_translations = new NOOP_Translations(); } return $noop_translations; } function is_textdomain_loaded( $domain ) { global $l10n; return isset( $l10n[ $domain ] ); } function translate_user_role( $name, $domain = 'default' ) { return translate_with_gettext_context( before_last_bar( $name ), 'User role', $domain ); } function get_available_languages( $dir = null ) { $languages = array(); $lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' ); if ( $lang_files ) { foreach ( $lang_files as $lang_file ) { $lang_file = basename( $lang_file, '.mo' ); if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && 0 !== strpos( $lang_file, 'admin-' ) ) { $languages[] = $lang_file; } } } return apply_filters( 'get_available_languages', $languages, $dir ); } function wp_get_installed_translations( $type ) { if ( 'themes' !== $type && 'plugins' !== $type && 'core' !== $type ) { return array(); } $dir = 'core' === $type ? '' : "/$type"; if ( ! is_dir( WP_LANG_DIR ) ) { return array(); } if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) { return array(); } $files = scandir( WP_LANG_DIR . $dir ); if ( ! $files ) { return array(); } $language_data = array(); foreach ( $files as $file ) { if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "$dir/$file" ) ) { continue; } if ( substr( $file, -3 ) !== '.po' ) { continue; } if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) { continue; } if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files, true ) ) { continue; } list( , $textdomain, $language ) = $match; if ( '' === $textdomain ) { $textdomain = 'default'; } $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" ); } return $language_data; } function wp_get_pomo_file_data( $po_file ) { $headers = get_file_data( $po_file, array( 'POT-Creation-Date' => '"POT-Creation-Date', 'PO-Revision-Date' => '"PO-Revision-Date', 'Project-Id-Version' => '"Project-Id-Version', 'X-Generator' => '"X-Generator', ) ); foreach ( $headers as $header => $value ) { $headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value ); } return $headers; } function wp_dropdown_languages( $args = array() ) { $parsed_args = wp_parse_args( $args, array( 'id' => 'locale', 'name' => 'locale', 'languages' => array(), 'translations' => array(), 'selected' => '', 'echo' => 1, 'show_available_translations' => true, 'show_option_site_default' => false, 'show_option_en_us' => true, 'explicit_option_en_us' => false, ) ); if ( ! $parsed_args['id'] || ! $parsed_args['name'] ) { return; } if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) { $parsed_args['selected'] = ''; } $translations = $parsed_args['translations']; if ( empty( $translations ) ) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); } $languages = array(); foreach ( $parsed_args['languages'] as $locale ) { if ( isset( $translations[ $locale ] ) ) { $translation = $translations[ $locale ]; $languages[] = array( 'language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => current( $translation['iso'] ), ); unset( $translations[ $locale ] ); } else { $languages[] = array( 'language' => $locale, 'native_name' => $locale, 'lang' => '', ); } } $translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] ); $structure = array(); if ( $translations_available ) { $structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">'; } if ( $parsed_args['show_option_site_default'] ) { $structure[] = sprintf( '<option value="site-default" data-installed="1"%s>%s</option>', selected( 'site-default', $parsed_args['selected'], false ), _x( 'Site Default', 'default site language' ) ); } if ( $parsed_args['show_option_en_us'] ) { $value = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : ''; $structure[] = sprintf( '<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>', esc_attr( $value ), selected( '', $parsed_args['selected'], false ) ); } foreach ( $languages as $language ) { $structure[] = sprintf( '<option value="%s" lang="%s"%s data-installed="1">%s</option>', esc_attr( $language['language'] ), esc_attr( $language['lang'] ), selected( $language['language'], $parsed_args['selected'], false ), esc_html( $language['native_name'] ) ); } if ( $translations_available ) { $structure[] = '</optgroup>'; } if ( $translations_available ) { $structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">'; foreach ( $translations as $translation ) { $structure[] = sprintf( '<option value="%s" lang="%s"%s>%s</option>', esc_attr( $translation['language'] ), esc_attr( current( $translation['iso'] ) ), selected( $translation['language'], $parsed_args['selected'], false ), esc_html( $translation['native_name'] ) ); } $structure[] = '</optgroup>'; } $output = sprintf( '<select name="%s" id="%s">', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) ); $output .= implode( "\n", $structure ); $output .= '</select>'; if ( $parsed_args['echo'] ) { echo $output; } return $output; } function is_rtl() { global $wp_locale; if ( ! ( $wp_locale instanceof WP_Locale ) ) { return false; } return $wp_locale->is_rtl(); } function switch_to_locale( $locale ) { global $wp_locale_switcher; return $wp_locale_switcher->switch_to_locale( $locale ); } function restore_previous_locale() { global $wp_locale_switcher; return $wp_locale_switcher->restore_previous_locale(); } function restore_current_locale() { global $wp_locale_switcher; return $wp_locale_switcher->restore_current_locale(); } function is_locale_switched() { global $wp_locale_switcher; return $wp_locale_switcher->is_switched(); } function translate_settings_using_i18n_schema( $i18n_schema, $settings, $textdomain ) { if ( empty( $i18n_schema ) || empty( $settings ) || empty( $textdomain ) ) { return $settings; } if ( is_string( $i18n_schema ) && is_string( $settings ) ) { return translate_with_gettext_context( $settings, $i18n_schema, $textdomain ); } if ( is_array( $i18n_schema ) && is_array( $settings ) ) { $translated_settings = array(); foreach ( $settings as $value ) { $translated_settings[] = translate_settings_using_i18n_schema( $i18n_schema[0], $value, $textdomain ); } return $translated_settings; } if ( is_object( $i18n_schema ) && is_array( $settings ) ) { $group_key = '*'; $translated_settings = array(); foreach ( $settings as $key => $value ) { if ( isset( $i18n_schema->$key ) ) { $translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $value, $textdomain ); } elseif ( isset( $i18n_schema->$group_key ) ) { $translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$group_key, $value, $textdomain ); } else { $translated_settings[ $key ] = $value; } } return $translated_settings; } return $settings; } function wp_get_list_item_separator() { global $wp_locale; return $wp_locale->get_list_item_separator(); } <?php - function the_permalink( $post = 0 ) { echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ); } function user_trailingslashit( $url, $type_of_url = '' ) { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes ) { $url = trailingslashit( $url ); } else { $url = untrailingslashit( $url ); } return apply_filters( 'user_trailingslashit', $url, $type_of_url ); } function permalink_anchor( $mode = 'id' ) { $post = get_post(); switch ( strtolower( $mode ) ) { case 'title': $title = sanitize_title( $post->post_title ) . '-' . $post->ID; echo '<a id="' . $title . '"></a>'; break; case 'id': default: echo '<a id="post-' . $post->ID . '"></a>'; break; } } function wp_force_plain_post_permalink( $post = null, $sample = null ) { if ( null === $sample && is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) { $sample = true; } else { $post = get_post( $post ); $sample = null !== $sample ? $sample : false; } if ( ! $post ) { return true; } $post_status_obj = get_post_status_object( get_post_status( $post ) ); $post_type_obj = get_post_type_object( get_post_type( $post ) ); if ( ! $post_status_obj || ! $post_type_obj ) { return true; } if ( is_post_status_viewable( $post_status_obj ) || ( $post_status_obj->private && current_user_can( 'read_post', $post->ID ) ) || ( $post_status_obj->protected && $sample ) ) { return false; } return true; } function get_the_permalink( $post = 0, $leavename = false ) { return get_permalink( $post, $leavename ); } function get_permalink( $post = 0, $leavename = false ) { $rewritecode = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%', ); if ( is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) { $sample = true; } else { $post = get_post( $post ); $sample = false; } if ( empty( $post->ID ) ) { return false; } if ( 'page' === $post->post_type ) { return get_page_link( $post, $leavename, $sample ); } elseif ( 'attachment' === $post->post_type ) { return get_attachment_link( $post, $leavename ); } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) { return get_post_permalink( $post, $leavename, $sample ); } $permalink = get_option( 'permalink_structure' ); $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); if ( $permalink && ! wp_force_plain_post_permalink( $post ) ) { $category = ''; if ( strpos( $permalink, '%category%' ) !== false ) { $cats = get_the_category( $post->ID ); if ( $cats ) { $cats = wp_list_sort( $cats, array( 'term_id' => 'ASC', ) ); $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); $category_object = get_term( $category_object, 'category' ); $category = $category_object->slug; if ( $category_object->parent ) { $category = get_category_parents( $category_object->parent, false, '/', true ) . $category; } } if ( empty( $category ) ) { $default_category = get_term( get_option( 'default_category' ), 'category' ); if ( $default_category && ! is_wp_error( $default_category ) ) { $category = $default_category->slug; } } } $author = ''; if ( strpos( $permalink, '%author%' ) !== false ) { $authordata = get_userdata( $post->post_author ); $author = $authordata->user_nicename; } $date = explode( ' ', str_replace( array( '-', ':' ), ' ', $post->post_date ) ); $rewritereplace = array( $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name, ); $permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) ); $permalink = user_trailingslashit( $permalink, 'single' ); } else { $permalink = home_url( '?p=' . $post->ID ); } return apply_filters( 'post_link', $permalink, $post, $leavename ); } function get_post_permalink( $post = 0, $leavename = false, $sample = false ) { global $wp_rewrite; $post = get_post( $post ); if ( ! $post ) { return false; } $post_link = $wp_rewrite->get_extra_permastruct( $post->post_type ); $slug = $post->post_name; $force_plain_link = wp_force_plain_post_permalink( $post ); $post_type = get_post_type_object( $post->post_type ); if ( $post_type->hierarchical ) { $slug = get_page_uri( $post ); } if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) { if ( ! $leavename ) { $post_link = str_replace( "%$post->post_type%", $slug, $post_link ); } $post_link = home_url( user_trailingslashit( $post_link ) ); } else { if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_plain_link ) ) { $post_link = add_query_arg( $post_type->query_var, $slug, '' ); } else { $post_link = add_query_arg( array( 'post_type' => $post->post_type, 'p' => $post->ID, ), '' ); } $post_link = home_url( $post_link ); } return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample ); } function get_page_link( $post = false, $leavename = false, $sample = false ) { $post = get_post( $post ); if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { $link = home_url( '/' ); } else { $link = _get_page_link( $post, $leavename, $sample ); } return apply_filters( 'page_link', $link, $post->ID, $sample ); } function _get_page_link( $post = false, $leavename = false, $sample = false ) { global $wp_rewrite; $post = get_post( $post ); $force_plain_link = wp_force_plain_post_permalink( $post ); $link = $wp_rewrite->get_page_permastruct(); if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) { if ( ! $leavename ) { $link = str_replace( '%pagename%', get_page_uri( $post ), $link ); } $link = home_url( $link ); $link = user_trailingslashit( $link, 'page' ); } else { $link = home_url( '?page_id=' . $post->ID ); } return apply_filters( '_get_page_link', $link, $post->ID ); } function get_attachment_link( $post = null, $leavename = false ) { global $wp_rewrite; $link = false; $post = get_post( $post ); $force_plain_link = wp_force_plain_post_permalink( $post ); $parent_id = $post->post_parent; $parent = $parent_id ? get_post( $parent_id ) : false; $parent_valid = true; if ( $parent_id && ( $post->post_parent === $post->ID || ! $parent || ! is_post_type_viewable( get_post_type( $parent ) ) ) ) { $parent_valid = false; } if ( $force_plain_link || ! $parent_valid ) { $link = false; } elseif ( $wp_rewrite->using_permalinks() && $parent ) { if ( 'page' === $parent->post_type ) { $parentlink = _get_page_link( $post->post_parent ); } else { $parentlink = get_permalink( $post->post_parent ); } if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) { $name = 'attachment/' . $post->post_name; } else { $name = $post->post_name; } if ( strpos( $parentlink, '?' ) === false ) { $link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' ); } if ( ! $leavename ) { $link = str_replace( '%postname%', $name, $link ); } } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) { $link = home_url( user_trailingslashit( $post->post_name ) ); } if ( ! $link ) { $link = home_url( '/?attachment_id=' . $post->ID ); } return apply_filters( 'attachment_link', $link, $post->ID ); } function get_year_link( $year ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } $yearlink = $wp_rewrite->get_year_permastruct(); if ( ! empty( $yearlink ) ) { $yearlink = str_replace( '%year%', $year, $yearlink ); $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); } else { $yearlink = home_url( '?m=' . $year ); } return apply_filters( 'year_link', $yearlink, $year ); } function get_month_link( $year, $month ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } if ( ! $month ) { $month = current_time( 'm' ); } $monthlink = $wp_rewrite->get_month_permastruct(); if ( ! empty( $monthlink ) ) { $monthlink = str_replace( '%year%', $year, $monthlink ); $monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink ); $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); } else { $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); } return apply_filters( 'month_link', $monthlink, $year, $month ); } function get_day_link( $year, $month, $day ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } if ( ! $month ) { $month = current_time( 'm' ); } if ( ! $day ) { $day = current_time( 'j' ); } $daylink = $wp_rewrite->get_day_permastruct(); if ( ! empty( $daylink ) ) { $daylink = str_replace( '%year%', $year, $daylink ); $daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink ); $daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink ); $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); } else { $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); } return apply_filters( 'day_link', $daylink, $year, $month, $day ); } function the_feed_link( $anchor, $feed = '' ) { $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; echo apply_filters( 'the_feed_link', $link, $feed ); } function get_feed_link( $feed = '' ) { global $wp_rewrite; $permalink = $wp_rewrite->get_feed_permastruct(); if ( $permalink ) { if ( false !== strpos( $feed, 'comments_' ) ) { $feed = str_replace( 'comments_', '', $feed ); $permalink = $wp_rewrite->get_comment_feed_permastruct(); } if ( get_default_feed() == $feed ) { $feed = ''; } $permalink = str_replace( '%feed%', $feed, $permalink ); $permalink = preg_replace( '#/+#', '/', "/$permalink" ); $output = home_url( user_trailingslashit( $permalink, 'feed' ) ); } else { if ( empty( $feed ) ) { $feed = get_default_feed(); } if ( false !== strpos( $feed, 'comments_' ) ) { $feed = str_replace( 'comments_', 'comments-', $feed ); } $output = home_url( "?feed={$feed}" ); } return apply_filters( 'feed_link', $output, $feed ); } function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { $post_id = absint( $post_id ); if ( ! $post_id ) { $post_id = get_the_ID(); } if ( empty( $feed ) ) { $feed = get_default_feed(); } $post = get_post( $post_id ); if ( ! $post instanceof WP_Post ) { return ''; } $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; if ( get_option( 'permalink_structure' ) ) { if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) { $url = _get_page_link( $post_id ); } else { $url = get_permalink( $post_id ); } if ( $unattached ) { $url = home_url( '/feed/' ); if ( get_default_feed() !== $feed ) { $url .= "$feed/"; } $url = add_query_arg( 'attachment_id', $post_id, $url ); } else { $url = trailingslashit( $url ) . 'feed'; if ( get_default_feed() != $feed ) { $url .= "/$feed"; } $url = user_trailingslashit( $url, 'single_feed' ); } } else { if ( $unattached ) { $url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id, ), home_url( '/' ) ); } elseif ( 'page' === $post->post_type ) { $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id, ), home_url( '/' ) ); } else { $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id, ), home_url( '/' ) ); } } return apply_filters( 'post_comments_feed_link', $url ); } function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { $url = get_post_comments_feed_link( $post_id, $feed ); if ( empty( $link_text ) ) { $link_text = __( 'Comments Feed' ); } $link = '<a href="' . esc_url( $url ) . '">' . $link_text . '</a>'; echo apply_filters( 'post_comments_feed_link_html', $link, $post_id, $feed ); } function get_author_feed_link( $author_id, $feed = '' ) { $author_id = (int) $author_id; $permalink_structure = get_option( 'permalink_structure' ); if ( empty( $feed ) ) { $feed = get_default_feed(); } if ( ! $permalink_structure ) { $link = home_url( "?feed=$feed&author=" . $author_id ); } else { $link = get_author_posts_url( $author_id ); if ( get_default_feed() == $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; } $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); } $link = apply_filters( 'author_feed_link', $link, $feed ); return $link; } function get_category_feed_link( $cat, $feed = '' ) { return get_term_feed_link( $cat, 'category', $feed ); } function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) { if ( ! is_object( $term ) ) { $term = (int) $term; } $term = get_term( $term, $taxonomy ); if ( empty( $term ) || is_wp_error( $term ) ) { return false; } $taxonomy = $term->taxonomy; if ( empty( $feed ) ) { $feed = get_default_feed(); } $permalink_structure = get_option( 'permalink_structure' ); if ( ! $permalink_structure ) { if ( 'category' === $taxonomy ) { $link = home_url( "?feed=$feed&cat=$term->term_id" ); } elseif ( 'post_tag' === $taxonomy ) { $link = home_url( "?feed=$feed&tag=$term->slug" ); } else { $t = get_taxonomy( $taxonomy ); $link = home_url( "?feed=$feed&$t->query_var=$term->slug" ); } } else { $link = get_term_link( $term, $term->taxonomy ); if ( get_default_feed() == $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; } $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); } if ( 'category' === $taxonomy ) { $link = apply_filters( 'category_feed_link', $link, $feed ); } elseif ( 'post_tag' === $taxonomy ) { $link = apply_filters( 'tag_feed_link', $link, $feed ); } else { $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); } return $link; } function get_tag_feed_link( $tag, $feed = '' ) { return get_term_feed_link( $tag, 'post_tag', $feed ); } function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) { return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) ); } function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { $link = edit_term_link( $link, '', '', $tag, false ); echo $before . apply_filters( 'edit_tag_link', $link ) . $after; } function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) { $term = get_term( $term, $taxonomy ); if ( ! $term || is_wp_error( $term ) ) { return; } $tax = get_taxonomy( $term->taxonomy ); $term_id = $term->term_id; if ( ! $tax || ! current_user_can( 'edit_term', $term_id ) ) { return; } $args = array( 'taxonomy' => $taxonomy, 'tag_ID' => $term_id, ); if ( $object_type ) { $args['post_type'] = $object_type; } elseif ( ! empty( $tax->object_type ) ) { $args['post_type'] = reset( $tax->object_type ); } if ( $tax->show_ui ) { $location = add_query_arg( $args, admin_url( 'term.php' ) ); } else { $location = ''; } return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); } function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) { if ( is_null( $term ) ) { $term = get_queried_object(); } else { $term = get_term( $term ); } if ( ! $term ) { return; } $tax = get_taxonomy( $term->taxonomy ); if ( ! current_user_can( 'edit_term', $term->term_id ) ) { return; } if ( empty( $link ) ) { $link = __( 'Edit This' ); } $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; if ( $display ) { echo $link; } else { return $link; } } function get_search_link( $query = '' ) { global $wp_rewrite; if ( empty( $query ) ) { $search = get_search_query( false ); } else { $search = stripslashes( $query ); } $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = home_url( '?s=' . urlencode( $search ) ); } else { $search = urlencode( $search ); $search = str_replace( '%2F', '/', $search ); $link = str_replace( '%search%', $search, $permastruct ); $link = home_url( user_trailingslashit( $link, 'search' ) ); } return apply_filters( 'search_link', $link, $search ); } function get_search_feed_link( $search_query = '', $feed = '' ) { global $wp_rewrite; $link = get_search_link( $search_query ); if ( empty( $feed ) ) { $feed = get_default_feed(); } $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = add_query_arg( 'feed', $feed, $link ); } else { $link = trailingslashit( $link ); $link .= "feed/$feed/"; } return apply_filters( 'search_feed_link', $link, $feed, 'posts' ); } function get_search_comments_feed_link( $search_query = '', $feed = '' ) { global $wp_rewrite; if ( empty( $feed ) ) { $feed = get_default_feed(); } $link = get_search_feed_link( $search_query, $feed ); $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = add_query_arg( 'feed', 'comments-' . $feed, $link ); } else { $link = add_query_arg( 'withcomments', 1, $link ); } return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); } function get_post_type_archive_link( $post_type ) { global $wp_rewrite; $post_type_obj = get_post_type_object( $post_type ); if ( ! $post_type_obj ) { return false; } if ( 'post' === $post_type ) { $show_on_front = get_option( 'show_on_front' ); $page_for_posts = get_option( 'page_for_posts' ); if ( 'page' === $show_on_front && $page_for_posts ) { $link = get_permalink( $page_for_posts ); } else { $link = get_home_url(); } return apply_filters( 'post_type_archive_link', $link, $post_type ); } if ( ! $post_type_obj->has_archive ) { return false; } if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; if ( $post_type_obj->rewrite['with_front'] ) { $struct = $wp_rewrite->front . $struct; } else { $struct = $wp_rewrite->root . $struct; } $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); } else { $link = home_url( '?post_type=' . $post_type ); } return apply_filters( 'post_type_archive_link', $link, $post_type ); } function get_post_type_archive_feed_link( $post_type, $feed = '' ) { $default_feed = get_default_feed(); if ( empty( $feed ) ) { $feed = $default_feed; } $link = get_post_type_archive_link( $post_type ); if ( ! $link ) { return false; } $post_type_obj = get_post_type_object( $post_type ); if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { $link = trailingslashit( $link ); $link .= 'feed/'; if ( $feed != $default_feed ) { $link .= "$feed/"; } } else { $link = add_query_arg( 'feed', $feed, $link ); } return apply_filters( 'post_type_archive_feed_link', $link, $feed ); } function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) { $post = get_post( $post ); if ( ! $post ) { return; } $post_type_object = get_post_type_object( $post->post_type ); if ( is_post_type_viewable( $post_type_object ) ) { if ( ! $preview_link ) { $preview_link = set_url_scheme( get_permalink( $post ) ); } $query_args['preview'] = 'true'; $preview_link = add_query_arg( $query_args, $preview_link ); } return apply_filters( 'preview_post_link', $preview_link, $post ); } function get_edit_post_link( $post = 0, $context = 'display' ) { $post = get_post( $post ); if ( ! $post ) { return; } if ( 'revision' === $post->post_type ) { $action = ''; } elseif ( 'display' === $context ) { $action = '&action=edit'; } else { $action = '&action=edit'; } $post_type_object = get_post_type_object( $post->post_type ); if ( ! $post_type_object ) { return; } if ( ! current_user_can( 'edit_post', $post->ID ) ) { return; } if ( $post_type_object->_edit_link ) { $link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ); } else { $link = ''; } return apply_filters( 'get_edit_post_link', $link, $post->ID, $context ); } function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' ) { $post = get_post( $post ); if ( ! $post ) { return; } $url = get_edit_post_link( $post->ID ); if ( ! $url ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="' . esc_attr( $css_class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>'; echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; } function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '3.0.0' ); } $post = get_post( $post ); if ( ! $post ) { return; } $post_type_object = get_post_type_object( $post->post_type ); if ( ! $post_type_object ) { return; } if ( ! current_user_can( 'delete_post', $post->ID ) ) { return; } $action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); } function get_edit_comment_link( $comment_id = 0 ) { $comment = get_comment( $comment_id ); if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } $location = admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID; return apply_filters( 'get_edit_comment_link', $location ); } function edit_comment_link( $text = null, $before = '', $after = '' ) { $comment = get_comment(); if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>'; echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; } function get_edit_bookmark_link( $link = 0 ) { $link = get_bookmark( $link ); if ( ! current_user_can( 'manage_links' ) ) { return; } $location = admin_url( 'link.php?action=edit&link_id=' ) . $link->link_id; return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); } function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { $bookmark = get_bookmark( $bookmark ); if ( ! current_user_can( 'manage_links' ) ) { return; } if ( empty( $link ) ) { $link = __( 'Edit This' ); } $link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; } function get_edit_user_link( $user_id = null ) { if ( ! $user_id ) { $user_id = get_current_user_id(); } if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) { return ''; } $user = get_userdata( $user_id ); if ( ! $user ) { return ''; } if ( get_current_user_id() == $user->ID ) { $link = get_edit_profile_url( $user->ID ); } else { $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); } return apply_filters( 'get_edit_user_link', $link, $user->ID ); } function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); } function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); } function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { global $wpdb; $post = get_post(); if ( ! $post || ! taxonomy_exists( $taxonomy ) ) { return null; } $current_post_date = $post->post_date; $join = ''; $where = ''; $adjacent = $previous ? 'previous' : 'next'; if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { if ( false !== strpos( $excluded_terms, ' and ' ) ) { _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); $excluded_terms = explode( ' and ', $excluded_terms ); } else { $excluded_terms = explode( ',', $excluded_terms ); } $excluded_terms = array_map( 'intval', $excluded_terms ); } $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); if ( $in_same_term || ! empty( $excluded_terms ) ) { if ( $in_same_term ) { $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy ); if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { return ''; } $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); $term_array = array_diff( $term_array, (array) $excluded_terms ); $term_array = array_map( 'intval', $term_array ); if ( ! $term_array || is_wp_error( $term_array ) ) { return ''; } $where .= ' AND tt.term_id IN (' . implode( ',', $term_array ) . ')'; } if ( ! empty( $excluded_terms ) ) { $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', array_map( 'intval', $excluded_terms ) ) . ') )'; } } if ( is_user_logged_in() ) { $user_id = get_current_user_id(); $post_type_object = get_post_type_object( $post->post_type ); if ( empty( $post_type_object ) ) { $post_type_cap = $post->post_type; $read_private_cap = 'read_private_' . $post_type_cap . 's'; } else { $read_private_cap = $post_type_object->cap->read_private_posts; } $private_states = get_post_stati( array( 'private' => true ) ); $where .= " AND ( p.post_status = 'publish'"; foreach ( $private_states as $state ) { if ( current_user_can( $read_private_cap ) ) { $where .= $wpdb->prepare( ' OR p.post_status = %s', $state ); } else { $where .= $wpdb->prepare( ' OR (p.post_author = %d AND p.post_status = %s)', $user_id, $state ); } } $where .= ' )'; } else { $where .= " AND p.post_status = 'publish'"; } $op = $previous ? '<' : '>'; $order = $previous ? 'DESC' : 'ASC'; $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post ); $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post ); $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order ); $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; $query_key = 'adjacent_post_' . md5( $query ); $result = wp_cache_get( $query_key, 'counts' ); if ( false !== $result ) { if ( $result ) { $result = get_post( $result ); } return $result; } $result = $wpdb->get_var( $query ); if ( null === $result ) { $result = ''; } wp_cache_set( $query_key, $result, 'counts' ); if ( $result ) { $result = get_post( $result ); } return $result; } function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { $post = get_post(); if ( $previous && is_attachment() && $post ) { $post = get_post( $post->post_parent ); } else { $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); } if ( empty( $post ) ) { return; } $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post, ) ); if ( empty( $post_title ) ) { $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); } $date = mysql2date( get_option( 'date_format' ), $post->post_date ); $title = str_replace( '%title', $post_title, $title ); $title = str_replace( '%date', $date, $title ); $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; $link .= esc_attr( $title ); $link .= "' href='" . get_permalink( $post ) . "' />\n"; $adjacent = $previous ? 'previous' : 'next'; return apply_filters( "{$adjacent}_post_rel_link", $link ); } function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); } function adjacent_posts_rel_link_wp_head() { if ( ! is_single() || is_attachment() ) { return; } adjacent_posts_rel_link(); } function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); } function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); } function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { $post = get_post(); if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) { return null; } $query_args = array( 'posts_per_page' => 1, 'order' => $start ? 'ASC' : 'DESC', 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ); $term_array = array(); if ( ! is_array( $excluded_terms ) ) { if ( ! empty( $excluded_terms ) ) { $excluded_terms = explode( ',', $excluded_terms ); } else { $excluded_terms = array(); } } if ( $in_same_term || ! empty( $excluded_terms ) ) { if ( $in_same_term ) { $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); } if ( ! empty( $excluded_terms ) ) { $excluded_terms = array_map( 'intval', $excluded_terms ); $excluded_terms = array_diff( $excluded_terms, $term_array ); $inverse_terms = array(); foreach ( $excluded_terms as $excluded_term ) { $inverse_terms[] = $excluded_term * -1; } $excluded_terms = $inverse_terms; } $query_args['tax_query'] = array( array( 'taxonomy' => $taxonomy, 'terms' => array_merge( $term_array, $excluded_terms ), ), ); } return get_posts( $query_args ); } function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy ); } function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); } function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy ); } function next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); } function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { if ( $previous && is_attachment() ) { $post = get_post( get_post()->post_parent ); } else { $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); } if ( ! $post ) { $output = ''; } else { $title = $post->post_title; if ( empty( $post->post_title ) ) { $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); } $title = apply_filters( 'the_title', $title, $post->ID ); $date = mysql2date( get_option( 'date_format' ), $post->post_date ); $rel = $previous ? 'prev' : 'next'; $string = '<a href="' . get_permalink( $post ) . '" rel="' . $rel . '">'; $inlink = str_replace( '%title', $title, $link ); $inlink = str_replace( '%date', $date, $inlink ); $inlink = $string . $inlink . '</a>'; $output = str_replace( '%link', $inlink, $format ); } $adjacent = $previous ? 'previous' : 'next'; return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent ); } function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy ); } function get_pagenum_link( $pagenum = 1, $escape = true ) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( 'paged' ); $home_root = parse_url( home_url() ); $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : ''; $home_root = preg_quote( $home_root, '|' ); $request = preg_replace( '|^' . $home_root . '|i', '', $request ); $request = preg_replace( '|^/+|', '', $request ); if ( ! $wp_rewrite->using_permalinks() || is_admin() ) { $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $pagenum > 1 ) { $result = add_query_arg( 'paged', $pagenum, $base . $request ); } else { $result = $base . $request; } } else { $qs_regex = '|\?.*?$|'; preg_match( $qs_regex, $request, $qs_match ); if ( ! empty( $qs_match[0] ) ) { $query_string = $qs_match[0]; $request = preg_replace( $qs_regex, '', $request ); } else { $query_string = ''; } $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request ); $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request ); $request = ltrim( $request, '/' ); $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) { $base .= $wp_rewrite->index . '/'; } if ( $pagenum > 1 ) { $request = ( ( ! empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . '/' . $pagenum, 'paged' ); } $result = $base . $request . $query_string; } $result = apply_filters( 'get_pagenum_link', $result, $pagenum ); if ( $escape ) { return esc_url( $result ); } else { return sanitize_url( $result ); } } function get_next_posts_page_link( $max_page = 0 ) { global $paged; if ( ! is_single() ) { if ( ! $paged ) { $paged = 1; } $nextpage = (int) $paged + 1; if ( ! $max_page || $max_page >= $nextpage ) { return get_pagenum_link( $nextpage ); } } } function next_posts( $max_page = 0, $display = true ) { $output = esc_url( get_next_posts_page_link( $max_page ) ); if ( $display ) { echo $output; } else { return $output; } } function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; if ( ! $max_page ) { $max_page = $wp_query->max_num_pages; } if ( ! $paged ) { $paged = 1; } $nextpage = (int) $paged + 1; if ( null === $label ) { $label = __( 'Next Page »' ); } if ( ! is_single() && ( $nextpage <= $max_page ) ) { $attr = apply_filters( 'next_posts_link_attributes', '' ); return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } } function next_posts_link( $label = null, $max_page = 0 ) { echo get_next_posts_link( $label, $max_page ); } function get_previous_posts_page_link() { global $paged; if ( ! is_single() ) { $nextpage = (int) $paged - 1; if ( $nextpage < 1 ) { $nextpage = 1; } return get_pagenum_link( $nextpage ); } } function previous_posts( $display = true ) { $output = esc_url( get_previous_posts_page_link() ); if ( $display ) { echo $output; } else { return $output; } } function get_previous_posts_link( $label = null ) { global $paged; if ( null === $label ) { $label = __( '« Previous Page' ); } if ( ! is_single() && $paged > 1 ) { $attr = apply_filters( 'previous_posts_link_attributes', '' ); return '<a href="' . previous_posts( false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } } function previous_posts_link( $label = null ) { echo get_previous_posts_link( $label ); } function get_posts_nav_link( $args = array() ) { global $wp_query; $return = ''; if ( ! is_singular() ) { $defaults = array( 'sep' => ' — ', 'prelabel' => __( '« Previous Page' ), 'nxtlabel' => __( 'Next Page »' ), ); $args = wp_parse_args( $args, $defaults ); $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var( 'paged' ); if ( $paged < 2 || $paged >= $max_num_pages ) { $args['sep'] = ''; } if ( $max_num_pages > 1 ) { $return = get_previous_posts_link( $args['prelabel'] ); $return .= preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $args['sep'] ); $return .= get_next_posts_link( $args['nxtlabel'] ); } } return $return; } function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { $args = array_filter( compact( 'sep', 'prelabel', 'nxtlabel' ) ); echo get_posts_nav_link( $args ); } function get_the_post_navigation( $args = array() ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'prev_text' => '%title', 'next_text' => '%title', 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category', 'screen_reader_text' => __( 'Post navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'post-navigation', ) ); $navigation = ''; $previous = get_previous_post_link( '<div class="nav-previous">%link</div>', $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy'] ); $next = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy'] ); if ( $previous || $next ) { $navigation = _navigation_markup( $previous . $next, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_post_navigation( $args = array() ) { echo get_the_post_navigation( $args ); } function get_the_posts_navigation( $args = array() ) { global $wp_query; $navigation = ''; if ( $wp_query->max_num_pages > 1 ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'prev_text' => __( 'Older posts' ), 'next_text' => __( 'Newer posts' ), 'screen_reader_text' => __( 'Posts navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'posts-navigation', ) ); $next_link = get_previous_posts_link( $args['next_text'] ); $prev_link = get_next_posts_link( $args['prev_text'] ); if ( $prev_link ) { $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; } if ( $next_link ) { $navigation .= '<div class="nav-next">' . $next_link . '</div>'; } $navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_posts_navigation( $args = array() ) { echo get_the_posts_navigation( $args ); } function get_the_posts_pagination( $args = array() ) { global $wp_query; $navigation = ''; if ( $wp_query->max_num_pages > 1 ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'mid_size' => 1, 'prev_text' => _x( 'Previous', 'previous set of posts' ), 'next_text' => _x( 'Next', 'next set of posts' ), 'screen_reader_text' => __( 'Posts navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'pagination', ) ); $args = apply_filters( 'the_posts_pagination_args', $args ); if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } $links = paginate_links( $args ); if ( $links ) { $navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } } return $navigation; } function the_posts_pagination( $args = array() ) { echo get_the_posts_pagination( $args ); } function _navigation_markup( $links, $css_class = 'posts-navigation', $screen_reader_text = '', $aria_label = '' ) { if ( empty( $screen_reader_text ) ) { $screen_reader_text = __( 'Posts navigation' ); } if ( empty( $aria_label ) ) { $aria_label = $screen_reader_text; } $template = ' + function the_permalink( $post = 0 ) { echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ); } function user_trailingslashit( $url, $type_of_url = '' ) { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes ) { $url = trailingslashit( $url ); } else { $url = untrailingslashit( $url ); } return apply_filters( 'user_trailingslashit', $url, $type_of_url ); } function permalink_anchor( $mode = 'id' ) { $post = get_post(); switch ( strtolower( $mode ) ) { case 'title': $title = sanitize_title( $post->post_title ) . '-' . $post->ID; echo '<a id="' . $title . '"></a>'; break; case 'id': default: echo '<a id="post-' . $post->ID . '"></a>'; break; } } function wp_force_plain_post_permalink( $post = null, $sample = null ) { if ( null === $sample && is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) { $sample = true; } else { $post = get_post( $post ); $sample = null !== $sample ? $sample : false; } if ( ! $post ) { return true; } $post_status_obj = get_post_status_object( get_post_status( $post ) ); $post_type_obj = get_post_type_object( get_post_type( $post ) ); if ( ! $post_status_obj || ! $post_type_obj ) { return true; } if ( is_post_status_viewable( $post_status_obj ) || ( $post_status_obj->private && current_user_can( 'read_post', $post->ID ) ) || ( $post_status_obj->protected && $sample ) ) { return false; } return true; } function get_the_permalink( $post = 0, $leavename = false ) { return get_permalink( $post, $leavename ); } function get_permalink( $post = 0, $leavename = false ) { $rewritecode = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%', ); if ( is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) { $sample = true; } else { $post = get_post( $post ); $sample = false; } if ( empty( $post->ID ) ) { return false; } if ( 'page' === $post->post_type ) { return get_page_link( $post, $leavename, $sample ); } elseif ( 'attachment' === $post->post_type ) { return get_attachment_link( $post, $leavename ); } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) { return get_post_permalink( $post, $leavename, $sample ); } $permalink = get_option( 'permalink_structure' ); $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); if ( $permalink && ! wp_force_plain_post_permalink( $post ) ) { $category = ''; if ( strpos( $permalink, '%category%' ) !== false ) { $cats = get_the_category( $post->ID ); if ( $cats ) { $cats = wp_list_sort( $cats, array( 'term_id' => 'ASC', ) ); $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); $category_object = get_term( $category_object, 'category' ); $category = $category_object->slug; if ( $category_object->parent ) { $category = get_category_parents( $category_object->parent, false, '/', true ) . $category; } } if ( empty( $category ) ) { $default_category = get_term( get_option( 'default_category' ), 'category' ); if ( $default_category && ! is_wp_error( $default_category ) ) { $category = $default_category->slug; } } } $author = ''; if ( strpos( $permalink, '%author%' ) !== false ) { $authordata = get_userdata( $post->post_author ); $author = $authordata->user_nicename; } $date = explode( ' ', str_replace( array( '-', ':' ), ' ', $post->post_date ) ); $rewritereplace = array( $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name, ); $permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) ); $permalink = user_trailingslashit( $permalink, 'single' ); } else { $permalink = home_url( '?p=' . $post->ID ); } return apply_filters( 'post_link', $permalink, $post, $leavename ); } function get_post_permalink( $post = 0, $leavename = false, $sample = false ) { global $wp_rewrite; $post = get_post( $post ); if ( ! $post ) { return false; } $post_link = $wp_rewrite->get_extra_permastruct( $post->post_type ); $slug = $post->post_name; $force_plain_link = wp_force_plain_post_permalink( $post ); $post_type = get_post_type_object( $post->post_type ); if ( $post_type->hierarchical ) { $slug = get_page_uri( $post ); } if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) { if ( ! $leavename ) { $post_link = str_replace( "%$post->post_type%", $slug, $post_link ); } $post_link = home_url( user_trailingslashit( $post_link ) ); } else { if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_plain_link ) ) { $post_link = add_query_arg( $post_type->query_var, $slug, '' ); } else { $post_link = add_query_arg( array( 'post_type' => $post->post_type, 'p' => $post->ID, ), '' ); } $post_link = home_url( $post_link ); } return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample ); } function get_page_link( $post = false, $leavename = false, $sample = false ) { $post = get_post( $post ); if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { $link = home_url( '/' ); } else { $link = _get_page_link( $post, $leavename, $sample ); } return apply_filters( 'page_link', $link, $post->ID, $sample ); } function _get_page_link( $post = false, $leavename = false, $sample = false ) { global $wp_rewrite; $post = get_post( $post ); $force_plain_link = wp_force_plain_post_permalink( $post ); $link = $wp_rewrite->get_page_permastruct(); if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) { if ( ! $leavename ) { $link = str_replace( '%pagename%', get_page_uri( $post ), $link ); } $link = home_url( $link ); $link = user_trailingslashit( $link, 'page' ); } else { $link = home_url( '?page_id=' . $post->ID ); } return apply_filters( '_get_page_link', $link, $post->ID ); } function get_attachment_link( $post = null, $leavename = false ) { global $wp_rewrite; $link = false; $post = get_post( $post ); $force_plain_link = wp_force_plain_post_permalink( $post ); $parent_id = $post->post_parent; $parent = $parent_id ? get_post( $parent_id ) : false; $parent_valid = true; if ( $parent_id && ( $post->post_parent === $post->ID || ! $parent || ! is_post_type_viewable( get_post_type( $parent ) ) ) ) { $parent_valid = false; } if ( $force_plain_link || ! $parent_valid ) { $link = false; } elseif ( $wp_rewrite->using_permalinks() && $parent ) { if ( 'page' === $parent->post_type ) { $parentlink = _get_page_link( $post->post_parent ); } else { $parentlink = get_permalink( $post->post_parent ); } if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) { $name = 'attachment/' . $post->post_name; } else { $name = $post->post_name; } if ( strpos( $parentlink, '?' ) === false ) { $link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' ); } if ( ! $leavename ) { $link = str_replace( '%postname%', $name, $link ); } } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) { $link = home_url( user_trailingslashit( $post->post_name ) ); } if ( ! $link ) { $link = home_url( '/?attachment_id=' . $post->ID ); } return apply_filters( 'attachment_link', $link, $post->ID ); } function get_year_link( $year ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } $yearlink = $wp_rewrite->get_year_permastruct(); if ( ! empty( $yearlink ) ) { $yearlink = str_replace( '%year%', $year, $yearlink ); $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); } else { $yearlink = home_url( '?m=' . $year ); } return apply_filters( 'year_link', $yearlink, $year ); } function get_month_link( $year, $month ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } if ( ! $month ) { $month = current_time( 'm' ); } $monthlink = $wp_rewrite->get_month_permastruct(); if ( ! empty( $monthlink ) ) { $monthlink = str_replace( '%year%', $year, $monthlink ); $monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink ); $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); } else { $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); } return apply_filters( 'month_link', $monthlink, $year, $month ); } function get_day_link( $year, $month, $day ) { global $wp_rewrite; if ( ! $year ) { $year = current_time( 'Y' ); } if ( ! $month ) { $month = current_time( 'm' ); } if ( ! $day ) { $day = current_time( 'j' ); } $daylink = $wp_rewrite->get_day_permastruct(); if ( ! empty( $daylink ) ) { $daylink = str_replace( '%year%', $year, $daylink ); $daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink ); $daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink ); $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); } else { $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); } return apply_filters( 'day_link', $daylink, $year, $month, $day ); } function the_feed_link( $anchor, $feed = '' ) { $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; echo apply_filters( 'the_feed_link', $link, $feed ); } function get_feed_link( $feed = '' ) { global $wp_rewrite; $permalink = $wp_rewrite->get_feed_permastruct(); if ( $permalink ) { if ( false !== strpos( $feed, 'comments_' ) ) { $feed = str_replace( 'comments_', '', $feed ); $permalink = $wp_rewrite->get_comment_feed_permastruct(); } if ( get_default_feed() == $feed ) { $feed = ''; } $permalink = str_replace( '%feed%', $feed, $permalink ); $permalink = preg_replace( '#/+#', '/', "/$permalink" ); $output = home_url( user_trailingslashit( $permalink, 'feed' ) ); } else { if ( empty( $feed ) ) { $feed = get_default_feed(); } if ( false !== strpos( $feed, 'comments_' ) ) { $feed = str_replace( 'comments_', 'comments-', $feed ); } $output = home_url( "?feed={$feed}" ); } return apply_filters( 'feed_link', $output, $feed ); } function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { $post_id = absint( $post_id ); if ( ! $post_id ) { $post_id = get_the_ID(); } if ( empty( $feed ) ) { $feed = get_default_feed(); } $post = get_post( $post_id ); if ( ! $post instanceof WP_Post ) { return ''; } $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; if ( get_option( 'permalink_structure' ) ) { if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) { $url = _get_page_link( $post_id ); } else { $url = get_permalink( $post_id ); } if ( $unattached ) { $url = home_url( '/feed/' ); if ( get_default_feed() !== $feed ) { $url .= "$feed/"; } $url = add_query_arg( 'attachment_id', $post_id, $url ); } else { $url = trailingslashit( $url ) . 'feed'; if ( get_default_feed() != $feed ) { $url .= "/$feed"; } $url = user_trailingslashit( $url, 'single_feed' ); } } else { if ( $unattached ) { $url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id, ), home_url( '/' ) ); } elseif ( 'page' === $post->post_type ) { $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id, ), home_url( '/' ) ); } else { $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id, ), home_url( '/' ) ); } } return apply_filters( 'post_comments_feed_link', $url ); } function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { $url = get_post_comments_feed_link( $post_id, $feed ); if ( empty( $link_text ) ) { $link_text = __( 'Comments Feed' ); } $link = '<a href="' . esc_url( $url ) . '">' . $link_text . '</a>'; echo apply_filters( 'post_comments_feed_link_html', $link, $post_id, $feed ); } function get_author_feed_link( $author_id, $feed = '' ) { $author_id = (int) $author_id; $permalink_structure = get_option( 'permalink_structure' ); if ( empty( $feed ) ) { $feed = get_default_feed(); } if ( ! $permalink_structure ) { $link = home_url( "?feed=$feed&author=" . $author_id ); } else { $link = get_author_posts_url( $author_id ); if ( get_default_feed() == $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; } $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); } $link = apply_filters( 'author_feed_link', $link, $feed ); return $link; } function get_category_feed_link( $cat, $feed = '' ) { return get_term_feed_link( $cat, 'category', $feed ); } function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) { if ( ! is_object( $term ) ) { $term = (int) $term; } $term = get_term( $term, $taxonomy ); if ( empty( $term ) || is_wp_error( $term ) ) { return false; } $taxonomy = $term->taxonomy; if ( empty( $feed ) ) { $feed = get_default_feed(); } $permalink_structure = get_option( 'permalink_structure' ); if ( ! $permalink_structure ) { if ( 'category' === $taxonomy ) { $link = home_url( "?feed=$feed&cat=$term->term_id" ); } elseif ( 'post_tag' === $taxonomy ) { $link = home_url( "?feed=$feed&tag=$term->slug" ); } else { $t = get_taxonomy( $taxonomy ); $link = home_url( "?feed=$feed&$t->query_var=$term->slug" ); } } else { $link = get_term_link( $term, $term->taxonomy ); if ( get_default_feed() == $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; } $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); } if ( 'category' === $taxonomy ) { $link = apply_filters( 'category_feed_link', $link, $feed ); } elseif ( 'post_tag' === $taxonomy ) { $link = apply_filters( 'tag_feed_link', $link, $feed ); } else { $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); } return $link; } function get_tag_feed_link( $tag, $feed = '' ) { return get_term_feed_link( $tag, 'post_tag', $feed ); } function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) { return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) ); } function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { $link = edit_term_link( $link, '', '', $tag, false ); echo $before . apply_filters( 'edit_tag_link', $link ) . $after; } function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) { $term = get_term( $term, $taxonomy ); if ( ! $term || is_wp_error( $term ) ) { return; } $tax = get_taxonomy( $term->taxonomy ); $term_id = $term->term_id; if ( ! $tax || ! current_user_can( 'edit_term', $term_id ) ) { return; } $args = array( 'taxonomy' => $taxonomy, 'tag_ID' => $term_id, ); if ( $object_type ) { $args['post_type'] = $object_type; } elseif ( ! empty( $tax->object_type ) ) { $args['post_type'] = reset( $tax->object_type ); } if ( $tax->show_ui ) { $location = add_query_arg( $args, admin_url( 'term.php' ) ); } else { $location = ''; } return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); } function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) { if ( is_null( $term ) ) { $term = get_queried_object(); } else { $term = get_term( $term ); } if ( ! $term ) { return; } $tax = get_taxonomy( $term->taxonomy ); if ( ! current_user_can( 'edit_term', $term->term_id ) ) { return; } if ( empty( $link ) ) { $link = __( 'Edit This' ); } $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; if ( $display ) { echo $link; } else { return $link; } } function get_search_link( $query = '' ) { global $wp_rewrite; if ( empty( $query ) ) { $search = get_search_query( false ); } else { $search = stripslashes( $query ); } $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = home_url( '?s=' . urlencode( $search ) ); } else { $search = urlencode( $search ); $search = str_replace( '%2F', '/', $search ); $link = str_replace( '%search%', $search, $permastruct ); $link = home_url( user_trailingslashit( $link, 'search' ) ); } return apply_filters( 'search_link', $link, $search ); } function get_search_feed_link( $search_query = '', $feed = '' ) { global $wp_rewrite; $link = get_search_link( $search_query ); if ( empty( $feed ) ) { $feed = get_default_feed(); } $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = add_query_arg( 'feed', $feed, $link ); } else { $link = trailingslashit( $link ); $link .= "feed/$feed/"; } return apply_filters( 'search_feed_link', $link, $feed, 'posts' ); } function get_search_comments_feed_link( $search_query = '', $feed = '' ) { global $wp_rewrite; if ( empty( $feed ) ) { $feed = get_default_feed(); } $link = get_search_feed_link( $search_query, $feed ); $permastruct = $wp_rewrite->get_search_permastruct(); if ( empty( $permastruct ) ) { $link = add_query_arg( 'feed', 'comments-' . $feed, $link ); } else { $link = add_query_arg( 'withcomments', 1, $link ); } return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); } function get_post_type_archive_link( $post_type ) { global $wp_rewrite; $post_type_obj = get_post_type_object( $post_type ); if ( ! $post_type_obj ) { return false; } if ( 'post' === $post_type ) { $show_on_front = get_option( 'show_on_front' ); $page_for_posts = get_option( 'page_for_posts' ); if ( 'page' === $show_on_front && $page_for_posts ) { $link = get_permalink( $page_for_posts ); } else { $link = get_home_url(); } return apply_filters( 'post_type_archive_link', $link, $post_type ); } if ( ! $post_type_obj->has_archive ) { return false; } if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; if ( $post_type_obj->rewrite['with_front'] ) { $struct = $wp_rewrite->front . $struct; } else { $struct = $wp_rewrite->root . $struct; } $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); } else { $link = home_url( '?post_type=' . $post_type ); } return apply_filters( 'post_type_archive_link', $link, $post_type ); } function get_post_type_archive_feed_link( $post_type, $feed = '' ) { $default_feed = get_default_feed(); if ( empty( $feed ) ) { $feed = $default_feed; } $link = get_post_type_archive_link( $post_type ); if ( ! $link ) { return false; } $post_type_obj = get_post_type_object( $post_type ); if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { $link = trailingslashit( $link ); $link .= 'feed/'; if ( $feed != $default_feed ) { $link .= "$feed/"; } } else { $link = add_query_arg( 'feed', $feed, $link ); } return apply_filters( 'post_type_archive_feed_link', $link, $feed ); } function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) { $post = get_post( $post ); if ( ! $post ) { return; } $post_type_object = get_post_type_object( $post->post_type ); if ( is_post_type_viewable( $post_type_object ) ) { if ( ! $preview_link ) { $preview_link = set_url_scheme( get_permalink( $post ) ); } $query_args['preview'] = 'true'; $preview_link = add_query_arg( $query_args, $preview_link ); } return apply_filters( 'preview_post_link', $preview_link, $post ); } function get_edit_post_link( $post = 0, $context = 'display' ) { $post = get_post( $post ); if ( ! $post ) { return; } if ( 'revision' === $post->post_type ) { $action = ''; } elseif ( 'display' === $context ) { $action = '&action=edit'; } else { $action = '&action=edit'; } $post_type_object = get_post_type_object( $post->post_type ); if ( ! $post_type_object ) { return; } if ( ! current_user_can( 'edit_post', $post->ID ) ) { return; } if ( $post_type_object->_edit_link ) { $link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ); } else { $link = ''; } return apply_filters( 'get_edit_post_link', $link, $post->ID, $context ); } function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' ) { $post = get_post( $post ); if ( ! $post ) { return; } $url = get_edit_post_link( $post->ID ); if ( ! $url ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="' . esc_attr( $css_class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>'; echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; } function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '3.0.0' ); } $post = get_post( $post ); if ( ! $post ) { return; } $post_type_object = get_post_type_object( $post->post_type ); if ( ! $post_type_object ) { return; } if ( ! current_user_can( 'delete_post', $post->ID ) ) { return; } $action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); } function get_edit_comment_link( $comment_id = 0 ) { $comment = get_comment( $comment_id ); if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } $location = admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID; return apply_filters( 'get_edit_comment_link', $location ); } function edit_comment_link( $text = null, $before = '', $after = '' ) { $comment = get_comment(); if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } if ( null === $text ) { $text = __( 'Edit This' ); } $link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>'; echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; } function get_edit_bookmark_link( $link = 0 ) { $link = get_bookmark( $link ); if ( ! current_user_can( 'manage_links' ) ) { return; } $location = admin_url( 'link.php?action=edit&link_id=' ) . $link->link_id; return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); } function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { $bookmark = get_bookmark( $bookmark ); if ( ! current_user_can( 'manage_links' ) ) { return; } if ( empty( $link ) ) { $link = __( 'Edit This' ); } $link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>'; echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; } function get_edit_user_link( $user_id = null ) { if ( ! $user_id ) { $user_id = get_current_user_id(); } if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) { return ''; } $user = get_userdata( $user_id ); if ( ! $user ) { return ''; } if ( get_current_user_id() == $user->ID ) { $link = get_edit_profile_url( $user->ID ); } else { $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); } return apply_filters( 'get_edit_user_link', $link, $user->ID ); } function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); } function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); } function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { global $wpdb; $post = get_post(); if ( ! $post || ! taxonomy_exists( $taxonomy ) ) { return null; } $current_post_date = $post->post_date; $join = ''; $where = ''; $adjacent = $previous ? 'previous' : 'next'; if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { if ( false !== strpos( $excluded_terms, ' and ' ) ) { _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); $excluded_terms = explode( ' and ', $excluded_terms ); } else { $excluded_terms = explode( ',', $excluded_terms ); } $excluded_terms = array_map( 'intval', $excluded_terms ); } $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); if ( $in_same_term || ! empty( $excluded_terms ) ) { if ( $in_same_term ) { $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy ); if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { return ''; } $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); $term_array = array_diff( $term_array, (array) $excluded_terms ); $term_array = array_map( 'intval', $term_array ); if ( ! $term_array || is_wp_error( $term_array ) ) { return ''; } $where .= ' AND tt.term_id IN (' . implode( ',', $term_array ) . ')'; } if ( ! empty( $excluded_terms ) ) { $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', array_map( 'intval', $excluded_terms ) ) . ') )'; } } if ( is_user_logged_in() ) { $user_id = get_current_user_id(); $post_type_object = get_post_type_object( $post->post_type ); if ( empty( $post_type_object ) ) { $post_type_cap = $post->post_type; $read_private_cap = 'read_private_' . $post_type_cap . 's'; } else { $read_private_cap = $post_type_object->cap->read_private_posts; } $private_states = get_post_stati( array( 'private' => true ) ); $where .= " AND ( p.post_status = 'publish'"; foreach ( $private_states as $state ) { if ( current_user_can( $read_private_cap ) ) { $where .= $wpdb->prepare( ' OR p.post_status = %s', $state ); } else { $where .= $wpdb->prepare( ' OR (p.post_author = %d AND p.post_status = %s)', $user_id, $state ); } } $where .= ' )'; } else { $where .= " AND p.post_status = 'publish'"; } $op = $previous ? '<' : '>'; $order = $previous ? 'DESC' : 'ASC'; $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post ); $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post ); $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order ); $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; $key = md5( $query ); $last_changed = wp_cache_get_last_changed( 'posts' ); if ( $in_same_term || ! empty( $excluded_terms ) ) { $last_changed .= wp_cache_get_last_changed( 'terms' ); } $cache_key = "adjacent_post:$key:$last_changed"; $result = wp_cache_get( $cache_key, 'posts' ); if ( false !== $result ) { if ( $result ) { $result = get_post( $result ); } return $result; } $result = $wpdb->get_var( $query ); if ( null === $result ) { $result = ''; } wp_cache_set( $cache_key, $result, 'posts' ); if ( $result ) { $result = get_post( $result ); } return $result; } function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { $post = get_post(); if ( $previous && is_attachment() && $post ) { $post = get_post( $post->post_parent ); } else { $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); } if ( empty( $post ) ) { return; } $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post, ) ); if ( empty( $post_title ) ) { $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); } $date = mysql2date( get_option( 'date_format' ), $post->post_date ); $title = str_replace( '%title', $post_title, $title ); $title = str_replace( '%date', $date, $title ); $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; $link .= esc_attr( $title ); $link .= "' href='" . get_permalink( $post ) . "' />\n"; $adjacent = $previous ? 'previous' : 'next'; return apply_filters( "{$adjacent}_post_rel_link", $link ); } function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); } function adjacent_posts_rel_link_wp_head() { if ( ! is_single() || is_attachment() ) { return; } adjacent_posts_rel_link(); } function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); } function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); } function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { $post = get_post(); if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) { return null; } $query_args = array( 'posts_per_page' => 1, 'order' => $start ? 'ASC' : 'DESC', 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ); $term_array = array(); if ( ! is_array( $excluded_terms ) ) { if ( ! empty( $excluded_terms ) ) { $excluded_terms = explode( ',', $excluded_terms ); } else { $excluded_terms = array(); } } if ( $in_same_term || ! empty( $excluded_terms ) ) { if ( $in_same_term ) { $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); } if ( ! empty( $excluded_terms ) ) { $excluded_terms = array_map( 'intval', $excluded_terms ); $excluded_terms = array_diff( $excluded_terms, $term_array ); $inverse_terms = array(); foreach ( $excluded_terms as $excluded_term ) { $inverse_terms[] = $excluded_term * -1; } $excluded_terms = $inverse_terms; } $query_args['tax_query'] = array( array( 'taxonomy' => $taxonomy, 'terms' => array_merge( $term_array, $excluded_terms ), ), ); } return get_posts( $query_args ); } function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy ); } function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); } function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy ); } function next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); } function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { if ( $previous && is_attachment() ) { $post = get_post( get_post()->post_parent ); } else { $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); } if ( ! $post ) { $output = ''; } else { $title = $post->post_title; if ( empty( $post->post_title ) ) { $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); } $title = apply_filters( 'the_title', $title, $post->ID ); $date = mysql2date( get_option( 'date_format' ), $post->post_date ); $rel = $previous ? 'prev' : 'next'; $string = '<a href="' . get_permalink( $post ) . '" rel="' . $rel . '">'; $inlink = str_replace( '%title', $title, $link ); $inlink = str_replace( '%date', $date, $inlink ); $inlink = $string . $inlink . '</a>'; $output = str_replace( '%link', $inlink, $format ); } $adjacent = $previous ? 'previous' : 'next'; return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent ); } function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy ); } function get_pagenum_link( $pagenum = 1, $escape = true ) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( 'paged' ); $home_root = parse_url( home_url() ); $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : ''; $home_root = preg_quote( $home_root, '|' ); $request = preg_replace( '|^' . $home_root . '|i', '', $request ); $request = preg_replace( '|^/+|', '', $request ); if ( ! $wp_rewrite->using_permalinks() || is_admin() ) { $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $pagenum > 1 ) { $result = add_query_arg( 'paged', $pagenum, $base . $request ); } else { $result = $base . $request; } } else { $qs_regex = '|\?.*?$|'; preg_match( $qs_regex, $request, $qs_match ); if ( ! empty( $qs_match[0] ) ) { $query_string = $qs_match[0]; $request = preg_replace( $qs_regex, '', $request ); } else { $query_string = ''; } $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request ); $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request ); $request = ltrim( $request, '/' ); $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) { $base .= $wp_rewrite->index . '/'; } if ( $pagenum > 1 ) { $request = ( ( ! empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . '/' . $pagenum, 'paged' ); } $result = $base . $request . $query_string; } $result = apply_filters( 'get_pagenum_link', $result, $pagenum ); if ( $escape ) { return esc_url( $result ); } else { return sanitize_url( $result ); } } function get_next_posts_page_link( $max_page = 0 ) { global $paged; if ( ! is_single() ) { if ( ! $paged ) { $paged = 1; } $nextpage = (int) $paged + 1; if ( ! $max_page || $max_page >= $nextpage ) { return get_pagenum_link( $nextpage ); } } } function next_posts( $max_page = 0, $display = true ) { $output = esc_url( get_next_posts_page_link( $max_page ) ); if ( $display ) { echo $output; } else { return $output; } } function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; if ( ! $max_page ) { $max_page = $wp_query->max_num_pages; } if ( ! $paged ) { $paged = 1; } $nextpage = (int) $paged + 1; if ( null === $label ) { $label = __( 'Next Page »' ); } if ( ! is_single() && ( $nextpage <= $max_page ) ) { $attr = apply_filters( 'next_posts_link_attributes', '' ); return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } } function next_posts_link( $label = null, $max_page = 0 ) { echo get_next_posts_link( $label, $max_page ); } function get_previous_posts_page_link() { global $paged; if ( ! is_single() ) { $nextpage = (int) $paged - 1; if ( $nextpage < 1 ) { $nextpage = 1; } return get_pagenum_link( $nextpage ); } } function previous_posts( $display = true ) { $output = esc_url( get_previous_posts_page_link() ); if ( $display ) { echo $output; } else { return $output; } } function get_previous_posts_link( $label = null ) { global $paged; if ( null === $label ) { $label = __( '« Previous Page' ); } if ( ! is_single() && $paged > 1 ) { $attr = apply_filters( 'previous_posts_link_attributes', '' ); return '<a href="' . previous_posts( false ) . "\" $attr>" . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } } function previous_posts_link( $label = null ) { echo get_previous_posts_link( $label ); } function get_posts_nav_link( $args = array() ) { global $wp_query; $return = ''; if ( ! is_singular() ) { $defaults = array( 'sep' => ' — ', 'prelabel' => __( '« Previous Page' ), 'nxtlabel' => __( 'Next Page »' ), ); $args = wp_parse_args( $args, $defaults ); $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var( 'paged' ); if ( $paged < 2 || $paged >= $max_num_pages ) { $args['sep'] = ''; } if ( $max_num_pages > 1 ) { $return = get_previous_posts_link( $args['prelabel'] ); $return .= preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $args['sep'] ); $return .= get_next_posts_link( $args['nxtlabel'] ); } } return $return; } function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { $args = array_filter( compact( 'sep', 'prelabel', 'nxtlabel' ) ); echo get_posts_nav_link( $args ); } function get_the_post_navigation( $args = array() ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'prev_text' => '%title', 'next_text' => '%title', 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category', 'screen_reader_text' => __( 'Post navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'post-navigation', ) ); $navigation = ''; $previous = get_previous_post_link( '<div class="nav-previous">%link</div>', $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy'] ); $next = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy'] ); if ( $previous || $next ) { $navigation = _navigation_markup( $previous . $next, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_post_navigation( $args = array() ) { echo get_the_post_navigation( $args ); } function get_the_posts_navigation( $args = array() ) { global $wp_query; $navigation = ''; if ( $wp_query->max_num_pages > 1 ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'prev_text' => __( 'Older posts' ), 'next_text' => __( 'Newer posts' ), 'screen_reader_text' => __( 'Posts navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'posts-navigation', ) ); $next_link = get_previous_posts_link( $args['next_text'] ); $prev_link = get_next_posts_link( $args['prev_text'] ); if ( $prev_link ) { $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; } if ( $next_link ) { $navigation .= '<div class="nav-next">' . $next_link . '</div>'; } $navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_posts_navigation( $args = array() ) { echo get_the_posts_navigation( $args ); } function get_the_posts_pagination( $args = array() ) { global $wp_query; $navigation = ''; if ( $wp_query->max_num_pages > 1 ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'mid_size' => 1, 'prev_text' => _x( 'Previous', 'previous set of posts' ), 'next_text' => _x( 'Next', 'next set of posts' ), 'screen_reader_text' => __( 'Posts navigation' ), 'aria_label' => __( 'Posts' ), 'class' => 'pagination', ) ); $args = apply_filters( 'the_posts_pagination_args', $args ); if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } $links = paginate_links( $args ); if ( $links ) { $navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } } return $navigation; } function the_posts_pagination( $args = array() ) { echo get_the_posts_pagination( $args ); } function _navigation_markup( $links, $css_class = 'posts-navigation', $screen_reader_text = '', $aria_label = '' ) { if ( empty( $screen_reader_text ) ) { $screen_reader_text = __( 'Posts navigation' ); } if ( empty( $aria_label ) ) { $aria_label = $screen_reader_text; } $template = ' <nav class="navigation %1$s" aria-label="%4$s"> <h2 class="screen-reader-text">%2$s</h2> <div class="nav-links">%3$s</div> </nav>'; $template = apply_filters( 'navigation_markup_template', $template, $css_class ); return sprintf( $template, sanitize_html_class( $css_class ), esc_html( $screen_reader_text ), $links, esc_html( $aria_label ) ); } function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { global $wp_rewrite; $pagenum = (int) $pagenum; $result = get_permalink(); if ( 'newest' === get_option( 'default_comments_page' ) ) { if ( $pagenum != $max_page ) { if ( $wp_rewrite->using_permalinks() ) { $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' ); } else { $result = add_query_arg( 'cpage', $pagenum, $result ); } } } elseif ( $pagenum > 1 ) { if ( $wp_rewrite->using_permalinks() ) { $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' ); } else { $result = add_query_arg( 'cpage', $pagenum, $result ); } } $result .= '#comments'; return apply_filters( 'get_comments_pagenum_link', $result ); } function get_next_comments_link( $label = '', $max_page = 0 ) { global $wp_query; if ( ! is_singular() ) { return; } $page = get_query_var( 'cpage' ); if ( ! $page ) { $page = 1; } $nextpage = (int) $page + 1; if ( empty( $max_page ) ) { $max_page = $wp_query->max_num_comment_pages; } if ( empty( $max_page ) ) { $max_page = get_comment_pages_count(); } if ( $nextpage > $max_page ) { return; } if ( empty( $label ) ) { $label = __( 'Newer Comments »' ); } return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } function next_comments_link( $label = '', $max_page = 0 ) { echo get_next_comments_link( $label, $max_page ); } function get_previous_comments_link( $label = '' ) { if ( ! is_singular() ) { return; } $page = get_query_var( 'cpage' ); if ( (int) $page <= 1 ) { return; } $prevpage = (int) $page - 1; if ( empty( $label ) ) { $label = __( '« Older Comments' ); } return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) . '</a>'; } function previous_comments_link( $label = '' ) { echo get_previous_comments_link( $label ); } function paginate_comments_links( $args = array() ) { global $wp_rewrite; if ( ! is_singular() ) { return; } $page = get_query_var( 'cpage' ); if ( ! $page ) { $page = 1; } $max_page = get_comment_pages_count(); $defaults = array( 'base' => add_query_arg( 'cpage', '%#%' ), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'type' => 'plain', 'add_fragment' => '#comments', ); if ( $wp_rewrite->using_permalinks() ) { $defaults['base'] = user_trailingslashit( trailingslashit( get_permalink() ) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged' ); } $args = wp_parse_args( $args, $defaults ); $page_links = paginate_links( $args ); if ( $args['echo'] && 'array' !== $args['type'] ) { echo $page_links; } else { return $page_links; } } function get_the_comments_navigation( $args = array() ) { $navigation = ''; if ( get_comment_pages_count() > 1 ) { if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'prev_text' => __( 'Older comments' ), 'next_text' => __( 'Newer comments' ), 'screen_reader_text' => __( 'Comments navigation' ), 'aria_label' => __( 'Comments' ), 'class' => 'comment-navigation', ) ); $prev_link = get_previous_comments_link( $args['prev_text'] ); $next_link = get_next_comments_link( $args['next_text'] ); if ( $prev_link ) { $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; } if ( $next_link ) { $navigation .= '<div class="nav-next">' . $next_link . '</div>'; } $navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_comments_navigation( $args = array() ) { echo get_the_comments_navigation( $args ); } function get_the_comments_pagination( $args = array() ) { $navigation = ''; if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) { $args['aria_label'] = $args['screen_reader_text']; } $args = wp_parse_args( $args, array( 'screen_reader_text' => __( 'Comments navigation' ), 'aria_label' => __( 'Comments' ), 'class' => 'comments-pagination', ) ); $args['echo'] = false; if ( isset( $args['type'] ) && 'array' === $args['type'] ) { $args['type'] = 'plain'; } $links = paginate_comments_links( $args ); if ( $links ) { $navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] ); } return $navigation; } function the_comments_pagination( $args = array() ) { echo get_the_comments_pagination( $args ); } function home_url( $path = '', $scheme = null ) { return get_home_url( null, $path, $scheme ); } function get_home_url( $blog_id = null, $path = '', $scheme = null ) { $orig_scheme = $scheme; if ( empty( $blog_id ) || ! is_multisite() ) { $url = get_option( 'home' ); } else { switch_to_blog( $blog_id ); $url = get_option( 'home' ); restore_current_blog(); } if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) { if ( is_ssl() ) { $scheme = 'https'; } else { $scheme = parse_url( $url, PHP_URL_SCHEME ); } } $url = set_url_scheme( $url, $scheme ); if ( $path && is_string( $path ) ) { $url .= '/' . ltrim( $path, '/' ); } return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); } function site_url( $path = '', $scheme = null ) { return get_site_url( null, $path, $scheme ); } function get_site_url( $blog_id = null, $path = '', $scheme = null ) { if ( empty( $blog_id ) || ! is_multisite() ) { $url = get_option( 'siteurl' ); } else { switch_to_blog( $blog_id ); $url = get_option( 'siteurl' ); restore_current_blog(); } $url = set_url_scheme( $url, $scheme ); if ( $path && is_string( $path ) ) { $url .= '/' . ltrim( $path, '/' ); } return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); } function admin_url( $path = '', $scheme = 'admin' ) { return get_admin_url( null, $path, $scheme ); } function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { $url = get_site_url( $blog_id, 'wp-admin/', $scheme ); if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'admin_url', $url, $path, $blog_id, $scheme ); } function includes_url( $path = '', $scheme = null ) { $url = site_url( '/' . WPINC . '/', $scheme ); if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'includes_url', $url, $path, $scheme ); } function content_url( $path = '' ) { $url = set_url_scheme( WP_CONTENT_URL ); if ( $path && is_string( $path ) ) { $url .= '/' . ltrim( $path, '/' ); } return apply_filters( 'content_url', $url, $path ); } function plugins_url( $path = '', $plugin = '' ) { $path = wp_normalize_path( $path ); $plugin = wp_normalize_path( $plugin ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); if ( ! empty( $plugin ) && 0 === strpos( $plugin, $mu_plugin_dir ) ) { $url = WPMU_PLUGIN_URL; } else { $url = WP_PLUGIN_URL; } $url = set_url_scheme( $url ); if ( ! empty( $plugin ) && is_string( $plugin ) ) { $folder = dirname( plugin_basename( $plugin ) ); if ( '.' !== $folder ) { $url .= '/' . ltrim( $folder, '/' ); } } if ( $path && is_string( $path ) ) { $url .= '/' . ltrim( $path, '/' ); } return apply_filters( 'plugins_url', $url, $path, $plugin ); } function network_site_url( $path = '', $scheme = null ) { if ( ! is_multisite() ) { return site_url( $path, $scheme ); } $current_network = get_network(); if ( 'relative' === $scheme ) { $url = $current_network->path; } else { $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); } if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'network_site_url', $url, $path, $scheme ); } function network_home_url( $path = '', $scheme = null ) { if ( ! is_multisite() ) { return home_url( $path, $scheme ); } $current_network = get_network(); $orig_scheme = $scheme; if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) { $scheme = is_ssl() ? 'https' : 'http'; } if ( 'relative' === $scheme ) { $url = $current_network->path; } else { $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme ); } if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'network_home_url', $url, $path, $orig_scheme ); } function network_admin_url( $path = '', $scheme = 'admin' ) { if ( ! is_multisite() ) { return admin_url( $path, $scheme ); } $url = network_site_url( 'wp-admin/network/', $scheme ); if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'network_admin_url', $url, $path, $scheme ); } function user_admin_url( $path = '', $scheme = 'admin' ) { $url = network_site_url( 'wp-admin/user/', $scheme ); if ( $path && is_string( $path ) ) { $url .= ltrim( $path, '/' ); } return apply_filters( 'user_admin_url', $url, $path, $scheme ); } function self_admin_url( $path = '', $scheme = 'admin' ) { if ( is_network_admin() ) { $url = network_admin_url( $path, $scheme ); } elseif ( is_user_admin() ) { $url = user_admin_url( $path, $scheme ); } else { $url = admin_url( $path, $scheme ); } return apply_filters( 'self_admin_url', $url, $path, $scheme ); } function set_url_scheme( $url, $scheme = null ) { $orig_scheme = $scheme; if ( ! $scheme ) { $scheme = is_ssl() ? 'https' : 'http'; } elseif ( 'admin' === $scheme || 'login' === $scheme || 'login_post' === $scheme || 'rpc' === $scheme ) { $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; } elseif ( 'http' !== $scheme && 'https' !== $scheme && 'relative' !== $scheme ) { $scheme = is_ssl() ? 'https' : 'http'; } $url = trim( $url ); if ( substr( $url, 0, 2 ) === '//' ) { $url = 'http:' . $url; } if ( 'relative' === $scheme ) { $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); if ( '' !== $url && '/' === $url[0] ) { $url = '/' . ltrim( $url, "/ \t\n\r\0\x0B" ); } } else { $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); } return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); } function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); $blogs = get_blogs_of_user( $user_id ); if ( is_multisite() && ! user_can( $user_id, 'manage_network' ) && empty( $blogs ) ) { $url = user_admin_url( $path, $scheme ); } elseif ( ! is_multisite() ) { $url = admin_url( $path, $scheme ); } else { $current_blog = get_current_blog_id(); if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ), true ) ) ) { $url = admin_url( $path, $scheme ); } else { $active = get_active_blog_for_user( $user_id ); if ( $active ) { $url = get_admin_url( $active->blog_id, $path, $scheme ); } else { $url = user_admin_url( $path, $scheme ); } } } return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme ); } function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); if ( is_user_admin() ) { $url = user_admin_url( 'profile.php', $scheme ); } elseif ( is_network_admin() ) { $url = network_admin_url( 'profile.php', $scheme ); } else { $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); } return apply_filters( 'edit_profile_url', $url, $user_id, $scheme ); } function wp_get_canonical_url( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } if ( 'publish' !== $post->post_status ) { return false; } $canonical_url = get_permalink( $post ); if ( get_queried_object_id() === $post->ID ) { $page = get_query_var( 'page', 0 ); if ( $page >= 2 ) { if ( ! get_option( 'permalink_structure' ) ) { $canonical_url = add_query_arg( 'page', $page, $canonical_url ); } else { $canonical_url = trailingslashit( $canonical_url ) . user_trailingslashit( $page, 'single_paged' ); } } $cpage = get_query_var( 'cpage', 0 ); if ( $cpage ) { $canonical_url = get_comments_pagenum_link( $cpage ); } } return apply_filters( 'get_canonical_url', $canonical_url, $post ); } function rel_canonical() { if ( ! is_singular() ) { return; } $id = get_queried_object_id(); if ( 0 === $id ) { return; } $url = wp_get_canonical_url( $id ); if ( ! empty( $url ) ) { echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n"; } } function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); if ( false !== $shortlink ) { return $shortlink; } $post_id = 0; if ( 'query' === $context && is_singular() ) { $post_id = get_queried_object_id(); $post = get_post( $post_id ); } elseif ( 'post' === $context ) { $post = get_post( $id ); if ( ! empty( $post->ID ) ) { $post_id = $post->ID; } } $shortlink = ''; if ( ! empty( $post_id ) ) { $post_type = get_post_type_object( $post->post_type ); if ( 'page' === $post->post_type && get_option( 'page_on_front' ) == $post->ID && 'page' === get_option( 'show_on_front' ) ) { $shortlink = home_url( '/' ); } elseif ( $post_type && $post_type->public ) { $shortlink = home_url( '?p=' . $post_id ); } } return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs ); } function wp_shortlink_wp_head() { $shortlink = wp_get_shortlink( 0, 'query' ); if ( empty( $shortlink ) ) { return; } echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n"; } function wp_shortlink_header() { if ( headers_sent() ) { return; } $shortlink = wp_get_shortlink( 0, 'query' ); if ( empty( $shortlink ) ) { return; } header( 'Link: <' . $shortlink . '>; rel=shortlink', false ); } function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { $post = get_post(); if ( empty( $text ) ) { $text = __( 'This is the short link.' ); } if ( empty( $title ) ) { $title = the_title_attribute( array( 'echo' => false ) ); } $shortlink = wp_get_shortlink( $post->ID ); if ( ! empty( $shortlink ) ) { $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); echo $before, $link, $after; } } function get_avatar_url( $id_or_email, $args = null ) { $args = get_avatar_data( $id_or_email, $args ); return $args['url']; } function is_avatar_comment_type( $comment_type ) { $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); return in_array( $comment_type, (array) $allowed_comment_types, true ); } function get_avatar_data( $id_or_email, $args = null ) { $args = wp_parse_args( $args, array( 'size' => 96, 'height' => null, 'width' => null, 'default' => get_option( 'avatar_default', 'mystery' ), 'force_default' => false, 'rating' => get_option( 'avatar_rating' ), 'scheme' => null, 'processed_args' => null, 'extra_attr' => '', ) ); if ( is_numeric( $args['size'] ) ) { $args['size'] = absint( $args['size'] ); if ( ! $args['size'] ) { $args['size'] = 96; } } else { $args['size'] = 96; } if ( is_numeric( $args['height'] ) ) { $args['height'] = absint( $args['height'] ); if ( ! $args['height'] ) { $args['height'] = $args['size']; } } else { $args['height'] = $args['size']; } if ( is_numeric( $args['width'] ) ) { $args['width'] = absint( $args['width'] ); if ( ! $args['width'] ) { $args['width'] = $args['size']; } } else { $args['width'] = $args['size']; } if ( empty( $args['default'] ) ) { $args['default'] = get_option( 'avatar_default', 'mystery' ); } switch ( $args['default'] ) { case 'mm': case 'mystery': case 'mysteryman': $args['default'] = 'mm'; break; case 'gravatar_default': $args['default'] = false; break; } $args['force_default'] = (bool) $args['force_default']; $args['rating'] = strtolower( $args['rating'] ); $args['found_avatar'] = false; $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email ); if ( isset( $args['url'] ) ) { return apply_filters( 'get_avatar_data', $args, $id_or_email ); } $email_hash = ''; $user = false; $email = false; if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { $id_or_email = get_comment( $id_or_email ); } if ( is_numeric( $id_or_email ) ) { $user = get_user_by( 'id', absint( $id_or_email ) ); } elseif ( is_string( $id_or_email ) ) { if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) { list( $email_hash ) = explode( '@', $id_or_email ); } else { $email = $id_or_email; } } elseif ( $id_or_email instanceof WP_User ) { $user = $id_or_email; } elseif ( $id_or_email instanceof WP_Post ) { $user = get_user_by( 'id', (int) $id_or_email->post_author ); } elseif ( $id_or_email instanceof WP_Comment ) { if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) { $args['url'] = false; return apply_filters( 'get_avatar_data', $args, $id_or_email ); } if ( ! empty( $id_or_email->user_id ) ) { $user = get_user_by( 'id', (int) $id_or_email->user_id ); } if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) { $email = $id_or_email->comment_author_email; } } if ( ! $email_hash ) { if ( $user ) { $email = $user->user_email; } if ( $email ) { $email_hash = md5( strtolower( trim( $email ) ) ); } } if ( $email_hash ) { $args['found_avatar'] = true; $gravatar_server = hexdec( $email_hash[0] ) % 3; } else { $gravatar_server = rand( 0, 2 ); } $url_args = array( 's' => $args['size'], 'd' => $args['default'], 'f' => $args['force_default'] ? 'y' : false, 'r' => $args['rating'], ); if ( is_ssl() ) { $url = 'https://secure.gravatar.com/avatar/' . $email_hash; } else { $url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash ); } $url = add_query_arg( rawurlencode_deep( array_filter( $url_args ) ), set_url_scheme( $url, $args['scheme'] ) ); $args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args ); return apply_filters( 'get_avatar_data', $args, $id_or_email ); } function get_theme_file_uri( $file = '' ) { $file = ltrim( $file, '/' ); if ( empty( $file ) ) { $url = get_stylesheet_directory_uri(); } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { $url = get_stylesheet_directory_uri() . '/' . $file; } else { $url = get_template_directory_uri() . '/' . $file; } return apply_filters( 'theme_file_uri', $url, $file ); } function get_parent_theme_file_uri( $file = '' ) { $file = ltrim( $file, '/' ); if ( empty( $file ) ) { $url = get_template_directory_uri(); } else { $url = get_template_directory_uri() . '/' . $file; } return apply_filters( 'parent_theme_file_uri', $url, $file ); } function get_theme_file_path( $file = '' ) { $file = ltrim( $file, '/' ); if ( empty( $file ) ) { $path = get_stylesheet_directory(); } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { $path = get_stylesheet_directory() . '/' . $file; } else { $path = get_template_directory() . '/' . $file; } return apply_filters( 'theme_file_path', $path, $file ); } function get_parent_theme_file_path( $file = '' ) { $file = ltrim( $file, '/' ); if ( empty( $file ) ) { $path = get_template_directory(); } else { $path = get_template_directory() . '/' . $file; } return apply_filters( 'parent_theme_file_path', $path, $file ); } function get_privacy_policy_url() { $url = ''; $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); if ( ! empty( $policy_page_id ) && get_post_status( $policy_page_id ) === 'publish' ) { $url = (string) get_permalink( $policy_page_id ); } return apply_filters( 'privacy_policy_url', $url, $policy_page_id ); } function the_privacy_policy_link( $before = '', $after = '' ) { echo get_the_privacy_policy_link( $before, $after ); } function get_the_privacy_policy_link( $before = '', $after = '' ) { $link = ''; $privacy_policy_url = get_privacy_policy_url(); $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); $page_title = ( $policy_page_id ) ? get_the_title( $policy_page_id ) : ''; if ( $privacy_policy_url && $page_title ) { $link = sprintf( '<a class="privacy-policy-link" href="%s">%s</a>', esc_url( $privacy_policy_url ), esc_html( $page_title ) ); } $link = apply_filters( 'the_privacy_policy_link', $link, $privacy_policy_url ); if ( $link ) { return $before . $link . $after; } return ''; } <?php - function wp_get_server_protocol() { $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { $protocol = 'HTTP/1.0'; } return $protocol; } function wp_fix_server_vars() { global $PHP_SELF; $default_server_values = array( 'SERVER_SOFTWARE' => '', 'REQUEST_URI' => '', ); $_SERVER = array_merge( $default_server_values, $_SERVER ); if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; } if ( isset( $_SERVER['PATH_INFO'] ) ) { if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; } else { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; } } if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; } if ( isset( $_SERVER['SCRIPT_NAME'] ) && ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) ) { unset( $_SERVER['PATH_INFO'] ); } $PHP_SELF = $_SERVER['PHP_SELF']; if ( empty( $PHP_SELF ) ) { $_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); $PHP_SELF = $_SERVER['PHP_SELF']; } wp_populate_basic_auth_from_authorization_header(); } function wp_populate_basic_auth_from_authorization_header() { if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) && ! isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) { return; } if ( isset( $_SERVER['PHP_AUTH_USER'] ) || isset( $_SERVER['PHP_AUTH_PW'] ) ) { return; } $header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) { return; } $token = substr( $header, 6 ); $userpass = base64_decode( $token ); list( $user, $pass ) = explode( ':', $userpass ); $_SERVER['PHP_AUTH_USER'] = $user; $_SERVER['PHP_AUTH_PW'] = $pass; } function wp_check_php_mysql_versions() { global $required_php_version, $wp_version; $php_version = PHP_VERSION; if ( version_compare( $required_php_version, $php_version, '>' ) ) { $protocol = wp_get_server_protocol(); header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); header( 'Content-Type: text/html; charset=utf-8' ); printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version ); exit( 1 ); } if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ( defined( 'WP_CONTENT_DIR' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) || ! file_exists( ABSPATH . 'wp-content/db.php' ) ) ) { require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early(); $args = array( 'exit' => false, 'code' => 'mysql_not_found', ); wp_die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ), __( 'Requirements Not Met' ), $args ); exit( 1 ); } } function wp_get_environment_type() { static $current_env = ''; if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) { return $current_env; } $wp_environments = array( 'local', 'development', 'staging', 'production', ); if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) { if ( function_exists( '__' ) ) { $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' ); } else { $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' ); } _deprecated_argument( 'define()', '5.5.1', $message ); } if ( function_exists( 'getenv' ) ) { $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); if ( false !== $has_env ) { $current_env = $has_env; } } if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) { $current_env = WP_ENVIRONMENT_TYPE; } if ( ! in_array( $current_env, $wp_environments, true ) ) { $current_env = 'production'; } return $current_env; } function wp_favicon_request() { if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) { header( 'Content-Type: image/vnd.microsoft.icon' ); exit; } } function wp_maintenance() { if ( ! wp_is_maintenance_mode() ) { return; } if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { require_once WP_CONTENT_DIR . '/maintenance.php'; die(); } require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early(); header( 'Retry-After: 600' ); wp_die( __( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ), __( 'Maintenance' ), 503 ); } function wp_is_maintenance_mode() { global $upgrading; if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { return false; } require ABSPATH . '.maintenance'; if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) { return false; } if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { return false; } return true; } function timer_float() { return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT']; } function timer_start() { global $timestart; $timestart = microtime( true ); return true; } function timer_stop( $display = 0, $precision = 3 ) { global $timestart, $timeend; $timeend = microtime( true ); $timetotal = $timeend - $timestart; $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); if ( $display ) { echo $r; } return $r; } function wp_debug_mode() { if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) { return; } if ( WP_DEBUG ) { error_reporting( E_ALL ); if ( WP_DEBUG_DISPLAY ) { ini_set( 'display_errors', 1 ); } elseif ( null !== WP_DEBUG_DISPLAY ) { ini_set( 'display_errors', 0 ); } if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { $log_path = WP_CONTENT_DIR . '/debug.log'; } elseif ( is_string( WP_DEBUG_LOG ) ) { $log_path = WP_DEBUG_LOG; } else { $log_path = false; } if ( $log_path ) { ini_set( 'log_errors', 1 ); ini_set( 'error_log', $log_path ); } } else { error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); } if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { ini_set( 'display_errors', 0 ); } } function wp_set_lang_dir() { if ( ! defined( 'WP_LANG_DIR' ) ) { if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) { define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { define( 'LANGDIR', 'wp-content/languages' ); } } else { define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { define( 'LANGDIR', WPINC . '/languages' ); } } } } function require_wp_db() { global $wpdb; require_once ABSPATH . WPINC . '/class-wpdb.php'; if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { require_once WP_CONTENT_DIR . '/db.php'; } if ( isset( $wpdb ) ) { return; } $dbuser = defined( 'DB_USER' ) ? DB_USER : ''; $dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : ''; $dbname = defined( 'DB_NAME' ) ? DB_NAME : ''; $dbhost = defined( 'DB_HOST' ) ? DB_HOST : ''; $wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost ); } function wp_set_wpdb_vars() { global $wpdb, $table_prefix; if ( ! empty( $wpdb->error ) ) { dead_db(); } $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', ); $prefix = $wpdb->set_prefix( $table_prefix ); if ( is_wp_error( $prefix ) ) { wp_load_translations_early(); wp_die( sprintf( __( '<strong>Error:</strong> %1$s in %2$s can only contain numbers, letters, and underscores.' ), '<code>$table_prefix</code>', '<code>wp-config.php</code>' ) ); } } function wp_using_ext_object_cache( $using = null ) { global $_wp_using_ext_object_cache; $current_using = $_wp_using_ext_object_cache; if ( null !== $using ) { $_wp_using_ext_object_cache = $using; } return $current_using; } function wp_start_object_cache() { global $wp_filter; static $first_init = true; if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { if ( ! function_exists( 'wp_cache_init' ) ) { if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { require_once WP_CONTENT_DIR . '/object-cache.php'; if ( function_exists( 'wp_cache_init' ) ) { wp_using_ext_object_cache( true ); } if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } } } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { wp_using_ext_object_cache( true ); } } if ( ! wp_using_ext_object_cache() ) { require_once ABSPATH . WPINC . '/cache.php'; } require_once ABSPATH . WPINC . '/cache-compat.php'; if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( get_current_blog_id() ); } elseif ( function_exists( 'wp_cache_init' ) ) { wp_cache_init(); } if ( function_exists( 'wp_cache_add_global_groups' ) ) { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); } $first_init = false; } function wp_not_installed() { if ( is_blog_installed() || wp_installing() ) { return; } nocache_headers(); if ( is_multisite() ) { wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); } require ABSPATH . WPINC . '/kses.php'; require ABSPATH . WPINC . '/pluggable.php'; $link = wp_guess_url() . '/wp-admin/install.php'; wp_redirect( $link ); die(); } function wp_get_mu_plugins() { $mu_plugins = array(); if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { return $mu_plugins; } $dh = opendir( WPMU_PLUGIN_DIR ); if ( ! $dh ) { return $mu_plugins; } while ( ( $plugin = readdir( $dh ) ) !== false ) { if ( '.php' === substr( $plugin, -4 ) ) { $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; } } closedir( $dh ); sort( $mu_plugins ); return $mu_plugins; } function wp_get_active_and_valid_plugins() { $plugins = array(); $active_plugins = (array) get_option( 'active_plugins', array() ); if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { _deprecated_file( 'my-hacks.php', '1.5.0' ); array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); } if ( empty( $active_plugins ) || wp_installing() ) { return $plugins; } $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) && '.php' === substr( $plugin, -4 ) && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) ) ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; } } if ( wp_is_recovery_mode() ) { $plugins = wp_skip_paused_plugins( $plugins ); } return $plugins; } function wp_skip_paused_plugins( array $plugins ) { $paused_plugins = wp_paused_plugins()->get_all(); if ( empty( $paused_plugins ) ) { return $plugins; } foreach ( $plugins as $index => $plugin ) { list( $plugin ) = explode( '/', plugin_basename( $plugin ) ); if ( array_key_exists( $plugin, $paused_plugins ) ) { unset( $plugins[ $index ] ); $GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ]; } } return $plugins; } function wp_get_active_and_valid_themes() { global $pagenow; $themes = array(); if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { return $themes; } if ( TEMPLATEPATH !== STYLESHEETPATH ) { $themes[] = STYLESHEETPATH; } $themes[] = TEMPLATEPATH; if ( wp_is_recovery_mode() ) { $themes = wp_skip_paused_themes( $themes ); if ( empty( $themes ) ) { add_filter( 'wp_using_themes', '__return_false' ); } } return $themes; } function wp_skip_paused_themes( array $themes ) { $paused_themes = wp_paused_themes()->get_all(); if ( empty( $paused_themes ) ) { return $themes; } foreach ( $themes as $index => $theme ) { $theme = basename( $theme ); if ( array_key_exists( $theme, $paused_themes ) ) { unset( $themes[ $index ] ); $GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ]; } } return $themes; } function wp_is_recovery_mode() { return wp_recovery_mode()->is_active(); } function is_protected_endpoint() { if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { return true; } if ( is_admin() && ! wp_doing_ajax() ) { return true; } if ( is_protected_ajax_action() ) { return true; } return (bool) apply_filters( 'is_protected_endpoint', false ); } function is_protected_ajax_action() { if ( ! wp_doing_ajax() ) { return false; } if ( ! isset( $_REQUEST['action'] ) ) { return false; } $actions_to_protect = array( 'edit-theme-plugin-file', 'heartbeat', 'install-plugin', 'install-theme', 'search-plugins', 'search-install-plugins', 'update-plugin', 'update-theme', ); $actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect ); if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) { return false; } return true; } function wp_set_internal_encoding() { if ( function_exists( 'mb_internal_encoding' ) ) { $charset = get_option( 'blog_charset' ); if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { mb_internal_encoding( 'UTF-8' ); } } } function wp_magic_quotes() { $_GET = add_magic_quotes( $_GET ); $_POST = add_magic_quotes( $_POST ); $_COOKIE = add_magic_quotes( $_COOKIE ); $_SERVER = add_magic_quotes( $_SERVER ); $_REQUEST = array_merge( $_GET, $_POST ); } function shutdown_action_hook() { do_action( 'shutdown' ); wp_cache_close(); } function wp_clone( $input_object ) { return clone( $input_object ); } function is_login() { return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME'] ); } function is_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin(); } elseif ( defined( 'WP_ADMIN' ) ) { return WP_ADMIN; } return false; } function is_blog_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'site' ); } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { return WP_BLOG_ADMIN; } return false; } function is_network_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'network' ); } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { return WP_NETWORK_ADMIN; } return false; } function is_user_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'user' ); } elseif ( defined( 'WP_USER_ADMIN' ) ) { return WP_USER_ADMIN; } return false; } function is_multisite() { if ( defined( 'MULTISITE' ) ) { return MULTISITE; } if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { return true; } return false; } function get_current_blog_id() { global $blog_id; return absint( $blog_id ); } function get_current_network_id() { if ( ! is_multisite() ) { return 1; } $current_network = get_network(); if ( ! isset( $current_network->id ) ) { return get_main_network_id(); } return absint( $current_network->id ); } function wp_load_translations_early() { global $wp_textdomain_registry, $wp_locale; static $loaded = false; if ( $loaded ) { return; } $loaded = true; if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { return; } require ABSPATH . WPINC . '/version.php'; require_once ABSPATH . WPINC . '/pomo/mo.php'; require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; require_once ABSPATH . WPINC . '/plugin.php'; $locales = array(); $locations = array(); if ( ! $wp_textdomain_registry instanceof WP_Textdomain_Registry ) { $wp_textdomain_registry = new WP_Textdomain_Registry(); } while ( true ) { if ( defined( 'WPLANG' ) ) { if ( '' === WPLANG ) { break; } $locales[] = WPLANG; } if ( isset( $wp_local_package ) ) { $locales[] = $wp_local_package; } if ( ! $locales ) { break; } if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { $locations[] = WP_LANG_DIR; } if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { $locations[] = WP_CONTENT_DIR . '/languages'; } if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { $locations[] = ABSPATH . 'wp-content/languages'; } if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { $locations[] = ABSPATH . WPINC . '/languages'; } if ( ! $locations ) { break; } $locations = array_unique( $locations ); foreach ( $locales as $locale ) { foreach ( $locations as $location ) { if ( file_exists( $location . '/' . $locale . '.mo' ) ) { load_textdomain( 'default', $location . '/' . $locale . '.mo', $locale ); if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { load_textdomain( 'default', $location . '/admin-' . $locale . '.mo', $locale ); } break 2; } } } break; } $wp_locale = new WP_Locale(); } function wp_installing( $is_installing = null ) { static $installing = null; if ( is_null( $installing ) ) { $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; } if ( ! is_null( $is_installing ) ) { $old_installing = $installing; $installing = $is_installing; return (bool) $old_installing; } return (bool) $installing; } function is_ssl() { if ( isset( $_SERVER['HTTPS'] ) ) { if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) { return true; } if ( '1' == $_SERVER['HTTPS'] ) { return true; } } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { return true; } return false; } function wp_convert_hr_to_bytes( $value ) { $value = strtolower( trim( $value ) ); $bytes = (int) $value; if ( false !== strpos( $value, 'g' ) ) { $bytes *= GB_IN_BYTES; } elseif ( false !== strpos( $value, 'm' ) ) { $bytes *= MB_IN_BYTES; } elseif ( false !== strpos( $value, 'k' ) ) { $bytes *= KB_IN_BYTES; } return min( $bytes, PHP_INT_MAX ); } function wp_is_ini_value_changeable( $setting ) { static $ini_all; if ( ! isset( $ini_all ) ) { $ini_all = false; if ( function_exists( 'ini_get_all' ) ) { $ini_all = ini_get_all(); } } if ( isset( $ini_all[ $setting ]['access'] ) && ( INI_ALL === ( $ini_all[ $setting ]['access'] & 7 ) || INI_USER === ( $ini_all[ $setting ]['access'] & 7 ) ) ) { return true; } if ( ! is_array( $ini_all ) ) { return true; } return false; } function wp_doing_ajax() { return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); } function wp_using_themes() { return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ); } function wp_doing_cron() { return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); } function is_wp_error( $thing ) { $is_wp_error = ( $thing instanceof WP_Error ); if ( $is_wp_error ) { do_action( 'is_wp_error_instance', $thing ); } return $is_wp_error; } function wp_is_file_mod_allowed( $context ) { return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context ); } function wp_start_scraping_edited_file_errors() { if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) { return; } $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); $nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { echo "###### wp_scraping_result_start:$key ######"; echo wp_json_encode( array( 'code' => 'scrape_nonce_failure', 'message' => __( 'Scrape key check failed. Please try again.' ), ) ); echo "###### wp_scraping_result_end:$key ######"; die(); } if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { define( 'WP_SANDBOX_SCRAPING', true ); } register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key ); } function wp_finalize_scraping_edited_file_errors( $scrape_key ) { $error = error_get_last(); echo "\n###### wp_scraping_result_start:$scrape_key ######\n"; if ( ! empty( $error ) && in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) { $error = str_replace( ABSPATH, '', $error ); echo wp_json_encode( $error ); } else { echo wp_json_encode( true ); } echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; } function wp_is_json_request() { if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) { return true; } if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) { return true; } return false; } function wp_is_jsonp_request() { if ( ! isset( $_GET['_jsonp'] ) ) { return false; } if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } $jsonp_callback = $_GET['_jsonp']; if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { return false; } $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); return $jsonp_enabled; } function wp_is_json_media_type( $media_type ) { static $cache = array(); if ( ! isset( $cache[ $media_type ] ) ) { $cache[ $media_type ] = (bool) preg_match( '/(^|\s|,)application\/([\w!#\$&-\^\.\+]+\+)?json(\+oembed)?($|\s|;|,)/i', $media_type ); } return $cache[ $media_type ]; } function wp_is_xml_request() { $accepted = array( 'text/xml', 'application/rss+xml', 'application/atom+xml', 'application/rdf+xml', 'text/xml+oembed', 'application/xml+oembed', ); if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { foreach ( $accepted as $type ) { if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { return true; } } } if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { return true; } return false; } function wp_is_site_protected_by_basic_auth( $context = '' ) { global $pagenow; if ( ! $context ) { if ( 'wp-login.php' === $pagenow ) { $context = 'login'; } elseif ( is_admin() ) { $context = 'admin'; } else { $context = 'front'; } } $is_protected = ! empty( $_SERVER['PHP_AUTH_USER'] ) || ! empty( $_SERVER['PHP_AUTH_PW'] ); return apply_filters( 'wp_is_site_protected_by_basic_auth', $is_protected, $context ); } <?php + function wp_get_server_protocol() { $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { $protocol = 'HTTP/1.0'; } return $protocol; } function wp_fix_server_vars() { global $PHP_SELF; $default_server_values = array( 'SERVER_SOFTWARE' => '', 'REQUEST_URI' => '', ); $_SERVER = array_merge( $default_server_values, $_SERVER ); if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; } if ( isset( $_SERVER['PATH_INFO'] ) ) { if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; } else { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; } } if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; } if ( isset( $_SERVER['SCRIPT_NAME'] ) && ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) ) { unset( $_SERVER['PATH_INFO'] ); } $PHP_SELF = $_SERVER['PHP_SELF']; if ( empty( $PHP_SELF ) ) { $_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); $PHP_SELF = $_SERVER['PHP_SELF']; } wp_populate_basic_auth_from_authorization_header(); } function wp_populate_basic_auth_from_authorization_header() { if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) && ! isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) { return; } if ( isset( $_SERVER['PHP_AUTH_USER'] ) || isset( $_SERVER['PHP_AUTH_PW'] ) ) { return; } $header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) { return; } $token = substr( $header, 6 ); $userpass = base64_decode( $token ); list( $user, $pass ) = explode( ':', $userpass ); $_SERVER['PHP_AUTH_USER'] = $user; $_SERVER['PHP_AUTH_PW'] = $pass; } function wp_check_php_mysql_versions() { global $required_php_version, $wp_version; $php_version = PHP_VERSION; if ( version_compare( $required_php_version, $php_version, '>' ) ) { $protocol = wp_get_server_protocol(); header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); header( 'Content-Type: text/html; charset=utf-8' ); printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version ); exit( 1 ); } if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ( defined( 'WP_CONTENT_DIR' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) || ! file_exists( ABSPATH . 'wp-content/db.php' ) ) ) { require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early(); $args = array( 'exit' => false, 'code' => 'mysql_not_found', ); wp_die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ), __( 'Requirements Not Met' ), $args ); exit( 1 ); } } function wp_get_environment_type() { static $current_env = ''; if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) { return $current_env; } $wp_environments = array( 'local', 'development', 'staging', 'production', ); if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) { if ( function_exists( '__' ) ) { $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' ); } else { $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' ); } _deprecated_argument( 'define()', '5.5.1', $message ); } if ( function_exists( 'getenv' ) ) { $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); if ( false !== $has_env ) { $current_env = $has_env; } } if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) { $current_env = WP_ENVIRONMENT_TYPE; } if ( ! in_array( $current_env, $wp_environments, true ) ) { $current_env = 'production'; } return $current_env; } function wp_favicon_request() { if ( '/favicon.ico' === $_SERVER['REQUEST_URI'] ) { header( 'Content-Type: image/vnd.microsoft.icon' ); exit; } } function wp_maintenance() { if ( ! wp_is_maintenance_mode() ) { return; } if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { require_once WP_CONTENT_DIR . '/maintenance.php'; die(); } require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early(); header( 'Retry-After: 600' ); wp_die( __( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ), __( 'Maintenance' ), 503 ); } function wp_is_maintenance_mode() { global $upgrading; if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { return false; } require ABSPATH . '.maintenance'; if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) { return false; } if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { return false; } return true; } function timer_float() { return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT']; } function timer_start() { global $timestart; $timestart = microtime( true ); return true; } function timer_stop( $display = 0, $precision = 3 ) { global $timestart, $timeend; $timeend = microtime( true ); $timetotal = $timeend - $timestart; $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); if ( $display ) { echo $r; } return $r; } function wp_debug_mode() { if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) { return; } if ( WP_DEBUG ) { error_reporting( E_ALL ); if ( WP_DEBUG_DISPLAY ) { ini_set( 'display_errors', 1 ); } elseif ( null !== WP_DEBUG_DISPLAY ) { ini_set( 'display_errors', 0 ); } if ( in_array( strtolower( (string) WP_DEBUG_LOG ), array( 'true', '1' ), true ) ) { $log_path = WP_CONTENT_DIR . '/debug.log'; } elseif ( is_string( WP_DEBUG_LOG ) ) { $log_path = WP_DEBUG_LOG; } else { $log_path = false; } if ( $log_path ) { ini_set( 'log_errors', 1 ); ini_set( 'error_log', $log_path ); } } else { error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); } if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || defined( 'MS_FILES_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() || wp_is_json_request() ) { ini_set( 'display_errors', 0 ); } } function wp_set_lang_dir() { if ( ! defined( 'WP_LANG_DIR' ) ) { if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) { define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { define( 'LANGDIR', 'wp-content/languages' ); } } else { define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { define( 'LANGDIR', WPINC . '/languages' ); } } } } function require_wp_db() { global $wpdb; require_once ABSPATH . WPINC . '/class-wpdb.php'; if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { require_once WP_CONTENT_DIR . '/db.php'; } if ( isset( $wpdb ) ) { return; } $dbuser = defined( 'DB_USER' ) ? DB_USER : ''; $dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : ''; $dbname = defined( 'DB_NAME' ) ? DB_NAME : ''; $dbhost = defined( 'DB_HOST' ) ? DB_HOST : ''; $wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost ); } function wp_set_wpdb_vars() { global $wpdb, $table_prefix; if ( ! empty( $wpdb->error ) ) { dead_db(); } $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', ); $prefix = $wpdb->set_prefix( $table_prefix ); if ( is_wp_error( $prefix ) ) { wp_load_translations_early(); wp_die( sprintf( __( '<strong>Error:</strong> %1$s in %2$s can only contain numbers, letters, and underscores.' ), '<code>$table_prefix</code>', '<code>wp-config.php</code>' ) ); } } function wp_using_ext_object_cache( $using = null ) { global $_wp_using_ext_object_cache; $current_using = $_wp_using_ext_object_cache; if ( null !== $using ) { $_wp_using_ext_object_cache = $using; } return $current_using; } function wp_start_object_cache() { global $wp_filter; static $first_init = true; if ( $first_init && apply_filters( 'enable_loading_object_cache_dropin', true ) ) { if ( ! function_exists( 'wp_cache_init' ) ) { if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { require_once WP_CONTENT_DIR . '/object-cache.php'; if ( function_exists( 'wp_cache_init' ) ) { wp_using_ext_object_cache( true ); } if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } } } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { wp_using_ext_object_cache( true ); } } if ( ! wp_using_ext_object_cache() ) { require_once ABSPATH . WPINC . '/cache.php'; } require_once ABSPATH . WPINC . '/cache-compat.php'; if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( get_current_blog_id() ); } elseif ( function_exists( 'wp_cache_init' ) ) { wp_cache_init(); } if ( function_exists( 'wp_cache_add_global_groups' ) ) { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } $first_init = false; } function wp_not_installed() { if ( is_blog_installed() || wp_installing() ) { return; } nocache_headers(); if ( is_multisite() ) { wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); } require ABSPATH . WPINC . '/kses.php'; require ABSPATH . WPINC . '/pluggable.php'; $link = wp_guess_url() . '/wp-admin/install.php'; wp_redirect( $link ); die(); } function wp_get_mu_plugins() { $mu_plugins = array(); if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { return $mu_plugins; } $dh = opendir( WPMU_PLUGIN_DIR ); if ( ! $dh ) { return $mu_plugins; } while ( ( $plugin = readdir( $dh ) ) !== false ) { if ( '.php' === substr( $plugin, -4 ) ) { $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; } } closedir( $dh ); sort( $mu_plugins ); return $mu_plugins; } function wp_get_active_and_valid_plugins() { $plugins = array(); $active_plugins = (array) get_option( 'active_plugins', array() ); if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { _deprecated_file( 'my-hacks.php', '1.5.0' ); array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); } if ( empty( $active_plugins ) || wp_installing() ) { return $plugins; } $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; foreach ( $active_plugins as $plugin ) { if ( ! validate_file( $plugin ) && '.php' === substr( $plugin, -4 ) && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) ) ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; } } if ( wp_is_recovery_mode() ) { $plugins = wp_skip_paused_plugins( $plugins ); } return $plugins; } function wp_skip_paused_plugins( array $plugins ) { $paused_plugins = wp_paused_plugins()->get_all(); if ( empty( $paused_plugins ) ) { return $plugins; } foreach ( $plugins as $index => $plugin ) { list( $plugin ) = explode( '/', plugin_basename( $plugin ) ); if ( array_key_exists( $plugin, $paused_plugins ) ) { unset( $plugins[ $index ] ); $GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ]; } } return $plugins; } function wp_get_active_and_valid_themes() { global $pagenow; $themes = array(); if ( wp_installing() && 'wp-activate.php' !== $pagenow ) { return $themes; } if ( TEMPLATEPATH !== STYLESHEETPATH ) { $themes[] = STYLESHEETPATH; } $themes[] = TEMPLATEPATH; if ( wp_is_recovery_mode() ) { $themes = wp_skip_paused_themes( $themes ); if ( empty( $themes ) ) { add_filter( 'wp_using_themes', '__return_false' ); } } return $themes; } function wp_skip_paused_themes( array $themes ) { $paused_themes = wp_paused_themes()->get_all(); if ( empty( $paused_themes ) ) { return $themes; } foreach ( $themes as $index => $theme ) { $theme = basename( $theme ); if ( array_key_exists( $theme, $paused_themes ) ) { unset( $themes[ $index ] ); $GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ]; } } return $themes; } function wp_is_recovery_mode() { return wp_recovery_mode()->is_active(); } function is_protected_endpoint() { if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { return true; } if ( is_admin() && ! wp_doing_ajax() ) { return true; } if ( is_protected_ajax_action() ) { return true; } return (bool) apply_filters( 'is_protected_endpoint', false ); } function is_protected_ajax_action() { if ( ! wp_doing_ajax() ) { return false; } if ( ! isset( $_REQUEST['action'] ) ) { return false; } $actions_to_protect = array( 'edit-theme-plugin-file', 'heartbeat', 'install-plugin', 'install-theme', 'search-plugins', 'search-install-plugins', 'update-plugin', 'update-theme', ); $actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect ); if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) { return false; } return true; } function wp_set_internal_encoding() { if ( function_exists( 'mb_internal_encoding' ) ) { $charset = get_option( 'blog_charset' ); if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { mb_internal_encoding( 'UTF-8' ); } } } function wp_magic_quotes() { $_GET = add_magic_quotes( $_GET ); $_POST = add_magic_quotes( $_POST ); $_COOKIE = add_magic_quotes( $_COOKIE ); $_SERVER = add_magic_quotes( $_SERVER ); $_REQUEST = array_merge( $_GET, $_POST ); } function shutdown_action_hook() { do_action( 'shutdown' ); wp_cache_close(); } function wp_clone( $input_object ) { return clone( $input_object ); } function is_login() { return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME'] ); } function is_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin(); } elseif ( defined( 'WP_ADMIN' ) ) { return WP_ADMIN; } return false; } function is_blog_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'site' ); } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { return WP_BLOG_ADMIN; } return false; } function is_network_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'network' ); } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { return WP_NETWORK_ADMIN; } return false; } function is_user_admin() { if ( isset( $GLOBALS['current_screen'] ) ) { return $GLOBALS['current_screen']->in_admin( 'user' ); } elseif ( defined( 'WP_USER_ADMIN' ) ) { return WP_USER_ADMIN; } return false; } function is_multisite() { if ( defined( 'MULTISITE' ) ) { return MULTISITE; } if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { return true; } return false; } function get_current_blog_id() { global $blog_id; return absint( $blog_id ); } function get_current_network_id() { if ( ! is_multisite() ) { return 1; } $current_network = get_network(); if ( ! isset( $current_network->id ) ) { return get_main_network_id(); } return absint( $current_network->id ); } function wp_load_translations_early() { global $wp_textdomain_registry, $wp_locale; static $loaded = false; if ( $loaded ) { return; } $loaded = true; if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { return; } require ABSPATH . WPINC . '/version.php'; require_once ABSPATH . WPINC . '/pomo/mo.php'; require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; require_once ABSPATH . WPINC . '/plugin.php'; $locales = array(); $locations = array(); if ( ! $wp_textdomain_registry instanceof WP_Textdomain_Registry ) { $wp_textdomain_registry = new WP_Textdomain_Registry(); } while ( true ) { if ( defined( 'WPLANG' ) ) { if ( '' === WPLANG ) { break; } $locales[] = WPLANG; } if ( isset( $wp_local_package ) ) { $locales[] = $wp_local_package; } if ( ! $locales ) { break; } if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { $locations[] = WP_LANG_DIR; } if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { $locations[] = WP_CONTENT_DIR . '/languages'; } if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { $locations[] = ABSPATH . 'wp-content/languages'; } if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { $locations[] = ABSPATH . WPINC . '/languages'; } if ( ! $locations ) { break; } $locations = array_unique( $locations ); foreach ( $locales as $locale ) { foreach ( $locations as $location ) { if ( file_exists( $location . '/' . $locale . '.mo' ) ) { load_textdomain( 'default', $location . '/' . $locale . '.mo', $locale ); if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { load_textdomain( 'default', $location . '/admin-' . $locale . '.mo', $locale ); } break 2; } } } break; } $wp_locale = new WP_Locale(); } function wp_installing( $is_installing = null ) { static $installing = null; if ( is_null( $installing ) ) { $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; } if ( ! is_null( $is_installing ) ) { $old_installing = $installing; $installing = $is_installing; return (bool) $old_installing; } return (bool) $installing; } function is_ssl() { if ( isset( $_SERVER['HTTPS'] ) ) { if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) { return true; } if ( '1' == $_SERVER['HTTPS'] ) { return true; } } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { return true; } return false; } function wp_convert_hr_to_bytes( $value ) { $value = strtolower( trim( $value ) ); $bytes = (int) $value; if ( false !== strpos( $value, 'g' ) ) { $bytes *= GB_IN_BYTES; } elseif ( false !== strpos( $value, 'm' ) ) { $bytes *= MB_IN_BYTES; } elseif ( false !== strpos( $value, 'k' ) ) { $bytes *= KB_IN_BYTES; } return min( $bytes, PHP_INT_MAX ); } function wp_is_ini_value_changeable( $setting ) { static $ini_all; if ( ! isset( $ini_all ) ) { $ini_all = false; if ( function_exists( 'ini_get_all' ) ) { $ini_all = ini_get_all(); } } if ( isset( $ini_all[ $setting ]['access'] ) && ( INI_ALL === ( $ini_all[ $setting ]['access'] & 7 ) || INI_USER === ( $ini_all[ $setting ]['access'] & 7 ) ) ) { return true; } if ( ! is_array( $ini_all ) ) { return true; } return false; } function wp_doing_ajax() { return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); } function wp_using_themes() { return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ); } function wp_doing_cron() { return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); } function is_wp_error( $thing ) { $is_wp_error = ( $thing instanceof WP_Error ); if ( $is_wp_error ) { do_action( 'is_wp_error_instance', $thing ); } return $is_wp_error; } function wp_is_file_mod_allowed( $context ) { return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context ); } function wp_start_scraping_edited_file_errors() { if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) { return; } $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); $nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { echo "###### wp_scraping_result_start:$key ######"; echo wp_json_encode( array( 'code' => 'scrape_nonce_failure', 'message' => __( 'Scrape key check failed. Please try again.' ), ) ); echo "###### wp_scraping_result_end:$key ######"; die(); } if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { define( 'WP_SANDBOX_SCRAPING', true ); } register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key ); } function wp_finalize_scraping_edited_file_errors( $scrape_key ) { $error = error_get_last(); echo "\n###### wp_scraping_result_start:$scrape_key ######\n"; if ( ! empty( $error ) && in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) { $error = str_replace( ABSPATH, '', $error ); echo wp_json_encode( $error ); } else { echo wp_json_encode( true ); } echo "\n###### wp_scraping_result_end:$scrape_key ######\n"; } function wp_is_json_request() { if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) { return true; } if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) { return true; } return false; } function wp_is_jsonp_request() { if ( ! isset( $_GET['_jsonp'] ) ) { return false; } if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } $jsonp_callback = $_GET['_jsonp']; if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { return false; } $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); return $jsonp_enabled; } function wp_is_json_media_type( $media_type ) { static $cache = array(); if ( ! isset( $cache[ $media_type ] ) ) { $cache[ $media_type ] = (bool) preg_match( '/(^|\s|,)application\/([\w!#\$&-\^\.\+]+\+)?json(\+oembed)?($|\s|;|,)/i', $media_type ); } return $cache[ $media_type ]; } function wp_is_xml_request() { $accepted = array( 'text/xml', 'application/rss+xml', 'application/atom+xml', 'application/rdf+xml', 'text/xml+oembed', 'application/xml+oembed', ); if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) { foreach ( $accepted as $type ) { if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) { return true; } } } if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) { return true; } return false; } function wp_is_site_protected_by_basic_auth( $context = '' ) { global $pagenow; if ( ! $context ) { if ( 'wp-login.php' === $pagenow ) { $context = 'login'; } elseif ( is_admin() ) { $context = 'admin'; } else { $context = 'front'; } } $is_protected = ! empty( $_SERVER['PHP_AUTH_USER'] ) || ! empty( $_SERVER['PHP_AUTH_PW'] ); return apply_filters( 'wp_is_site_protected_by_basic_auth', $is_protected, $context ); } <?php _deprecated_file( basename( __FILE__ ), '4.7.0' ); <?php function wp_underscore_audio_template() { $audio_types = wp_get_audio_extensions(); ?> <audio style="visibility: hidden" @@ -30458,6 +33141,10 @@ All at ###SITENAME### <# } #> <a href="{{ data.editLink }}"><?php _e( 'Edit more details' ); ?></a> <# } #> + <# if ( data.can.save && data.link ) { #> + <span class="links-separator">|</span> + <a href="{{ data.url }}" download><?php _e( 'Download file' ); ?></a> + <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <# if ( data.link || data.can.save ) { #> <span class="links-separator">|</span> @@ -31485,7 +34172,7 @@ All at ###SITENAME### ORDER BY post_date DESC ", 'attachment' ) ); } foreach ( $months as $month_year ) { $month_year->text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month_year->month ), $month_year->year ); } $infinite_scrolling = apply_filters( 'media_library_infinite_scrolling', false ); $settings = array( 'tabs' => $tabs, 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url( 'media-upload.php' ) ), 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ), 'captions' => ! apply_filters( 'disable_captions', '' ), 'nonce' => array( 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ), ), 'post' => array( 'id' => 0, ), 'defaultProps' => $props, 'attachmentCounts' => array( 'audio' => ( $show_audio_playlist ) ? 1 : 0, 'video' => ( $show_video_playlist ) ? 1 : 0, ), 'oEmbedProxyUrl' => rest_url( 'oembed/1.0/proxy' ), 'embedExts' => $exts, 'embedMimes' => $ext_mimes, 'contentWidth' => $content_width, 'months' => $months, 'mediaTrash' => MEDIA_TRASH ? 1 : 0, 'infiniteScrolling' => ( $infinite_scrolling ) ? 1 : 0, ); $post = null; if ( isset( $args['post'] ) ) { $post = get_post( $args['post'] ); $settings['post'] = array( 'id' => $post->ID, 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), ); $thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ); if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) { if ( wp_attachment_is( 'audio', $post ) ) { $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); } elseif ( wp_attachment_is( 'video', $post ) ) { $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); } } if ( $thumbnail_support ) { $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } } if ( $post ) { $post_type_object = get_post_type_object( $post->post_type ); } else { $post_type_object = get_post_type_object( 'post' ); } $strings = array( 'mediaFrameDefaultTitle' => __( 'Media' ), 'url' => __( 'URL' ), 'addMedia' => __( 'Add media' ), 'search' => __( 'Search' ), 'select' => __( 'Select' ), 'cancel' => __( 'Cancel' ), 'update' => __( 'Update' ), 'replace' => __( 'Replace' ), 'remove' => __( 'Remove' ), 'back' => __( 'Back' ), 'selected' => __( '%d selected' ), 'dragInfo' => __( 'Drag and drop to reorder media files.' ), 'uploadFilesTitle' => __( 'Upload files' ), 'uploadImagesTitle' => __( 'Upload images' ), 'mediaLibraryTitle' => __( 'Media Library' ), 'insertMediaTitle' => __( 'Add media' ), 'createNewGallery' => __( 'Create a new gallery' ), 'createNewPlaylist' => __( 'Create a new playlist' ), 'createNewVideoPlaylist' => __( 'Create a new video playlist' ), 'returnToLibrary' => __( '← Go to library' ), 'allMediaItems' => __( 'All media items' ), 'allDates' => __( 'All dates' ), 'noItemsFound' => __( 'No items found.' ), 'insertIntoPost' => $post_type_object->labels->insert_into_item, 'unattached' => _x( 'Unattached', 'media items' ), 'mine' => _x( 'Mine', 'media items' ), 'trash' => _x( 'Trash', 'noun' ), 'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item, 'warnDelete' => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), 'warnBulkDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), 'warnBulkTrash' => __( "You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete." ), 'bulkSelect' => __( 'Bulk select' ), 'trashSelected' => __( 'Move to Trash' ), 'restoreSelected' => __( 'Restore from Trash' ), 'deletePermanently' => __( 'Delete permanently' ), 'errorDeleting' => __( 'Error in deleting the attachment.' ), 'apply' => __( 'Apply' ), 'filterByDate' => __( 'Filter by date' ), 'filterByType' => __( 'Filter by type' ), 'searchLabel' => __( 'Search' ), 'searchMediaLabel' => __( 'Search media' ), 'searchMediaPlaceholder' => __( 'Search media items...' ), 'mediaFound' => __( 'Number of media items found: %d' ), 'noMedia' => __( 'No media items found.' ), 'noMediaTryNewSearch' => __( 'No media items found. Try a different search.' ), 'attachmentDetails' => __( 'Attachment details' ), 'insertFromUrlTitle' => __( 'Insert from URL' ), 'setFeaturedImageTitle' => $post_type_object->labels->featured_image, 'setFeaturedImage' => $post_type_object->labels->set_featured_image, 'createGalleryTitle' => __( 'Create gallery' ), 'editGalleryTitle' => __( 'Edit gallery' ), 'cancelGalleryTitle' => __( '← Cancel gallery' ), 'insertGallery' => __( 'Insert gallery' ), 'updateGallery' => __( 'Update gallery' ), 'addToGallery' => __( 'Add to gallery' ), 'addToGalleryTitle' => __( 'Add to gallery' ), 'reverseOrder' => __( 'Reverse order' ), 'imageDetailsTitle' => __( 'Image details' ), 'imageReplaceTitle' => __( 'Replace image' ), 'imageDetailsCancel' => __( 'Cancel edit' ), 'editImage' => __( 'Edit image' ), 'chooseImage' => __( 'Choose image' ), 'selectAndCrop' => __( 'Select and crop' ), 'skipCropping' => __( 'Skip cropping' ), 'cropImage' => __( 'Crop image' ), 'cropYourImage' => __( 'Crop your image' ), 'cropping' => __( 'Cropping…' ), 'suggestedDimensions' => __( 'Suggested image dimensions: %1$s by %2$s pixels.' ), 'cropError' => __( 'There has been an error cropping your image.' ), 'audioDetailsTitle' => __( 'Audio details' ), 'audioReplaceTitle' => __( 'Replace audio' ), 'audioAddSourceTitle' => __( 'Add audio source' ), 'audioDetailsCancel' => __( 'Cancel edit' ), 'videoDetailsTitle' => __( 'Video details' ), 'videoReplaceTitle' => __( 'Replace video' ), 'videoAddSourceTitle' => __( 'Add video source' ), 'videoDetailsCancel' => __( 'Cancel edit' ), 'videoSelectPosterImageTitle' => __( 'Select poster image' ), 'videoAddTrackTitle' => __( 'Add subtitles' ), 'playlistDragInfo' => __( 'Drag and drop to reorder tracks.' ), 'createPlaylistTitle' => __( 'Create audio playlist' ), 'editPlaylistTitle' => __( 'Edit audio playlist' ), 'cancelPlaylistTitle' => __( '← Cancel audio playlist' ), 'insertPlaylist' => __( 'Insert audio playlist' ), 'updatePlaylist' => __( 'Update audio playlist' ), 'addToPlaylist' => __( 'Add to audio playlist' ), 'addToPlaylistTitle' => __( 'Add to Audio Playlist' ), 'videoPlaylistDragInfo' => __( 'Drag and drop to reorder videos.' ), 'createVideoPlaylistTitle' => __( 'Create video playlist' ), 'editVideoPlaylistTitle' => __( 'Edit video playlist' ), 'cancelVideoPlaylistTitle' => __( '← Cancel video playlist' ), 'insertVideoPlaylist' => __( 'Insert video playlist' ), 'updateVideoPlaylist' => __( 'Update video playlist' ), 'addToVideoPlaylist' => __( 'Add to video playlist' ), 'addToVideoPlaylistTitle' => __( 'Add to video Playlist' ), 'filterAttachments' => __( 'Filter media' ), 'attachmentsList' => __( 'Media list' ), ); $settings = apply_filters( 'media_view_settings', $settings, $post ); $strings = apply_filters( 'media_view_strings', $strings, $post ); $strings['settings'] = $settings; wp_enqueue_script( 'media-editor' ); wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); wp_enqueue_script( 'media-audiovideo' ); wp_enqueue_style( 'media-views' ); if ( is_admin() ) { wp_enqueue_script( 'mce-view' ); wp_enqueue_script( 'image-edit' ); } wp_enqueue_style( 'imgareaselect' ); wp_plupload_default_settings(); require_once ABSPATH . WPINC . '/media-template.php'; add_action( 'admin_footer', 'wp_print_media_templates' ); add_action( 'wp_footer', 'wp_print_media_templates' ); add_action( 'customize_controls_print_footer_scripts', 'wp_print_media_templates' ); do_action( 'wp_enqueue_media' ); } function get_attached_media( $type, $post = 0 ) { $post = get_post( $post ); if ( ! $post ) { return array(); } $args = array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => $type, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ); $args = apply_filters( 'get_attached_media_args', $args, $type, $post ); $children = get_children( $args ); return (array) apply_filters( 'get_attached_media', $children, $type, $post ); } function get_media_embedded_in_content( $content, $types = null ) { $html = array(); $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe' ) ); if ( ! empty( $types ) ) { if ( ! is_array( $types ) ) { $types = array( $types ); } $allowed_media_types = array_intersect( $allowed_media_types, $types ); } $tags = implode( '|', $allowed_media_types ); if ( preg_match_all( '#<(?P<tag>' . $tags . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) { foreach ( $matches[0] as $match ) { $html[] = $match; } } return $html; } function get_post_galleries( $post, $html = true ) { $post = get_post( $post ); if ( ! $post ) { return array(); } if ( ! has_shortcode( $post->post_content, 'gallery' ) && ! has_block( 'gallery', $post->post_content ) ) { return array(); } $galleries = array(); if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) { foreach ( $matches as $shortcode ) { if ( 'gallery' === $shortcode[2] ) { $srcs = array(); $shortcode_attrs = shortcode_parse_atts( $shortcode[3] ); if ( ! is_array( $shortcode_attrs ) ) { $shortcode_attrs = array(); } if ( ! isset( $shortcode_attrs['id'] ) ) { $shortcode[3] .= ' id="' . (int) $post->ID . '"'; } $gallery = do_shortcode_tag( $shortcode ); if ( $html ) { $galleries[] = $gallery; } else { preg_match_all( '#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER ); if ( ! empty( $src ) ) { foreach ( $src as $s ) { $srcs[] = $s[2]; } } $galleries[] = array_merge( $shortcode_attrs, array( 'src' => array_values( array_unique( $srcs ) ), ) ); } } } } if ( has_block( 'gallery', $post->post_content ) ) { $post_blocks = parse_blocks( $post->post_content ); while ( $block = array_shift( $post_blocks ) ) { $has_inner_blocks = ! empty( $block['innerBlocks'] ); if ( ! $block['blockName'] ) { continue; } if ( 'core/gallery' !== $block['blockName'] ) { if ( $has_inner_blocks ) { array_push( $post_blocks, ...$block['innerBlocks'] ); } continue; } if ( $has_inner_blocks && $html ) { $block_html = wp_list_pluck( $block['innerBlocks'], 'innerHTML' ); $galleries[] = '<figure>' . implode( ' ', $block_html ) . '</figure>'; continue; } $srcs = array(); if ( $has_inner_blocks ) { $attrs = wp_list_pluck( $block['innerBlocks'], 'attrs' ); $ids = wp_list_pluck( $attrs, 'id' ); foreach ( $ids as $id ) { $url = wp_get_attachment_url( $id ); if ( is_string( $url ) && ! in_array( $url, $srcs, true ) ) { $srcs[] = $url; } } $galleries[] = array( 'ids' => implode( ',', $ids ), 'src' => $srcs, ); continue; } if ( $html ) { $galleries[] = $block['innerHTML']; continue; } $ids = ! empty( $block['attrs']['ids'] ) ? $block['attrs']['ids'] : array(); if ( ! empty( $ids ) ) { foreach ( $ids as $id ) { $url = wp_get_attachment_url( $id ); if ( is_string( $url ) && ! in_array( $url, $srcs, true ) ) { $srcs[] = $url; } } $galleries[] = array( 'ids' => implode( ',', $ids ), 'src' => $srcs, ); continue; } preg_match_all( '#src=([\'"])(.+?)\1#is', $block['innerHTML'], $found_srcs, PREG_SET_ORDER ); if ( ! empty( $found_srcs[0] ) ) { foreach ( $found_srcs as $src ) { if ( isset( $src[2] ) && ! in_array( $src[2], $srcs, true ) ) { $srcs[] = $src[2]; } } } $galleries[] = array( 'src' => $srcs ); } } return apply_filters( 'get_post_galleries', $galleries, $post ); } function get_post_gallery( $post = 0, $html = true ) { $galleries = get_post_galleries( $post, $html ); $gallery = reset( $galleries ); return apply_filters( 'get_post_gallery', $gallery, $post, $galleries ); } function get_post_galleries_images( $post = 0 ) { $galleries = get_post_galleries( $post, false ); return wp_list_pluck( $galleries, 'src' ); } function get_post_gallery_images( $post = 0 ) { $gallery = get_post_gallery( $post, false ); return empty( $gallery['src'] ) ? array() : $gallery['src']; } function wp_maybe_generate_attachment_metadata( $attachment ) { if ( empty( $attachment ) || empty( $attachment->ID ) ) { return; } $attachment_id = (int) $attachment->ID; $file = get_attached_file( $attachment_id ); $meta = wp_get_attachment_metadata( $attachment_id ); if ( empty( $meta ) && file_exists( $file ) ) { $_meta = get_post_meta( $attachment_id ); $_lock = 'wp_generating_att_' . $attachment_id; if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) && ! get_transient( $_lock ) ) { set_transient( $_lock, $file ); wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); delete_transient( $_lock ); } } } function attachment_url_to_postid( $url ) { global $wpdb; $dir = wp_get_upload_dir(); $path = $url; $site_url = parse_url( $dir['url'] ); $image_path = parse_url( $path ); if ( isset( $image_path['scheme'] ) && ( $image_path['scheme'] !== $site_url['scheme'] ) ) { $path = str_replace( $image_path['scheme'], $site_url['scheme'], $path ); } if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) { $path = substr( $path, strlen( $dir['baseurl'] . '/' ) ); } $sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s", $path ); $results = $wpdb->get_results( $sql ); $post_id = null; if ( $results ) { $post_id = reset( $results )->post_id; if ( count( $results ) > 1 ) { foreach ( $results as $result ) { if ( $path === $result->meta_value ) { $post_id = $result->post_id; break; } } } } return (int) apply_filters( 'attachment_url_to_postid', $post_id, $url ); } function wpview_media_sandbox_styles() { $version = 'ver=' . get_bloginfo( 'version' ); $mediaelement = includes_url( "js/mediaelement/mediaelementplayer-legacy.min.css?$version" ); $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" ); return array( $mediaelement, $wpmediaelement ); } function wp_register_media_personal_data_exporter( $exporters ) { $exporters['wordpress-media'] = array( 'exporter_friendly_name' => __( 'WordPress Media' ), 'callback' => 'wp_media_personal_data_exporter', ); return $exporters; } function wp_media_personal_data_exporter( $email_address, $page = 1 ) { $number = 50; $page = (int) $page; $data_to_export = array(); $user = get_user_by( 'email', $email_address ); if ( false === $user ) { return array( 'data' => $data_to_export, 'done' => true, ); } $post_query = new WP_Query( array( 'author' => $user->ID, 'posts_per_page' => $number, 'paged' => $page, 'post_type' => 'attachment', 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', ) ); foreach ( (array) $post_query->posts as $post ) { $attachment_url = wp_get_attachment_url( $post->ID ); if ( $attachment_url ) { $post_data_to_export = array( array( 'name' => __( 'URL' ), 'value' => $attachment_url, ), ); $data_to_export[] = array( 'group_id' => 'media', 'group_label' => __( 'Media' ), 'group_description' => __( 'User’s media data.' ), 'item_id' => "post-{$post->ID}", 'data' => $post_data_to_export, ); } } $done = $post_query->max_num_pages <= $page; return array( 'data' => $data_to_export, 'done' => $done, ); } function _wp_add_additional_image_sizes() { add_image_size( '1536x1536', 1536, 1536 ); add_image_size( '2048x2048', 2048, 2048 ); } function wp_show_heic_upload_error( $plupload_settings ) { $plupload_settings['heic_upload_error'] = true; return $plupload_settings; } function wp_getimagesize( $filename, array &$image_info = null ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! defined( 'WP_RUN_CORE_TESTS' ) ) { if ( 2 === func_num_args() ) { $info = getimagesize( $filename, $image_info ); } else { $info = getimagesize( $filename ); } } else { if ( 2 === func_num_args() ) { $info = @getimagesize( $filename, $image_info ); } else { $info = @getimagesize( $filename ); } } if ( false !== $info ) { return $info; } if ( 'image/webp' === wp_get_image_mime( $filename ) ) { $webp_info = wp_get_webp_info( $filename ); $width = $webp_info['width']; $height = $webp_info['height']; if ( $width && $height ) { return array( $width, $height, IMAGETYPE_WEBP, sprintf( 'width="%d" height="%d"', $width, $height ), 'mime' => 'image/webp', ); } } return false; } function wp_get_webp_info( $filename ) { $width = false; $height = false; $type = false; if ( 'image/webp' !== wp_get_image_mime( $filename ) ) { return compact( 'width', 'height', 'type' ); } $magic = file_get_contents( $filename, false, null, 0, 40 ); if ( false === $magic ) { return compact( 'width', 'height', 'type' ); } if ( strlen( $magic ) < 40 ) { return compact( 'width', 'height', 'type' ); } switch ( substr( $magic, 12, 4 ) ) { case 'VP8 ': $parts = unpack( 'v2', substr( $magic, 26, 4 ) ); $width = (int) ( $parts[1] & 0x3FFF ); $height = (int) ( $parts[2] & 0x3FFF ); $type = 'lossy'; break; case 'VP8L': $parts = unpack( 'C4', substr( $magic, 21, 4 ) ); $width = (int) ( $parts[1] | ( ( $parts[2] & 0x3F ) << 8 ) ) + 1; $height = (int) ( ( ( $parts[2] & 0xC0 ) >> 6 ) | ( $parts[3] << 2 ) | ( ( $parts[4] & 0x03 ) << 10 ) ) + 1; $type = 'lossless'; break; case 'VP8X': $width = unpack( 'V', substr( $magic, 24, 3 ) . "\x00" ); $width = (int) ( $width[1] & 0xFFFFFF ) + 1; $height = unpack( 'V', substr( $magic, 27, 3 ) . "\x00" ); $height = (int) ( $height[1] & 0xFFFFFF ) + 1; $type = 'animated-alpha'; break; } return compact( 'width', 'height', 'type' ); } function wp_get_loading_attr_default( $context ) { if ( 'the_content' !== $context && 'the_post_thumbnail' !== $context ) { return 'lazy'; } if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { return 'lazy'; } $content_media_count = wp_increase_content_media_count(); if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { return false; } return 'lazy'; } function wp_omit_loading_attr_threshold( $force = false ) { static $omit_threshold; if ( ! isset( $omit_threshold ) || $force ) { $omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 1 ); } return $omit_threshold; } function wp_increase_content_media_count( $amount = 1 ) { static $content_media_count = 0; $content_media_count += $amount; return $content_media_count; } <?php function add_metadata( $meta_type, $object_id, $meta_key, $meta_value, $unique = false ) { global $wpdb; if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { return false; } $object_id = absint( $object_id ); if ( ! $object_id ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $meta_subtype = get_object_subtype( $meta_type, $object_id ); $column = sanitize_key( $meta_type . '_id' ); $meta_key = wp_unslash( $meta_key ); $meta_value = wp_unslash( $meta_value ); $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique ); if ( null !== $check ) { return $check; } if ( $unique && $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) ) { return false; } $_meta_value = $meta_value; $meta_value = maybe_serialize( $meta_value ); do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value ); $result = $wpdb->insert( $table, array( $column => $object_id, 'meta_key' => $meta_key, 'meta_value' => $meta_value, ) ); if ( ! $result ) { return false; } $mid = (int) $wpdb->insert_id; wp_cache_delete( $object_id, $meta_type . '_meta' ); do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value ); return $mid; } function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_value = '' ) { global $wpdb; if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) ) { return false; } $object_id = absint( $object_id ); if ( ! $object_id ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $meta_subtype = get_object_subtype( $meta_type, $object_id ); $column = sanitize_key( $meta_type . '_id' ); $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $raw_meta_key = $meta_key; $meta_key = wp_unslash( $meta_key ); $passed_value = $meta_value; $meta_value = wp_unslash( $meta_value ); $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value ); if ( null !== $check ) { return (bool) $check; } if ( empty( $prev_value ) ) { $old_value = get_metadata_raw( $meta_type, $object_id, $meta_key ); if ( is_countable( $old_value ) && count( $old_value ) === 1 ) { if ( $old_value[0] === $meta_value ) { return false; } } } $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ); if ( empty( $meta_ids ) ) { return add_metadata( $meta_type, $object_id, $raw_meta_key, $passed_value ); } $_meta_value = $meta_value; $meta_value = maybe_serialize( $meta_value ); $data = compact( 'meta_value' ); $where = array( $column => $object_id, 'meta_key' => $meta_key, ); if ( ! empty( $prev_value ) ) { $prev_value = maybe_serialize( $prev_value ); $where['meta_value'] = $prev_value; } foreach ( $meta_ids as $meta_id ) { do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } } $result = $wpdb->update( $table, $data, $where ); if ( ! $result ) { return false; } wp_cache_delete( $object_id, $meta_type . '_meta' ); foreach ( $meta_ids as $meta_id ) { do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } } return true; } function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false ) { global $wpdb; if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) && ! $delete_all ) { return false; } $object_id = absint( $object_id ); if ( ! $object_id && ! $delete_all ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $type_column = sanitize_key( $meta_type . '_id' ); $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $meta_key = wp_unslash( $meta_key ); $meta_value = wp_unslash( $meta_value ); $check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all ); if ( null !== $check ) { return (bool) $check; } $_meta_value = $meta_value; $meta_value = maybe_serialize( $meta_value ); $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key ); if ( ! $delete_all ) { $query .= $wpdb->prepare( " AND $type_column = %d", $object_id ); } if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) { $query .= $wpdb->prepare( ' AND meta_value = %s', $meta_value ); } $meta_ids = $wpdb->get_col( $query ); if ( ! count( $meta_ids ) ) { return false; } if ( $delete_all ) { if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) { $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s AND meta_value = %s", $meta_key, $meta_value ) ); } else { $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) ); } } do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'delete_postmeta', $meta_ids ); } $query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . ' )'; $count = $wpdb->query( $query ); if ( ! $count ) { return false; } if ( $delete_all ) { $data = (array) $object_ids; } else { $data = array( $object_id ); } wp_cache_delete_multiple( $data, $meta_type . '_meta' ); do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'deleted_postmeta', $meta_ids ); } return true; } function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) { $value = get_metadata_raw( $meta_type, $object_id, $meta_key, $single ); if ( ! is_null( $value ) ) { return $value; } return get_metadata_default( $meta_type, $object_id, $meta_key, $single ); } function get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single = false ) { if ( ! $meta_type || ! is_numeric( $object_id ) ) { return false; } $object_id = absint( $object_id ); if ( ! $object_id ) { return false; } $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type ); if ( null !== $check ) { if ( $single && is_array( $check ) ) { return $check[0]; } else { return $check; } } $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); if ( ! $meta_cache ) { $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); if ( isset( $meta_cache[ $object_id ] ) ) { $meta_cache = $meta_cache[ $object_id ]; } else { $meta_cache = null; } } if ( ! $meta_key ) { return $meta_cache; } if ( isset( $meta_cache[ $meta_key ] ) ) { if ( $single ) { return maybe_unserialize( $meta_cache[ $meta_key ][0] ); } else { return array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] ); } } return null; } function get_metadata_default( $meta_type, $object_id, $meta_key, $single = false ) { if ( $single ) { $value = ''; } else { $value = array(); } $value = apply_filters( "default_{$meta_type}_metadata", $value, $object_id, $meta_key, $single, $meta_type ); if ( ! $single && ! wp_is_numeric_array( $value ) ) { $value = array( $value ); } return $value; } function metadata_exists( $meta_type, $object_id, $meta_key ) { if ( ! $meta_type || ! is_numeric( $object_id ) ) { return false; } $object_id = absint( $object_id ); if ( ! $object_id ) { return false; } $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, true, $meta_type ); if ( null !== $check ) { return (bool) $check; } $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); if ( ! $meta_cache ) { $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); $meta_cache = $meta_cache[ $object_id ]; } if ( isset( $meta_cache[ $meta_key ] ) ) { return true; } return false; } function get_metadata_by_mid( $meta_type, $meta_id ) { global $wpdb; if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) { return false; } $meta_id = (int) $meta_id; if ( $meta_id <= 0 ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $check = apply_filters( "get_{$meta_type}_metadata_by_mid", null, $meta_id ); if ( null !== $check ) { return $check; } $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table WHERE $id_column = %d", $meta_id ) ); if ( empty( $meta ) ) { return false; } if ( isset( $meta->meta_value ) ) { $meta->meta_value = maybe_unserialize( $meta->meta_value ); } return $meta; } function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) { global $wpdb; if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) { return false; } $meta_id = (int) $meta_id; if ( $meta_id <= 0 ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $column = sanitize_key( $meta_type . '_id' ); $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $check = apply_filters( "update_{$meta_type}_metadata_by_mid", null, $meta_id, $meta_value, $meta_key ); if ( null !== $check ) { return (bool) $check; } $meta = get_metadata_by_mid( $meta_type, $meta_id ); if ( $meta ) { $original_key = $meta->meta_key; $object_id = $meta->{$column}; if ( false === $meta_key ) { $meta_key = $original_key; } elseif ( ! is_string( $meta_key ) ) { return false; } $meta_subtype = get_object_subtype( $meta_type, $object_id ); $_meta_value = $meta_value; $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); $meta_value = maybe_serialize( $meta_value ); $data = array( 'meta_key' => $meta_key, 'meta_value' => $meta_value, ); $where = array(); $where[ $id_column ] = $meta_id; do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } $result = $wpdb->update( $table, $data, $where, '%s', '%d' ); if ( ! $result ) { return false; } wp_cache_delete( $object_id, $meta_type . '_meta' ); do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value ); if ( 'post' === $meta_type ) { do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value ); } return true; } return false; } function delete_metadata_by_mid( $meta_type, $meta_id ) { global $wpdb; if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) { return false; } $meta_id = (int) $meta_id; if ( $meta_id <= 0 ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $column = sanitize_key( $meta_type . '_id' ); $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $check = apply_filters( "delete_{$meta_type}_metadata_by_mid", null, $meta_id ); if ( null !== $check ) { return (bool) $check; } $meta = get_metadata_by_mid( $meta_type, $meta_id ); if ( $meta ) { $object_id = (int) $meta->{$column}; do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); if ( 'post' === $meta_type || 'comment' === $meta_type ) { do_action( "delete_{$meta_type}meta", $meta_id ); } $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) ); wp_cache_delete( $object_id, $meta_type . '_meta' ); do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); if ( 'post' === $meta_type || 'comment' === $meta_type ) { do_action( "deleted_{$meta_type}meta", $meta_id ); } return $result; } return false; } function update_meta_cache( $meta_type, $object_ids ) { global $wpdb; if ( ! $meta_type || ! $object_ids ) { return false; } $table = _get_meta_table( $meta_type ); if ( ! $table ) { return false; } $column = sanitize_key( $meta_type . '_id' ); if ( ! is_array( $object_ids ) ) { $object_ids = preg_replace( '|[^0-9,]|', '', $object_ids ); $object_ids = explode( ',', $object_ids ); } $object_ids = array_map( 'intval', $object_ids ); $check = apply_filters( "update_{$meta_type}_metadata_cache", null, $object_ids ); if ( null !== $check ) { return (bool) $check; } $cache_key = $meta_type . '_meta'; $non_cached_ids = array(); $cache = array(); $cache_values = wp_cache_get_multiple( $object_ids, $cache_key ); foreach ( $cache_values as $id => $cached_object ) { if ( false === $cached_object ) { $non_cached_ids[] = $id; } else { $cache[ $id ] = $cached_object; } } if ( empty( $non_cached_ids ) ) { return $cache; } $id_list = implode( ',', $non_cached_ids ); $id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id'; $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); if ( ! empty( $meta_list ) ) { foreach ( $meta_list as $metarow ) { $mpid = (int) $metarow[ $column ]; $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; if ( ! isset( $cache[ $mpid ] ) || ! is_array( $cache[ $mpid ] ) ) { $cache[ $mpid ] = array(); } if ( ! isset( $cache[ $mpid ][ $mkey ] ) || ! is_array( $cache[ $mpid ][ $mkey ] ) ) { $cache[ $mpid ][ $mkey ] = array(); } $cache[ $mpid ][ $mkey ][] = $mval; } } $data = array(); foreach ( $non_cached_ids as $id ) { if ( ! isset( $cache[ $id ] ) ) { $cache[ $id ] = array(); } $data[ $id ] = $cache[ $id ]; } wp_cache_add_multiple( $data, $cache_key ); return $cache; } function wp_metadata_lazyloader() { static $wp_metadata_lazyloader; if ( null === $wp_metadata_lazyloader ) { $wp_metadata_lazyloader = new WP_Metadata_Lazyloader(); } return $wp_metadata_lazyloader; } function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) { $meta_query_obj = new WP_Meta_Query( $meta_query ); return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context ); } function _get_meta_table( $type ) { global $wpdb; $table_name = $type . 'meta'; if ( empty( $wpdb->$table_name ) ) { return false; } return $wpdb->$table_name; } function is_protected_meta( $meta_key, $meta_type = '' ) { $sanitized_key = preg_replace( "/[^\x20-\x7E\p{L}]/", '', $meta_key ); $protected = strlen( $sanitized_key ) > 0 && ( '_' === $sanitized_key[0] ); return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type ); } function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype = '' ) { if ( ! empty( $object_subtype ) && has_filter( "sanitize_{$object_type}_meta_{$meta_key}_for_{$object_subtype}" ) ) { return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $meta_value, $meta_key, $object_type, $object_subtype ); } return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}", $meta_value, $meta_key, $object_type ); } function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { global $wp_meta_keys; if ( ! is_array( $wp_meta_keys ) ) { $wp_meta_keys = array(); } $defaults = array( 'object_subtype' => '', 'type' => 'string', 'description' => '', 'default' => '', 'single' => false, 'sanitize_callback' => null, 'auth_callback' => null, 'show_in_rest' => false, ); $has_old_sanitize_cb = false; $has_old_auth_cb = false; if ( is_callable( $args ) ) { $args = array( 'sanitize_callback' => $args, ); $has_old_sanitize_cb = true; } else { $args = (array) $args; } if ( is_callable( $deprecated ) ) { $args['auth_callback'] = $deprecated; $has_old_auth_cb = true; } $args = apply_filters( 'register_meta_args', $args, $defaults, $object_type, $meta_key ); unset( $defaults['default'] ); $args = wp_parse_args( $args, $defaults ); if ( false !== $args['show_in_rest'] && 'array' === $args['type'] ) { if ( ! is_array( $args['show_in_rest'] ) || ! isset( $args['show_in_rest']['schema']['items'] ) ) { _doing_it_wrong( __FUNCTION__, __( 'When registering an "array" meta type to show in the REST API, you must specify the schema for each array item in "show_in_rest.schema.items".' ), '5.3.0' ); return false; } } $object_subtype = ! empty( $args['object_subtype'] ) ? $args['object_subtype'] : ''; if ( empty( $args['auth_callback'] ) ) { if ( is_protected_meta( $meta_key, $object_type ) ) { $args['auth_callback'] = '__return_false'; } else { $args['auth_callback'] = '__return_true'; } } if ( is_callable( $args['sanitize_callback'] ) ) { if ( ! empty( $object_subtype ) ) { add_filter( "sanitize_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['sanitize_callback'], 10, 4 ); } else { add_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'], 10, 3 ); } } if ( is_callable( $args['auth_callback'] ) ) { if ( ! empty( $object_subtype ) ) { add_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['auth_callback'], 10, 6 ); } else { add_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'], 10, 6 ); } } if ( array_key_exists( 'default', $args ) ) { $schema = $args; if ( is_array( $args['show_in_rest'] ) && isset( $args['show_in_rest']['schema'] ) ) { $schema = array_merge( $schema, $args['show_in_rest']['schema'] ); } $check = rest_validate_value_from_schema( $args['default'], $schema ); if ( is_wp_error( $check ) ) { _doing_it_wrong( __FUNCTION__, __( 'When registering a default meta value the data must match the type provided.' ), '5.5.0' ); return false; } if ( ! has_filter( "default_{$object_type}_metadata", 'filter_default_metadata' ) ) { add_filter( "default_{$object_type}_metadata", 'filter_default_metadata', 10, 5 ); } } if ( ! $has_old_auth_cb && ! $has_old_sanitize_cb ) { unset( $args['object_subtype'] ); $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] = $args; return true; } return false; } function filter_default_metadata( $value, $object_id, $meta_key, $single, $meta_type ) { global $wp_meta_keys; if ( wp_installing() ) { return $value; } if ( ! is_array( $wp_meta_keys ) || ! isset( $wp_meta_keys[ $meta_type ] ) ) { return $value; } $defaults = array(); foreach ( $wp_meta_keys[ $meta_type ] as $sub_type => $meta_data ) { foreach ( $meta_data as $_meta_key => $args ) { if ( $_meta_key === $meta_key && array_key_exists( 'default', $args ) ) { $defaults[ $sub_type ] = $args; } } } if ( ! $defaults ) { return $value; } if ( isset( $defaults[''] ) ) { $metadata = $defaults['']; } else { $sub_type = get_object_subtype( $meta_type, $object_id ); if ( ! isset( $defaults[ $sub_type ] ) ) { return $value; } $metadata = $defaults[ $sub_type ]; } if ( $single ) { $value = $metadata['default']; } else { $value = array( $metadata['default'] ); } return $value; } function registered_meta_key_exists( $object_type, $meta_key, $object_subtype = '' ) { $meta_keys = get_registered_meta_keys( $object_type, $object_subtype ); return isset( $meta_keys[ $meta_key ] ); } function unregister_meta_key( $object_type, $meta_key, $object_subtype = '' ) { global $wp_meta_keys; if ( ! registered_meta_key_exists( $object_type, $meta_key, $object_subtype ) ) { return false; } $args = $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ]; if ( isset( $args['sanitize_callback'] ) && is_callable( $args['sanitize_callback'] ) ) { if ( ! empty( $object_subtype ) ) { remove_filter( "sanitize_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['sanitize_callback'] ); } else { remove_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'] ); } } if ( isset( $args['auth_callback'] ) && is_callable( $args['auth_callback'] ) ) { if ( ! empty( $object_subtype ) ) { remove_filter( "auth_{$object_type}_meta_{$meta_key}_for_{$object_subtype}", $args['auth_callback'] ); } else { remove_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'] ); } } unset( $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] ); if ( empty( $wp_meta_keys[ $object_type ][ $object_subtype ] ) ) { unset( $wp_meta_keys[ $object_type ][ $object_subtype ] ); } if ( empty( $wp_meta_keys[ $object_type ] ) ) { unset( $wp_meta_keys[ $object_type ] ); } return true; } function get_registered_meta_keys( $object_type, $object_subtype = '' ) { global $wp_meta_keys; if ( ! is_array( $wp_meta_keys ) || ! isset( $wp_meta_keys[ $object_type ] ) || ! isset( $wp_meta_keys[ $object_type ][ $object_subtype ] ) ) { return array(); } return $wp_meta_keys[ $object_type ][ $object_subtype ]; } function get_registered_metadata( $object_type, $object_id, $meta_key = '' ) { $object_subtype = get_object_subtype( $object_type, $object_id ); if ( ! empty( $meta_key ) ) { if ( ! empty( $object_subtype ) && ! registered_meta_key_exists( $object_type, $meta_key, $object_subtype ) ) { $object_subtype = ''; } if ( ! registered_meta_key_exists( $object_type, $meta_key, $object_subtype ) ) { return false; } $meta_keys = get_registered_meta_keys( $object_type, $object_subtype ); $meta_key_data = $meta_keys[ $meta_key ]; $data = get_metadata( $object_type, $object_id, $meta_key, $meta_key_data['single'] ); return $data; } $data = get_metadata( $object_type, $object_id ); if ( ! $data ) { return array(); } $meta_keys = get_registered_meta_keys( $object_type ); if ( ! empty( $object_subtype ) ) { $meta_keys = array_merge( $meta_keys, get_registered_meta_keys( $object_type, $object_subtype ) ); } return array_intersect_key( $data, $meta_keys ); } function _wp_register_meta_args_allowed_list( $args, $default_args ) { return array_intersect_key( $args, $default_args ); } function get_object_subtype( $object_type, $object_id ) { $object_id = (int) $object_id; $object_subtype = ''; switch ( $object_type ) { case 'post': $post_type = get_post_type( $object_id ); if ( ! empty( $post_type ) ) { $object_subtype = $post_type; } break; case 'term': $term = get_term( $object_id ); if ( ! $term instanceof WP_Term ) { break; } $object_subtype = $term->taxonomy; break; case 'comment': $comment = get_comment( $object_id ); if ( ! $comment ) { break; } $object_subtype = 'comment'; break; case 'user': $user = get_user_by( 'id', $object_id ); if ( ! $user ) { break; } $object_subtype = 'user'; break; } return apply_filters( "get_object_subtype_{$object_type}", $object_subtype, $object_id ); } <?php - require_once ABSPATH . WPINC . '/ms-site.php'; require_once ABSPATH . WPINC . '/ms-network.php'; function wpmu_update_blogs_date() { $site_id = get_current_blog_id(); update_blog_details( $site_id, array( 'last_updated' => current_time( 'mysql', true ) ) ); do_action( 'wpmu_blog_updated', $site_id ); } function get_blogaddress_by_id( $blog_id ) { $bloginfo = get_site( (int) $blog_id ); if ( empty( $bloginfo ) ) { return ''; } $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME ); $scheme = empty( $scheme ) ? 'http' : $scheme; return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path ); } function get_blogaddress_by_name( $blogname ) { if ( is_subdomain_install() ) { if ( 'main' === $blogname ) { $blogname = 'www'; } $url = rtrim( network_home_url(), '/' ); if ( ! empty( $blogname ) ) { $url = preg_replace( '|^([^\.]+://)|', '${1}' . $blogname . '.', $url ); } } else { $url = network_home_url( $blogname ); } return esc_url( $url . '/' ); } function get_id_from_blogname( $slug ) { $current_network = get_network(); $slug = trim( $slug, '/' ); if ( is_subdomain_install() ) { $domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain ); $path = $current_network->path; } else { $domain = $current_network->domain; $path = $current_network->path . $slug . '/'; } $site_ids = get_sites( array( 'number' => 1, 'fields' => 'ids', 'domain' => $domain, 'path' => $path, 'update_site_meta_cache' => false, ) ); if ( empty( $site_ids ) ) { return null; } return array_shift( $site_ids ); } function get_blog_details( $fields = null, $get_all = true ) { global $wpdb; if ( is_array( $fields ) ) { if ( isset( $fields['blog_id'] ) ) { $blog_id = $fields['blog_id']; } elseif ( isset( $fields['domain'] ) && isset( $fields['path'] ) ) { $key = md5( $fields['domain'] . $fields['path'] ); $blog = wp_cache_get( $key, 'blog-lookup' ); if ( false !== $blog ) { return $blog; } if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); } else { $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) ); } if ( $blog ) { wp_cache_set( $blog->blog_id . 'short', $blog, 'blog-details' ); $blog_id = $blog->blog_id; } else { return false; } } elseif ( isset( $fields['domain'] ) && is_subdomain_install() ) { $key = md5( $fields['domain'] ); $blog = wp_cache_get( $key, 'blog-lookup' ); if ( false !== $blog ) { return $blog; } if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); } else { $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) ); } if ( $blog ) { wp_cache_set( $blog->blog_id . 'short', $blog, 'blog-details' ); $blog_id = $blog->blog_id; } else { return false; } } else { return false; } } else { if ( ! $fields ) { $blog_id = get_current_blog_id(); } elseif ( ! is_numeric( $fields ) ) { $blog_id = get_id_from_blogname( $fields ); } else { $blog_id = $fields; } } $blog_id = (int) $blog_id; $all = $get_all ? '' : 'short'; $details = wp_cache_get( $blog_id . $all, 'blog-details' ); if ( $details ) { if ( ! is_object( $details ) ) { if ( -1 == $details ) { return false; } else { wp_cache_delete( $blog_id . $all, 'blog-details' ); unset( $details ); } } else { return $details; } } if ( $get_all ) { $details = wp_cache_get( $blog_id . 'short', 'blog-details' ); } else { $details = wp_cache_get( $blog_id, 'blog-details' ); if ( $details ) { if ( ! is_object( $details ) ) { if ( -1 == $details ) { return false; } else { wp_cache_delete( $blog_id, 'blog-details' ); unset( $details ); } } else { return $details; } } } if ( empty( $details ) ) { $details = WP_Site::get_instance( $blog_id ); if ( ! $details ) { wp_cache_set( $blog_id, -1, 'blog-details' ); return false; } } if ( ! $details instanceof WP_Site ) { $details = new WP_Site( $details ); } if ( ! $get_all ) { wp_cache_set( $blog_id . $all, $details, 'blog-details' ); return $details; } $switched_blog = false; if ( get_current_blog_id() !== $blog_id ) { switch_to_blog( $blog_id ); $switched_blog = true; } $details->blogname = get_option( 'blogname' ); $details->siteurl = get_option( 'siteurl' ); $details->post_count = get_option( 'post_count' ); $details->home = get_option( 'home' ); if ( $switched_blog ) { restore_current_blog(); } $details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' ); wp_cache_set( $blog_id . $all, $details, 'blog-details' ); $key = md5( $details->domain . $details->path ); wp_cache_set( $key, $details, 'blog-lookup' ); return $details; } function refresh_blog_details( $blog_id = 0 ) { $blog_id = (int) $blog_id; if ( ! $blog_id ) { $blog_id = get_current_blog_id(); } clean_blog_cache( $blog_id ); } function update_blog_details( $blog_id, $details = array() ) { global $wpdb; if ( empty( $details ) ) { return false; } if ( is_object( $details ) ) { $details = get_object_vars( $details ); } $site = wp_update_site( $blog_id, $details ); if ( is_wp_error( $site ) ) { return false; } return true; } function clean_site_details_cache( $site_id = 0 ) { $site_id = (int) $site_id; if ( ! $site_id ) { $site_id = get_current_blog_id(); } wp_cache_delete( $site_id, 'site-details' ); wp_cache_delete( $site_id, 'blog-details' ); } function get_blog_option( $id, $option, $default_value = false ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return get_option( $option, $default_value ); } switch_to_blog( $id ); $value = get_option( $option, $default_value ); restore_current_blog(); return apply_filters( "blog_option_{$option}", $value, $id ); } function add_blog_option( $id, $option, $value ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return add_option( $option, $value ); } switch_to_blog( $id ); $return = add_option( $option, $value ); restore_current_blog(); return $return; } function delete_blog_option( $id, $option ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return delete_option( $option ); } switch_to_blog( $id ); $return = delete_option( $option ); restore_current_blog(); return $return; } function update_blog_option( $id, $option, $value, $deprecated = null ) { $id = (int) $id; if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.1.0' ); } if ( get_current_blog_id() == $id ) { return update_option( $option, $value ); } switch_to_blog( $id ); $return = update_option( $option, $value ); restore_current_blog(); return $return; } function switch_to_blog( $new_blog_id, $deprecated = null ) { global $wpdb; $prev_blog_id = get_current_blog_id(); if ( empty( $new_blog_id ) ) { $new_blog_id = $prev_blog_id; } $GLOBALS['_wp_switched_stack'][] = $prev_blog_id; if ( $new_blog_id == $prev_blog_id ) { do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); $GLOBALS['switched'] = true; return true; } $wpdb->set_blog_id( $new_blog_id ); $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); $GLOBALS['blog_id'] = $new_blog_id; if ( function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( $new_blog_id ); } else { global $wp_object_cache; if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if ( function_exists( 'wp_cache_add_global_groups' ) ) { if ( is_array( $global_groups ) ) { wp_cache_add_global_groups( $global_groups ); } else { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); } wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); } } do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); $GLOBALS['switched'] = true; return true; } function restore_current_blog() { global $wpdb; if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { return false; } $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); $prev_blog_id = get_current_blog_id(); if ( $new_blog_id == $prev_blog_id ) { do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; } $wpdb->set_blog_id( $new_blog_id ); $GLOBALS['blog_id'] = $new_blog_id; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); if ( function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( $new_blog_id ); } else { global $wp_object_cache; if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if ( function_exists( 'wp_cache_add_global_groups' ) ) { if ( is_array( $global_groups ) ) { wp_cache_add_global_groups( $global_groups ); } else { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); } wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); } } do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; } function wp_switch_roles_and_user( $new_site_id, $old_site_id ) { if ( $new_site_id == $old_site_id ) { return; } if ( ! did_action( 'init' ) ) { return; } wp_roles()->for_site( $new_site_id ); wp_get_current_user()->for_site( $new_site_id ); } function ms_is_switched() { return ! empty( $GLOBALS['_wp_switched_stack'] ); } function is_archived( $id ) { return get_blog_status( $id, 'archived' ); } function update_archived( $id, $archived ) { update_blog_status( $id, 'archived', $archived ); return $archived; } function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { global $wpdb; if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.1.0' ); } $allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); if ( ! in_array( $pref, $allowed_field_names, true ) ) { return $value; } $result = wp_update_site( $blog_id, array( $pref => $value, ) ); if ( is_wp_error( $result ) ) { return false; } return $value; } function get_blog_status( $id, $pref ) { global $wpdb; $details = get_site( $id ); if ( $details ) { return $details->$pref; } return $wpdb->get_var( $wpdb->prepare( "SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id ) ); } function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { global $wpdb; if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, 'MU' ); } return $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", get_current_network_id(), $start, $quantity ), ARRAY_A ); } function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { $post_type_obj = get_post_type_object( $post->post_type ); if ( ! $post_type_obj || ! $post_type_obj->public ) { return; } if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } wpmu_update_blogs_date(); } function _update_blog_date_on_post_delete( $post_id ) { $post = get_post( $post_id ); $post_type_obj = get_post_type_object( $post->post_type ); if ( ! $post_type_obj || ! $post_type_obj->public ) { return; } if ( 'publish' !== $post->post_status ) { return; } wpmu_update_blogs_date(); } function _update_posts_count_on_delete( $post_id ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { return; } update_posts_count(); } function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) { if ( $new_status === $old_status ) { return; } if ( 'post' !== get_post_type( $post ) ) { return; } if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } update_posts_count(); } function wp_count_sites( $network_id = null ) { if ( empty( $network_id ) ) { $network_id = get_current_network_id(); } $counts = array(); $args = array( 'network_id' => $network_id, 'number' => 1, 'fields' => 'ids', 'no_found_rows' => false, ); $q = new WP_Site_Query( $args ); $counts['all'] = $q->found_sites; $_args = $args; $statuses = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); foreach ( $statuses as $status ) { $_args = $args; $_args[ $status ] = 1; $q = new WP_Site_Query( $_args ); $counts[ $status ] = $q->found_sites; } return $counts; } <?php + require_once ABSPATH . WPINC . '/ms-site.php'; require_once ABSPATH . WPINC . '/ms-network.php'; function wpmu_update_blogs_date() { $site_id = get_current_blog_id(); update_blog_details( $site_id, array( 'last_updated' => current_time( 'mysql', true ) ) ); do_action( 'wpmu_blog_updated', $site_id ); } function get_blogaddress_by_id( $blog_id ) { $bloginfo = get_site( (int) $blog_id ); if ( empty( $bloginfo ) ) { return ''; } $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME ); $scheme = empty( $scheme ) ? 'http' : $scheme; return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path ); } function get_blogaddress_by_name( $blogname ) { if ( is_subdomain_install() ) { if ( 'main' === $blogname ) { $blogname = 'www'; } $url = rtrim( network_home_url(), '/' ); if ( ! empty( $blogname ) ) { $url = preg_replace( '|^([^\.]+://)|', '${1}' . $blogname . '.', $url ); } } else { $url = network_home_url( $blogname ); } return esc_url( $url . '/' ); } function get_id_from_blogname( $slug ) { $current_network = get_network(); $slug = trim( $slug, '/' ); if ( is_subdomain_install() ) { $domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain ); $path = $current_network->path; } else { $domain = $current_network->domain; $path = $current_network->path . $slug . '/'; } $site_ids = get_sites( array( 'number' => 1, 'fields' => 'ids', 'domain' => $domain, 'path' => $path, 'update_site_meta_cache' => false, ) ); if ( empty( $site_ids ) ) { return null; } return array_shift( $site_ids ); } function get_blog_details( $fields = null, $get_all = true ) { global $wpdb; if ( is_array( $fields ) ) { if ( isset( $fields['blog_id'] ) ) { $blog_id = $fields['blog_id']; } elseif ( isset( $fields['domain'] ) && isset( $fields['path'] ) ) { $key = md5( $fields['domain'] . $fields['path'] ); $blog = wp_cache_get( $key, 'blog-lookup' ); if ( false !== $blog ) { return $blog; } if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); } else { $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) ); } if ( $blog ) { wp_cache_set( $blog->blog_id . 'short', $blog, 'blog-details' ); $blog_id = $blog->blog_id; } else { return false; } } elseif ( isset( $fields['domain'] ) && is_subdomain_install() ) { $key = md5( $fields['domain'] ); $blog = wp_cache_get( $key, 'blog-lookup' ); if ( false !== $blog ) { return $blog; } if ( 'www.' === substr( $fields['domain'], 0, 4 ) ) { $nowww = substr( $fields['domain'], 4 ); $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); } else { $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) ); } if ( $blog ) { wp_cache_set( $blog->blog_id . 'short', $blog, 'blog-details' ); $blog_id = $blog->blog_id; } else { return false; } } else { return false; } } else { if ( ! $fields ) { $blog_id = get_current_blog_id(); } elseif ( ! is_numeric( $fields ) ) { $blog_id = get_id_from_blogname( $fields ); } else { $blog_id = $fields; } } $blog_id = (int) $blog_id; $all = $get_all ? '' : 'short'; $details = wp_cache_get( $blog_id . $all, 'blog-details' ); if ( $details ) { if ( ! is_object( $details ) ) { if ( -1 == $details ) { return false; } else { wp_cache_delete( $blog_id . $all, 'blog-details' ); unset( $details ); } } else { return $details; } } if ( $get_all ) { $details = wp_cache_get( $blog_id . 'short', 'blog-details' ); } else { $details = wp_cache_get( $blog_id, 'blog-details' ); if ( $details ) { if ( ! is_object( $details ) ) { if ( -1 == $details ) { return false; } else { wp_cache_delete( $blog_id, 'blog-details' ); unset( $details ); } } else { return $details; } } } if ( empty( $details ) ) { $details = WP_Site::get_instance( $blog_id ); if ( ! $details ) { wp_cache_set( $blog_id, -1, 'blog-details' ); return false; } } if ( ! $details instanceof WP_Site ) { $details = new WP_Site( $details ); } if ( ! $get_all ) { wp_cache_set( $blog_id . $all, $details, 'blog-details' ); return $details; } $switched_blog = false; if ( get_current_blog_id() !== $blog_id ) { switch_to_blog( $blog_id ); $switched_blog = true; } $details->blogname = get_option( 'blogname' ); $details->siteurl = get_option( 'siteurl' ); $details->post_count = get_option( 'post_count' ); $details->home = get_option( 'home' ); if ( $switched_blog ) { restore_current_blog(); } $details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' ); wp_cache_set( $blog_id . $all, $details, 'blog-details' ); $key = md5( $details->domain . $details->path ); wp_cache_set( $key, $details, 'blog-lookup' ); return $details; } function refresh_blog_details( $blog_id = 0 ) { $blog_id = (int) $blog_id; if ( ! $blog_id ) { $blog_id = get_current_blog_id(); } clean_blog_cache( $blog_id ); } function update_blog_details( $blog_id, $details = array() ) { global $wpdb; if ( empty( $details ) ) { return false; } if ( is_object( $details ) ) { $details = get_object_vars( $details ); } $site = wp_update_site( $blog_id, $details ); if ( is_wp_error( $site ) ) { return false; } return true; } function clean_site_details_cache( $site_id = 0 ) { $site_id = (int) $site_id; if ( ! $site_id ) { $site_id = get_current_blog_id(); } wp_cache_delete( $site_id, 'site-details' ); wp_cache_delete( $site_id, 'blog-details' ); } function get_blog_option( $id, $option, $default_value = false ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return get_option( $option, $default_value ); } switch_to_blog( $id ); $value = get_option( $option, $default_value ); restore_current_blog(); return apply_filters( "blog_option_{$option}", $value, $id ); } function add_blog_option( $id, $option, $value ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return add_option( $option, $value ); } switch_to_blog( $id ); $return = add_option( $option, $value ); restore_current_blog(); return $return; } function delete_blog_option( $id, $option ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return delete_option( $option ); } switch_to_blog( $id ); $return = delete_option( $option ); restore_current_blog(); return $return; } function update_blog_option( $id, $option, $value, $deprecated = null ) { $id = (int) $id; if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.1.0' ); } if ( get_current_blog_id() == $id ) { return update_option( $option, $value ); } switch_to_blog( $id ); $return = update_option( $option, $value ); restore_current_blog(); return $return; } function switch_to_blog( $new_blog_id, $deprecated = null ) { global $wpdb; $prev_blog_id = get_current_blog_id(); if ( empty( $new_blog_id ) ) { $new_blog_id = $prev_blog_id; } $GLOBALS['_wp_switched_stack'][] = $prev_blog_id; if ( $new_blog_id == $prev_blog_id ) { do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); $GLOBALS['switched'] = true; return true; } $wpdb->set_blog_id( $new_blog_id ); $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); $GLOBALS['blog_id'] = $new_blog_id; if ( function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( $new_blog_id ); } else { global $wp_object_cache; if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if ( function_exists( 'wp_cache_add_global_groups' ) ) { if ( is_array( $global_groups ) ) { wp_cache_add_global_groups( $global_groups ); } else { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); } wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } } do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); $GLOBALS['switched'] = true; return true; } function restore_current_blog() { global $wpdb; if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { return false; } $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); $prev_blog_id = get_current_blog_id(); if ( $new_blog_id == $prev_blog_id ) { do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; } $wpdb->set_blog_id( $new_blog_id ); $GLOBALS['blog_id'] = $new_blog_id; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); if ( function_exists( 'wp_cache_switch_to_blog' ) ) { wp_cache_switch_to_blog( $new_blog_id ); } else { global $wp_object_cache; if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if ( function_exists( 'wp_cache_add_global_groups' ) ) { if ( is_array( $global_groups ) ) { wp_cache_add_global_groups( $global_groups ); } else { wp_cache_add_global_groups( array( 'blog-details', 'blog-id-cache', 'blog-lookup', 'blog_meta', 'global-posts', 'networks', 'sites', 'site-details', 'site-options', 'site-transient', 'rss', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs', ) ); } wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } } do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; } function wp_switch_roles_and_user( $new_site_id, $old_site_id ) { if ( $new_site_id == $old_site_id ) { return; } if ( ! did_action( 'init' ) ) { return; } wp_roles()->for_site( $new_site_id ); wp_get_current_user()->for_site( $new_site_id ); } function ms_is_switched() { return ! empty( $GLOBALS['_wp_switched_stack'] ); } function is_archived( $id ) { return get_blog_status( $id, 'archived' ); } function update_archived( $id, $archived ) { update_blog_status( $id, 'archived', $archived ); return $archived; } function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { global $wpdb; if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.1.0' ); } $allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); if ( ! in_array( $pref, $allowed_field_names, true ) ) { return $value; } $result = wp_update_site( $blog_id, array( $pref => $value, ) ); if ( is_wp_error( $result ) ) { return false; } return $value; } function get_blog_status( $id, $pref ) { global $wpdb; $details = get_site( $id ); if ( $details ) { return $details->$pref; } return $wpdb->get_var( $wpdb->prepare( "SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id ) ); } function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { global $wpdb; if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, 'MU' ); } return $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", get_current_network_id(), $start, $quantity ), ARRAY_A ); } function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { $post_type_obj = get_post_type_object( $post->post_type ); if ( ! $post_type_obj || ! $post_type_obj->public ) { return; } if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } wpmu_update_blogs_date(); } function _update_blog_date_on_post_delete( $post_id ) { $post = get_post( $post_id ); $post_type_obj = get_post_type_object( $post->post_type ); if ( ! $post_type_obj || ! $post_type_obj->public ) { return; } if ( 'publish' !== $post->post_status ) { return; } wpmu_update_blogs_date(); } function _update_posts_count_on_delete( $post_id ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { return; } update_posts_count(); } function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) { if ( $new_status === $old_status ) { return; } if ( 'post' !== get_post_type( $post ) ) { return; } if ( 'publish' !== $new_status && 'publish' !== $old_status ) { return; } update_posts_count(); } function wp_count_sites( $network_id = null ) { if ( empty( $network_id ) ) { $network_id = get_current_network_id(); } $counts = array(); $args = array( 'network_id' => $network_id, 'number' => 1, 'fields' => 'ids', 'no_found_rows' => false, ); $q = new WP_Site_Query( $args ); $counts['all'] = $q->found_sites; $_args = $args; $statuses = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); foreach ( $statuses as $status ) { $_args = $args; $_args[ $status ] = 1; $q = new WP_Site_Query( $_args ); $counts[ $status ] = $q->found_sites; } return $counts; } <?php function ms_upload_constants() { add_filter( 'default_site_option_ms_files_rewriting', '__return_true' ); if ( ! get_site_option( 'ms_files_rewriting' ) ) { return; } if ( ! defined( 'UPLOADBLOGSDIR' ) ) { define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); } if ( ! defined( 'UPLOADS' ) ) { $site_id = get_current_blog_id(); define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' ); if ( 'wp-content/blogs.dir' === UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) { define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' ); } } } function ms_cookie_constants() { $current_network = get_network(); if ( ! defined( 'COOKIEPATH' ) ) { define( 'COOKIEPATH', $current_network->path ); } if ( ! defined( 'SITECOOKIEPATH' ) ) { define( 'SITECOOKIEPATH', $current_network->path ); } if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) { $site_path = parse_url( get_option( 'siteurl' ), PHP_URL_PATH ); if ( ! is_subdomain_install() || is_string( $site_path ) && trim( $site_path, '/' ) ) { define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH ); } else { define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' ); } } if ( ! defined( 'COOKIE_DOMAIN' ) && is_subdomain_install() ) { if ( ! empty( $current_network->cookie_domain ) ) { define( 'COOKIE_DOMAIN', '.' . $current_network->cookie_domain ); } else { define( 'COOKIE_DOMAIN', '.' . $current_network->domain ); } } } function ms_file_constants() { if ( ! defined( 'WPMU_SENDFILE' ) ) { define( 'WPMU_SENDFILE', false ); } if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) { define( 'WPMU_ACCEL_REDIRECT', false ); } } function ms_subdomain_constants() { static $subdomain_error = null; static $subdomain_error_warn = null; if ( false === $subdomain_error ) { return; } if ( $subdomain_error ) { $vhost_deprecated = sprintf( __( 'The constant %1$s <strong>is deprecated</strong>. Use the boolean constant %2$s in %3$s to enable a subdomain configuration. Use %4$s to check whether a subdomain configuration is enabled.' ), '<code>VHOST</code>', '<code>SUBDOMAIN_INSTALL</code>', '<code>wp-config.php</code>', '<code>is_subdomain_install()</code>' ); if ( $subdomain_error_warn ) { trigger_error( sprintf( __( '<strong>Conflicting values for the constants %1$s and %2$s.</strong> The value of %2$s will be assumed to be your subdomain configuration setting.' ), '<code>VHOST</code>', '<code>SUBDOMAIN_INSTALL</code>' ) . ' ' . $vhost_deprecated, E_USER_WARNING ); } else { _deprecated_argument( 'define()', '3.0.0', $vhost_deprecated ); } return; } if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { $subdomain_error = true; if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) { $subdomain_error_warn = true; } } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { $subdomain_error = false; define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); } elseif ( defined( 'VHOST' ) ) { $subdomain_error = true; define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST ); } else { $subdomain_error = false; define( 'SUBDOMAIN_INSTALL', false ); define( 'VHOST', 'no' ); } } <?php add_action( 'init', 'ms_subdomain_constants' ); add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 ); add_filter( 'option_users_can_register', 'users_can_register_signup_filter' ); add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' ); add_action( 'init', 'maybe_add_existing_user_to_blog' ); add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' ); add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 ); add_action( 'wpmu_activate_user', 'wpmu_welcome_user_notification', 10, 3 ); add_action( 'after_signup_user', 'wpmu_signup_user_notification', 10, 4 ); add_action( 'network_site_new_created_user', 'wp_send_new_user_notifications' ); add_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' ); add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' ); add_filter( 'sanitize_user', 'strtolower' ); add_action( 'deleted_user', 'wp_delete_signup_on_user_delete', 10, 3 ); add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' ); add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 ); add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 ); add_filter( 'wp_normalize_site_data', 'wp_normalize_site_data', 10, 1 ); add_action( 'wp_validate_site_data', 'wp_validate_site_data', 10, 3 ); add_action( 'wp_insert_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 ); add_action( 'wp_update_site', 'wp_maybe_update_network_site_counts_on_update', 10, 2 ); add_action( 'wp_delete_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 ); add_action( 'wp_insert_site', 'wp_maybe_transition_site_statuses_on_update', 10, 1 ); add_action( 'wp_update_site', 'wp_maybe_transition_site_statuses_on_update', 10, 2 ); add_action( 'wp_update_site', 'wp_maybe_clean_new_site_cache_on_update', 10, 2 ); add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 ); add_action( 'wp_initialize_site', 'wpmu_log_new_registrations', 100, 2 ); add_action( 'wp_initialize_site', 'newblog_notify_siteadmin', 100, 1 ); add_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10, 1 ); add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 ); add_action( 'added_blog_meta', 'wp_cache_set_sites_last_changed' ); add_action( 'updated_blog_meta', 'wp_cache_set_sites_last_changed' ); add_action( 'deleted_blog_meta', 'wp_cache_set_sites_last_changed' ); add_filter( 'get_blog_metadata', 'wp_check_site_meta_support_prefilter' ); add_filter( 'add_blog_metadata', 'wp_check_site_meta_support_prefilter' ); add_filter( 'update_blog_metadata', 'wp_check_site_meta_support_prefilter' ); add_filter( 'delete_blog_metadata', 'wp_check_site_meta_support_prefilter' ); add_filter( 'get_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' ); add_filter( 'update_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' ); add_filter( 'delete_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' ); add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ); add_action( 'signup_hidden_fields', 'signup_nonce_fields' ); add_action( 'template_redirect', 'maybe_redirect_404' ); add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); add_action( 'after_delete_post', '_update_posts_count_on_delete' ); add_action( 'delete_post', '_update_blog_date_on_post_delete' ); add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 ); add_action( 'admin_init', 'wp_schedule_update_network_counts' ); add_action( 'update_network_counts', 'wp_update_network_counts', 10, 0 ); foreach ( array( 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) { add_action( $action, 'wp_maybe_update_network_user_counts', 10, 0 ); } remove_action( 'admin_init', 'wp_schedule_update_user_counts' ); remove_action( 'wp_update_user_counts', 'wp_schedule_update_user_counts' ); foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action ) { add_action( $action, 'wp_maybe_update_network_site_counts', 10, 0 ); } unset( $action ); add_filter( 'wp_upload_bits', 'upload_is_file_too_big' ); add_filter( 'import_upload_size_limit', 'fix_import_form_size' ); add_filter( 'upload_mimes', 'check_upload_mimes' ); add_filter( 'upload_size_limit', 'upload_size_limit_filter' ); add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' ); add_action( 'phpmailer_init', 'fix_phpmailer_messageid' ); add_filter( 'enable_update_services_configuration', '__return_false' ); if ( ! defined( 'POST_BY_EMAIL' ) || ! POST_BY_EMAIL ) { add_filter( 'enable_post_by_email_configuration', '__return_false' ); } if ( ! defined( 'EDIT_ANY_USER' ) || ! EDIT_ANY_USER ) { add_filter( 'enable_edit_any_user_configuration', '__return_false' ); } add_filter( 'force_filtered_html_on_import', '__return_true' ); remove_filter( 'option_siteurl', '_config_wp_siteurl' ); remove_filter( 'option_home', '_config_wp_home' ); add_action( 'update_option_blogname', 'clean_site_details_cache', 10, 0 ); add_action( 'update_option_siteurl', 'clean_site_details_cache', 10, 0 ); add_action( 'update_option_post_count', 'clean_site_details_cache', 10, 0 ); add_action( 'update_option_home', 'clean_site_details_cache', 10, 0 ); add_filter( 'default_site_option_ms_files_rewriting', '__return_true' ); add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 ); <?php function get_dashboard_blog() { _deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' ); if ( $blog = get_site_option( 'dashboard_blog' ) ) { return get_site( $blog ); } return get_site( get_network()->site_id ); } function generate_random_password( $len = 8 ) { _deprecated_function( __FUNCTION__, '3.0.0', 'wp_generate_password()' ); return wp_generate_password( $len ); } function is_site_admin( $user_login = '' ) { _deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' ); if ( empty( $user_login ) ) { $user_id = get_current_user_id(); if ( !$user_id ) return false; } else { $user = get_user_by( 'login', $user_login ); if ( ! $user->exists() ) return false; $user_id = $user->ID; } return is_super_admin( $user_id ); } if ( !function_exists( 'graceful_fail' ) ) : function graceful_fail( $message ) { _deprecated_function( __FUNCTION__, '3.0.0', 'wp_die()' ); $message = apply_filters( 'graceful_fail', $message ); $message_template = apply_filters( 'graceful_fail_template', '<!DOCTYPE html> @@ -31576,7 +34263,7 @@ All at ###SITENAME### function get_network( $network = null ) { global $current_site; if ( empty( $network ) && isset( $current_site ) ) { $network = $current_site; } if ( $network instanceof WP_Network ) { $_network = $network; } elseif ( is_object( $network ) ) { $_network = new WP_Network( $network ); } else { $_network = WP_Network::get_instance( $network ); } if ( ! $_network ) { return null; } $_network = apply_filters( 'get_network', $_network ); return $_network; } function get_networks( $args = array() ) { $query = new WP_Network_Query(); return $query->query( $args ); } function clean_network_cache( $ids ) { global $_wp_suspend_cache_invalidation; if ( ! empty( $_wp_suspend_cache_invalidation ) ) { return; } $network_ids = (array) $ids; wp_cache_delete_multiple( $network_ids, 'networks' ); foreach ( $network_ids as $id ) { do_action( 'clean_network_cache', $id ); } wp_cache_set( 'last_changed', microtime(), 'networks' ); } function update_network_cache( $networks ) { $data = array(); foreach ( (array) $networks as $network ) { $data[ $network->id ] = $network; } wp_cache_add_multiple( $data, 'networks' ); } function _prime_network_caches( $network_ids ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' ); if ( ! empty( $non_cached_ids ) ) { $fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); update_network_cache( $fresh_networks ); } } <?php global $current_site, $current_blog, $domain, $path, $site_id, $public; require_once ABSPATH . WPINC . '/class-wp-network.php'; require_once ABSPATH . WPINC . '/class-wp-site.php'; require_once ABSPATH . WPINC . '/ms-load.php'; require_once ABSPATH . WPINC . '/ms-default-constants.php'; if ( defined( 'SUNRISE' ) ) { include_once WP_CONTENT_DIR . '/sunrise.php'; } ms_subdomain_constants(); if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); if ( ':80' === substr( $domain, -3 ) ) { $domain = substr( $domain, 0, -3 ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); } elseif ( ':443' === substr( $domain, -4 ) ) { $domain = substr( $domain, 0, -4 ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); } $path = stripslashes( $_SERVER['REQUEST_URI'] ); if ( is_admin() ) { $path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path ); } list( $path ) = explode( '?', $path ); $bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() ); if ( true === $bootstrap_result ) { } elseif ( false === $bootstrap_result ) { ms_not_installed( $domain, $path ); } else { header( 'Location: ' . $bootstrap_result ); exit; } unset( $bootstrap_result ); $blog_id = $current_blog->blog_id; $public = $current_blog->public; if ( empty( $current_blog->site_id ) ) { $current_blog->site_id = 1; } $site_id = $current_blog->site_id; wp_load_core_site_options( $site_id ); } $wpdb->set_prefix( $table_prefix, false ); $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); $table_prefix = $wpdb->get_blog_prefix(); $_wp_switched_stack = array(); $switched = false; wp_start_object_cache(); if ( ! $current_site instanceof WP_Network ) { $current_site = new WP_Network( $current_site ); } if ( ! $current_blog instanceof WP_Site ) { $current_blog = new WP_Site( $current_blog ); } ms_upload_constants(); do_action( 'ms_loaded' ); <?php function wp_insert_site( array $data ) { global $wpdb; $now = current_time( 'mysql', true ); $defaults = array( 'domain' => '', 'path' => '/', 'network_id' => get_current_network_id(), 'registered' => $now, 'last_updated' => $now, 'public' => 1, 'archived' => 0, 'mature' => 0, 'spam' => 0, 'deleted' => 0, 'lang_id' => 0, ); $prepared_data = wp_prepare_site_data( $data, $defaults ); if ( is_wp_error( $prepared_data ) ) { return $prepared_data; } if ( false === $wpdb->insert( $wpdb->blogs, $prepared_data ) ) { return new WP_Error( 'db_insert_error', __( 'Could not insert site into the database.' ), $wpdb->last_error ); } $site_id = (int) $wpdb->insert_id; clean_blog_cache( $site_id ); $new_site = get_site( $site_id ); if ( ! $new_site ) { return new WP_Error( 'get_site_error', __( 'Could not retrieve site data.' ) ); } do_action( 'wp_insert_site', $new_site ); $args = array_diff_key( $data, $defaults ); if ( isset( $args['site_id'] ) ) { unset( $args['site_id'] ); } do_action( 'wp_initialize_site', $new_site, $args ); if ( has_action( 'wpmu_new_blog' ) ) { $user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0; $meta = ! empty( $args['options'] ) ? $args['options'] : array(); if ( ! array_key_exists( 'WPLANG', $meta ) ) { $meta['WPLANG'] = get_network_option( $new_site->network_id, 'WPLANG' ); } $allowed_data_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); $meta = array_merge( array_intersect_key( $data, array_flip( $allowed_data_fields ) ), $meta ); do_action_deprecated( 'wpmu_new_blog', array( $new_site->id, $user_id, $new_site->domain, $new_site->path, $new_site->network_id, $meta ), '5.1.0', 'wp_initialize_site' ); } return (int) $new_site->id; } function wp_update_site( $site_id, array $data ) { global $wpdb; if ( empty( $site_id ) ) { return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) ); } $old_site = get_site( $site_id ); if ( ! $old_site ) { return new WP_Error( 'site_not_exist', __( 'Site does not exist.' ) ); } $defaults = $old_site->to_array(); $defaults['network_id'] = (int) $defaults['site_id']; $defaults['last_updated'] = current_time( 'mysql', true ); unset( $defaults['blog_id'], $defaults['site_id'] ); $data = wp_prepare_site_data( $data, $defaults, $old_site ); if ( is_wp_error( $data ) ) { return $data; } if ( false === $wpdb->update( $wpdb->blogs, $data, array( 'blog_id' => $old_site->id ) ) ) { return new WP_Error( 'db_update_error', __( 'Could not update site in the database.' ), $wpdb->last_error ); } clean_blog_cache( $old_site ); $new_site = get_site( $old_site->id ); do_action( 'wp_update_site', $new_site, $old_site ); return (int) $new_site->id; } function wp_delete_site( $site_id ) { global $wpdb; if ( empty( $site_id ) ) { return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) ); } $old_site = get_site( $site_id ); if ( ! $old_site ) { return new WP_Error( 'site_not_exist', __( 'Site does not exist.' ) ); } $errors = new WP_Error(); do_action( 'wp_validate_site_deletion', $errors, $old_site ); if ( ! empty( $errors->errors ) ) { return $errors; } do_action_deprecated( 'delete_blog', array( $old_site->id, true ), '5.1.0' ); do_action( 'wp_uninitialize_site', $old_site ); if ( is_site_meta_supported() ) { $blog_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->blogmeta WHERE blog_id = %d ", $old_site->id ) ); foreach ( $blog_meta_ids as $mid ) { delete_metadata_by_mid( 'blog', $mid ); } } if ( false === $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $old_site->id ) ) ) { return new WP_Error( 'db_delete_error', __( 'Could not delete site from the database.' ), $wpdb->last_error ); } clean_blog_cache( $old_site ); do_action( 'wp_delete_site', $old_site ); do_action_deprecated( 'deleted_blog', array( $old_site->id, true ), '5.1.0' ); return $old_site; } function get_site( $site = null ) { if ( empty( $site ) ) { $site = get_current_blog_id(); } if ( $site instanceof WP_Site ) { $_site = $site; } elseif ( is_object( $site ) ) { $_site = new WP_Site( $site ); } else { $_site = WP_Site::get_instance( $site ); } if ( ! $_site ) { return null; } $_site = apply_filters( 'get_site', $_site ); return $_site; } function _prime_site_caches( $ids, $update_meta_cache = true ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $ids, 'sites' ); if ( ! empty( $non_cached_ids ) ) { $fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); update_site_cache( $fresh_sites, $update_meta_cache ); } } function update_site_cache( $sites, $update_meta_cache = true ) { if ( ! $sites ) { return; } $site_ids = array(); $site_data = array(); $blog_details_data = array(); foreach ( $sites as $site ) { $site_ids[] = $site->blog_id; $site_data[ $site->blog_id ] = $site; $blog_details_data[ $site->blog_id . 'short' ] = $site; } wp_cache_add_multiple( $site_data, 'sites' ); wp_cache_add_multiple( $blog_details_data, 'blog-details' ); if ( $update_meta_cache ) { update_sitemeta_cache( $site_ids ); } } function update_sitemeta_cache( $site_ids ) { if ( ! has_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ) ) { add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ); } return update_meta_cache( 'blog', $site_ids ); } function get_sites( $args = array() ) { $query = new WP_Site_Query(); return $query->query( $args ); } function wp_prepare_site_data( $data, $defaults, $old_site = null ) { if ( isset( $data['site_id'] ) ) { if ( ! empty( $data['site_id'] ) && empty( $data['network_id'] ) ) { $data['network_id'] = $data['site_id']; } unset( $data['site_id'] ); } $data = apply_filters( 'wp_normalize_site_data', $data ); $allowed_data_fields = array( 'domain', 'path', 'network_id', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); $data = array_intersect_key( wp_parse_args( $data, $defaults ), array_flip( $allowed_data_fields ) ); $errors = new WP_Error(); do_action( 'wp_validate_site_data', $errors, $data, $old_site ); if ( ! empty( $errors->errors ) ) { return $errors; } $data['site_id'] = $data['network_id']; unset( $data['network_id'] ); return $data; } function wp_normalize_site_data( $data ) { if ( array_key_exists( 'domain', $data ) ) { $data['domain'] = trim( $data['domain'] ); $data['domain'] = preg_replace( '/\s+/', '', sanitize_user( $data['domain'], true ) ); if ( is_subdomain_install() ) { $data['domain'] = str_replace( '@', '', $data['domain'] ); } } if ( array_key_exists( 'path', $data ) ) { $data['path'] = trailingslashit( '/' . trim( $data['path'], '/' ) ); } if ( array_key_exists( 'network_id', $data ) ) { $data['network_id'] = (int) $data['network_id']; } $status_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); foreach ( $status_fields as $status_field ) { if ( array_key_exists( $status_field, $data ) ) { $data[ $status_field ] = (int) $data[ $status_field ]; } } $date_fields = array( 'registered', 'last_updated' ); foreach ( $date_fields as $date_field ) { if ( ! array_key_exists( $date_field, $data ) ) { continue; } if ( empty( $data[ $date_field ] ) || '0000-00-00 00:00:00' === $data[ $date_field ] ) { unset( $data[ $date_field ] ); } } return $data; } function wp_validate_site_data( $errors, $data, $old_site = null ) { if ( empty( $data['domain'] ) ) { $errors->add( 'site_empty_domain', __( 'Site domain must not be empty.' ) ); } if ( empty( $data['path'] ) ) { $errors->add( 'site_empty_path', __( 'Site path must not be empty.' ) ); } if ( empty( $data['network_id'] ) ) { $errors->add( 'site_empty_network_id', __( 'Site network ID must be provided.' ) ); } $date_fields = array( 'registered', 'last_updated' ); foreach ( $date_fields as $date_field ) { if ( empty( $data[ $date_field ] ) ) { $errors->add( 'site_empty_' . $date_field, __( 'Both registration and last updated dates must be provided.' ) ); break; } if ( '0000-00-00 00:00:00' !== $data[ $date_field ] ) { $month = substr( $data[ $date_field ], 5, 2 ); $day = substr( $data[ $date_field ], 8, 2 ); $year = substr( $data[ $date_field ], 0, 4 ); $valid_date = wp_checkdate( $month, $day, $year, $data[ $date_field ] ); if ( ! $valid_date ) { $errors->add( 'site_invalid_' . $date_field, __( 'Both registration and last updated dates must be valid dates.' ) ); break; } } } if ( ! empty( $errors->errors ) ) { return; } if ( ! $old_site || $data['domain'] !== $old_site->domain || $data['path'] !== $old_site->path || $data['network_id'] !== $old_site->network_id ) { if ( domain_exists( $data['domain'], $data['path'], $data['network_id'] ) ) { $errors->add( 'site_taken', __( 'Sorry, that site already exists!' ) ); } } } function wp_initialize_site( $site_id, array $args = array() ) { global $wpdb, $wp_roles; if ( empty( $site_id ) ) { return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) ); } $site = get_site( $site_id ); if ( ! $site ) { return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) ); } if ( wp_is_site_initialized( $site ) ) { return new WP_Error( 'site_already_initialized', __( 'The site appears to be already initialized.' ) ); } $network = get_network( $site->network_id ); if ( ! $network ) { $network = get_network(); } $args = wp_parse_args( $args, array( 'user_id' => 0, 'title' => sprintf( __( 'Site %d' ), $site->id ), 'options' => array(), 'meta' => array(), ) ); $args = apply_filters( 'wp_initialize_site_args', $args, $site, $network ); $orig_installing = wp_installing(); if ( ! $orig_installing ) { wp_installing( true ); } $switch = false; if ( get_current_blog_id() !== $site->id ) { $switch = true; switch_to_blog( $site->id ); } require_once ABSPATH . 'wp-admin/includes/upgrade.php'; make_db_current_silent( 'blog' ); $home_scheme = 'http'; $siteurl_scheme = 'http'; if ( ! is_subdomain_install() ) { if ( 'https' === parse_url( get_home_url( $network->site_id ), PHP_URL_SCHEME ) ) { $home_scheme = 'https'; } if ( 'https' === parse_url( get_network_option( $network->id, 'siteurl' ), PHP_URL_SCHEME ) ) { $siteurl_scheme = 'https'; } } populate_options( array_merge( array( 'home' => untrailingslashit( $home_scheme . '://' . $site->domain . $site->path ), 'siteurl' => untrailingslashit( $siteurl_scheme . '://' . $site->domain . $site->path ), 'blogname' => wp_unslash( $args['title'] ), 'admin_email' => '', 'upload_path' => get_network_option( $network->id, 'ms_files_rewriting' ) ? UPLOADBLOGSDIR . "/{$site->id}/files" : get_blog_option( $network->site_id, 'upload_path' ), 'blog_public' => (int) $site->public, 'WPLANG' => get_network_option( $network->id, 'WPLANG' ), ), $args['options'] ) ); clean_blog_cache( $site ); populate_roles(); $wp_roles = new WP_Roles(); populate_site_meta( $site->id, $args['meta'] ); $table_prefix = $wpdb->get_blog_prefix(); delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); wp_install_defaults( $args['user_id'] ); add_user_to_blog( $site->id, $args['user_id'], 'administrator' ); if ( ! user_can( $args['user_id'], 'manage_network' ) && ! get_user_meta( $args['user_id'], 'primary_blog', true ) ) { update_user_meta( $args['user_id'], 'primary_blog', $site->id ); } if ( $switch ) { restore_current_blog(); } wp_installing( $orig_installing ); return true; } function wp_uninitialize_site( $site_id ) { global $wpdb; if ( empty( $site_id ) ) { return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) ); } $site = get_site( $site_id ); if ( ! $site ) { return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) ); } if ( ! wp_is_site_initialized( $site ) ) { return new WP_Error( 'site_already_uninitialized', __( 'The site appears to be already uninitialized.' ) ); } $users = get_users( array( 'blog_id' => $site->id, 'fields' => 'ids', ) ); if ( ! empty( $users ) ) { foreach ( $users as $user_id ) { remove_user_from_blog( $user_id, $site->id ); } } $switch = false; if ( get_current_blog_id() !== $site->id ) { $switch = true; switch_to_blog( $site->id ); } $uploads = wp_get_upload_dir(); $tables = $wpdb->tables( 'blog' ); $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $site->id ); foreach ( (array) $drop_tables as $table ) { $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); } $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $site->id ); $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); $top_dir = $dir; $stack = array( $dir ); $index = 0; while ( $index < count( $stack ) ) { $dir = $stack[ $index ]; $dh = @opendir( $dir ); if ( $dh ) { $file = @readdir( $dh ); while ( false !== $file ) { if ( '.' === $file || '..' === $file ) { $file = @readdir( $dh ); continue; } if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) { $stack[] = $dir . DIRECTORY_SEPARATOR . $file; } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) { @unlink( $dir . DIRECTORY_SEPARATOR . $file ); } $file = @readdir( $dh ); } @closedir( $dh ); } $index++; } $stack = array_reverse( $stack ); foreach ( (array) $stack as $dir ) { if ( $dir != $top_dir ) { @rmdir( $dir ); } } if ( $switch ) { restore_current_blog(); } return true; } function wp_is_site_initialized( $site_id ) { global $wpdb; if ( is_object( $site_id ) ) { $site_id = $site_id->blog_id; } $site_id = (int) $site_id; $pre = apply_filters( 'pre_wp_is_site_initialized', null, $site_id ); if ( null !== $pre ) { return (bool) $pre; } $switch = false; if ( get_current_blog_id() !== $site_id ) { $switch = true; remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 ); switch_to_blog( $site_id ); } $suppress = $wpdb->suppress_errors(); $result = (bool) $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ); $wpdb->suppress_errors( $suppress ); if ( $switch ) { restore_current_blog(); add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); } return $result; } function clean_blog_cache( $blog ) { global $_wp_suspend_cache_invalidation; if ( ! empty( $_wp_suspend_cache_invalidation ) ) { return; } if ( empty( $blog ) ) { return; } $blog_id = $blog; $blog = get_site( $blog_id ); if ( ! $blog ) { if ( ! is_numeric( $blog_id ) ) { return; } $blog = new WP_Site( (object) array( 'blog_id' => $blog_id, 'domain' => null, 'path' => null, ) ); } $blog_id = $blog->blog_id; $domain_path_key = md5( $blog->domain . $blog->path ); wp_cache_delete( $blog_id, 'sites' ); wp_cache_delete( $blog_id, 'site-details' ); wp_cache_delete( $blog_id, 'blog-details' ); wp_cache_delete( $blog_id . 'short', 'blog-details' ); wp_cache_delete( $domain_path_key, 'blog-lookup' ); wp_cache_delete( $domain_path_key, 'blog-id-cache' ); wp_cache_delete( $blog_id, 'blog_meta' ); do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key ); wp_cache_set( 'last_changed', microtime(), 'sites' ); do_action_deprecated( 'refresh_blog_details', array( $blog_id ), '4.9.0', 'clean_site_cache' ); } function add_site_meta( $site_id, $meta_key, $meta_value, $unique = false ) { return add_metadata( 'blog', $site_id, $meta_key, $meta_value, $unique ); } function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) { return delete_metadata( 'blog', $site_id, $meta_key, $meta_value ); } function get_site_meta( $site_id, $key = '', $single = false ) { return get_metadata( 'blog', $site_id, $key, $single ); } function update_site_meta( $site_id, $meta_key, $meta_value, $prev_value = '' ) { return update_metadata( 'blog', $site_id, $meta_key, $meta_value, $prev_value ); } function delete_site_meta_by_key( $meta_key ) { return delete_metadata( 'blog', null, $meta_key, '', true ); } function wp_maybe_update_network_site_counts_on_update( $new_site, $old_site = null ) { if ( null === $old_site ) { wp_maybe_update_network_site_counts( $new_site->network_id ); return; } if ( $new_site->network_id != $old_site->network_id ) { wp_maybe_update_network_site_counts( $new_site->network_id ); wp_maybe_update_network_site_counts( $old_site->network_id ); } } function wp_maybe_transition_site_statuses_on_update( $new_site, $old_site = null ) { $site_id = $new_site->id; if ( ! $old_site ) { $old_site = new WP_Site( new stdClass() ); } if ( $new_site->spam != $old_site->spam ) { if ( 1 == $new_site->spam ) { do_action( 'make_spam_blog', $site_id ); } else { do_action( 'make_ham_blog', $site_id ); } } if ( $new_site->mature != $old_site->mature ) { if ( 1 == $new_site->mature ) { do_action( 'mature_blog', $site_id ); } else { do_action( 'unmature_blog', $site_id ); } } if ( $new_site->archived != $old_site->archived ) { if ( 1 == $new_site->archived ) { do_action( 'archive_blog', $site_id ); } else { do_action( 'unarchive_blog', $site_id ); } } if ( $new_site->deleted != $old_site->deleted ) { if ( 1 == $new_site->deleted ) { do_action( 'make_delete_blog', $site_id ); } else { do_action( 'make_undelete_blog', $site_id ); } } if ( $new_site->public != $old_site->public ) { do_action( 'update_blog_public', $site_id, $new_site->public ); } } function wp_maybe_clean_new_site_cache_on_update( $new_site, $old_site ) { if ( $old_site->domain !== $new_site->domain || $old_site->path !== $new_site->path ) { clean_blog_cache( $new_site ); } } function wp_update_blog_public_option_on_site_update( $site_id, $is_public ) { if ( ! wp_is_site_initialized( $site_id ) ) { return; } update_blog_option( $site_id, 'blog_public', $is_public ); } function wp_cache_set_sites_last_changed() { wp_cache_set( 'last_changed', microtime(), 'sites' ); } function wp_check_site_meta_support_prefilter( $check ) { if ( ! is_site_meta_supported() ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.1.0' ); return false; } return $check; } <?php - require_once ABSPATH . WPINC . '/class-walker-nav-menu.php'; function wp_nav_menu( $args = array() ) { static $menu_id_slugs = array(); $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'container_aria_label' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'item_spacing' => 'preserve', 'depth' => 0, 'walker' => '', 'theme_location' => '', ); $args = wp_parse_args( $args, $defaults ); if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { $args['item_spacing'] = $defaults['item_spacing']; } $args = apply_filters( 'wp_nav_menu_args', $args ); $args = (object) $args; $nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args ); if ( null !== $nav_menu ) { if ( $args->echo ) { echo $nav_menu; return; } return $nav_menu; } $menu = wp_get_nav_menu_object( $args->menu ); $locations = get_nav_menu_locations(); if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] ); } if ( ! $menu && ! $args->theme_location ) { $menus = wp_get_nav_menus(); foreach ( $menus as $menu_maybe ) { $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ); if ( $menu_items ) { $menu = $menu_maybe; break; } } } if ( empty( $args->menu ) ) { $args->menu = $menu; } if ( $menu && ! is_wp_error( $menu ) && ! isset( $menu_items ) ) { $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) ); } if ( ( ! $menu || is_wp_error( $menu ) || ( isset( $menu_items ) && empty( $menu_items ) && ! $args->theme_location ) ) && isset( $args->fallback_cb ) && $args->fallback_cb && is_callable( $args->fallback_cb ) ) { return call_user_func( $args->fallback_cb, (array) $args ); } if ( ! $menu || is_wp_error( $menu ) ) { return false; } $nav_menu = ''; $items = ''; $show_container = false; if ( $args->container ) { $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ); if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags, true ) ) { $show_container = true; $class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"'; $id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : ''; $aria_label = ( 'nav' === $args->container && $args->container_aria_label ) ? ' aria-label="' . esc_attr( $args->container_aria_label ) . '"' : ''; $nav_menu .= '<' . $args->container . $id . $class . $aria_label . '>'; } } _wp_menu_item_classes_by_context( $menu_items ); $sorted_menu_items = array(); $menu_items_with_children = array(); foreach ( (array) $menu_items as $menu_item ) { if ( (int) $menu_item->ID === (int) $menu_item->menu_item_parent ) { $menu_item->menu_item_parent = 0; } $sorted_menu_items[ $menu_item->menu_order ] = $menu_item; if ( $menu_item->menu_item_parent ) { $menu_items_with_children[ $menu_item->menu_item_parent ] = true; } } if ( $menu_items_with_children ) { foreach ( $sorted_menu_items as &$menu_item ) { if ( isset( $menu_items_with_children[ $menu_item->ID ] ) ) { $menu_item->classes[] = 'menu-item-has-children'; } } } unset( $menu_items, $menu_item ); $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args ); $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args ); unset( $sorted_menu_items ); if ( ! empty( $args->menu_id ) ) { $wrap_id = $args->menu_id; } else { $wrap_id = 'menu-' . $menu->slug; while ( in_array( $wrap_id, $menu_id_slugs, true ) ) { if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) { $wrap_id = preg_replace( '#-(\d+)$#', '-' . ++$matches[1], $wrap_id ); } else { $wrap_id = $wrap_id . '-1'; } } } $menu_id_slugs[] = $wrap_id; $wrap_class = $args->menu_class ? $args->menu_class : ''; $items = apply_filters( 'wp_nav_menu_items', $items, $args ); $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args ); if ( empty( $items ) ) { return false; } $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items ); unset( $items ); if ( $show_container ) { $nav_menu .= '</' . $args->container . '>'; } $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args ); if ( $args->echo ) { echo $nav_menu; } else { return $nav_menu; } } function _wp_menu_item_classes_by_context( &$menu_items ) { global $wp_query, $wp_rewrite; $queried_object = $wp_query->get_queried_object(); $queried_object_id = (int) $wp_query->queried_object_id; $active_object = ''; $active_ancestor_item_ids = array(); $active_parent_item_ids = array(); $active_parent_object_ids = array(); $possible_taxonomy_ancestors = array(); $possible_object_parents = array(); $home_page_id = (int) get_option( 'page_for_posts' ); if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) { foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) { if ( is_taxonomy_hierarchical( $taxonomy ) ) { $term_hierarchy = _get_term_hierarchy( $taxonomy ); $terms = wp_get_object_terms( $queried_object_id, $taxonomy, array( 'fields' => 'ids' ) ); if ( is_array( $terms ) ) { $possible_object_parents = array_merge( $possible_object_parents, $terms ); $term_to_ancestor = array(); foreach ( (array) $term_hierarchy as $anc => $descs ) { foreach ( (array) $descs as $desc ) { $term_to_ancestor[ $desc ] = $anc; } } foreach ( $terms as $desc ) { do { $possible_taxonomy_ancestors[ $taxonomy ][] = $desc; if ( isset( $term_to_ancestor[ $desc ] ) ) { $_desc = $term_to_ancestor[ $desc ]; unset( $term_to_ancestor[ $desc ] ); $desc = $_desc; } else { $desc = 0; } } while ( ! empty( $desc ) ); } } } } } elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) { $term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy ); $term_to_ancestor = array(); foreach ( (array) $term_hierarchy as $anc => $descs ) { foreach ( (array) $descs as $desc ) { $term_to_ancestor[ $desc ] = $anc; } } $desc = $queried_object->term_id; do { $possible_taxonomy_ancestors[ $queried_object->taxonomy ][] = $desc; if ( isset( $term_to_ancestor[ $desc ] ) ) { $_desc = $term_to_ancestor[ $desc ]; unset( $term_to_ancestor[ $desc ] ); $desc = $_desc; } else { $desc = 0; } } while ( ! empty( $desc ) ); } $possible_object_parents = array_filter( $possible_object_parents ); $front_page_url = home_url(); $front_page_id = (int) get_option( 'page_on_front' ); $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); foreach ( (array) $menu_items as $key => $menu_item ) { $menu_items[ $key ]->current = false; $classes = (array) $menu_item->classes; $classes[] = 'menu-item'; $classes[] = 'menu-item-type-' . $menu_item->type; $classes[] = 'menu-item-object-' . $menu_item->object; if ( 'post_type' === $menu_item->type && $front_page_id === (int) $menu_item->object_id ) { $classes[] = 'menu-item-home'; } if ( 'post_type' === $menu_item->type && $privacy_policy_page_id === (int) $menu_item->object_id ) { $classes[] = 'menu-item-privacy-policy'; } if ( $wp_query->is_singular && 'taxonomy' === $menu_item->type && in_array( (int) $menu_item->object_id, $possible_object_parents, true ) ) { $active_parent_object_ids[] = (int) $menu_item->object_id; $active_parent_item_ids[] = (int) $menu_item->db_id; $active_object = $queried_object->post_type; } elseif ( $menu_item->object_id == $queried_object_id && ( ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) || ( 'post_type' === $menu_item->type && $wp_query->is_singular ) || ( 'taxonomy' === $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) { $classes[] = 'page_item'; $classes[] = 'page-item-' . $menu_item->object_id; $classes[] = 'current_page_item'; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; } elseif ( 'post_type_archive' === $menu_item->type && is_post_type_archive( array( $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; } elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); if ( is_customize_preview() ) { $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); } $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; $item_url = set_url_scheme( untrailingslashit( $raw_item_url ) ); $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); $matches = array( $current_url, urldecode( $current_url ), $_indexless_current, urldecode( $_indexless_current ), $_root_relative_current, urldecode( $_root_relative_current ), ); if ( $raw_item_url && in_array( $item_url, $matches, true ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ), true ) ) { $classes[] = 'current_page_item'; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; } elseif ( $item_url == $front_page_url && is_front_page() ) { $classes[] = 'current-menu-item'; } if ( untrailingslashit( $item_url ) == home_url() ) { $classes[] = 'menu-item-home'; } } if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) { $classes[] = 'current_page_parent'; } $menu_items[ $key ]->classes = array_unique( $classes ); } $active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) ); $active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) ); $active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) ); foreach ( (array) $menu_items as $key => $parent_item ) { $classes = (array) $parent_item->classes; $menu_items[ $key ]->current_item_ancestor = false; $menu_items[ $key ]->current_item_parent = false; if ( isset( $parent_item->type ) && ( ( 'post_type' === $parent_item->type && ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) && in_array( (int) $parent_item->object_id, $queried_object->ancestors, true ) && $parent_item->object != $queried_object->ID ) || ( 'taxonomy' === $parent_item->type && isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true ) && ( ! isset( $queried_object->term_id ) || $parent_item->object_id != $queried_object->term_id ) ) ) ) { if ( ! empty( $queried_object->taxonomy ) ) { $classes[] = 'current-' . $queried_object->taxonomy . '-ancestor'; } else { $classes[] = 'current-' . $queried_object->post_type . '-ancestor'; } } if ( in_array( (int) $parent_item->db_id, $active_ancestor_item_ids, true ) ) { $classes[] = 'current-menu-ancestor'; $menu_items[ $key ]->current_item_ancestor = true; } if ( in_array( (int) $parent_item->db_id, $active_parent_item_ids, true ) ) { $classes[] = 'current-menu-parent'; $menu_items[ $key ]->current_item_parent = true; } if ( in_array( (int) $parent_item->object_id, $active_parent_object_ids, true ) ) { $classes[] = 'current-' . $active_object . '-parent'; } if ( 'post_type' === $parent_item->type && 'page' === $parent_item->object ) { if ( in_array( 'current-menu-parent', $classes, true ) ) { $classes[] = 'current_page_parent'; } if ( in_array( 'current-menu-ancestor', $classes, true ) ) { $classes[] = 'current_page_ancestor'; } } $menu_items[ $key ]->classes = array_unique( $classes ); } } function walk_nav_menu_tree( $items, $depth, $args ) { $walker = ( empty( $args->walker ) ) ? new Walker_Nav_Menu() : $args->walker; return $walker->walk( $items, $depth, $args ); } function _nav_menu_item_id_use_once( $id, $item ) { static $_used_ids = array(); if ( in_array( $item->ID, $_used_ids, true ) ) { return ''; } $_used_ids[] = $item->ID; return $id; } function wp_nav_menu_remove_menu_item_has_children_class( $classes, $menu_item, $args = false, $depth = false ) { if ( false === $depth || false === $args ) { return $classes; } $max_depth = isset( $args->depth ) ? (int) $args->depth : 0; $depth = $depth + 1; if ( 0 === $max_depth ) { return $classes; } if ( -1 === $max_depth || $depth >= $max_depth ) { $classes = array_diff( $classes, array( 'menu-item-has-children' ) ); } return $classes; } <?php + require_once ABSPATH . WPINC . '/class-walker-nav-menu.php'; function wp_nav_menu( $args = array() ) { static $menu_id_slugs = array(); $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'container_aria_label' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'item_spacing' => 'preserve', 'depth' => 0, 'walker' => '', 'theme_location' => '', ); $args = wp_parse_args( $args, $defaults ); if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { $args['item_spacing'] = $defaults['item_spacing']; } $args = apply_filters( 'wp_nav_menu_args', $args ); $args = (object) $args; $nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args ); if ( null !== $nav_menu ) { if ( $args->echo ) { echo $nav_menu; return; } return $nav_menu; } $menu = wp_get_nav_menu_object( $args->menu ); $locations = get_nav_menu_locations(); if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] ); } if ( ! $menu && ! $args->theme_location ) { $menus = wp_get_nav_menus(); foreach ( $menus as $menu_maybe ) { $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ); if ( $menu_items ) { $menu = $menu_maybe; break; } } } if ( empty( $args->menu ) ) { $args->menu = $menu; } if ( $menu && ! is_wp_error( $menu ) && ! isset( $menu_items ) ) { $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) ); } if ( ( ! $menu || is_wp_error( $menu ) || ( isset( $menu_items ) && empty( $menu_items ) && ! $args->theme_location ) ) && isset( $args->fallback_cb ) && $args->fallback_cb && is_callable( $args->fallback_cb ) ) { return call_user_func( $args->fallback_cb, (array) $args ); } if ( ! $menu || is_wp_error( $menu ) ) { return false; } $nav_menu = ''; $items = ''; $show_container = false; if ( $args->container ) { $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ); if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags, true ) ) { $show_container = true; $class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"'; $id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : ''; $aria_label = ( 'nav' === $args->container && $args->container_aria_label ) ? ' aria-label="' . esc_attr( $args->container_aria_label ) . '"' : ''; $nav_menu .= '<' . $args->container . $id . $class . $aria_label . '>'; } } _wp_menu_item_classes_by_context( $menu_items ); $sorted_menu_items = array(); $menu_items_with_children = array(); foreach ( (array) $menu_items as $menu_item ) { if ( strval( $menu_item->ID ) === strval( $menu_item->menu_item_parent ) ) { $menu_item->menu_item_parent = 0; } $sorted_menu_items[ $menu_item->menu_order ] = $menu_item; if ( $menu_item->menu_item_parent ) { $menu_items_with_children[ $menu_item->menu_item_parent ] = true; } } if ( $menu_items_with_children ) { foreach ( $sorted_menu_items as &$menu_item ) { if ( isset( $menu_items_with_children[ $menu_item->ID ] ) ) { $menu_item->classes[] = 'menu-item-has-children'; } } } unset( $menu_items, $menu_item ); $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args ); $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args ); unset( $sorted_menu_items ); if ( ! empty( $args->menu_id ) ) { $wrap_id = $args->menu_id; } else { $wrap_id = 'menu-' . $menu->slug; while ( in_array( $wrap_id, $menu_id_slugs, true ) ) { if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) { $wrap_id = preg_replace( '#-(\d+)$#', '-' . ++$matches[1], $wrap_id ); } else { $wrap_id = $wrap_id . '-1'; } } } $menu_id_slugs[] = $wrap_id; $wrap_class = $args->menu_class ? $args->menu_class : ''; $items = apply_filters( 'wp_nav_menu_items', $items, $args ); $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args ); if ( empty( $items ) ) { return false; } $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items ); unset( $items ); if ( $show_container ) { $nav_menu .= '</' . $args->container . '>'; } $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args ); if ( $args->echo ) { echo $nav_menu; } else { return $nav_menu; } } function _wp_menu_item_classes_by_context( &$menu_items ) { global $wp_query, $wp_rewrite; $queried_object = $wp_query->get_queried_object(); $queried_object_id = (int) $wp_query->queried_object_id; $active_object = ''; $active_ancestor_item_ids = array(); $active_parent_item_ids = array(); $active_parent_object_ids = array(); $possible_taxonomy_ancestors = array(); $possible_object_parents = array(); $home_page_id = (int) get_option( 'page_for_posts' ); if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) { foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) { if ( is_taxonomy_hierarchical( $taxonomy ) ) { $term_hierarchy = _get_term_hierarchy( $taxonomy ); $terms = wp_get_object_terms( $queried_object_id, $taxonomy, array( 'fields' => 'ids' ) ); if ( is_array( $terms ) ) { $possible_object_parents = array_merge( $possible_object_parents, $terms ); $term_to_ancestor = array(); foreach ( (array) $term_hierarchy as $anc => $descs ) { foreach ( (array) $descs as $desc ) { $term_to_ancestor[ $desc ] = $anc; } } foreach ( $terms as $desc ) { do { $possible_taxonomy_ancestors[ $taxonomy ][] = $desc; if ( isset( $term_to_ancestor[ $desc ] ) ) { $_desc = $term_to_ancestor[ $desc ]; unset( $term_to_ancestor[ $desc ] ); $desc = $_desc; } else { $desc = 0; } } while ( ! empty( $desc ) ); } } } } } elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) { $term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy ); $term_to_ancestor = array(); foreach ( (array) $term_hierarchy as $anc => $descs ) { foreach ( (array) $descs as $desc ) { $term_to_ancestor[ $desc ] = $anc; } } $desc = $queried_object->term_id; do { $possible_taxonomy_ancestors[ $queried_object->taxonomy ][] = $desc; if ( isset( $term_to_ancestor[ $desc ] ) ) { $_desc = $term_to_ancestor[ $desc ]; unset( $term_to_ancestor[ $desc ] ); $desc = $_desc; } else { $desc = 0; } } while ( ! empty( $desc ) ); } $possible_object_parents = array_filter( $possible_object_parents ); $front_page_url = home_url(); $front_page_id = (int) get_option( 'page_on_front' ); $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); foreach ( (array) $menu_items as $key => $menu_item ) { $menu_items[ $key ]->current = false; $classes = (array) $menu_item->classes; $classes[] = 'menu-item'; $classes[] = 'menu-item-type-' . $menu_item->type; $classes[] = 'menu-item-object-' . $menu_item->object; if ( 'post_type' === $menu_item->type && $front_page_id === (int) $menu_item->object_id ) { $classes[] = 'menu-item-home'; } if ( 'post_type' === $menu_item->type && $privacy_policy_page_id === (int) $menu_item->object_id ) { $classes[] = 'menu-item-privacy-policy'; } if ( $wp_query->is_singular && 'taxonomy' === $menu_item->type && in_array( (int) $menu_item->object_id, $possible_object_parents, true ) ) { $active_parent_object_ids[] = (int) $menu_item->object_id; $active_parent_item_ids[] = (int) $menu_item->db_id; $active_object = $queried_object->post_type; } elseif ( $menu_item->object_id == $queried_object_id && ( ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) || ( 'post_type' === $menu_item->type && $wp_query->is_singular ) || ( 'taxonomy' === $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) { $classes[] = 'page_item'; $classes[] = 'page-item-' . $menu_item->object_id; $classes[] = 'current_page_item'; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; } elseif ( 'post_type_archive' === $menu_item->type && is_post_type_archive( array( $menu_item->object ) ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; } elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); if ( is_customize_preview() ) { $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); } $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; $item_url = set_url_scheme( untrailingslashit( $raw_item_url ) ); $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); $matches = array( $current_url, urldecode( $current_url ), $_indexless_current, urldecode( $_indexless_current ), $_root_relative_current, urldecode( $_root_relative_current ), ); if ( $raw_item_url && in_array( $item_url, $matches, true ) ) { $classes[] = 'current-menu-item'; $menu_items[ $key ]->current = true; $_anc_id = (int) $menu_item->db_id; while ( ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $active_ancestor_item_ids, true ) ) { $active_ancestor_item_ids[] = $_anc_id; } if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ), true ) ) { $classes[] = 'current_page_item'; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; } elseif ( $item_url == $front_page_url && is_front_page() ) { $classes[] = 'current-menu-item'; } if ( untrailingslashit( $item_url ) == home_url() ) { $classes[] = 'menu-item-home'; } } if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) { $classes[] = 'current_page_parent'; } $menu_items[ $key ]->classes = array_unique( $classes ); } $active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) ); $active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) ); $active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) ); foreach ( (array) $menu_items as $key => $parent_item ) { $classes = (array) $parent_item->classes; $menu_items[ $key ]->current_item_ancestor = false; $menu_items[ $key ]->current_item_parent = false; if ( isset( $parent_item->type ) && ( ( 'post_type' === $parent_item->type && ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) && in_array( (int) $parent_item->object_id, $queried_object->ancestors, true ) && $parent_item->object != $queried_object->ID ) || ( 'taxonomy' === $parent_item->type && isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) && in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true ) && ( ! isset( $queried_object->term_id ) || $parent_item->object_id != $queried_object->term_id ) ) ) ) { if ( ! empty( $queried_object->taxonomy ) ) { $classes[] = 'current-' . $queried_object->taxonomy . '-ancestor'; } else { $classes[] = 'current-' . $queried_object->post_type . '-ancestor'; } } if ( in_array( (int) $parent_item->db_id, $active_ancestor_item_ids, true ) ) { $classes[] = 'current-menu-ancestor'; $menu_items[ $key ]->current_item_ancestor = true; } if ( in_array( (int) $parent_item->db_id, $active_parent_item_ids, true ) ) { $classes[] = 'current-menu-parent'; $menu_items[ $key ]->current_item_parent = true; } if ( in_array( (int) $parent_item->object_id, $active_parent_object_ids, true ) ) { $classes[] = 'current-' . $active_object . '-parent'; } if ( 'post_type' === $parent_item->type && 'page' === $parent_item->object ) { if ( in_array( 'current-menu-parent', $classes, true ) ) { $classes[] = 'current_page_parent'; } if ( in_array( 'current-menu-ancestor', $classes, true ) ) { $classes[] = 'current_page_ancestor'; } } $menu_items[ $key ]->classes = array_unique( $classes ); } } function walk_nav_menu_tree( $items, $depth, $args ) { $walker = ( empty( $args->walker ) ) ? new Walker_Nav_Menu() : $args->walker; return $walker->walk( $items, $depth, $args ); } function _nav_menu_item_id_use_once( $id, $item ) { static $_used_ids = array(); if ( in_array( $item->ID, $_used_ids, true ) ) { return ''; } $_used_ids[] = $item->ID; return $id; } function wp_nav_menu_remove_menu_item_has_children_class( $classes, $menu_item, $args = false, $depth = false ) { if ( false === $depth || false === $args ) { return $classes; } $max_depth = isset( $args->depth ) ? (int) $args->depth : 0; $depth = $depth + 1; if ( 0 === $max_depth ) { return $classes; } if ( -1 === $max_depth || $depth >= $max_depth ) { $classes = array_diff( $classes, array( 'menu-item-has-children' ) ); } return $classes; } <?php function wp_get_nav_menu_object( $menu ) { $menu_obj = false; if ( is_object( $menu ) ) { $menu_obj = $menu; } if ( $menu && ! $menu_obj ) { $menu_obj = get_term( $menu, 'nav_menu' ); if ( ! $menu_obj ) { $menu_obj = get_term_by( 'slug', $menu, 'nav_menu' ); } if ( ! $menu_obj ) { $menu_obj = get_term_by( 'name', $menu, 'nav_menu' ); } } if ( ! $menu_obj || is_wp_error( $menu_obj ) ) { $menu_obj = false; } return apply_filters( 'wp_get_nav_menu_object', $menu_obj, $menu ); } function is_nav_menu( $menu ) { if ( ! $menu ) { return false; } $menu_obj = wp_get_nav_menu_object( $menu ); if ( $menu_obj && ! is_wp_error( $menu_obj ) && ! empty( $menu_obj->taxonomy ) && 'nav_menu' === $menu_obj->taxonomy ) { return true; } return false; } function register_nav_menus( $locations = array() ) { global $_wp_registered_nav_menus; add_theme_support( 'menus' ); foreach ( $locations as $key => $value ) { if ( is_int( $key ) ) { _doing_it_wrong( __FUNCTION__, __( 'Nav menu locations must be strings.' ), '5.3.0' ); break; } } $_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations ); } function unregister_nav_menu( $location ) { global $_wp_registered_nav_menus; if ( is_array( $_wp_registered_nav_menus ) && isset( $_wp_registered_nav_menus[ $location ] ) ) { unset( $_wp_registered_nav_menus[ $location ] ); if ( empty( $_wp_registered_nav_menus ) ) { _remove_theme_support( 'menus' ); } return true; } return false; } function register_nav_menu( $location, $description ) { register_nav_menus( array( $location => $description ) ); } function get_registered_nav_menus() { global $_wp_registered_nav_menus; if ( isset( $_wp_registered_nav_menus ) ) { return $_wp_registered_nav_menus; } return array(); } function get_nav_menu_locations() { $locations = get_theme_mod( 'nav_menu_locations' ); return ( is_array( $locations ) ) ? $locations : array(); } function has_nav_menu( $location ) { $has_nav_menu = false; $registered_nav_menus = get_registered_nav_menus(); if ( isset( $registered_nav_menus[ $location ] ) ) { $locations = get_nav_menu_locations(); $has_nav_menu = ! empty( $locations[ $location ] ); } return apply_filters( 'has_nav_menu', $has_nav_menu, $location ); } function wp_get_nav_menu_name( $location ) { $menu_name = ''; $locations = get_nav_menu_locations(); if ( isset( $locations[ $location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $location ] ); if ( $menu && $menu->name ) { $menu_name = $menu->name; } } return apply_filters( 'wp_get_nav_menu_name', $menu_name, $location ); } function is_nav_menu_item( $menu_item_id = 0 ) { return ( ! is_wp_error( $menu_item_id ) && ( 'nav_menu_item' === get_post_type( $menu_item_id ) ) ); } function wp_create_nav_menu( $menu_name ) { return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) ); } function wp_delete_nav_menu( $menu ) { $menu = wp_get_nav_menu_object( $menu ); if ( ! $menu ) { return false; } $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' ); if ( ! empty( $menu_objects ) ) { foreach ( $menu_objects as $item ) { wp_delete_post( $item ); } } $result = wp_delete_term( $menu->term_id, 'nav_menu' ); $locations = get_nav_menu_locations(); foreach ( $locations as $location => $menu_id ) { if ( $menu_id == $menu->term_id ) { $locations[ $location ] = 0; } } set_theme_mod( 'nav_menu_locations', $locations ); if ( $result && ! is_wp_error( $result ) ) { do_action( 'wp_delete_nav_menu', $menu->term_id ); } return $result; } function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { $menu_id = (int) $menu_id; $_menu = wp_get_nav_menu_object( $menu_id ); $args = array( 'description' => ( isset( $menu_data['description'] ) ? $menu_data['description'] : '' ), 'name' => ( isset( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : '' ), 'parent' => ( isset( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ), 'slug' => null, ); $_possible_existing = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); if ( $_possible_existing && ! is_wp_error( $_possible_existing ) && isset( $_possible_existing->term_id ) && $_possible_existing->term_id != $menu_id ) { return new WP_Error( 'menu_exists', sprintf( __( 'The menu name %s conflicts with another menu name. Please try another.' ), '<strong>' . esc_html( $menu_data['menu-name'] ) . '</strong>' ) ); } if ( ! $_menu || is_wp_error( $_menu ) ) { $menu_exists = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); if ( $menu_exists ) { return new WP_Error( 'menu_exists', sprintf( __( 'The menu name %s conflicts with another menu name. Please try another.' ), '<strong>' . esc_html( $menu_data['menu-name'] ) . '</strong>' ) ); } $_menu = wp_insert_term( $menu_data['menu-name'], 'nav_menu', $args ); if ( is_wp_error( $_menu ) ) { return $_menu; } do_action( 'wp_create_nav_menu', $_menu['term_id'], $menu_data ); return (int) $_menu['term_id']; } if ( ! $_menu || ! isset( $_menu->term_id ) ) { return 0; } $menu_id = (int) $_menu->term_id; $update_response = wp_update_term( $menu_id, 'nav_menu', $args ); if ( is_wp_error( $update_response ) ) { return $update_response; } $menu_id = (int) $update_response['term_id']; do_action( 'wp_update_nav_menu', $menu_id, $menu_data ); return $menu_id; } function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array(), $fire_after_hooks = true ) { $menu_id = (int) $menu_id; $menu_item_db_id = (int) $menu_item_db_id; if ( ! empty( $menu_item_db_id ) && ! is_nav_menu_item( $menu_item_db_id ) ) { return new WP_Error( 'update_nav_menu_item_failed', __( 'The given object ID is not that of a menu item.' ) ); } $menu = wp_get_nav_menu_object( $menu_id ); if ( ! $menu && 0 !== $menu_id ) { return new WP_Error( 'invalid_menu_id', __( 'Invalid menu ID.' ) ); } if ( is_wp_error( $menu ) ) { return $menu; } $defaults = array( 'menu-item-db-id' => $menu_item_db_id, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 0, 'menu-item-type' => 'custom', 'menu-item-title' => '', 'menu-item-url' => '', 'menu-item-description' => '', 'menu-item-attr-title' => '', 'menu-item-target' => '', 'menu-item-classes' => '', 'menu-item-xfn' => '', 'menu-item-status' => '', 'menu-item-post-date' => '', 'menu-item-post-date-gmt' => '', ); $args = wp_parse_args( $menu_item_data, $defaults ); if ( 0 == $menu_id ) { $args['menu-item-position'] = 1; } elseif ( 0 == (int) $args['menu-item-position'] ) { $menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) ); $last_item = array_pop( $menu_items ); $args['menu-item-position'] = ( $last_item && isset( $last_item->menu_order ) ) ? 1 + $last_item->menu_order : count( $menu_items ); } $original_parent = 0 < $menu_item_db_id ? get_post_field( 'post_parent', $menu_item_db_id ) : 0; if ( 'custom' === $args['menu-item-type'] ) { $args['menu-item-url'] = trim( $args['menu-item-url'] ); } else { $args['menu-item-url'] = ''; $original_title = ''; if ( 'taxonomy' === $args['menu-item-type'] ) { $original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); $original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); } elseif ( 'post_type' === $args['menu-item-type'] ) { $original_object = get_post( $args['menu-item-object-id'] ); $original_parent = (int) $original_object->post_parent; $original_title = $original_object->post_title; } elseif ( 'post_type_archive' === $args['menu-item-type'] ) { $original_object = get_post_type_object( $args['menu-item-object'] ); if ( $original_object ) { $original_title = $original_object->labels->archives; } } if ( wp_unslash( $args['menu-item-title'] ) === wp_specialchars_decode( $original_title ) ) { $args['menu-item-title'] = ''; } if ( '' === $args['menu-item-title'] && '' === $args['menu-item-description'] ) { $args['menu-item-description'] = ' '; } } $post = array( 'menu_order' => $args['menu-item-position'], 'ping_status' => 0, 'post_content' => $args['menu-item-description'], 'post_excerpt' => $args['menu-item-attr-title'], 'post_parent' => $original_parent, 'post_title' => $args['menu-item-title'], 'post_type' => 'nav_menu_item', ); $post_date = wp_resolve_post_date( $args['menu-item-post-date'], $args['menu-item-post-date-gmt'] ); if ( $post_date ) { $post['post_date'] = $post_date; } $update = 0 != $menu_item_db_id; if ( ! $update ) { $post['ID'] = 0; $post['post_status'] = 'publish' === $args['menu-item-status'] ? 'publish' : 'draft'; $menu_item_db_id = wp_insert_post( $post, true, $fire_after_hooks ); if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) ) { return $menu_item_db_id; } do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args ); } if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) ) { $update_terms = wp_set_object_terms( $menu_item_db_id, array( $menu->term_id ), 'nav_menu' ); if ( is_wp_error( $update_terms ) ) { return $update_terms; } } if ( 'custom' === $args['menu-item-type'] ) { $args['menu-item-object-id'] = $menu_item_db_id; $args['menu-item-object'] = 'custom'; } $menu_item_db_id = (int) $menu_item_db_id; if ( (int) $args['menu-item-parent-id'] === $menu_item_db_id ) { $args['menu-item-parent-id'] = 0; } update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key( $args['menu-item-type'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', (string) ( (int) $args['menu-item-parent-id'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_object_id', (string) ( (int) $args['menu-item-object-id'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key( $args['menu-item-object'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key( $args['menu-item-target'] ) ); $args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-classes'] ) ); $args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-xfn'] ) ) ); update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] ); update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] ); update_post_meta( $menu_item_db_id, '_menu_item_url', sanitize_url( $args['menu-item-url'] ) ); if ( 0 == $menu_id ) { update_post_meta( $menu_item_db_id, '_menu_item_orphaned', (string) time() ); } elseif ( get_post_meta( $menu_item_db_id, '_menu_item_orphaned' ) ) { delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' ); } if ( $update ) { $post['ID'] = $menu_item_db_id; $post['post_status'] = ( 'draft' === $args['menu-item-status'] ) ? 'draft' : 'publish'; $update_post = wp_update_post( $post, true ); if ( is_wp_error( $update_post ) ) { return $update_post; } } do_action( 'wp_update_nav_menu_item', $menu_id, $menu_item_db_id, $args ); return $menu_item_db_id; } function wp_get_nav_menus( $args = array() ) { $defaults = array( 'taxonomy' => 'nav_menu', 'hide_empty' => false, 'orderby' => 'name', ); $args = wp_parse_args( $args, $defaults ); return apply_filters( 'wp_get_nav_menus', get_terms( $args ), $args ); } function _is_valid_nav_menu_item( $item ) { return empty( $item->_invalid ); } function wp_get_nav_menu_items( $menu, $args = array() ) { $menu = wp_get_nav_menu_object( $menu ); if ( ! $menu ) { return false; } if ( ! taxonomy_exists( 'nav_menu' ) ) { return false; } $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 'update_menu_item_cache' => true, 'tax_query' => array( array( 'taxonomy' => 'nav_menu', 'field' => 'term_taxonomy_id', 'terms' => $menu->term_taxonomy_id, ), ), ); $args = wp_parse_args( $args, $defaults ); if ( $menu->count > 0 ) { $items = get_posts( $args ); } else { $items = array(); } $items = array_map( 'wp_setup_nav_menu_item', $items ); if ( ! is_admin() ) { $items = array_filter( $items, '_is_valid_nav_menu_item' ); } if ( ARRAY_A === $args['output'] ) { $items = wp_list_sort( $items, array( $args['output_key'] => 'ASC', ) ); $i = 1; foreach ( $items as $k => $item ) { $items[ $k ]->{$args['output_key']} = $i++; } } return apply_filters( 'wp_get_nav_menu_items', $items, $menu, $args ); } function update_menu_item_cache( $menu_items ) { $post_ids = array(); $term_ids = array(); foreach ( $menu_items as $menu_item ) { if ( 'nav_menu_item' !== $menu_item->post_type ) { continue; } $object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true ); $type = get_post_meta( $menu_item->ID, '_menu_item_type', true ); if ( 'post_type' === $type ) { $post_ids[] = (int) $object_id; } elseif ( 'taxonomy' === $type ) { $term_ids[] = (int) $object_id; } } if ( ! empty( $post_ids ) ) { _prime_post_caches( $post_ids, false ); } if ( ! empty( $term_ids ) ) { _prime_term_caches( $term_ids ); } } function wp_setup_nav_menu_item( $menu_item ) { if ( isset( $menu_item->post_type ) ) { if ( 'nav_menu_item' === $menu_item->post_type ) { $menu_item->db_id = (int) $menu_item->ID; $menu_item->menu_item_parent = ! isset( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent; $menu_item->object_id = ! isset( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id; $menu_item->object = ! isset( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object; $menu_item->type = ! isset( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type; if ( 'post_type' === $menu_item->type ) { $object = get_post_type_object( $menu_item->object ); if ( $object ) { $menu_item->type_label = $object->labels->singular_name; if ( function_exists( 'get_post_states' ) ) { $menu_post = get_post( $menu_item->object_id ); $post_states = get_post_states( $menu_post ); if ( $post_states ) { $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); } } } else { $menu_item->type_label = $menu_item->object; $menu_item->_invalid = true; } if ( 'trash' === get_post_status( $menu_item->object_id ) ) { $menu_item->_invalid = true; } $original_object = get_post( $menu_item->object_id ); if ( $original_object ) { $menu_item->url = get_permalink( $original_object->ID ); $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID ); } else { $menu_item->url = ''; $original_title = ''; $menu_item->_invalid = true; } if ( '' === $original_title ) { $original_title = sprintf( __( '#%d (no title)' ), $menu_item->object_id ); } $menu_item->title = ( '' === $menu_item->post_title ) ? $original_title : $menu_item->post_title; } elseif ( 'post_type_archive' === $menu_item->type ) { $object = get_post_type_object( $menu_item->object ); if ( $object ) { $menu_item->title = ( '' === $menu_item->post_title ) ? $object->labels->archives : $menu_item->post_title; $post_type_description = $object->description; } else { $post_type_description = ''; $menu_item->_invalid = true; } $menu_item->type_label = __( 'Post Type Archive' ); $post_content = wp_trim_words( $menu_item->post_content, 200 ); $post_type_description = ( '' === $post_content ) ? $post_type_description : $post_content; $menu_item->url = get_post_type_archive_link( $menu_item->object ); } elseif ( 'taxonomy' === $menu_item->type ) { $object = get_taxonomy( $menu_item->object ); if ( $object ) { $menu_item->type_label = $object->labels->singular_name; } else { $menu_item->type_label = $menu_item->object; $menu_item->_invalid = true; } $original_object = get_term( (int) $menu_item->object_id, $menu_item->object ); if ( $original_object && ! is_wp_error( $original_object ) ) { $menu_item->url = get_term_link( (int) $menu_item->object_id, $menu_item->object ); $original_title = $original_object->name; } else { $menu_item->url = ''; $original_title = ''; $menu_item->_invalid = true; } if ( '' === $original_title ) { $original_title = sprintf( __( '#%d (no title)' ), $menu_item->object_id ); } $menu_item->title = ( '' === $menu_item->post_title ) ? $original_title : $menu_item->post_title; } else { $menu_item->type_label = __( 'Custom Link' ); $menu_item->title = $menu_item->post_title; $menu_item->url = ! isset( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url; } $menu_item->target = ! isset( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target; $menu_item->attr_title = ! isset( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title; if ( ! isset( $menu_item->description ) ) { $menu_item->description = apply_filters( 'nav_menu_description', wp_trim_words( $menu_item->post_content, 200 ) ); } $menu_item->classes = ! isset( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes; $menu_item->xfn = ! isset( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn; } else { $menu_item->db_id = 0; $menu_item->menu_item_parent = 0; $menu_item->object_id = (int) $menu_item->ID; $menu_item->type = 'post_type'; $object = get_post_type_object( $menu_item->post_type ); $menu_item->object = $object->name; $menu_item->type_label = $object->labels->singular_name; if ( '' === $menu_item->post_title ) { $menu_item->post_title = sprintf( __( '#%d (no title)' ), $menu_item->ID ); } $menu_item->title = $menu_item->post_title; $menu_item->url = get_permalink( $menu_item->ID ); $menu_item->target = ''; $menu_item->attr_title = apply_filters( 'nav_menu_attr_title', '' ); $menu_item->description = apply_filters( 'nav_menu_description', '' ); $menu_item->classes = array(); $menu_item->xfn = ''; } } elseif ( isset( $menu_item->taxonomy ) ) { $menu_item->ID = $menu_item->term_id; $menu_item->db_id = 0; $menu_item->menu_item_parent = 0; $menu_item->object_id = (int) $menu_item->term_id; $menu_item->post_parent = (int) $menu_item->parent; $menu_item->type = 'taxonomy'; $object = get_taxonomy( $menu_item->taxonomy ); $menu_item->object = $object->name; $menu_item->type_label = $object->labels->singular_name; $menu_item->title = $menu_item->name; $menu_item->url = get_term_link( $menu_item, $menu_item->taxonomy ); $menu_item->target = ''; $menu_item->attr_title = ''; $menu_item->description = get_term_field( 'description', $menu_item->term_id, $menu_item->taxonomy ); $menu_item->classes = array(); $menu_item->xfn = ''; } return apply_filters( 'wp_setup_nav_menu_item', $menu_item ); } function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' ) { $object_id = (int) $object_id; $menu_item_ids = array(); $query = new WP_Query(); $menu_items = $query->query( array( 'meta_key' => '_menu_item_object_id', 'meta_value' => $object_id, 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'posts_per_page' => -1, ) ); foreach ( (array) $menu_items as $menu_item ) { if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) { $menu_item_type = get_post_meta( $menu_item->ID, '_menu_item_type', true ); if ( 'post_type' === $object_type && 'post_type' === $menu_item_type ) { $menu_item_ids[] = (int) $menu_item->ID; } elseif ( 'taxonomy' === $object_type && 'taxonomy' === $menu_item_type && get_post_meta( $menu_item->ID, '_menu_item_object', true ) == $taxonomy ) { $menu_item_ids[] = (int) $menu_item->ID; } } } return array_unique( $menu_item_ids ); } function _wp_delete_post_menu_item( $object_id ) { $object_id = (int) $object_id; $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'post_type' ); foreach ( (array) $menu_item_ids as $menu_item_id ) { wp_delete_post( $menu_item_id, true ); } } function _wp_delete_tax_menu_item( $object_id, $tt_id, $taxonomy ) { $object_id = (int) $object_id; $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy ); foreach ( (array) $menu_item_ids as $menu_item_id ) { wp_delete_post( $menu_item_id, true ); } } function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) { if ( 'publish' !== $new_status || 'publish' === $old_status || 'page' !== $post->post_type ) { return; } if ( ! empty( $post->post_parent ) ) { return; } $auto_add = get_option( 'nav_menu_options' ); if ( empty( $auto_add ) || ! is_array( $auto_add ) || ! isset( $auto_add['auto_add'] ) ) { return; } $auto_add = $auto_add['auto_add']; if ( empty( $auto_add ) || ! is_array( $auto_add ) ) { return; } $args = array( 'menu-item-object-id' => $post->ID, 'menu-item-object' => $post->post_type, 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish', ); foreach ( $auto_add as $menu_id ) { $items = wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) ); if ( ! is_array( $items ) ) { continue; } foreach ( $items as $item ) { if ( $post->ID == $item->object_id ) { continue 2; } } wp_update_nav_menu_item( $menu_id, 0, $args ); } } function _wp_delete_customize_changeset_dependent_auto_drafts( $post_id ) { $post = get_post( $post_id ); if ( ! $post || 'customize_changeset' !== $post->post_type ) { return; } $data = json_decode( $post->post_content, true ); if ( empty( $data['nav_menus_created_posts']['value'] ) ) { return; } remove_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' ); foreach ( $data['nav_menus_created_posts']['value'] as $stub_post_id ) { if ( empty( $stub_post_id ) ) { continue; } if ( 'auto-draft' === get_post_status( $stub_post_id ) ) { wp_delete_post( $stub_post_id, true ); } elseif ( 'draft' === get_post_status( $stub_post_id ) ) { wp_trash_post( $stub_post_id ); delete_post_meta( $stub_post_id, '_customize_changeset_uuid' ); } } add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' ); } function _wp_menus_changed() { $old_nav_menu_locations = get_option( 'theme_switch_menu_locations', array() ); $new_nav_menu_locations = get_nav_menu_locations(); $mapped_nav_menu_locations = wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations ); set_theme_mod( 'nav_menu_locations', $mapped_nav_menu_locations ); delete_option( 'theme_switch_menu_locations' ); } function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations ) { $registered_nav_menus = get_registered_nav_menus(); $new_nav_menu_locations = array_intersect_key( $new_nav_menu_locations, $registered_nav_menus ); if ( empty( $old_nav_menu_locations ) ) { return $new_nav_menu_locations; } if ( 1 === count( $old_nav_menu_locations ) && 1 === count( $registered_nav_menus ) ) { $new_nav_menu_locations[ key( $registered_nav_menus ) ] = array_pop( $old_nav_menu_locations ); return $new_nav_menu_locations; } $old_locations = array_keys( $old_nav_menu_locations ); foreach ( $registered_nav_menus as $location => $name ) { if ( in_array( $location, $old_locations, true ) ) { $new_nav_menu_locations[ $location ] = $old_nav_menu_locations[ $location ]; unset( $old_nav_menu_locations[ $location ] ); } } if ( empty( $old_nav_menu_locations ) ) { return $new_nav_menu_locations; } $common_slug_groups = array( array( 'primary', 'menu-1', 'main', 'header', 'navigation', 'top' ), array( 'secondary', 'menu-2', 'footer', 'subsidiary', 'bottom' ), array( 'social' ), ); foreach ( $common_slug_groups as $slug_group ) { foreach ( $slug_group as $slug ) { foreach ( $registered_nav_menus as $new_location => $name ) { if ( is_string( $new_location ) && false === stripos( $new_location, $slug ) && false === stripos( $slug, $new_location ) ) { continue; } elseif ( is_numeric( $new_location ) && $new_location !== $slug ) { continue; } foreach ( $old_nav_menu_locations as $location => $menu_id ) { foreach ( $slug_group as $slug ) { if ( is_string( $location ) && false === stripos( $location, $slug ) && false === stripos( $slug, $location ) ) { continue; } elseif ( is_numeric( $location ) && $location !== $slug ) { continue; } if ( ! empty( $old_nav_menu_locations[ $location ] ) ) { $new_nav_menu_locations[ $new_location ] = $old_nav_menu_locations[ $location ]; unset( $old_nav_menu_locations[ $location ] ); continue 3; } } } } } } return $new_nav_menu_locations; } function _wp_reset_invalid_menu_item_parent( $menu_item_data ) { if ( ! is_array( $menu_item_data ) ) { return $menu_item_data; } if ( ! empty( $menu_item_data['ID'] ) && ! empty( $menu_item_data['menu_item_parent'] ) && (int) $menu_item_data['ID'] === (int) $menu_item_data['menu_item_parent'] ) { $menu_item_data['menu_item_parent'] = 0; } return $menu_item_data; } <?php function get_option( $option, $default_value = false ) { global $wpdb; if ( is_scalar( $option ) ) { $option = trim( $option ); } if ( empty( $option ) ) { return false; } $deprecated_keys = array( 'blacklist_keys' => 'disallowed_keys', 'comment_whitelist' => 'comment_previously_approved', ); if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) { _deprecated_argument( __FUNCTION__, '5.5.0', sprintf( __( 'The "%1$s" option key has been renamed to "%2$s".' ), $option, $deprecated_keys[ $option ] ) ); return get_option( $deprecated_keys[ $option ], $default_value ); } $pre = apply_filters( "pre_option_{$option}", false, $option, $default_value ); $pre = apply_filters( 'pre_option', $pre, $option, $default_value ); if ( false !== $pre ) { return $pre; } if ( defined( 'WP_SETUP_CONFIG' ) ) { return false; } $passed_default = func_num_args() > 1; if ( ! wp_installing() ) { $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( ! is_array( $notoptions ) ) { $notoptions = array(); wp_cache_set( 'notoptions', $notoptions, 'options' ); } if ( isset( $notoptions[ $option ] ) ) { return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); } $alloptions = wp_load_alloptions(); if ( isset( $alloptions[ $option ] ) ) { $value = $alloptions[ $option ]; } else { $value = wp_cache_get( $option, 'options' ); if ( false === $value ) { $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); if ( is_object( $row ) ) { $value = $row->option_value; wp_cache_add( $option, $value, 'options' ); } else { if ( ! is_array( $notoptions ) ) { $notoptions = array(); } $notoptions[ $option ] = true; wp_cache_set( 'notoptions', $notoptions, 'options' ); return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); } } } } else { $suppress = $wpdb->suppress_errors(); $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); $wpdb->suppress_errors( $suppress ); if ( is_object( $row ) ) { $value = $row->option_value; } else { return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); } } if ( 'home' === $option && '' === $value ) { return get_option( 'siteurl' ); } if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { $value = untrailingslashit( $value ); } return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option ); } function wp_protect_special_option( $option ) { if ( 'alloptions' === $option || 'notoptions' === $option ) { wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) ); } } function form_option( $option ) { echo esc_attr( get_option( $option ) ); } function wp_load_alloptions( $force_cache = false ) { global $wpdb; if ( ! wp_installing() || ! is_multisite() ) { $alloptions = wp_cache_get( 'alloptions', 'options', $force_cache ); } else { $alloptions = false; } if ( ! $alloptions ) { $suppress = $wpdb->suppress_errors(); $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ); if ( ! $alloptions_db ) { $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); } $wpdb->suppress_errors( $suppress ); $alloptions = array(); foreach ( (array) $alloptions_db as $o ) { $alloptions[ $o->option_name ] = $o->option_value; } if ( ! wp_installing() || ! is_multisite() ) { $alloptions = apply_filters( 'pre_cache_alloptions', $alloptions ); wp_cache_add( 'alloptions', $alloptions, 'options' ); } } return apply_filters( 'alloptions', $alloptions ); } function wp_load_core_site_options( $network_id = null ) { global $wpdb; if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) { return; } if ( empty( $network_id ) ) { $network_id = get_current_network_id(); } $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); $core_options_in = "'" . implode( "', '", $core_options ) . "'"; $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) ); $data = array(); foreach ( $options as $option ) { $key = $option->meta_key; $cache_key = "{$network_id}:$key"; $option->meta_value = maybe_unserialize( $option->meta_value ); $data[ $cache_key ] = $option->meta_value; } wp_cache_set_multiple( $data, 'site-options' ); } function update_option( $option, $value, $autoload = null ) { global $wpdb; if ( is_scalar( $option ) ) { $option = trim( $option ); } if ( empty( $option ) ) { return false; } $deprecated_keys = array( 'blacklist_keys' => 'disallowed_keys', 'comment_whitelist' => 'comment_previously_approved', ); if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) { _deprecated_argument( __FUNCTION__, '5.5.0', sprintf( __( 'The "%1$s" option key has been renamed to "%2$s".' ), $option, $deprecated_keys[ $option ] ) ); return update_option( $deprecated_keys[ $option ], $value, $autoload ); } wp_protect_special_option( $option ); if ( is_object( $value ) ) { $value = clone $value; } $value = sanitize_option( $option, $value ); $old_value = get_option( $option ); $value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option ); $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { return false; } if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { if ( null === $autoload ) { $autoload = 'yes'; } return add_option( $option, $value, '', $autoload ); } $serialized_value = maybe_serialize( $value ); do_action( 'update_option', $option, $old_value, $value ); $update_args = array( 'option_value' => $serialized_value, ); if ( null !== $autoload ) { $update_args['autoload'] = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; } $result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) ); if ( ! $result ) { return false; } $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( 'notoptions', $notoptions, 'options' ); } if ( ! wp_installing() ) { $alloptions = wp_load_alloptions( true ); if ( isset( $alloptions[ $option ] ) ) { $alloptions[ $option ] = $serialized_value; wp_cache_set( 'alloptions', $alloptions, 'options' ); } else { wp_cache_set( $option, $serialized_value, 'options' ); } } do_action( "update_option_{$option}", $old_value, $value, $option ); do_action( 'updated_option', $option, $old_value, $value ); return true; } function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) { global $wpdb; if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.3.0' ); } if ( is_scalar( $option ) ) { $option = trim( $option ); } if ( empty( $option ) ) { return false; } $deprecated_keys = array( 'blacklist_keys' => 'disallowed_keys', 'comment_whitelist' => 'comment_previously_approved', ); if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) { _deprecated_argument( __FUNCTION__, '5.5.0', sprintf( __( 'The "%1$s" option key has been renamed to "%2$s".' ), $option, $deprecated_keys[ $option ] ) ); return add_option( $deprecated_keys[ $option ], $value, $deprecated, $autoload ); } wp_protect_special_option( $option ); if ( is_object( $value ) ) { $value = clone $value; } $value = sanitize_option( $option, $value ); $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) { return false; } } $serialized_value = maybe_serialize( $value ); $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; do_action( 'add_option', $option, $value ); $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) ); if ( ! $result ) { return false; } if ( ! wp_installing() ) { if ( 'yes' === $autoload ) { $alloptions = wp_load_alloptions( true ); $alloptions[ $option ] = $serialized_value; wp_cache_set( 'alloptions', $alloptions, 'options' ); } else { wp_cache_set( $option, $serialized_value, 'options' ); } } $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( 'notoptions', $notoptions, 'options' ); } do_action( "add_option_{$option}", $option, $value ); do_action( 'added_option', $option, $value ); return true; } function delete_option( $option ) { global $wpdb; if ( is_scalar( $option ) ) { $option = trim( $option ); } if ( empty( $option ) ) { return false; } wp_protect_special_option( $option ); $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); if ( is_null( $row ) ) { return false; } do_action( 'delete_option', $option ); $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); if ( ! wp_installing() ) { if ( 'yes' === $row->autoload ) { $alloptions = wp_load_alloptions( true ); if ( is_array( $alloptions ) && isset( $alloptions[ $option ] ) ) { unset( $alloptions[ $option ] ); wp_cache_set( 'alloptions', $alloptions, 'options' ); } } else { wp_cache_delete( $option, 'options' ); } } if ( $result ) { do_action( "delete_option_{$option}", $option ); do_action( 'deleted_option', $option ); return true; } return false; } function delete_transient( $transient ) { do_action( "delete_transient_{$transient}", $transient ); if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_delete( $transient, 'transient' ); } else { $option_timeout = '_transient_timeout_' . $transient; $option = '_transient_' . $transient; $result = delete_option( $option ); if ( $result ) { delete_option( $option_timeout ); } } if ( $result ) { do_action( 'deleted_transient', $transient ); } return $result; } function get_transient( $transient ) { $pre = apply_filters( "pre_transient_{$transient}", false, $transient ); if ( false !== $pre ) { return $pre; } if ( wp_using_ext_object_cache() || wp_installing() ) { $value = wp_cache_get( $transient, 'transient' ); } else { $transient_option = '_transient_' . $transient; if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); if ( ! isset( $alloptions[ $transient_option ] ) ) { $transient_timeout = '_transient_timeout_' . $transient; $timeout = get_option( $transient_timeout ); if ( false !== $timeout && $timeout < time() ) { delete_option( $transient_option ); delete_option( $transient_timeout ); $value = false; } } } if ( ! isset( $value ) ) { $value = get_option( $transient_option ); } } return apply_filters( "transient_{$transient}", $value, $transient ); } function set_transient( $transient, $value, $expiration = 0 ) { $expiration = (int) $expiration; $value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient ); $expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient ); if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_set( $transient, $value, 'transient', $expiration ); } else { $transient_timeout = '_transient_timeout_' . $transient; $transient_option = '_transient_' . $transient; if ( false === get_option( $transient_option ) ) { $autoload = 'yes'; if ( $expiration ) { $autoload = 'no'; add_option( $transient_timeout, time() + $expiration, '', 'no' ); } $result = add_option( $transient_option, $value, '', $autoload ); } else { $update = true; if ( $expiration ) { if ( false === get_option( $transient_timeout ) ) { delete_option( $transient_option ); add_option( $transient_timeout, time() + $expiration, '', 'no' ); $result = add_option( $transient_option, $value, '', 'no' ); $update = false; } else { update_option( $transient_timeout, time() + $expiration ); } } if ( $update ) { $result = update_option( $transient_option, $value ); } } } if ( $result ) { do_action( "set_transient_{$transient}", $value, $expiration, $transient ); do_action( 'setted_transient', $transient, $value, $expiration ); } return $result; } function delete_expired_transients( $force_db = false ) { global $wpdb; if ( ! $force_db && wp_using_ext_object_cache() ) { return; } $wpdb->query( $wpdb->prepare( "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b WHERE a.option_name LIKE %s @@ -31593,7 +34280,7 @@ All at ###SITENAME### AND b.meta_value < %d", $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', time() ) ); } } function wp_user_settings() { if ( ! is_admin() || wp_doing_ajax() ) { return; } $user_id = get_current_user_id(); if ( ! $user_id ) { return; } if ( ! is_user_member_of_blog() ) { return; } $settings = (string) get_user_option( 'user-settings', $user_id ); if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); if ( $cookie == $settings ) { return; } $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0; if ( $current > $last_saved ) { update_user_option( $user_id, 'user-settings', $cookie, false ); update_user_option( $user_id, 'user-settings-time', time() - 5, false ); return; } } $secure = ( 'https' === parse_url( admin_url(), PHP_URL_SCHEME ) ); setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, '', $secure ); setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, '', $secure ); $_COOKIE[ 'wp-settings-' . $user_id ] = $settings; } function get_user_setting( $name, $default_value = false ) { $all_user_settings = get_all_user_settings(); return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default_value; } function set_user_setting( $name, $value ) { if ( headers_sent() ) { return false; } $all_user_settings = get_all_user_settings(); $all_user_settings[ $name ] = $value; return wp_set_all_user_settings( $all_user_settings ); } function delete_user_setting( $names ) { if ( headers_sent() ) { return false; } $all_user_settings = get_all_user_settings(); $names = (array) $names; $deleted = false; foreach ( $names as $name ) { if ( isset( $all_user_settings[ $name ] ) ) { unset( $all_user_settings[ $name ] ); $deleted = true; } } if ( $deleted ) { return wp_set_all_user_settings( $all_user_settings ); } return false; } function get_all_user_settings() { global $_updated_user_settings; $user_id = get_current_user_id(); if ( ! $user_id ) { return array(); } if ( isset( $_updated_user_settings ) && is_array( $_updated_user_settings ) ) { return $_updated_user_settings; } $user_settings = array(); if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); if ( strpos( $cookie, '=' ) ) { parse_str( $cookie, $user_settings ); } } else { $option = get_user_option( 'user-settings', $user_id ); if ( $option && is_string( $option ) ) { parse_str( $option, $user_settings ); } } $_updated_user_settings = $user_settings; return $user_settings; } function wp_set_all_user_settings( $user_settings ) { global $_updated_user_settings; $user_id = get_current_user_id(); if ( ! $user_id ) { return false; } if ( ! is_user_member_of_blog() ) { return; } $settings = ''; foreach ( $user_settings as $name => $value ) { $_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name ); $_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value ); if ( ! empty( $_name ) ) { $settings .= $_name . '=' . $_value . '&'; } } $settings = rtrim( $settings, '&' ); parse_str( $settings, $_updated_user_settings ); update_user_option( $user_id, 'user-settings', $settings, false ); update_user_option( $user_id, 'user-settings-time', time(), false ); return true; } function delete_all_user_settings() { $user_id = get_current_user_id(); if ( ! $user_id ) { return; } update_user_option( $user_id, 'user-settings', '', false ); setcookie( 'wp-settings-' . $user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); } function get_site_option( $option, $default_value = false, $deprecated = true ) { return get_network_option( null, $option, $default_value ); } function add_site_option( $option, $value ) { return add_network_option( null, $option, $value ); } function delete_site_option( $option ) { return delete_network_option( null, $option ); } function update_site_option( $option, $value ) { return update_network_option( null, $option, $value ); } function get_network_option( $network_id, $option, $default_value = false ) { global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; } $network_id = (int) $network_id; if ( ! $network_id ) { $network_id = get_current_network_id(); } $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default_value ); if ( false !== $pre ) { return $pre; } $notoptions_key = "$network_id:notoptions"; $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { return apply_filters( "default_site_option_{$option}", $default_value, $option, $network_id ); } if ( ! is_multisite() ) { $default_value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id ); $value = get_option( $option, $default_value ); } else { $cache_key = "$network_id:$option"; $value = wp_cache_get( $cache_key, 'site-options' ); if ( ! isset( $value ) || false === $value ) { $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); if ( is_object( $row ) ) { $value = $row->meta_value; $value = maybe_unserialize( $value ); wp_cache_set( $cache_key, $value, 'site-options' ); } else { if ( ! is_array( $notoptions ) ) { $notoptions = array(); } $notoptions[ $option ] = true; wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); $value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id ); } } } if ( ! is_array( $notoptions ) ) { $notoptions = array(); wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); } return apply_filters( "site_option_{$option}", $value, $option, $network_id ); } function add_network_option( $network_id, $option, $value ) { global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; } $network_id = (int) $network_id; if ( ! $network_id ) { $network_id = get_current_network_id(); } wp_protect_special_option( $option ); $value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id ); $notoptions_key = "$network_id:notoptions"; if ( ! is_multisite() ) { $result = add_option( $option, $value, '', 'no' ); } else { $cache_key = "$network_id:$option"; $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { if ( false !== get_network_option( $network_id, $option, false ) ) { return false; } } $value = sanitize_option( $option, $value ); $serialized_value = maybe_serialize( $value ); $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $network_id, 'meta_key' => $option, 'meta_value' => $serialized_value, ) ); if ( ! $result ) { return false; } wp_cache_set( $cache_key, $value, 'site-options' ); $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); } } if ( $result ) { do_action( "add_site_option_{$option}", $option, $value, $network_id ); do_action( 'add_site_option', $option, $value, $network_id ); return true; } return false; } function delete_network_option( $network_id, $option ) { global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; } $network_id = (int) $network_id; if ( ! $network_id ) { $network_id = get_current_network_id(); } do_action( "pre_delete_site_option_{$option}", $option, $network_id ); if ( ! is_multisite() ) { $result = delete_option( $option ); } else { $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); if ( is_null( $row ) || ! $row->meta_id ) { return false; } $cache_key = "$network_id:$option"; wp_cache_delete( $cache_key, 'site-options' ); $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id, ) ); } if ( $result ) { do_action( "delete_site_option_{$option}", $option, $network_id ); do_action( 'delete_site_option', $option, $network_id ); return true; } return false; } function update_network_option( $network_id, $option, $value ) { global $wpdb; if ( $network_id && ! is_numeric( $network_id ) ) { return false; } $network_id = (int) $network_id; if ( ! $network_id ) { $network_id = get_current_network_id(); } wp_protect_special_option( $option ); $old_value = get_network_option( $network_id, $option, false ); $value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option, $network_id ); if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { return false; } if ( false === $old_value ) { return add_network_option( $network_id, $option, $value ); } $notoptions_key = "$network_id:notoptions"; $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); } if ( ! is_multisite() ) { $result = update_option( $option, $value, 'no' ); } else { $value = sanitize_option( $option, $value ); $serialized_value = maybe_serialize( $value ); $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option, ) ); if ( $result ) { $cache_key = "$network_id:$option"; wp_cache_set( $cache_key, $value, 'site-options' ); } } if ( $result ) { do_action( "update_site_option_{$option}", $option, $value, $old_value, $network_id ); do_action( 'update_site_option', $option, $value, $old_value, $network_id ); return true; } return false; } function delete_site_transient( $transient ) { do_action( "delete_site_transient_{$transient}", $transient ); if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_delete( $transient, 'site-transient' ); } else { $option_timeout = '_site_transient_timeout_' . $transient; $option = '_site_transient_' . $transient; $result = delete_site_option( $option ); if ( $result ) { delete_site_option( $option_timeout ); } } if ( $result ) { do_action( 'deleted_site_transient', $transient ); } return $result; } function get_site_transient( $transient ) { $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient ); if ( false !== $pre ) { return $pre; } if ( wp_using_ext_object_cache() || wp_installing() ) { $value = wp_cache_get( $transient, 'site-transient' ); } else { $no_timeout = array( 'update_core', 'update_plugins', 'update_themes' ); $transient_option = '_site_transient_' . $transient; if ( ! in_array( $transient, $no_timeout, true ) ) { $transient_timeout = '_site_transient_timeout_' . $transient; $timeout = get_site_option( $transient_timeout ); if ( false !== $timeout && $timeout < time() ) { delete_site_option( $transient_option ); delete_site_option( $transient_timeout ); $value = false; } } if ( ! isset( $value ) ) { $value = get_site_option( $transient_option ); } } return apply_filters( "site_transient_{$transient}", $value, $transient ); } function set_site_transient( $transient, $value, $expiration = 0 ) { $value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient ); $expiration = (int) $expiration; $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient ); if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); } else { $transient_timeout = '_site_transient_timeout_' . $transient; $option = '_site_transient_' . $transient; if ( false === get_site_option( $option ) ) { if ( $expiration ) { add_site_option( $transient_timeout, time() + $expiration ); } $result = add_site_option( $option, $value ); } else { if ( $expiration ) { update_site_option( $transient_timeout, time() + $expiration ); } $result = update_site_option( $option, $value ); } } if ( $result ) { do_action( "set_site_transient_{$transient}", $value, $expiration, $transient ); do_action( 'setted_site_transient', $transient, $value, $expiration ); } return $result; } function register_initial_settings() { register_setting( 'general', 'blogname', array( 'show_in_rest' => array( 'name' => 'title', ), 'type' => 'string', 'description' => __( 'Site title.' ), ) ); register_setting( 'general', 'blogdescription', array( 'show_in_rest' => array( 'name' => 'description', ), 'type' => 'string', 'description' => __( 'Site tagline.' ), ) ); if ( ! is_multisite() ) { register_setting( 'general', 'siteurl', array( 'show_in_rest' => array( 'name' => 'url', 'schema' => array( 'format' => 'uri', ), ), 'type' => 'string', 'description' => __( 'Site URL.' ), ) ); } if ( ! is_multisite() ) { register_setting( 'general', 'admin_email', array( 'show_in_rest' => array( 'name' => 'email', 'schema' => array( 'format' => 'email', ), ), 'type' => 'string', 'description' => __( 'This address is used for admin purposes, like new user notification.' ), ) ); } register_setting( 'general', 'timezone_string', array( 'show_in_rest' => array( 'name' => 'timezone', ), 'type' => 'string', 'description' => __( 'A city in the same timezone as you.' ), ) ); register_setting( 'general', 'date_format', array( 'show_in_rest' => true, 'type' => 'string', 'description' => __( 'A date format for all date strings.' ), ) ); register_setting( 'general', 'time_format', array( 'show_in_rest' => true, 'type' => 'string', 'description' => __( 'A time format for all time strings.' ), ) ); register_setting( 'general', 'start_of_week', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'A day number of the week that the week should start on.' ), ) ); register_setting( 'general', 'WPLANG', array( 'show_in_rest' => array( 'name' => 'language', ), 'type' => 'string', 'description' => __( 'WordPress locale code.' ), 'default' => 'en_US', ) ); register_setting( 'writing', 'use_smilies', array( 'show_in_rest' => true, 'type' => 'boolean', 'description' => __( 'Convert emoticons like :-) and :-P to graphics on display.' ), 'default' => true, ) ); register_setting( 'writing', 'default_category', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'Default post category.' ), ) ); register_setting( 'writing', 'default_post_format', array( 'show_in_rest' => true, 'type' => 'string', 'description' => __( 'Default post format.' ), ) ); register_setting( 'reading', 'posts_per_page', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'Blog pages show at most.' ), 'default' => 10, ) ); register_setting( 'reading', 'show_on_front', array( 'show_in_rest' => true, 'type' => 'string', 'description' => __( 'What to show on the front page' ), ) ); register_setting( 'reading', 'page_on_front', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'The ID of the page that should be displayed on the front page' ), ) ); register_setting( 'reading', 'page_for_posts', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'The ID of the page that should display the latest posts' ), ) ); register_setting( 'discussion', 'default_ping_status', array( 'show_in_rest' => array( 'schema' => array( 'enum' => array( 'open', 'closed' ), ), ), 'type' => 'string', 'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ), ) ); register_setting( 'discussion', 'default_comment_status', array( 'show_in_rest' => array( 'schema' => array( 'enum' => array( 'open', 'closed' ), ), ), 'type' => 'string', 'description' => __( 'Allow people to submit comments on new posts.' ), ) ); } function register_setting( $option_group, $option_name, $args = array() ) { global $new_allowed_options, $wp_registered_settings; $GLOBALS['new_whitelist_options'] = &$new_allowed_options; $defaults = array( 'type' => 'string', 'group' => $option_group, 'description' => '', 'sanitize_callback' => null, 'show_in_rest' => false, ); if ( is_callable( $args ) ) { $args = array( 'sanitize_callback' => $args, ); } $args = apply_filters( 'register_setting_args', $args, $defaults, $option_group, $option_name ); $args = wp_parse_args( $args, $defaults ); if ( false !== $args['show_in_rest'] && 'array' === $args['type'] && ( ! is_array( $args['show_in_rest'] ) || ! isset( $args['show_in_rest']['schema']['items'] ) ) ) { _doing_it_wrong( __FUNCTION__, __( 'When registering an "array" setting to show in the REST API, you must specify the schema for each array item in "show_in_rest.schema.items".' ), '5.4.0' ); } if ( ! is_array( $wp_registered_settings ) ) { $wp_registered_settings = array(); } if ( 'misc' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); $option_group = 'general'; } if ( 'privacy' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); $option_group = 'reading'; } $new_allowed_options[ $option_group ][] = $option_name; if ( ! empty( $args['sanitize_callback'] ) ) { add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] ); } if ( array_key_exists( 'default', $args ) ) { add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 ); } do_action( 'register_setting', $option_group, $option_name, $args ); $wp_registered_settings[ $option_name ] = $args; } function unregister_setting( $option_group, $option_name, $deprecated = '' ) { global $new_allowed_options, $wp_registered_settings; $GLOBALS['new_whitelist_options'] = &$new_allowed_options; if ( 'misc' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); $option_group = 'general'; } if ( 'privacy' === $option_group ) { _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); $option_group = 'reading'; } $pos = array_search( $option_name, (array) $new_allowed_options[ $option_group ], true ); if ( false !== $pos ) { unset( $new_allowed_options[ $option_group ][ $pos ] ); } if ( '' !== $deprecated ) { _deprecated_argument( __FUNCTION__, '4.7.0', sprintf( __( '%1$s is deprecated. The callback from %2$s is used instead.' ), '<code>$sanitize_callback</code>', '<code>register_setting()</code>' ) ); remove_filter( "sanitize_option_{$option_name}", $deprecated ); } if ( isset( $wp_registered_settings[ $option_name ] ) ) { if ( ! empty( $wp_registered_settings[ $option_name ]['sanitize_callback'] ) ) { remove_filter( "sanitize_option_{$option_name}", $wp_registered_settings[ $option_name ]['sanitize_callback'] ); } if ( array_key_exists( 'default', $wp_registered_settings[ $option_name ] ) ) { remove_filter( "default_option_{$option_name}", 'filter_default_option', 10 ); } do_action( 'unregister_setting', $option_group, $option_name ); unset( $wp_registered_settings[ $option_name ] ); } } function get_registered_settings() { global $wp_registered_settings; if ( ! is_array( $wp_registered_settings ) ) { return array(); } return $wp_registered_settings; } function filter_default_option( $default_value, $option, $passed_default ) { if ( $passed_default ) { return $default_value; } $registered = get_registered_settings(); if ( empty( $registered[ $option ] ) ) { return $default_value; } return $registered[ $option ]['default']; } <?php function readonly( $readonly_value, $current = true, $display = true ) { _deprecated_function( __FUNCTION__, '5.9.0', 'wp_readonly()' ); return wp_readonly( $readonly_value, $current, $display ); } <?php if ( !function_exists('set_current_user') ) : function set_current_user($id, $name = '') { _deprecated_function( __FUNCTION__, '3.0.0', 'wp_set_current_user()' ); return wp_set_current_user($id, $name); } endif; if ( !function_exists('get_currentuserinfo') ) : function get_currentuserinfo() { _deprecated_function( __FUNCTION__, '4.5.0', 'wp_get_current_user()' ); return _wp_get_current_user(); } endif; if ( !function_exists('get_userdatabylogin') ) : function get_userdatabylogin($user_login) { _deprecated_function( __FUNCTION__, '3.3.0', "get_user_by('login')" ); return get_user_by('login', $user_login); } endif; if ( !function_exists('get_user_by_email') ) : function get_user_by_email($email) { _deprecated_function( __FUNCTION__, '3.3.0', "get_user_by('email')" ); return get_user_by('email', $email); } endif; if ( !function_exists('wp_setcookie') ) : function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' ); $user = get_user_by('login', $username); wp_set_auth_cookie($user->ID, $remember); } else : _deprecated_function( 'wp_setcookie', '2.5.0', 'wp_set_auth_cookie()' ); endif; if ( !function_exists('wp_clearcookie') ) : function wp_clearcookie() { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()' ); wp_clear_auth_cookie(); } else : _deprecated_function( 'wp_clearcookie', '2.5.0', 'wp_clear_auth_cookie()' ); endif; if ( !function_exists('wp_get_cookie_login') ): function wp_get_cookie_login() { _deprecated_function( __FUNCTION__, '2.5.0' ); return false; } else : _deprecated_function( 'wp_get_cookie_login', '2.5.0' ); endif; if ( !function_exists('wp_login') ) : function wp_login($username, $password, $deprecated = '') { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_signon()' ); global $error; $user = wp_authenticate($username, $password); if ( ! is_wp_error($user) ) return true; $error = $user->get_error_message(); return false; } else : _deprecated_function( 'wp_login', '2.5.0', 'wp_signon()' ); endif; if ( ! class_exists( 'wp_atom_server', false ) ) { class wp_atom_server { public function __call( $name, $arguments ) { _deprecated_function( __CLASS__ . '::' . $name, '3.5.0', 'the Atom Publishing Protocol plugin' ); } public static function __callStatic( $name, $arguments ) { _deprecated_function( __CLASS__ . '::' . $name, '3.5.0', 'the Atom Publishing Protocol plugin' ); } } } <?php - if ( ! function_exists( 'wp_set_current_user' ) ) : function wp_set_current_user( $id, $name = '' ) { global $current_user; if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) && ( null !== $id ) ) { return $current_user; } $current_user = new WP_User( $id, $name ); setup_userdata( $current_user->ID ); do_action( 'set_current_user' ); return $current_user; } endif; if ( ! function_exists( 'wp_get_current_user' ) ) : function wp_get_current_user() { return _wp_get_current_user(); } endif; if ( ! function_exists( 'get_userdata' ) ) : function get_userdata( $user_id ) { return get_user_by( 'id', $user_id ); } endif; if ( ! function_exists( 'get_user_by' ) ) : function get_user_by( $field, $value ) { $userdata = WP_User::get_data_by( $field, $value ); if ( ! $userdata ) { return false; } $user = new WP_User(); $user->init( $userdata ); return $user; } endif; if ( ! function_exists( 'cache_users' ) ) : function cache_users( $user_ids ) { global $wpdb; update_meta_cache( 'user', $user_ids ); $clean = _get_non_cached_ids( $user_ids, 'users' ); if ( empty( $clean ) ) { return; } $list = implode( ',', $clean ); $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" ); foreach ( $users as $user ) { update_user_caches( $user ); } } endif; if ( ! function_exists( 'wp_mail' ) ) : function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); $pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts ); if ( null !== $pre_wp_mail ) { return $pre_wp_mail; } if ( isset( $atts['to'] ) ) { $to = $atts['to']; } if ( ! is_array( $to ) ) { $to = explode( ',', $to ); } if ( isset( $atts['subject'] ) ) { $subject = $atts['subject']; } if ( isset( $atts['message'] ) ) { $message = $atts['message']; } if ( isset( $atts['headers'] ) ) { $headers = $atts['headers']; } if ( isset( $atts['attachments'] ) ) { $attachments = $atts['attachments']; } if ( ! is_array( $attachments ) ) { $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) ); } global $phpmailer; if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) { require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true ); $phpmailer::$validator = static function ( $email ) { return (bool) is_email( $email ); }; } $cc = array(); $bcc = array(); $reply_to = array(); if ( empty( $headers ) ) { $headers = array(); } else { if ( ! is_array( $headers ) ) { $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) ); } else { $tempheaders = $headers; } $headers = array(); if ( ! empty( $tempheaders ) ) { foreach ( (array) $tempheaders as $header ) { if ( strpos( $header, ':' ) === false ) { if ( false !== stripos( $header, 'boundary=' ) ) { $parts = preg_split( '/boundary=/i', trim( $header ) ); $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) ); } continue; } list( $name, $content ) = explode( ':', trim( $header ), 2 ); $name = trim( $name ); $content = trim( $content ); switch ( strtolower( $name ) ) { case 'from': $bracket_pos = strpos( $content, '<' ); if ( false !== $bracket_pos ) { if ( $bracket_pos > 0 ) { $from_name = substr( $content, 0, $bracket_pos ); $from_name = str_replace( '"', '', $from_name ); $from_name = trim( $from_name ); } $from_email = substr( $content, $bracket_pos + 1 ); $from_email = str_replace( '>', '', $from_email ); $from_email = trim( $from_email ); } elseif ( '' !== trim( $content ) ) { $from_email = trim( $content ); } break; case 'content-type': if ( strpos( $content, ';' ) !== false ) { list( $type, $charset_content ) = explode( ';', $content ); $content_type = trim( $type ); if ( false !== stripos( $charset_content, 'charset=' ) ) { $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) ); } elseif ( false !== stripos( $charset_content, 'boundary=' ) ) { $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) ); $charset = ''; } } elseif ( '' !== trim( $content ) ) { $content_type = trim( $content ); } break; case 'cc': $cc = array_merge( (array) $cc, explode( ',', $content ) ); break; case 'bcc': $bcc = array_merge( (array) $bcc, explode( ',', $content ) ); break; case 'reply-to': $reply_to = array_merge( (array) $reply_to, explode( ',', $content ) ); break; default: $headers[ trim( $name ) ] = trim( $content ); break; } } } } $phpmailer->clearAllRecipients(); $phpmailer->clearAttachments(); $phpmailer->clearCustomHeaders(); $phpmailer->clearReplyTos(); $phpmailer->Body = ''; $phpmailer->AltBody = ''; if ( ! isset( $from_name ) ) { $from_name = 'WordPress'; } if ( ! isset( $from_email ) ) { $sitename = wp_parse_url( network_home_url(), PHP_URL_HOST ); $from_email = 'wordpress@'; if ( null !== $sitename ) { if ( 'www.' === substr( $sitename, 0, 4 ) ) { $sitename = substr( $sitename, 4 ); } $from_email .= $sitename; } } $from_email = apply_filters( 'wp_mail_from', $from_email ); $from_name = apply_filters( 'wp_mail_from_name', $from_name ); try { $phpmailer->setFrom( $from_email, $from_name, false ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) ); return false; } $phpmailer->Subject = $subject; $phpmailer->Body = $message; $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' ); foreach ( $address_headers as $address_header => $addresses ) { if ( empty( $addresses ) ) { continue; } foreach ( (array) $addresses as $address ) { try { $recipient_name = ''; if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { if ( count( $matches ) == 3 ) { $recipient_name = $matches[1]; $address = $matches[2]; } } switch ( $address_header ) { case 'to': $phpmailer->addAddress( $address, $recipient_name ); break; case 'cc': $phpmailer->addCc( $address, $recipient_name ); break; case 'bcc': $phpmailer->addBcc( $address, $recipient_name ); break; case 'reply_to': $phpmailer->addReplyTo( $address, $recipient_name ); break; } } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } $phpmailer->isMail(); if ( ! isset( $content_type ) ) { $content_type = 'text/plain'; } $content_type = apply_filters( 'wp_mail_content_type', $content_type ); $phpmailer->ContentType = $content_type; if ( 'text/html' === $content_type ) { $phpmailer->isHTML( true ); } if ( ! isset( $charset ) ) { $charset = get_bloginfo( 'charset' ); } $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); if ( ! empty( $headers ) ) { foreach ( (array) $headers as $name => $content ) { if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) { try { $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) { $phpmailer->addCustomHeader( sprintf( 'Content-Type: %s; boundary="%s"', $content_type, $boundary ) ); } } if ( ! empty( $attachments ) ) { foreach ( $attachments as $attachment ) { try { $phpmailer->addAttachment( $attachment ); } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); $mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); try { $send = $phpmailer->send(); do_action( 'wp_mail_succeeded', $mail_data ); return $send; } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_data['phpmailer_exception_code'] = $e->getCode(); do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) ); return false; } } endif; if ( ! function_exists( 'wp_authenticate' ) ) : function wp_authenticate( $username, $password ) { $username = sanitize_user( $username ); $password = trim( $password ); $user = apply_filters( 'authenticate', null, $username, $password ); if ( null == $user ) { $user = new WP_Error( 'authentication_failed', __( '<strong>Error:</strong> Invalid username, email address or incorrect password.' ) ); } $ignore_codes = array( 'empty_username', 'empty_password' ); if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes, true ) ) { $error = $user; do_action( 'wp_login_failed', $username, $error ); } return $user; } endif; if ( ! function_exists( 'wp_logout' ) ) : function wp_logout() { $user_id = get_current_user_id(); wp_destroy_current_session(); wp_clear_auth_cookie(); wp_set_current_user( 0 ); do_action( 'wp_logout', $user_id ); } endif; if ( ! function_exists( 'wp_validate_auth_cookie' ) ) : function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) { $cookie_elements = wp_parse_auth_cookie( $cookie, $scheme ); if ( ! $cookie_elements ) { do_action( 'auth_cookie_malformed', $cookie, $scheme ); return false; } $scheme = $cookie_elements['scheme']; $username = $cookie_elements['username']; $hmac = $cookie_elements['hmac']; $token = $cookie_elements['token']; $expired = $cookie_elements['expiration']; $expiration = $cookie_elements['expiration']; if ( wp_doing_ajax() || 'POST' === $_SERVER['REQUEST_METHOD'] ) { $expired += HOUR_IN_SECONDS; } if ( $expired < time() ) { do_action( 'auth_cookie_expired', $cookie_elements ); return false; } $user = get_user_by( 'login', $username ); if ( ! $user ) { do_action( 'auth_cookie_bad_username', $cookie_elements ); return false; } $pass_frag = substr( $user->user_pass, 8, 4 ); $key = wp_hash( $username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme ); $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $hash = hash_hmac( $algo, $username . '|' . $expiration . '|' . $token, $key ); if ( ! hash_equals( $hash, $hmac ) ) { do_action( 'auth_cookie_bad_hash', $cookie_elements ); return false; } $manager = WP_Session_Tokens::get_instance( $user->ID ); if ( ! $manager->verify( $token ) ) { do_action( 'auth_cookie_bad_session_token', $cookie_elements ); return false; } if ( $expiration < time() ) { $GLOBALS['login_grace_period'] = 1; } do_action( 'auth_cookie_valid', $cookie_elements, $user ); return $user->ID; } endif; if ( ! function_exists( 'wp_generate_auth_cookie' ) ) : function wp_generate_auth_cookie( $user_id, $expiration, $scheme = 'auth', $token = '' ) { $user = get_userdata( $user_id ); if ( ! $user ) { return ''; } if ( ! $token ) { $manager = WP_Session_Tokens::get_instance( $user_id ); $token = $manager->create( $expiration ); } $pass_frag = substr( $user->user_pass, 8, 4 ); $key = wp_hash( $user->user_login . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme ); $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $hash = hash_hmac( $algo, $user->user_login . '|' . $expiration . '|' . $token, $key ); $cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash; return apply_filters( 'auth_cookie', $cookie, $user_id, $expiration, $scheme, $token ); } endif; if ( ! function_exists( 'wp_parse_auth_cookie' ) ) : function wp_parse_auth_cookie( $cookie = '', $scheme = '' ) { if ( empty( $cookie ) ) { switch ( $scheme ) { case 'auth': $cookie_name = AUTH_COOKIE; break; case 'secure_auth': $cookie_name = SECURE_AUTH_COOKIE; break; case 'logged_in': $cookie_name = LOGGED_IN_COOKIE; break; default: if ( is_ssl() ) { $cookie_name = SECURE_AUTH_COOKIE; $scheme = 'secure_auth'; } else { $cookie_name = AUTH_COOKIE; $scheme = 'auth'; } } if ( empty( $_COOKIE[ $cookie_name ] ) ) { return false; } $cookie = $_COOKIE[ $cookie_name ]; } $cookie_elements = explode( '|', $cookie ); if ( count( $cookie_elements ) !== 4 ) { return false; } list( $username, $expiration, $token, $hmac ) = $cookie_elements; return compact( 'username', 'expiration', 'token', 'hmac', 'scheme' ); } endif; if ( ! function_exists( 'wp_set_auth_cookie' ) ) : function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) { if ( $remember ) { $expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember ); $expire = $expiration + ( 12 * HOUR_IN_SECONDS ); } else { $expiration = time() + apply_filters( 'auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember ); $expire = 0; } if ( '' === $secure ) { $secure = is_ssl(); } $secure_logged_in_cookie = $secure && 'https' === parse_url( get_option( 'home' ), PHP_URL_SCHEME ); $secure = apply_filters( 'secure_auth_cookie', $secure, $user_id ); $secure_logged_in_cookie = apply_filters( 'secure_logged_in_cookie', $secure_logged_in_cookie, $user_id, $secure ); if ( $secure ) { $auth_cookie_name = SECURE_AUTH_COOKIE; $scheme = 'secure_auth'; } else { $auth_cookie_name = AUTH_COOKIE; $scheme = 'auth'; } if ( '' === $token ) { $manager = WP_Session_Tokens::get_instance( $user_id ); $token = $manager->create( $expiration ); } $auth_cookie = wp_generate_auth_cookie( $user_id, $expiration, $scheme, $token ); $logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token ); do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme, $token ); do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in', $token ); if ( ! apply_filters( 'send_auth_cookies', true ) ) { return; } setcookie( $auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true ); setcookie( $auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true ); setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true ); if ( COOKIEPATH != SITECOOKIEPATH ) { setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true ); } } endif; if ( ! function_exists( 'wp_clear_auth_cookie' ) ) : function wp_clear_auth_cookie() { do_action( 'clear_auth_cookie' ); if ( ! apply_filters( 'send_auth_cookies', true ) ) { return; } setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( 'wp-settings-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); setcookie( 'wp-settings-time-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( 'wp-postpass_' . COOKIEHASH, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); } endif; if ( ! function_exists( 'is_user_logged_in' ) ) : function is_user_logged_in() { $user = wp_get_current_user(); return $user->exists(); } endif; if ( ! function_exists( 'auth_redirect' ) ) : function auth_redirect() { $secure = ( is_ssl() || force_ssl_admin() ); $secure = apply_filters( 'secure_auth_redirect', $secure ); if ( $secure && ! is_ssl() && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) { if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); exit; } } $scheme = apply_filters( 'auth_redirect_scheme', '' ); $user_id = wp_validate_auth_cookie( '', $scheme ); if ( $user_id ) { do_action( 'auth_redirect', $user_id ); if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) { if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); exit; } } return; } nocache_headers(); $redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $login_url = wp_login_url( $redirect, true ); wp_redirect( $login_url ); exit; } endif; if ( ! function_exists( 'check_admin_referer' ) ) : function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) { if ( -1 === $action ) { _doing_it_wrong( __FUNCTION__, __( 'You should specify an action to be verified by using the first parameter.' ), '3.2.0' ); } $adminurl = strtolower( admin_url() ); $referer = strtolower( wp_get_referer() ); $result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false; do_action( 'check_admin_referer', $action, $result ); if ( ! $result && ! ( -1 === $action && strpos( $referer, $adminurl ) === 0 ) ) { wp_nonce_ays( $action ); die(); } return $result; } endif; if ( ! function_exists( 'check_ajax_referer' ) ) : function check_ajax_referer( $action = -1, $query_arg = false, $stop = true ) { if ( -1 == $action ) { _doing_it_wrong( __FUNCTION__, __( 'You should specify an action to be verified by using the first parameter.' ), '4.7.0' ); } $nonce = ''; if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) ) { $nonce = $_REQUEST[ $query_arg ]; } elseif ( isset( $_REQUEST['_ajax_nonce'] ) ) { $nonce = $_REQUEST['_ajax_nonce']; } elseif ( isset( $_REQUEST['_wpnonce'] ) ) { $nonce = $_REQUEST['_wpnonce']; } $result = wp_verify_nonce( $nonce, $action ); do_action( 'check_ajax_referer', $action, $result ); if ( $stop && false === $result ) { if ( wp_doing_ajax() ) { wp_die( -1, 403 ); } else { die( '-1' ); } } return $result; } endif; if ( ! function_exists( 'wp_redirect' ) ) : function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { global $is_IIS; $location = apply_filters( 'wp_redirect', $location, $status ); $status = apply_filters( 'wp_redirect_status', $status, $location ); if ( ! $location ) { return false; } if ( $status < 300 || 399 < $status ) { wp_die( __( 'HTTP redirect status code must be a redirection code, 3xx.' ) ); } $location = wp_sanitize_redirect( $location ); if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) { status_header( $status ); } $x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location ); if ( is_string( $x_redirect_by ) ) { header( "X-Redirect-By: $x_redirect_by" ); } header( "Location: $location", true, $status ); return true; } endif; if ( ! function_exists( 'wp_sanitize_redirect' ) ) : function wp_sanitize_redirect( $location ) { $location = str_replace( ' ', '%20', $location ); $regex = '/ + if ( ! function_exists( 'wp_set_current_user' ) ) : function wp_set_current_user( $id, $name = '' ) { global $current_user; if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) && ( null !== $id ) ) { return $current_user; } $current_user = new WP_User( $id, $name ); setup_userdata( $current_user->ID ); do_action( 'set_current_user' ); return $current_user; } endif; if ( ! function_exists( 'wp_get_current_user' ) ) : function wp_get_current_user() { return _wp_get_current_user(); } endif; if ( ! function_exists( 'get_userdata' ) ) : function get_userdata( $user_id ) { return get_user_by( 'id', $user_id ); } endif; if ( ! function_exists( 'get_user_by' ) ) : function get_user_by( $field, $value ) { $userdata = WP_User::get_data_by( $field, $value ); if ( ! $userdata ) { return false; } $user = new WP_User(); $user->init( $userdata ); return $user; } endif; if ( ! function_exists( 'cache_users' ) ) : function cache_users( $user_ids ) { global $wpdb; update_meta_cache( 'user', $user_ids ); $clean = _get_non_cached_ids( $user_ids, 'users' ); if ( empty( $clean ) ) { return; } $list = implode( ',', $clean ); $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" ); foreach ( $users as $user ) { update_user_caches( $user ); } } endif; if ( ! function_exists( 'wp_mail' ) ) : function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); $pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts ); if ( null !== $pre_wp_mail ) { return $pre_wp_mail; } if ( isset( $atts['to'] ) ) { $to = $atts['to']; } if ( ! is_array( $to ) ) { $to = explode( ',', $to ); } if ( isset( $atts['subject'] ) ) { $subject = $atts['subject']; } if ( isset( $atts['message'] ) ) { $message = $atts['message']; } if ( isset( $atts['headers'] ) ) { $headers = $atts['headers']; } if ( isset( $atts['attachments'] ) ) { $attachments = $atts['attachments']; } if ( ! is_array( $attachments ) ) { $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) ); } global $phpmailer; if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) { require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true ); $phpmailer::$validator = static function ( $email ) { return (bool) is_email( $email ); }; } $cc = array(); $bcc = array(); $reply_to = array(); if ( empty( $headers ) ) { $headers = array(); } else { if ( ! is_array( $headers ) ) { $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) ); } else { $tempheaders = $headers; } $headers = array(); if ( ! empty( $tempheaders ) ) { foreach ( (array) $tempheaders as $header ) { if ( strpos( $header, ':' ) === false ) { if ( false !== stripos( $header, 'boundary=' ) ) { $parts = preg_split( '/boundary=/i', trim( $header ) ); $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) ); } continue; } list( $name, $content ) = explode( ':', trim( $header ), 2 ); $name = trim( $name ); $content = trim( $content ); switch ( strtolower( $name ) ) { case 'from': $bracket_pos = strpos( $content, '<' ); if ( false !== $bracket_pos ) { if ( $bracket_pos > 0 ) { $from_name = substr( $content, 0, $bracket_pos ); $from_name = str_replace( '"', '', $from_name ); $from_name = trim( $from_name ); } $from_email = substr( $content, $bracket_pos + 1 ); $from_email = str_replace( '>', '', $from_email ); $from_email = trim( $from_email ); } elseif ( '' !== trim( $content ) ) { $from_email = trim( $content ); } break; case 'content-type': if ( strpos( $content, ';' ) !== false ) { list( $type, $charset_content ) = explode( ';', $content ); $content_type = trim( $type ); if ( false !== stripos( $charset_content, 'charset=' ) ) { $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) ); } elseif ( false !== stripos( $charset_content, 'boundary=' ) ) { $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) ); $charset = ''; } } elseif ( '' !== trim( $content ) ) { $content_type = trim( $content ); } break; case 'cc': $cc = array_merge( (array) $cc, explode( ',', $content ) ); break; case 'bcc': $bcc = array_merge( (array) $bcc, explode( ',', $content ) ); break; case 'reply-to': $reply_to = array_merge( (array) $reply_to, explode( ',', $content ) ); break; default: $headers[ trim( $name ) ] = trim( $content ); break; } } } } $phpmailer->clearAllRecipients(); $phpmailer->clearAttachments(); $phpmailer->clearCustomHeaders(); $phpmailer->clearReplyTos(); $phpmailer->Body = ''; $phpmailer->AltBody = ''; if ( ! isset( $from_name ) ) { $from_name = 'WordPress'; } if ( ! isset( $from_email ) ) { $sitename = wp_parse_url( network_home_url(), PHP_URL_HOST ); $from_email = 'wordpress@'; if ( null !== $sitename ) { if ( 'www.' === substr( $sitename, 0, 4 ) ) { $sitename = substr( $sitename, 4 ); } $from_email .= $sitename; } } $from_email = apply_filters( 'wp_mail_from', $from_email ); $from_name = apply_filters( 'wp_mail_from_name', $from_name ); try { $phpmailer->setFrom( $from_email, $from_name, false ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) ); return false; } $phpmailer->Subject = $subject; $phpmailer->Body = $message; $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' ); foreach ( $address_headers as $address_header => $addresses ) { if ( empty( $addresses ) ) { continue; } foreach ( (array) $addresses as $address ) { try { $recipient_name = ''; if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { if ( count( $matches ) == 3 ) { $recipient_name = $matches[1]; $address = $matches[2]; } } switch ( $address_header ) { case 'to': $phpmailer->addAddress( $address, $recipient_name ); break; case 'cc': $phpmailer->addCc( $address, $recipient_name ); break; case 'bcc': $phpmailer->addBcc( $address, $recipient_name ); break; case 'reply_to': $phpmailer->addReplyTo( $address, $recipient_name ); break; } } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } $phpmailer->isMail(); if ( ! isset( $content_type ) ) { $content_type = 'text/plain'; } $content_type = apply_filters( 'wp_mail_content_type', $content_type ); $phpmailer->ContentType = $content_type; if ( 'text/html' === $content_type ) { $phpmailer->isHTML( true ); } if ( ! isset( $charset ) ) { $charset = get_bloginfo( 'charset' ); } $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); if ( ! empty( $headers ) ) { foreach ( (array) $headers as $name => $content ) { if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) { try { $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) ); } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) { $phpmailer->addCustomHeader( sprintf( 'Content-Type: %s; boundary="%s"', $content_type, $boundary ) ); } } if ( ! empty( $attachments ) ) { foreach ( $attachments as $filename => $attachment ) { $filename = is_string( $filename ) ? $filename : ''; try { $phpmailer->addAttachment( $attachment, $filename ); } catch ( PHPMailer\PHPMailer\Exception $e ) { continue; } } } do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); $mail_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); try { $send = $phpmailer->send(); do_action( 'wp_mail_succeeded', $mail_data ); return $send; } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_data['phpmailer_exception_code'] = $e->getCode(); do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_data ) ); return false; } } endif; if ( ! function_exists( 'wp_authenticate' ) ) : function wp_authenticate( $username, $password ) { $username = sanitize_user( $username ); $password = trim( $password ); $user = apply_filters( 'authenticate', null, $username, $password ); if ( null == $user ) { $user = new WP_Error( 'authentication_failed', __( '<strong>Error:</strong> Invalid username, email address or incorrect password.' ) ); } $ignore_codes = array( 'empty_username', 'empty_password' ); if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes, true ) ) { $error = $user; do_action( 'wp_login_failed', $username, $error ); } return $user; } endif; if ( ! function_exists( 'wp_logout' ) ) : function wp_logout() { $user_id = get_current_user_id(); wp_destroy_current_session(); wp_clear_auth_cookie(); wp_set_current_user( 0 ); do_action( 'wp_logout', $user_id ); } endif; if ( ! function_exists( 'wp_validate_auth_cookie' ) ) : function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) { $cookie_elements = wp_parse_auth_cookie( $cookie, $scheme ); if ( ! $cookie_elements ) { do_action( 'auth_cookie_malformed', $cookie, $scheme ); return false; } $scheme = $cookie_elements['scheme']; $username = $cookie_elements['username']; $hmac = $cookie_elements['hmac']; $token = $cookie_elements['token']; $expired = $cookie_elements['expiration']; $expiration = $cookie_elements['expiration']; if ( wp_doing_ajax() || 'POST' === $_SERVER['REQUEST_METHOD'] ) { $expired += HOUR_IN_SECONDS; } if ( $expired < time() ) { do_action( 'auth_cookie_expired', $cookie_elements ); return false; } $user = get_user_by( 'login', $username ); if ( ! $user ) { do_action( 'auth_cookie_bad_username', $cookie_elements ); return false; } $pass_frag = substr( $user->user_pass, 8, 4 ); $key = wp_hash( $username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme ); $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $hash = hash_hmac( $algo, $username . '|' . $expiration . '|' . $token, $key ); if ( ! hash_equals( $hash, $hmac ) ) { do_action( 'auth_cookie_bad_hash', $cookie_elements ); return false; } $manager = WP_Session_Tokens::get_instance( $user->ID ); if ( ! $manager->verify( $token ) ) { do_action( 'auth_cookie_bad_session_token', $cookie_elements ); return false; } if ( $expiration < time() ) { $GLOBALS['login_grace_period'] = 1; } do_action( 'auth_cookie_valid', $cookie_elements, $user ); return $user->ID; } endif; if ( ! function_exists( 'wp_generate_auth_cookie' ) ) : function wp_generate_auth_cookie( $user_id, $expiration, $scheme = 'auth', $token = '' ) { $user = get_userdata( $user_id ); if ( ! $user ) { return ''; } if ( ! $token ) { $manager = WP_Session_Tokens::get_instance( $user_id ); $token = $manager->create( $expiration ); } $pass_frag = substr( $user->user_pass, 8, 4 ); $key = wp_hash( $user->user_login . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme ); $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1'; $hash = hash_hmac( $algo, $user->user_login . '|' . $expiration . '|' . $token, $key ); $cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash; return apply_filters( 'auth_cookie', $cookie, $user_id, $expiration, $scheme, $token ); } endif; if ( ! function_exists( 'wp_parse_auth_cookie' ) ) : function wp_parse_auth_cookie( $cookie = '', $scheme = '' ) { if ( empty( $cookie ) ) { switch ( $scheme ) { case 'auth': $cookie_name = AUTH_COOKIE; break; case 'secure_auth': $cookie_name = SECURE_AUTH_COOKIE; break; case 'logged_in': $cookie_name = LOGGED_IN_COOKIE; break; default: if ( is_ssl() ) { $cookie_name = SECURE_AUTH_COOKIE; $scheme = 'secure_auth'; } else { $cookie_name = AUTH_COOKIE; $scheme = 'auth'; } } if ( empty( $_COOKIE[ $cookie_name ] ) ) { return false; } $cookie = $_COOKIE[ $cookie_name ]; } $cookie_elements = explode( '|', $cookie ); if ( count( $cookie_elements ) !== 4 ) { return false; } list( $username, $expiration, $token, $hmac ) = $cookie_elements; return compact( 'username', 'expiration', 'token', 'hmac', 'scheme' ); } endif; if ( ! function_exists( 'wp_set_auth_cookie' ) ) : function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) { if ( $remember ) { $expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember ); $expire = $expiration + ( 12 * HOUR_IN_SECONDS ); } else { $expiration = time() + apply_filters( 'auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember ); $expire = 0; } if ( '' === $secure ) { $secure = is_ssl(); } $secure_logged_in_cookie = $secure && 'https' === parse_url( get_option( 'home' ), PHP_URL_SCHEME ); $secure = apply_filters( 'secure_auth_cookie', $secure, $user_id ); $secure_logged_in_cookie = apply_filters( 'secure_logged_in_cookie', $secure_logged_in_cookie, $user_id, $secure ); if ( $secure ) { $auth_cookie_name = SECURE_AUTH_COOKIE; $scheme = 'secure_auth'; } else { $auth_cookie_name = AUTH_COOKIE; $scheme = 'auth'; } if ( '' === $token ) { $manager = WP_Session_Tokens::get_instance( $user_id ); $token = $manager->create( $expiration ); } $auth_cookie = wp_generate_auth_cookie( $user_id, $expiration, $scheme, $token ); $logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token ); do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme, $token ); do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in', $token ); if ( ! apply_filters( 'send_auth_cookies', true ) ) { return; } setcookie( $auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true ); setcookie( $auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true ); setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true ); if ( COOKIEPATH != SITECOOKIEPATH ) { setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true ); } } endif; if ( ! function_exists( 'wp_clear_auth_cookie' ) ) : function wp_clear_auth_cookie() { do_action( 'clear_auth_cookie' ); if ( ! apply_filters( 'send_auth_cookies', true ) ) { return; } setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( 'wp-settings-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); setcookie( 'wp-settings-time-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( 'wp-postpass_' . COOKIEHASH, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); } endif; if ( ! function_exists( 'is_user_logged_in' ) ) : function is_user_logged_in() { $user = wp_get_current_user(); return $user->exists(); } endif; if ( ! function_exists( 'auth_redirect' ) ) : function auth_redirect() { $secure = ( is_ssl() || force_ssl_admin() ); $secure = apply_filters( 'secure_auth_redirect', $secure ); if ( $secure && ! is_ssl() && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) { if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); exit; } } $scheme = apply_filters( 'auth_redirect_scheme', '' ); $user_id = wp_validate_auth_cookie( '', $scheme ); if ( $user_id ) { do_action( 'auth_redirect', $user_id ); if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) { if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); exit; } } return; } nocache_headers(); $redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $login_url = wp_login_url( $redirect, true ); wp_redirect( $login_url ); exit; } endif; if ( ! function_exists( 'check_admin_referer' ) ) : function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) { if ( -1 === $action ) { _doing_it_wrong( __FUNCTION__, __( 'You should specify an action to be verified by using the first parameter.' ), '3.2.0' ); } $adminurl = strtolower( admin_url() ); $referer = strtolower( wp_get_referer() ); $result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false; do_action( 'check_admin_referer', $action, $result ); if ( ! $result && ! ( -1 === $action && strpos( $referer, $adminurl ) === 0 ) ) { wp_nonce_ays( $action ); die(); } return $result; } endif; if ( ! function_exists( 'check_ajax_referer' ) ) : function check_ajax_referer( $action = -1, $query_arg = false, $stop = true ) { if ( -1 == $action ) { _doing_it_wrong( __FUNCTION__, __( 'You should specify an action to be verified by using the first parameter.' ), '4.7.0' ); } $nonce = ''; if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) ) { $nonce = $_REQUEST[ $query_arg ]; } elseif ( isset( $_REQUEST['_ajax_nonce'] ) ) { $nonce = $_REQUEST['_ajax_nonce']; } elseif ( isset( $_REQUEST['_wpnonce'] ) ) { $nonce = $_REQUEST['_wpnonce']; } $result = wp_verify_nonce( $nonce, $action ); do_action( 'check_ajax_referer', $action, $result ); if ( $stop && false === $result ) { if ( wp_doing_ajax() ) { wp_die( -1, 403 ); } else { die( '-1' ); } } return $result; } endif; if ( ! function_exists( 'wp_redirect' ) ) : function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { global $is_IIS; $location = apply_filters( 'wp_redirect', $location, $status ); $status = apply_filters( 'wp_redirect_status', $status, $location ); if ( ! $location ) { return false; } if ( $status < 300 || 399 < $status ) { wp_die( __( 'HTTP redirect status code must be a redirection code, 3xx.' ) ); } $location = wp_sanitize_redirect( $location ); if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) { status_header( $status ); } $x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location ); if ( is_string( $x_redirect_by ) ) { header( "X-Redirect-By: $x_redirect_by" ); } header( "Location: $location", true, $status ); return true; } endif; if ( ! function_exists( 'wp_sanitize_redirect' ) ) : function wp_sanitize_redirect( $location ) { $location = str_replace( ' ', '%20', $location ); $regex = '/ ( (?: [\xC2-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx | \xE0[\xA0-\xBF][\x80-\xBF] # triple-byte sequences 1110xxxx 10xxxxxx * 2 @@ -31604,7 +34291,7 @@ All at ###SITENAME### | [\xF1-\xF3][\x80-\xBF]{3} | \xF4[\x80-\x8F][\x80-\xBF]{2} ){1,40} # ...one or more times - )/x'; $location = preg_replace_callback( $regex, '_wp_sanitize_utf8_in_redirect', $location ); $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()@]|i', '', $location ); $location = wp_kses_no_null( $location ); $strip = array( '%0d', '%0a', '%0D', '%0A' ); return _deep_replace( $strip, $location ); } function _wp_sanitize_utf8_in_redirect( $matches ) { return urlencode( $matches[0] ); } endif; if ( ! function_exists( 'wp_safe_redirect' ) ) : function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { $location = wp_sanitize_redirect( $location ); $fallback_url = apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ); $location = wp_validate_redirect( $location, $fallback_url ); return wp_redirect( $location, $status, $x_redirect_by ); } endif; if ( ! function_exists( 'wp_validate_redirect' ) ) : function wp_validate_redirect( $location, $fallback_url = '' ) { $location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) ); if ( '//' === substr( $location, 0, 2 ) ) { $location = 'http:' . $location; } $cut = strpos( $location, '?' ); $test = $cut ? substr( $location, 0, $cut ) : $location; $lp = parse_url( $test ); if ( false === $lp ) { return $fallback_url; } if ( isset( $lp['scheme'] ) && ! ( 'http' === $lp['scheme'] || 'https' === $lp['scheme'] ) ) { return $fallback_url; } if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) { $path = ''; if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { $path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' ); $path = wp_normalize_path( $path ); } $location = '/' . ltrim( $path . '/', '/' ) . $location; } if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) { return $fallback_url; } foreach ( array( 'user', 'pass', 'host' ) as $component ) { if ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) { return $fallback_url; } } $wpp = parse_url( home_url() ); $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' ); if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) { $location = $fallback_url; } return $location; } endif; if ( ! function_exists( 'wp_notify_postauthor' ) ) : function wp_notify_postauthor( $comment_id, $deprecated = null ) { if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.8.0' ); } $comment = get_comment( $comment_id ); if ( empty( $comment ) || empty( $comment->comment_post_ID ) ) { return false; } $post = get_post( $comment->comment_post_ID ); $author = get_userdata( $post->post_author ); $emails = array(); if ( $author ) { $emails[] = $author->user_email; } $emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID ); $emails = array_filter( $emails ); if ( ! count( $emails ) ) { return false; } $emails = array_flip( $emails ); $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); if ( $author && ! $notify_author && $comment->user_id == $post->post_author ) { unset( $emails[ $author->user_email ] ); } if ( $author && ! $notify_author && get_current_user_id() == $post->post_author ) { unset( $emails[ $author->user_email ] ); } if ( $author && ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) { unset( $emails[ $author->user_email ] ); } if ( ! count( $emails ) ) { return false; } else { $emails = array_flip( $emails ); } $switched_locale = switch_to_locale( get_locale() ); $comment_author_domain = ''; if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); switch ( $comment->comment_type ) { case 'trackback': $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title ); break; case 'pingback': $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title ); break; default: $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; if ( $comment->comment_parent && user_can( $post->post_author, 'edit_comment', $comment->comment_parent ) ) { $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title ); break; } $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n"; $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n"; if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) { if ( EMPTY_TRASH_DAYS ) { $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } else { $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', wp_parse_url( network_home_url(), PHP_URL_HOST ) ); if ( '' === $comment->comment_author ) { $from = "From: \"$blogname\" <$wp_email>"; if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: $comment->comment_author_email"; } } else { $from = "From: \"$comment->comment_author\" <$wp_email>"; if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; } } $message_headers = "$from\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; if ( isset( $reply_to ) ) { $message_headers .= $reply_to . "\n"; } $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID ); $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID ); $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID ); foreach ( $emails as $email ) { wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); } if ( $switched_locale ) { restore_previous_locale(); } return true; } endif; if ( ! function_exists( 'wp_notify_moderator' ) ) : function wp_notify_moderator( $comment_id ) { global $wpdb; $maybe_notify = get_option( 'moderation_notify' ); $maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_id ); if ( ! $maybe_notify ) { return true; } $comment = get_comment( $comment_id ); $post = get_post( $comment->comment_post_ID ); $user = get_userdata( $post->post_author ); $emails = array( get_option( 'admin_email' ) ); if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) { if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { $emails[] = $user->user_email; } } $switched_locale = switch_to_locale( get_locale() ); $comment_author_domain = ''; if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } $comments_waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ); $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); switch ( $comment->comment_type ) { case 'trackback': $notify_message = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; break; case 'pingback': $notify_message = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; break; default: $notify_message = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; if ( $comment->comment_parent ) { $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; break; } $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n"; if ( EMPTY_TRASH_DAYS ) { $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n"; } else { $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n"; $notify_message .= sprintf( _n( 'Currently %s comment is waiting for approval. Please visit the moderation panel:', 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting ), number_format_i18n( $comments_waiting ) ) . "\r\n"; $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title ); $message_headers = ''; $emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id ); $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id ); $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id ); $message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id ); foreach ( $emails as $email ) { wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); } if ( $switched_locale ) { restore_previous_locale(); } return true; } endif; if ( ! function_exists( 'wp_password_change_notification' ) ) : function wp_password_change_notification( $user ) { if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { $message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n"; $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $wp_password_change_notification_email = array( 'to' => get_option( 'admin_email' ), 'subject' => __( '[%s] Password Changed' ), 'message' => $message, 'headers' => '', ); $wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname ); wp_mail( $wp_password_change_notification_email['to'], wp_specialchars_decode( sprintf( $wp_password_change_notification_email['subject'], $blogname ) ), $wp_password_change_notification_email['message'], $wp_password_change_notification_email['headers'] ); } } endif; if ( ! function_exists( 'wp_new_user_notification' ) ) : function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) { if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '4.3.1' ); } if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) { return; } $user = get_userdata( $user_id ); $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $send_notification_to_admin = apply_filters( 'wp_send_new_user_notification_to_admin', true, $user ); if ( 'user' !== $notify && true === $send_notification_to_admin ) { $switched_locale = switch_to_locale( get_locale() ); $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n"; $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n"; $wp_new_user_notification_email_admin = array( 'to' => get_option( 'admin_email' ), 'subject' => __( '[%s] New User Registration' ), 'message' => $message, 'headers' => '', ); $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname ); wp_mail( $wp_new_user_notification_email_admin['to'], wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ), $wp_new_user_notification_email_admin['message'], $wp_new_user_notification_email_admin['headers'] ); if ( $switched_locale ) { restore_previous_locale(); } } $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user ); if ( 'admin' === $notify || true !== $send_notification_to_user || ( empty( $deprecated ) && empty( $notify ) ) ) { return; } $key = get_password_reset_key( $user ); if ( is_wp_error( $key ) ) { return; } $switched_locale = switch_to_locale( get_user_locale( $user ) ); $message = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; $message .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n"; $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . "\r\n\r\n"; $message .= wp_login_url() . "\r\n"; $wp_new_user_notification_email = array( 'to' => $user->user_email, 'subject' => __( '[%s] Login Details' ), 'message' => $message, 'headers' => '', ); $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname ); wp_mail( $wp_new_user_notification_email['to'], wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ), $wp_new_user_notification_email['message'], $wp_new_user_notification_email['headers'] ); if ( $switched_locale ) { restore_previous_locale(); } } endif; if ( ! function_exists( 'wp_nonce_tick' ) ) : function wp_nonce_tick( $action = -1 ) { $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action ); return ceil( time() / ( $nonce_life / 2 ) ); } endif; if ( ! function_exists( 'wp_verify_nonce' ) ) : function wp_verify_nonce( $nonce, $action = -1 ) { $nonce = (string) $nonce; $user = wp_get_current_user(); $uid = (int) $user->ID; if ( ! $uid ) { $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); } if ( empty( $nonce ) ) { return false; } $token = wp_get_session_token(); $i = wp_nonce_tick( $action ); $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 1; } $expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 2; } do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token ); return false; } endif; if ( ! function_exists( 'wp_create_nonce' ) ) : function wp_create_nonce( $action = -1 ) { $user = wp_get_current_user(); $uid = (int) $user->ID; if ( ! $uid ) { $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); } $token = wp_get_session_token( $action ); $i = wp_nonce_tick( $action ); return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); } endif; if ( ! function_exists( 'wp_salt' ) ) : function wp_salt( $scheme = 'auth' ) { static $cached_salts = array(); if ( isset( $cached_salts[ $scheme ] ) ) { return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); } static $duplicated_keys; if ( null === $duplicated_keys ) { $duplicated_keys = array( 'put your unique phrase here' => true, __( 'put your unique phrase here' ) => true, ); foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) { foreach ( array( 'KEY', 'SALT' ) as $second ) { if ( ! defined( "{$first}_{$second}" ) ) { continue; } $value = constant( "{$first}_{$second}" ); $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] ); } } } $values = array( 'key' => '', 'salt' => '', ); if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) { $values['key'] = SECRET_KEY; } if ( 'auth' === $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) { $values['salt'] = SECRET_SALT; } if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ), true ) ) { foreach ( array( 'key', 'salt' ) as $type ) { $const = strtoupper( "{$scheme}_{$type}" ); if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { $values[ $type ] = constant( $const ); } elseif ( ! $values[ $type ] ) { $values[ $type ] = get_site_option( "{$scheme}_{$type}" ); if ( ! $values[ $type ] ) { $values[ $type ] = wp_generate_password( 64, true, true ); update_site_option( "{$scheme}_{$type}", $values[ $type ] ); } } } } else { if ( ! $values['key'] ) { $values['key'] = get_site_option( 'secret_key' ); if ( ! $values['key'] ) { $values['key'] = wp_generate_password( 64, true, true ); update_site_option( 'secret_key', $values['key'] ); } } $values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] ); } $cached_salts[ $scheme ] = $values['key'] . $values['salt']; return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); } endif; if ( ! function_exists( 'wp_hash' ) ) : function wp_hash( $data, $scheme = 'auth' ) { $salt = wp_salt( $scheme ); return hash_hmac( 'md5', $data, $salt ); } endif; if ( ! function_exists( 'wp_hash_password' ) ) : function wp_hash_password( $password ) { global $wp_hasher; if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } return $wp_hasher->HashPassword( trim( $password ) ); } endif; if ( ! function_exists( 'wp_check_password' ) ) : function wp_check_password( $password, $hash, $user_id = '' ) { global $wp_hasher; if ( strlen( $hash ) <= 32 ) { $check = hash_equals( $hash, md5( $password ) ); if ( $check && $user_id ) { wp_set_password( $password, $user_id ); $hash = wp_hash_password( $password ); } return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } $check = $wp_hasher->CheckPassword( $password, $hash ); return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } endif; if ( ! function_exists( 'wp_generate_password' ) ) : function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; if ( $special_chars ) { $chars .= '!@#$%^&*()'; } if ( $extra_special_chars ) { $chars .= '-_ []{}<>~`+=,.;:/?|'; } $password = ''; for ( $i = 0; $i < $length; $i++ ) { $password .= substr( $chars, wp_rand( 0, strlen( $chars ) - 1 ), 1 ); } return apply_filters( 'random_password', $password, $length, $special_chars, $extra_special_chars ); } endif; if ( ! function_exists( 'wp_rand' ) ) : function wp_rand( $min = null, $max = null ) { global $rnd_value; $max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; if ( null === $min ) { $min = 0; } if ( null === $max ) { $max = $max_random_number; } $min = (int) $min; $max = (int) $max; static $use_random_int_functionality = true; if ( $use_random_int_functionality ) { try { $_max = max( $min, $max ); $_min = min( $min, $max ); $val = random_int( $_min, $_max ); if ( false !== $val ) { return absint( $val ); } else { $use_random_int_functionality = false; } } catch ( Error $e ) { $use_random_int_functionality = false; } catch ( Exception $e ) { $use_random_int_functionality = false; } } if ( strlen( $rnd_value ) < 8 ) { if ( defined( 'WP_SETUP_CONFIG' ) ) { static $seed = ''; } else { $seed = get_transient( 'random_seed' ); } $rnd_value = md5( uniqid( microtime() . mt_rand(), true ) . $seed ); $rnd_value .= sha1( $rnd_value ); $rnd_value .= sha1( $rnd_value . $seed ); $seed = md5( $seed . $rnd_value ); if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) { set_transient( 'random_seed', $seed ); } } $value = substr( $rnd_value, 0, 8 ); $rnd_value = substr( $rnd_value, 8 ); $value = abs( hexdec( $value ) ); $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); return abs( (int) $value ); } endif; if ( ! function_exists( 'wp_set_password' ) ) : function wp_set_password( $password, $user_id ) { global $wpdb; $hash = wp_hash_password( $password ); $wpdb->update( $wpdb->users, array( 'user_pass' => $hash, 'user_activation_key' => '', ), array( 'ID' => $user_id ) ); clean_user_cache( $user_id ); } endif; if ( ! function_exists( 'get_avatar' ) ) : function get_avatar( $id_or_email, $size = 96, $default_value = '', $alt = '', $args = null ) { $defaults = array( 'size' => 96, 'height' => null, 'width' => null, 'default' => get_option( 'avatar_default', 'mystery' ), 'force_default' => false, 'rating' => get_option( 'avatar_rating' ), 'scheme' => null, 'alt' => '', 'class' => null, 'force_display' => false, 'loading' => null, 'extra_attr' => '', 'decoding' => 'async', ); if ( wp_lazy_loading_enabled( 'img', 'get_avatar' ) ) { $defaults['loading'] = wp_get_loading_attr_default( 'get_avatar' ); } if ( empty( $args ) ) { $args = array(); } $args['size'] = (int) $size; $args['default'] = $default_value; $args['alt'] = $alt; $args = wp_parse_args( $args, $defaults ); if ( empty( $args['height'] ) ) { $args['height'] = $args['size']; } if ( empty( $args['width'] ) ) { $args['width'] = $args['size']; } if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { $id_or_email = get_comment( $id_or_email ); } $avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args ); if ( ! is_null( $avatar ) ) { return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args ); } if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) { return false; } $url2x = get_avatar_url( $id_or_email, array_merge( $args, array( 'size' => $args['size'] * 2 ) ) ); $args = get_avatar_data( $id_or_email, $args ); $url = $args['url']; if ( ! $url || is_wp_error( $url ) ) { return false; } $class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' ); if ( ! $args['found_avatar'] || $args['force_default'] ) { $class[] = 'avatar-default'; } if ( $args['class'] ) { if ( is_array( $args['class'] ) ) { $class = array_merge( $class, $args['class'] ); } else { $class[] = $args['class']; } } $extra_attr = $args['extra_attr']; if ( in_array( $args['loading'], array( 'lazy', 'eager' ), true ) && ! preg_match( '/\bloading\s*=/', $extra_attr ) ) { if ( ! empty( $extra_attr ) ) { $extra_attr .= ' '; } $extra_attr .= "loading='{$args['loading']}'"; } if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ), true ) && ! preg_match( '/\bdecoding\s*=/', $extra_attr ) ) { if ( ! empty( $extra_attr ) ) { $extra_attr .= ' '; } $extra_attr .= "decoding='{$args['decoding']}'"; } $avatar = sprintf( "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>", esc_attr( $args['alt'] ), esc_url( $url ), esc_url( $url2x ) . ' 2x', esc_attr( implode( ' ', $class ) ), (int) $args['height'], (int) $args['width'], $extra_attr ); return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args ); } endif; if ( ! function_exists( 'wp_text_diff' ) ) : function wp_text_diff( $left_string, $right_string, $args = null ) { $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '', 'show_split_view' => true, ); $args = wp_parse_args( $args, $defaults ); if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) ) { require ABSPATH . WPINC . '/wp-diff.php'; } $left_string = normalize_whitespace( $left_string ); $right_string = normalize_whitespace( $right_string ); $left_lines = explode( "\n", $left_string ); $right_lines = explode( "\n", $right_string ); $text_diff = new Text_Diff( $left_lines, $right_lines ); $renderer = new WP_Text_Diff_Renderer_Table( $args ); $diff = $renderer->render( $text_diff ); if ( ! $diff ) { return ''; } $is_split_view = ! empty( $args['show_split_view'] ); $is_split_view_class = $is_split_view ? ' is-split-view' : ''; $r = "<table class='diff$is_split_view_class'>\n"; if ( $args['title'] ) { $r .= "<caption class='diff-title'>$args[title]</caption>\n"; } if ( $args['title_left'] || $args['title_right'] ) { $r .= '<thead>'; } if ( $args['title_left'] || $args['title_right'] ) { $th_or_td_left = empty( $args['title_left'] ) ? 'td' : 'th'; $th_or_td_right = empty( $args['title_right'] ) ? 'td' : 'th'; $r .= "<tr class='diff-sub-title'>\n"; $r .= "\t<$th_or_td_left>$args[title_left]</$th_or_td_left>\n"; if ( $is_split_view ) { $r .= "\t<$th_or_td_right>$args[title_right]</$th_or_td_right>\n"; } $r .= "</tr>\n"; } if ( $args['title_left'] || $args['title_right'] ) { $r .= "</thead>\n"; } $r .= "<tbody>\n$diff\n</tbody>\n"; $r .= '</table>'; return $r; } endif; <?php + )/x'; $location = preg_replace_callback( $regex, '_wp_sanitize_utf8_in_redirect', $location ); $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()@]|i', '', $location ); $location = wp_kses_no_null( $location ); $strip = array( '%0d', '%0a', '%0D', '%0A' ); return _deep_replace( $strip, $location ); } function _wp_sanitize_utf8_in_redirect( $matches ) { return urlencode( $matches[0] ); } endif; if ( ! function_exists( 'wp_safe_redirect' ) ) : function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { $location = wp_sanitize_redirect( $location ); $fallback_url = apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ); $location = wp_validate_redirect( $location, $fallback_url ); return wp_redirect( $location, $status, $x_redirect_by ); } endif; if ( ! function_exists( 'wp_validate_redirect' ) ) : function wp_validate_redirect( $location, $fallback_url = '' ) { $location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) ); if ( '//' === substr( $location, 0, 2 ) ) { $location = 'http:' . $location; } $cut = strpos( $location, '?' ); $test = $cut ? substr( $location, 0, $cut ) : $location; $lp = parse_url( $test ); if ( false === $lp ) { return $fallback_url; } if ( isset( $lp['scheme'] ) && ! ( 'http' === $lp['scheme'] || 'https' === $lp['scheme'] ) ) { return $fallback_url; } if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) { $path = ''; if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { $path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' ); $path = wp_normalize_path( $path ); } $location = '/' . ltrim( $path . '/', '/' ) . $location; } if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) { return $fallback_url; } foreach ( array( 'user', 'pass', 'host' ) as $component ) { if ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) { return $fallback_url; } } $wpp = parse_url( home_url() ); $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' ); if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) { $location = $fallback_url; } return $location; } endif; if ( ! function_exists( 'wp_notify_postauthor' ) ) : function wp_notify_postauthor( $comment_id, $deprecated = null ) { if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.8.0' ); } $comment = get_comment( $comment_id ); if ( empty( $comment ) || empty( $comment->comment_post_ID ) ) { return false; } $post = get_post( $comment->comment_post_ID ); $author = get_userdata( $post->post_author ); $emails = array(); if ( $author ) { $emails[] = $author->user_email; } $emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID ); $emails = array_filter( $emails ); if ( ! count( $emails ) ) { return false; } $emails = array_flip( $emails ); $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); if ( $author && ! $notify_author && $comment->user_id == $post->post_author ) { unset( $emails[ $author->user_email ] ); } if ( $author && ! $notify_author && get_current_user_id() == $post->post_author ) { unset( $emails[ $author->user_email ] ); } if ( $author && ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) { unset( $emails[ $author->user_email ] ); } if ( ! count( $emails ) ) { return false; } else { $emails = array_flip( $emails ); } $switched_locale = switch_to_locale( get_locale() ); $comment_author_domain = ''; if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); switch ( $comment->comment_type ) { case 'trackback': $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title ); break; case 'pingback': $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title ); break; default: $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n"; $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; if ( $comment->comment_parent && user_can( $post->post_author, 'edit_comment', $comment->comment_parent ) ) { $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title ); break; } $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n"; $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n"; if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) { if ( EMPTY_TRASH_DAYS ) { $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } else { $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n"; } $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', wp_parse_url( network_home_url(), PHP_URL_HOST ) ); if ( '' === $comment->comment_author ) { $from = "From: \"$blogname\" <$wp_email>"; if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: $comment->comment_author_email"; } } else { $from = "From: \"$comment->comment_author\" <$wp_email>"; if ( '' !== $comment->comment_author_email ) { $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>"; } } $message_headers = "$from\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; if ( isset( $reply_to ) ) { $message_headers .= $reply_to . "\n"; } $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID ); $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID ); $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID ); foreach ( $emails as $email ) { wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); } if ( $switched_locale ) { restore_previous_locale(); } return true; } endif; if ( ! function_exists( 'wp_notify_moderator' ) ) : function wp_notify_moderator( $comment_id ) { global $wpdb; $maybe_notify = get_option( 'moderation_notify' ); $maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_id ); if ( ! $maybe_notify ) { return true; } $comment = get_comment( $comment_id ); $post = get_post( $comment->comment_post_ID ); $user = get_userdata( $post->post_author ); $emails = array( get_option( 'admin_email' ) ); if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) { if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { $emails[] = $user->user_email; } } $switched_locale = switch_to_locale( get_locale() ); $comment_author_domain = ''; if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) { $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } $comments_waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ); $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); switch ( $comment->comment_type ) { case 'trackback': $notify_message = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; break; case 'pingback': $notify_message = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; break; default: $notify_message = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n"; $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n"; if ( $comment->comment_parent ) { $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n"; break; } $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n"; if ( EMPTY_TRASH_DAYS ) { $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n"; } else { $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n"; } $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n"; $notify_message .= sprintf( _n( 'Currently %s comment is waiting for approval. Please visit the moderation panel:', 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting ), number_format_i18n( $comments_waiting ) ) . "\r\n"; $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n"; $subject = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title ); $message_headers = ''; $emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id ); $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id ); $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id ); $message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id ); foreach ( $emails as $email ) { wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers ); } if ( $switched_locale ) { restore_previous_locale(); } return true; } endif; if ( ! function_exists( 'wp_password_change_notification' ) ) : function wp_password_change_notification( $user ) { if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { $message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n"; $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $wp_password_change_notification_email = array( 'to' => get_option( 'admin_email' ), 'subject' => __( '[%s] Password Changed' ), 'message' => $message, 'headers' => '', ); $wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname ); wp_mail( $wp_password_change_notification_email['to'], wp_specialchars_decode( sprintf( $wp_password_change_notification_email['subject'], $blogname ) ), $wp_password_change_notification_email['message'], $wp_password_change_notification_email['headers'] ); } } endif; if ( ! function_exists( 'wp_new_user_notification' ) ) : function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) { if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '4.3.1' ); } if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) { return; } $user = get_userdata( $user_id ); $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $send_notification_to_admin = apply_filters( 'wp_send_new_user_notification_to_admin', true, $user ); if ( 'user' !== $notify && true === $send_notification_to_admin ) { $switched_locale = switch_to_locale( get_locale() ); $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n"; $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n"; $wp_new_user_notification_email_admin = array( 'to' => get_option( 'admin_email' ), 'subject' => __( '[%s] New User Registration' ), 'message' => $message, 'headers' => '', ); $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname ); wp_mail( $wp_new_user_notification_email_admin['to'], wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ), $wp_new_user_notification_email_admin['message'], $wp_new_user_notification_email_admin['headers'] ); if ( $switched_locale ) { restore_previous_locale(); } } $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user ); if ( 'admin' === $notify || true !== $send_notification_to_user || ( empty( $deprecated ) && empty( $notify ) ) ) { return; } $key = get_password_reset_key( $user ); if ( is_wp_error( $key ) ) { return; } $switched_locale = switch_to_locale( get_user_locale( $user ) ); $message = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; $message .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n"; $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . "\r\n\r\n"; $message .= wp_login_url() . "\r\n"; $wp_new_user_notification_email = array( 'to' => $user->user_email, 'subject' => __( '[%s] Login Details' ), 'message' => $message, 'headers' => '', ); $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname ); wp_mail( $wp_new_user_notification_email['to'], wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ), $wp_new_user_notification_email['message'], $wp_new_user_notification_email['headers'] ); if ( $switched_locale ) { restore_previous_locale(); } } endif; if ( ! function_exists( 'wp_nonce_tick' ) ) : function wp_nonce_tick( $action = -1 ) { $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action ); return ceil( time() / ( $nonce_life / 2 ) ); } endif; if ( ! function_exists( 'wp_verify_nonce' ) ) : function wp_verify_nonce( $nonce, $action = -1 ) { $nonce = (string) $nonce; $user = wp_get_current_user(); $uid = (int) $user->ID; if ( ! $uid ) { $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); } if ( empty( $nonce ) ) { return false; } $token = wp_get_session_token(); $i = wp_nonce_tick( $action ); $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 1; } $expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 2; } do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token ); return false; } endif; if ( ! function_exists( 'wp_create_nonce' ) ) : function wp_create_nonce( $action = -1 ) { $user = wp_get_current_user(); $uid = (int) $user->ID; if ( ! $uid ) { $uid = apply_filters( 'nonce_user_logged_out', $uid, $action ); } $token = wp_get_session_token( $action ); $i = wp_nonce_tick( $action ); return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); } endif; if ( ! function_exists( 'wp_salt' ) ) : function wp_salt( $scheme = 'auth' ) { static $cached_salts = array(); if ( isset( $cached_salts[ $scheme ] ) ) { return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); } static $duplicated_keys; if ( null === $duplicated_keys ) { $duplicated_keys = array( 'put your unique phrase here' => true, __( 'put your unique phrase here' ) => true, ); foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) { foreach ( array( 'KEY', 'SALT' ) as $second ) { if ( ! defined( "{$first}_{$second}" ) ) { continue; } $value = constant( "{$first}_{$second}" ); $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] ); } } } $values = array( 'key' => '', 'salt' => '', ); if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) { $values['key'] = SECRET_KEY; } if ( 'auth' === $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) { $values['salt'] = SECRET_SALT; } if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ), true ) ) { foreach ( array( 'key', 'salt' ) as $type ) { $const = strtoupper( "{$scheme}_{$type}" ); if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { $values[ $type ] = constant( $const ); } elseif ( ! $values[ $type ] ) { $values[ $type ] = get_site_option( "{$scheme}_{$type}" ); if ( ! $values[ $type ] ) { $values[ $type ] = wp_generate_password( 64, true, true ); update_site_option( "{$scheme}_{$type}", $values[ $type ] ); } } } } else { if ( ! $values['key'] ) { $values['key'] = get_site_option( 'secret_key' ); if ( ! $values['key'] ) { $values['key'] = wp_generate_password( 64, true, true ); update_site_option( 'secret_key', $values['key'] ); } } $values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] ); } $cached_salts[ $scheme ] = $values['key'] . $values['salt']; return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme ); } endif; if ( ! function_exists( 'wp_hash' ) ) : function wp_hash( $data, $scheme = 'auth' ) { $salt = wp_salt( $scheme ); return hash_hmac( 'md5', $data, $salt ); } endif; if ( ! function_exists( 'wp_hash_password' ) ) : function wp_hash_password( $password ) { global $wp_hasher; if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } return $wp_hasher->HashPassword( trim( $password ) ); } endif; if ( ! function_exists( 'wp_check_password' ) ) : function wp_check_password( $password, $hash, $user_id = '' ) { global $wp_hasher; if ( strlen( $hash ) <= 32 ) { $check = hash_equals( $hash, md5( $password ) ); if ( $check && $user_id ) { wp_set_password( $password, $user_id ); $hash = wp_hash_password( $password ); } return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } $check = $wp_hasher->CheckPassword( $password, $hash ); return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } endif; if ( ! function_exists( 'wp_generate_password' ) ) : function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; if ( $special_chars ) { $chars .= '!@#$%^&*()'; } if ( $extra_special_chars ) { $chars .= '-_ []{}<>~`+=,.;:/?|'; } $password = ''; for ( $i = 0; $i < $length; $i++ ) { $password .= substr( $chars, wp_rand( 0, strlen( $chars ) - 1 ), 1 ); } return apply_filters( 'random_password', $password, $length, $special_chars, $extra_special_chars ); } endif; if ( ! function_exists( 'wp_rand' ) ) : function wp_rand( $min = null, $max = null ) { global $rnd_value; $max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; if ( null === $min ) { $min = 0; } if ( null === $max ) { $max = $max_random_number; } $min = (int) $min; $max = (int) $max; static $use_random_int_functionality = true; if ( $use_random_int_functionality ) { try { $_max = max( $min, $max ); $_min = min( $min, $max ); $val = random_int( $_min, $_max ); if ( false !== $val ) { return absint( $val ); } else { $use_random_int_functionality = false; } } catch ( Error $e ) { $use_random_int_functionality = false; } catch ( Exception $e ) { $use_random_int_functionality = false; } } if ( strlen( $rnd_value ) < 8 ) { if ( defined( 'WP_SETUP_CONFIG' ) ) { static $seed = ''; } else { $seed = get_transient( 'random_seed' ); } $rnd_value = md5( uniqid( microtime() . mt_rand(), true ) . $seed ); $rnd_value .= sha1( $rnd_value ); $rnd_value .= sha1( $rnd_value . $seed ); $seed = md5( $seed . $rnd_value ); if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) { set_transient( 'random_seed', $seed ); } } $value = substr( $rnd_value, 0, 8 ); $rnd_value = substr( $rnd_value, 8 ); $value = abs( hexdec( $value ) ); $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); return abs( (int) $value ); } endif; if ( ! function_exists( 'wp_set_password' ) ) : function wp_set_password( $password, $user_id ) { global $wpdb; $hash = wp_hash_password( $password ); $wpdb->update( $wpdb->users, array( 'user_pass' => $hash, 'user_activation_key' => '', ), array( 'ID' => $user_id ) ); clean_user_cache( $user_id ); do_action( 'wp_set_password', $password, $user_id ); } endif; if ( ! function_exists( 'get_avatar' ) ) : function get_avatar( $id_or_email, $size = 96, $default_value = '', $alt = '', $args = null ) { $defaults = array( 'size' => 96, 'height' => null, 'width' => null, 'default' => get_option( 'avatar_default', 'mystery' ), 'force_default' => false, 'rating' => get_option( 'avatar_rating' ), 'scheme' => null, 'alt' => '', 'class' => null, 'force_display' => false, 'loading' => null, 'extra_attr' => '', 'decoding' => 'async', ); if ( wp_lazy_loading_enabled( 'img', 'get_avatar' ) ) { $defaults['loading'] = wp_get_loading_attr_default( 'get_avatar' ); } if ( empty( $args ) ) { $args = array(); } $args['size'] = (int) $size; $args['default'] = $default_value; $args['alt'] = $alt; $args = wp_parse_args( $args, $defaults ); if ( empty( $args['height'] ) ) { $args['height'] = $args['size']; } if ( empty( $args['width'] ) ) { $args['width'] = $args['size']; } if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { $id_or_email = get_comment( $id_or_email ); } $avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args ); if ( ! is_null( $avatar ) ) { return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args ); } if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) { return false; } $url2x = get_avatar_url( $id_or_email, array_merge( $args, array( 'size' => $args['size'] * 2 ) ) ); $args = get_avatar_data( $id_or_email, $args ); $url = $args['url']; if ( ! $url || is_wp_error( $url ) ) { return false; } $class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' ); if ( ! $args['found_avatar'] || $args['force_default'] ) { $class[] = 'avatar-default'; } if ( $args['class'] ) { if ( is_array( $args['class'] ) ) { $class = array_merge( $class, $args['class'] ); } else { $class[] = $args['class']; } } $extra_attr = $args['extra_attr']; if ( in_array( $args['loading'], array( 'lazy', 'eager' ), true ) && ! preg_match( '/\bloading\s*=/', $extra_attr ) ) { if ( ! empty( $extra_attr ) ) { $extra_attr .= ' '; } $extra_attr .= "loading='{$args['loading']}'"; } if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ), true ) && ! preg_match( '/\bdecoding\s*=/', $extra_attr ) ) { if ( ! empty( $extra_attr ) ) { $extra_attr .= ' '; } $extra_attr .= "decoding='{$args['decoding']}'"; } $avatar = sprintf( "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>", esc_attr( $args['alt'] ), esc_url( $url ), esc_url( $url2x ) . ' 2x', esc_attr( implode( ' ', $class ) ), (int) $args['height'], (int) $args['width'], $extra_attr ); return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args ); } endif; if ( ! function_exists( 'wp_text_diff' ) ) : function wp_text_diff( $left_string, $right_string, $args = null ) { $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '', 'show_split_view' => true, ); $args = wp_parse_args( $args, $defaults ); if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) ) { require ABSPATH . WPINC . '/wp-diff.php'; } $left_string = normalize_whitespace( $left_string ); $right_string = normalize_whitespace( $right_string ); $left_lines = explode( "\n", $left_string ); $right_lines = explode( "\n", $right_string ); $text_diff = new Text_Diff( $left_lines, $right_lines ); $renderer = new WP_Text_Diff_Renderer_Table( $args ); $diff = $renderer->render( $text_diff ); if ( ! $diff ) { return ''; } $is_split_view = ! empty( $args['show_split_view'] ); $is_split_view_class = $is_split_view ? ' is-split-view' : ''; $r = "<table class='diff$is_split_view_class'>\n"; if ( $args['title'] ) { $r .= "<caption class='diff-title'>$args[title]</caption>\n"; } if ( $args['title_left'] || $args['title_right'] ) { $r .= '<thead>'; } if ( $args['title_left'] || $args['title_right'] ) { $th_or_td_left = empty( $args['title_left'] ) ? 'td' : 'th'; $th_or_td_right = empty( $args['title_right'] ) ? 'td' : 'th'; $r .= "<tr class='diff-sub-title'>\n"; $r .= "\t<$th_or_td_left>$args[title_left]</$th_or_td_left>\n"; if ( $is_split_view ) { $r .= "\t<$th_or_td_right>$args[title_right]</$th_or_td_right>\n"; } $r .= "</tr>\n"; } if ( $args['title_left'] || $args['title_right'] ) { $r .= "</thead>\n"; } $r .= "<tbody>\n$diff\n</tbody>\n"; $r .= '</table>'; return $r; } endif; <?php require __DIR__ . '/class-wp-hook.php'; global $wp_filter; global $wp_actions; global $wp_filters; global $wp_current_filter; if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } else { $wp_filter = array(); } if ( ! isset( $wp_actions ) ) { $wp_actions = array(); } if ( ! isset( $wp_filters ) ) { $wp_filters = array(); } if ( ! isset( $wp_current_filter ) ) { $wp_current_filter = array(); } function add_filter( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { global $wp_filter; if ( ! isset( $wp_filter[ $hook_name ] ) ) { $wp_filter[ $hook_name ] = new WP_Hook(); } $wp_filter[ $hook_name ]->add_filter( $hook_name, $callback, $priority, $accepted_args ); return true; } function apply_filters( $hook_name, $value, ...$args ) { global $wp_filter, $wp_filters, $wp_current_filter; if ( ! isset( $wp_filters[ $hook_name ] ) ) { $wp_filters[ $hook_name ] = 1; } else { ++$wp_filters[ $hook_name ]; } if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; $all_args = func_get_args(); _wp_call_all_hook( $all_args ); } if ( ! isset( $wp_filter[ $hook_name ] ) ) { if ( isset( $wp_filter['all'] ) ) { array_pop( $wp_current_filter ); } return $value; } if ( ! isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; } array_unshift( $args, $value ); $filtered = $wp_filter[ $hook_name ]->apply_filters( $value, $args ); array_pop( $wp_current_filter ); return $filtered; } function apply_filters_ref_array( $hook_name, $args ) { global $wp_filter, $wp_filters, $wp_current_filter; if ( ! isset( $wp_filters[ $hook_name ] ) ) { $wp_filters[ $hook_name ] = 1; } else { ++$wp_filters[ $hook_name ]; } if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; $all_args = func_get_args(); _wp_call_all_hook( $all_args ); } if ( ! isset( $wp_filter[ $hook_name ] ) ) { if ( isset( $wp_filter['all'] ) ) { array_pop( $wp_current_filter ); } return $args[0]; } if ( ! isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; } $filtered = $wp_filter[ $hook_name ]->apply_filters( $args[0], $args ); array_pop( $wp_current_filter ); return $filtered; } function has_filter( $hook_name, $callback = false ) { global $wp_filter; if ( ! isset( $wp_filter[ $hook_name ] ) ) { return false; } return $wp_filter[ $hook_name ]->has_filter( $hook_name, $callback ); } function remove_filter( $hook_name, $callback, $priority = 10 ) { global $wp_filter; $r = false; if ( isset( $wp_filter[ $hook_name ] ) ) { $r = $wp_filter[ $hook_name ]->remove_filter( $hook_name, $callback, $priority ); if ( ! $wp_filter[ $hook_name ]->callbacks ) { unset( $wp_filter[ $hook_name ] ); } } return $r; } function remove_all_filters( $hook_name, $priority = false ) { global $wp_filter; if ( isset( $wp_filter[ $hook_name ] ) ) { $wp_filter[ $hook_name ]->remove_all_filters( $priority ); if ( ! $wp_filter[ $hook_name ]->has_filters() ) { unset( $wp_filter[ $hook_name ] ); } } return true; } function current_filter() { global $wp_current_filter; return end( $wp_current_filter ); } function doing_filter( $hook_name = null ) { global $wp_current_filter; if ( null === $hook_name ) { return ! empty( $wp_current_filter ); } return in_array( $hook_name, $wp_current_filter, true ); } function did_filter( $hook_name ) { global $wp_filters; if ( ! isset( $wp_filters[ $hook_name ] ) ) { return 0; } return $wp_filters[ $hook_name ]; } function add_action( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { return add_filter( $hook_name, $callback, $priority, $accepted_args ); } function do_action( $hook_name, ...$arg ) { global $wp_filter, $wp_actions, $wp_current_filter; if ( ! isset( $wp_actions[ $hook_name ] ) ) { $wp_actions[ $hook_name ] = 1; } else { ++$wp_actions[ $hook_name ]; } if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; $all_args = func_get_args(); _wp_call_all_hook( $all_args ); } if ( ! isset( $wp_filter[ $hook_name ] ) ) { if ( isset( $wp_filter['all'] ) ) { array_pop( $wp_current_filter ); } return; } if ( ! isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; } if ( empty( $arg ) ) { $arg[] = ''; } elseif ( is_array( $arg[0] ) && 1 === count( $arg[0] ) && isset( $arg[0][0] ) && is_object( $arg[0][0] ) ) { $arg[0] = $arg[0][0]; } $wp_filter[ $hook_name ]->do_action( $arg ); array_pop( $wp_current_filter ); } function do_action_ref_array( $hook_name, $args ) { global $wp_filter, $wp_actions, $wp_current_filter; if ( ! isset( $wp_actions[ $hook_name ] ) ) { $wp_actions[ $hook_name ] = 1; } else { ++$wp_actions[ $hook_name ]; } if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; $all_args = func_get_args(); _wp_call_all_hook( $all_args ); } if ( ! isset( $wp_filter[ $hook_name ] ) ) { if ( isset( $wp_filter['all'] ) ) { array_pop( $wp_current_filter ); } return; } if ( ! isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $hook_name; } $wp_filter[ $hook_name ]->do_action( $args ); array_pop( $wp_current_filter ); } function has_action( $hook_name, $callback = false ) { return has_filter( $hook_name, $callback ); } function remove_action( $hook_name, $callback, $priority = 10 ) { return remove_filter( $hook_name, $callback, $priority ); } function remove_all_actions( $hook_name, $priority = false ) { return remove_all_filters( $hook_name, $priority ); } function current_action() { return current_filter(); } function doing_action( $hook_name = null ) { return doing_filter( $hook_name ); } function did_action( $hook_name ) { global $wp_actions; if ( ! isset( $wp_actions[ $hook_name ] ) ) { return 0; } return $wp_actions[ $hook_name ]; } function apply_filters_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { if ( ! has_filter( $hook_name ) ) { return $args[0]; } _deprecated_hook( $hook_name, $version, $replacement, $message ); return apply_filters_ref_array( $hook_name, $args ); } function do_action_deprecated( $hook_name, $args, $version, $replacement = '', $message = '' ) { if ( ! has_action( $hook_name ) ) { return; } _deprecated_hook( $hook_name, $version, $replacement, $message ); do_action_ref_array( $hook_name, $args ); } function plugin_basename( $file ) { global $wp_plugin_paths; $file = wp_normalize_path( $file ); arsort( $wp_plugin_paths ); foreach ( $wp_plugin_paths as $dir => $realdir ) { if ( strpos( $file, $realdir ) === 0 ) { $file = $dir . substr( $file, strlen( $realdir ) ); } } $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); $file = preg_replace( '#^' . preg_quote( $plugin_dir, '#' ) . '/|^' . preg_quote( $mu_plugin_dir, '#' ) . '/#', '', $file ); $file = trim( $file, '/' ); return $file; } function wp_register_plugin_realpath( $file ) { global $wp_plugin_paths; static $wp_plugin_path = null, $wpmu_plugin_path = null; if ( ! isset( $wp_plugin_path ) ) { $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR ); $wpmu_plugin_path = wp_normalize_path( WPMU_PLUGIN_DIR ); } $plugin_path = wp_normalize_path( dirname( $file ) ); $plugin_realpath = wp_normalize_path( dirname( realpath( $file ) ) ); if ( $plugin_path === $wp_plugin_path || $plugin_path === $wpmu_plugin_path ) { return false; } if ( $plugin_path !== $plugin_realpath ) { $wp_plugin_paths[ $plugin_path ] = $plugin_realpath; } return true; } function plugin_dir_path( $file ) { return trailingslashit( dirname( $file ) ); } function plugin_dir_url( $file ) { return trailingslashit( plugins_url( '', $file ) ); } function register_activation_hook( $file, $callback ) { $file = plugin_basename( $file ); add_action( 'activate_' . $file, $callback ); } function register_deactivation_hook( $file, $callback ) { $file = plugin_basename( $file ); add_action( 'deactivate_' . $file, $callback ); } function register_uninstall_hook( $file, $callback ) { if ( is_array( $callback ) && is_object( $callback[0] ) ) { _doing_it_wrong( __FUNCTION__, __( 'Only a static class method or function can be used in an uninstall hook.' ), '3.1.0' ); return; } $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); $plugin_basename = plugin_basename( $file ); if ( ! isset( $uninstallable_plugins[ $plugin_basename ] ) || $uninstallable_plugins[ $plugin_basename ] !== $callback ) { $uninstallable_plugins[ $plugin_basename ] = $callback; update_option( 'uninstall_plugins', $uninstallable_plugins ); } } function _wp_call_all_hook( $args ) { global $wp_filter; $wp_filter['all']->do_all_hook( $args ); } function _wp_filter_build_unique_id( $hook_name, $callback, $priority ) { if ( is_string( $callback ) ) { return $callback; } if ( is_object( $callback ) ) { $callback = array( $callback, '' ); } else { $callback = (array) $callback; } if ( is_object( $callback[0] ) ) { return spl_object_hash( $callback[0] ) . $callback[1]; } elseif ( is_string( $callback[0] ) ) { return $callback[0] . '::' . $callback[1]; } } <?php if ( ! class_exists( 'Translation_Entry', false ) ) : class Translation_Entry { public $is_plural = false; public $context = null; public $singular = null; public $plural = null; public $translations = array(); public $translator_comments = ''; public $extracted_comments = ''; public $references = array(); public $flags = array(); public function __construct( $args = array() ) { if ( ! isset( $args['singular'] ) ) { return; } foreach ( $args as $varname => $value ) { $this->$varname = $value; } if ( isset( $args['plural'] ) && $args['plural'] ) { $this->is_plural = true; } if ( ! is_array( $this->translations ) ) { $this->translations = array(); } if ( ! is_array( $this->references ) ) { $this->references = array(); } if ( ! is_array( $this->flags ) ) { $this->flags = array(); } } public function Translation_Entry( $args = array() ) { _deprecated_constructor( self::class, '5.4.0', static::class ); self::__construct( $args ); } public function key() { if ( null === $this->singular ) { return false; } $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular; $key = str_replace( array( "\r\n", "\r" ), "\n", $key ); return $key; } public function merge_with( &$other ) { $this->flags = array_unique( array_merge( $this->flags, $other->flags ) ); $this->references = array_unique( array_merge( $this->references, $other->references ) ); if ( $this->extracted_comments != $other->extracted_comments ) { $this->extracted_comments .= $other->extracted_comments; } } } endif; <?php require_once __DIR__ . '/translations.php'; require_once __DIR__ . '/streams.php'; if ( ! class_exists( 'MO', false ) ) : class MO extends Gettext_Translations { public $_nplurals = 2; private $filename = ''; public function get_filename() { return $this->filename; } public function import_from_file( $filename ) { $reader = new POMO_FileReader( $filename ); if ( ! $reader->is_resource() ) { return false; } $this->filename = (string) $filename; return $this->import_from_reader( $reader ); } public function export_to_file( $filename ) { $fh = fopen( $filename, 'wb' ); if ( ! $fh ) { return false; } $res = $this->export_to_file_handle( $fh ); fclose( $fh ); return $res; } public function export() { $tmp_fh = fopen( 'php://temp', 'r+' ); if ( ! $tmp_fh ) { return false; } $this->export_to_file_handle( $tmp_fh ); rewind( $tmp_fh ); return stream_get_contents( $tmp_fh ); } public function is_entry_good_for_export( $entry ) { if ( empty( $entry->translations ) ) { return false; } if ( ! array_filter( $entry->translations ) ) { return false; } return true; } public function export_to_file_handle( $fh ) { $entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) ); ksort( $entries ); $magic = 0x950412de; $revision = 0; $total = count( $entries ) + 1; $originals_lengths_addr = 28; $translations_lengths_addr = $originals_lengths_addr + 8 * $total; $size_of_hash = 0; $hash_addr = $translations_lengths_addr + 8 * $total; $current_addr = $hash_addr; fwrite( $fh, pack( 'V*', $magic, $revision, $total, $originals_lengths_addr, $translations_lengths_addr, $size_of_hash, $hash_addr ) ); fseek( $fh, $originals_lengths_addr ); fwrite( $fh, pack( 'VV', 0, $current_addr ) ); $current_addr++; $originals_table = "\0"; $reader = new POMO_Reader(); foreach ( $entries as $entry ) { $originals_table .= $this->export_original( $entry ) . "\0"; $length = $reader->strlen( $this->export_original( $entry ) ); fwrite( $fh, pack( 'VV', $length, $current_addr ) ); $current_addr += $length + 1; } $exported_headers = $this->export_headers(); fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) ); $current_addr += strlen( $exported_headers ) + 1; $translations_table = $exported_headers . "\0"; foreach ( $entries as $entry ) { $translations_table .= $this->export_translations( $entry ) . "\0"; $length = $reader->strlen( $this->export_translations( $entry ) ); fwrite( $fh, pack( 'VV', $length, $current_addr ) ); $current_addr += $length + 1; } fwrite( $fh, $originals_table ); fwrite( $fh, $translations_table ); return true; } public function export_original( $entry ) { $exported = $entry->singular; if ( $entry->is_plural ) { $exported .= "\0" . $entry->plural; } if ( $entry->context ) { $exported = $entry->context . "\4" . $exported; } return $exported; } public function export_translations( $entry ) { return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0]; } public function export_headers() { $exported = ''; foreach ( $this->headers as $header => $value ) { $exported .= "$header: $value\n"; } return $exported; } public function get_byteorder( $magic ) { $magic_little = (int) - 1794895138; $magic_little_64 = (int) 2500072158; $magic_big = ( (int) - 569244523 ) & 0xFFFFFFFF; if ( $magic_little == $magic || $magic_little_64 == $magic ) { return 'little'; } elseif ( $magic_big == $magic ) { return 'big'; } else { return false; } } public function import_from_reader( $reader ) { $endian_string = MO::get_byteorder( $reader->readint32() ); if ( false === $endian_string ) { return false; } $reader->setEndian( $endian_string ); $endian = ( 'big' === $endian_string ) ? 'N' : 'V'; $header = $reader->read( 24 ); if ( $reader->strlen( $header ) != 24 ) { return false; } $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lengths_addr/{$endian}translations_lengths_addr/{$endian}hash_length/{$endian}hash_addr", $header ); if ( ! is_array( $header ) ) { return false; } if ( 0 != $header['revision'] ) { return false; } $reader->seekto( $header['originals_lengths_addr'] ); $originals_lengths_length = $header['translations_lengths_addr'] - $header['originals_lengths_addr']; if ( $originals_lengths_length != $header['total'] * 8 ) { return false; } $originals = $reader->read( $originals_lengths_length ); if ( $reader->strlen( $originals ) != $originals_lengths_length ) { return false; } $translations_lengths_length = $header['hash_addr'] - $header['translations_lengths_addr']; if ( $translations_lengths_length != $header['total'] * 8 ) { return false; } $translations = $reader->read( $translations_lengths_length ); if ( $reader->strlen( $translations ) != $translations_lengths_length ) { return false; } $originals = $reader->str_split( $originals, 8 ); $translations = $reader->str_split( $translations, 8 ); $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4; $reader->seekto( $strings_addr ); $strings = $reader->read_all(); $reader->close(); for ( $i = 0; $i < $header['total']; $i++ ) { $o = unpack( "{$endian}length/{$endian}pos", $originals[ $i ] ); $t = unpack( "{$endian}length/{$endian}pos", $translations[ $i ] ); if ( ! $o || ! $t ) { return false; } $o['pos'] -= $strings_addr; $t['pos'] -= $strings_addr; $original = $reader->substr( $strings, $o['pos'], $o['length'] ); $translation = $reader->substr( $strings, $t['pos'], $t['length'] ); if ( '' === $original ) { $this->set_headers( $this->make_headers( $translation ) ); } else { $entry = &$this->make_entry( $original, $translation ); $this->entries[ $entry->key() ] = &$entry; } } return true; } public function &make_entry( $original, $translation ) { $entry = new Translation_Entry(); $parts = explode( "\4", $original ); if ( isset( $parts[1] ) ) { $original = $parts[1]; $entry->context = $parts[0]; } $parts = explode( "\0", $original ); $entry->singular = $parts[0]; if ( isset( $parts[1] ) ) { $entry->is_plural = true; $entry->plural = $parts[1]; } $entry->translations = explode( "\0", $translation ); return $entry; } public function select_plural_form( $count ) { return $this->gettext_select_plural_form( $count ); } public function get_plural_forms_count() { return $this->_nplurals; } } endif; <?php @@ -31615,9 +34302,9 @@ All at ###SITENAME### function get_post_format( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) { return false; } $_format = get_the_terms( $post->ID, 'post_format' ); if ( empty( $_format ) ) { return false; } $format = reset( $_format ); return str_replace( 'post-format-', '', $format->slug ); } function has_post_format( $format = array(), $post = null ) { $prefixed = array(); if ( $format ) { foreach ( (array) $format as $single ) { $prefixed[] = 'post-format-' . sanitize_key( $single ); } } return has_term( $prefixed, 'post_format', $post ); } function set_post_format( $post, $format ) { $post = get_post( $post ); if ( ! $post ) { return new WP_Error( 'invalid_post', __( 'Invalid post.' ) ); } if ( ! empty( $format ) ) { $format = sanitize_key( $format ); if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs(), true ) ) { $format = ''; } else { $format = 'post-format-' . $format; } } return wp_set_post_terms( $post->ID, $format, 'post_format' ); } function get_post_format_strings() { $strings = array( 'standard' => _x( 'Standard', 'Post format' ), 'aside' => _x( 'Aside', 'Post format' ), 'chat' => _x( 'Chat', 'Post format' ), 'gallery' => _x( 'Gallery', 'Post format' ), 'link' => _x( 'Link', 'Post format' ), 'image' => _x( 'Image', 'Post format' ), 'quote' => _x( 'Quote', 'Post format' ), 'status' => _x( 'Status', 'Post format' ), 'video' => _x( 'Video', 'Post format' ), 'audio' => _x( 'Audio', 'Post format' ), ); return $strings; } function get_post_format_slugs() { $slugs = array_keys( get_post_format_strings() ); return array_combine( $slugs, $slugs ); } function get_post_format_string( $slug ) { $strings = get_post_format_strings(); if ( ! $slug ) { return $strings['standard']; } else { return ( isset( $strings[ $slug ] ) ) ? $strings[ $slug ] : ''; } } function get_post_format_link( $format ) { $term = get_term_by( 'slug', 'post-format-' . $format, 'post_format' ); if ( ! $term || is_wp_error( $term ) ) { return false; } return get_term_link( $term ); } function _post_format_request( $qvs ) { if ( ! isset( $qvs['post_format'] ) ) { return $qvs; } $slugs = get_post_format_slugs(); if ( isset( $slugs[ $qvs['post_format'] ] ) ) { $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; } $tax = get_taxonomy( 'post_format' ); if ( ! is_admin() ) { $qvs['post_type'] = $tax->object_type; } return $qvs; } function _post_format_link( $link, $term, $taxonomy ) { global $wp_rewrite; if ( 'post_format' !== $taxonomy ) { return $link; } if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link ); } else { $link = remove_query_arg( 'post_format', $link ); return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link ); } } function _post_format_get_term( $term ) { if ( isset( $term->slug ) ) { $term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } return $term; } function _post_format_get_terms( $terms, $taxonomies, $args ) { if ( in_array( 'post_format', (array) $taxonomies, true ) ) { if ( isset( $args['fields'] ) && 'names' === $args['fields'] ) { foreach ( $terms as $order => $name ) { $terms[ $order ] = get_post_format_string( str_replace( 'post-format-', '', $name ) ); } } else { foreach ( (array) $terms as $order => $term ) { if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } } } return $terms; } function _post_format_wp_get_object_terms( $terms ) { foreach ( (array) $terms as $order => $term ) { if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } return $terms; } <?php function the_ID() { echo get_the_ID(); } function get_the_ID() { $post = get_post(); return ! empty( $post ) ? $post->ID : false; } function the_title( $before = '', $after = '', $display = true ) { $title = get_the_title(); if ( strlen( $title ) == 0 ) { return; } $title = $before . $title . $after; if ( $display ) { echo $title; } else { return $title; } } function the_title_attribute( $args = '' ) { $defaults = array( 'before' => '', 'after' => '', 'echo' => true, 'post' => get_post(), ); $parsed_args = wp_parse_args( $args, $defaults ); $title = get_the_title( $parsed_args['post'] ); if ( strlen( $title ) == 0 ) { return; } $title = $parsed_args['before'] . $title . $parsed_args['after']; $title = esc_attr( strip_tags( $title ) ); if ( $parsed_args['echo'] ) { echo $title; } else { return $title; } } function get_the_title( $post = 0 ) { $post = get_post( $post ); $post_title = isset( $post->post_title ) ? $post->post_title : ''; $post_id = isset( $post->ID ) ? $post->ID : 0; if ( ! is_admin() ) { if ( ! empty( $post->post_password ) ) { $prepend = __( 'Protected: %s' ); $protected_title_format = apply_filters( 'protected_title_format', $prepend, $post ); $post_title = sprintf( $protected_title_format, $post_title ); } elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) { $prepend = __( 'Private: %s' ); $private_title_format = apply_filters( 'private_title_format', $prepend, $post ); $post_title = sprintf( $private_title_format, $post_title ); } } return apply_filters( 'the_title', $post_title, $post_id ); } function the_guid( $post = 0 ) { $post = get_post( $post ); $post_guid = isset( $post->guid ) ? get_the_guid( $post ) : ''; $post_id = isset( $post->ID ) ? $post->ID : 0; echo apply_filters( 'the_guid', $post_guid, $post_id ); } function get_the_guid( $post = 0 ) { $post = get_post( $post ); $post_guid = isset( $post->guid ) ? $post->guid : ''; $post_id = isset( $post->ID ) ? $post->ID : 0; return apply_filters( 'get_the_guid', $post_guid, $post_id ); } function the_content( $more_link_text = null, $strip_teaser = false ) { $content = get_the_content( $more_link_text, $strip_teaser ); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); echo $content; } function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) { global $page, $more, $preview, $pages, $multipage; $_post = get_post( $post ); if ( ! ( $_post instanceof WP_Post ) ) { return ''; } if ( null === $post && did_action( 'the_post' ) ) { $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' ); } else { $elements = generate_postdata( $_post ); } if ( null === $more_link_text ) { $more_link_text = sprintf( '<span aria-label="%1$s">%2$s</span>', sprintf( __( 'Continue reading %s' ), the_title_attribute( array( 'echo' => false, 'post' => $_post, ) ) ), __( '(more…)' ) ); } $output = ''; $has_teaser = false; if ( post_password_required( $_post ) ) { return get_the_password_form( $_post ); } if ( $elements['page'] > count( $elements['pages'] ) ) { $elements['page'] = count( $elements['pages'] ); } $page_no = $elements['page']; $content = $elements['pages'][ $page_no - 1 ]; if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { if ( has_block( 'more', $content ) ) { $content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content ); } $content = explode( $matches[0], $content, 2 ); if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) { $more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) ); } $has_teaser = true; } else { $content = array( $content ); } if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || 1 == $elements['page'] ) ) { $strip_teaser = true; } $teaser = $content[0]; if ( $elements['more'] && $strip_teaser && $has_teaser ) { $teaser = ''; } $output .= $teaser; if ( count( $content ) > 1 ) { if ( $elements['more'] ) { $output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1]; } else { if ( ! empty( $more_link_text ) ) { $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); } $output = force_balance_tags( $output ); } } return $output; } function the_excerpt() { echo apply_filters( 'the_excerpt', get_the_excerpt() ); } function get_the_excerpt( $post = null ) { if ( is_bool( $post ) ) { _deprecated_argument( __FUNCTION__, '2.3.0' ); } $post = get_post( $post ); if ( empty( $post ) ) { return ''; } if ( post_password_required( $post ) ) { return __( 'There is no excerpt because this is a protected post.' ); } return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); } function has_excerpt( $post = 0 ) { $post = get_post( $post ); return ( ! empty( $post->post_excerpt ) ); } function post_class( $css_class = '', $post = null ) { echo 'class="' . esc_attr( implode( ' ', get_post_class( $css_class, $post ) ) ) . '"'; } function get_post_class( $css_class = '', $post = null ) { $post = get_post( $post ); $classes = array(); if ( $css_class ) { if ( ! is_array( $css_class ) ) { $css_class = preg_split( '#\s+#', $css_class ); } $classes = array_map( 'esc_attr', $css_class ); } else { $css_class = array(); } if ( ! $post ) { return $classes; } $classes[] = 'post-' . $post->ID; if ( ! is_admin() ) { $classes[] = $post->post_type; } $classes[] = 'type-' . $post->post_type; $classes[] = 'status-' . $post->post_status; if ( post_type_supports( $post->post_type, 'post-formats' ) ) { $post_format = get_post_format( $post->ID ); if ( $post_format && ! is_wp_error( $post_format ) ) { $classes[] = 'format-' . sanitize_html_class( $post_format ); } else { $classes[] = 'format-standard'; } } $post_password_required = post_password_required( $post->ID ); if ( $post_password_required ) { $classes[] = 'post-password-required'; } elseif ( ! empty( $post->post_password ) ) { $classes[] = 'post-password-protected'; } if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) { $classes[] = 'has-post-thumbnail'; } if ( is_sticky( $post->ID ) ) { if ( is_home() && ! is_paged() ) { $classes[] = 'sticky'; } elseif ( is_admin() ) { $classes[] = 'status-sticky'; } } $classes[] = 'hentry'; $taxonomies = get_taxonomies( array( 'public' => true ) ); $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class ); foreach ( (array) $taxonomies as $taxonomy ) { if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) { if ( empty( $term->slug ) ) { continue; } $term_class = sanitize_html_class( $term->slug, $term->term_id ); if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { $term_class = $term->term_id; } if ( 'post_tag' === $taxonomy ) { $classes[] = 'tag-' . $term_class; } else { $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); } } } } $classes = array_map( 'esc_attr', $classes ); $classes = apply_filters( 'post_class', $classes, $css_class, $post->ID ); return array_unique( $classes ); } function body_class( $css_class = '' ) { echo 'class="' . esc_attr( implode( ' ', get_body_class( $css_class ) ) ) . '"'; } function get_body_class( $css_class = '' ) { global $wp_query; $classes = array(); if ( is_rtl() ) { $classes[] = 'rtl'; } if ( is_front_page() ) { $classes[] = 'home'; } if ( is_home() ) { $classes[] = 'blog'; } if ( is_privacy_policy() ) { $classes[] = 'privacy-policy'; } if ( is_archive() ) { $classes[] = 'archive'; } if ( is_date() ) { $classes[] = 'date'; } if ( is_search() ) { $classes[] = 'search'; $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results'; } if ( is_paged() ) { $classes[] = 'paged'; } if ( is_attachment() ) { $classes[] = 'attachment'; } if ( is_404() ) { $classes[] = 'error404'; } if ( is_singular() ) { $post_id = $wp_query->get_queried_object_id(); $post = $wp_query->get_queried_object(); $post_type = $post->post_type; if ( is_page_template() ) { $classes[] = "{$post_type}-template"; $template_slug = get_page_template_slug( $post_id ); $template_parts = explode( '/', $template_slug ); foreach ( $template_parts as $part ) { $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) ); } $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) ); } else { $classes[] = "{$post_type}-template-default"; } if ( is_single() ) { $classes[] = 'single'; if ( isset( $post->post_type ) ) { $classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id ); $classes[] = 'postid-' . $post_id; if ( post_type_supports( $post->post_type, 'post-formats' ) ) { $post_format = get_post_format( $post->ID ); if ( $post_format && ! is_wp_error( $post_format ) ) { $classes[] = 'single-format-' . sanitize_html_class( $post_format ); } else { $classes[] = 'single-format-standard'; } } } } if ( is_attachment() ) { $mime_type = get_post_mime_type( $post_id ); $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' ); $classes[] = 'attachmentid-' . $post_id; $classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type ); } elseif ( is_page() ) { $classes[] = 'page'; $page_id = $wp_query->get_queried_object_id(); $post = get_post( $page_id ); $classes[] = 'page-id-' . $page_id; if ( get_pages( array( 'parent' => $page_id, 'number' => 1, ) ) ) { $classes[] = 'page-parent'; } if ( $post->post_parent ) { $classes[] = 'page-child'; $classes[] = 'parent-pageid-' . $post->post_parent; } } } elseif ( is_archive() ) { if ( is_post_type_archive() ) { $classes[] = 'post-type-archive'; $post_type = get_query_var( 'post_type' ); if ( is_array( $post_type ) ) { $post_type = reset( $post_type ); } $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type ); } elseif ( is_author() ) { $author = $wp_query->get_queried_object(); $classes[] = 'author'; if ( isset( $author->user_nicename ) ) { $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID ); $classes[] = 'author-' . $author->ID; } } elseif ( is_category() ) { $cat = $wp_query->get_queried_object(); $classes[] = 'category'; if ( isset( $cat->term_id ) ) { $cat_class = sanitize_html_class( $cat->slug, $cat->term_id ); if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) { $cat_class = $cat->term_id; } $classes[] = 'category-' . $cat_class; $classes[] = 'category-' . $cat->term_id; } } elseif ( is_tag() ) { $tag = $wp_query->get_queried_object(); $classes[] = 'tag'; if ( isset( $tag->term_id ) ) { $tag_class = sanitize_html_class( $tag->slug, $tag->term_id ); if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) { $tag_class = $tag->term_id; } $classes[] = 'tag-' . $tag_class; $classes[] = 'tag-' . $tag->term_id; } } elseif ( is_tax() ) { $term = $wp_query->get_queried_object(); if ( isset( $term->term_id ) ) { $term_class = sanitize_html_class( $term->slug, $term->term_id ); if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { $term_class = $term->term_id; } $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); $classes[] = 'term-' . $term_class; $classes[] = 'term-' . $term->term_id; } } } if ( is_user_logged_in() ) { $classes[] = 'logged-in'; } if ( is_admin_bar_showing() ) { $classes[] = 'admin-bar'; $classes[] = 'no-customize-support'; } if ( current_theme_supports( 'custom-background' ) && ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) ) { $classes[] = 'custom-background'; } if ( has_custom_logo() ) { $classes[] = 'wp-custom-logo'; } if ( current_theme_supports( 'responsive-embeds' ) ) { $classes[] = 'wp-embed-responsive'; } $page = $wp_query->get( 'page' ); if ( ! $page || $page < 2 ) { $page = $wp_query->get( 'paged' ); } if ( $page && $page > 1 && ! is_404() ) { $classes[] = 'paged-' . $page; if ( is_single() ) { $classes[] = 'single-paged-' . $page; } elseif ( is_page() ) { $classes[] = 'page-paged-' . $page; } elseif ( is_category() ) { $classes[] = 'category-paged-' . $page; } elseif ( is_tag() ) { $classes[] = 'tag-paged-' . $page; } elseif ( is_date() ) { $classes[] = 'date-paged-' . $page; } elseif ( is_author() ) { $classes[] = 'author-paged-' . $page; } elseif ( is_search() ) { $classes[] = 'search-paged-' . $page; } elseif ( is_post_type_archive() ) { $classes[] = 'post-type-paged-' . $page; } } if ( ! empty( $css_class ) ) { if ( ! is_array( $css_class ) ) { $css_class = preg_split( '#\s+#', $css_class ); } $classes = array_merge( $classes, $css_class ); } else { $css_class = array(); } $classes = array_map( 'esc_attr', $classes ); $classes = apply_filters( 'body_class', $classes, $css_class ); return array_unique( $classes ); } function post_password_required( $post = null ) { $post = get_post( $post ); if ( empty( $post->post_password ) ) { return apply_filters( 'post_password_required', false, $post ); } if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { return apply_filters( 'post_password_required', true, $post ); } require_once ABSPATH . WPINC . '/class-phpass.php'; $hasher = new PasswordHash( 8, true ); $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ); if ( 0 !== strpos( $hash, '$P$B' ) ) { $required = true; } else { $required = ! $hasher->CheckPassword( $post->post_password, $hash ); } return apply_filters( 'post_password_required', $required, $post ); } function wp_link_pages( $args = '' ) { global $page, $numpages, $multipage, $more; $defaults = array( 'before' => '<p class="post-nav-links">' . __( 'Pages:' ), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'aria_current' => 'page', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __( 'Next page' ), 'previouspagelink' => __( 'Previous page' ), 'pagelink' => '%', 'echo' => 1, ); $parsed_args = wp_parse_args( $args, $defaults ); $parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args ); $output = ''; if ( $multipage ) { if ( 'number' === $parsed_args['next_or_number'] ) { $output .= $parsed_args['before']; for ( $i = 1; $i <= $numpages; $i++ ) { $link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after']; if ( $i != $page || ! $more && 1 == $page ) { $link = _wp_link_page( $i ) . $link . '</a>'; } elseif ( $i === $page ) { $link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link . '</span>'; } $link = apply_filters( 'wp_link_pages_link', $link, $i ); $output .= ( 1 === $i ) ? ' ' : $parsed_args['separator']; $output .= $link; } $output .= $parsed_args['after']; } elseif ( $more ) { $output .= $parsed_args['before']; $prev = $page - 1; if ( $prev > 0 ) { $link = _wp_link_page( $prev ) . $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>'; $output .= apply_filters( 'wp_link_pages_link', $link, $prev ); } $next = $page + 1; if ( $next <= $numpages ) { if ( $prev ) { $output .= $parsed_args['separator']; } $link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>'; $output .= apply_filters( 'wp_link_pages_link', $link, $next ); } $output .= $parsed_args['after']; } } $html = apply_filters( 'wp_link_pages', $output, $args ); if ( $parsed_args['echo'] ) { echo $html; } return $html; } function _wp_link_page( $i ) { global $wp_rewrite; $post = get_post(); $query_args = array(); if ( 1 == $i ) { $url = get_permalink(); } else { if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) { $url = add_query_arg( 'page', $i, get_permalink() ); } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' ); } else { $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' ); } } if ( is_preview() ) { if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) { $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] ); $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] ); } $url = get_preview_post_link( $post, $query_args, $url ); } return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">'; } function post_custom( $key = '' ) { $custom = get_post_custom(); if ( ! isset( $custom[ $key ] ) ) { return false; } elseif ( 1 === count( $custom[ $key ] ) ) { return $custom[ $key ][0]; } else { return $custom[ $key ]; } } function the_meta() { _deprecated_function( __FUNCTION__, '6.0.2', 'get_post_meta()' ); $keys = get_post_custom_keys(); if ( $keys ) { $li_html = ''; foreach ( (array) $keys as $key ) { $keyt = trim( $key ); if ( is_protected_meta( $keyt, 'post' ) ) { continue; } $values = array_map( 'trim', get_post_custom_values( $key ) ); $value = implode( ', ', $values ); $html = sprintf( "<li><span class='post-meta-key'>%s</span> %s</li>\n", esc_html( sprintf( _x( '%s:', 'Post custom field name' ), $key ) ), esc_html( $value ) ); $li_html .= apply_filters( 'the_meta_key', $html, $key, $value ); } if ( $li_html ) { echo "<ul class='post-meta'>\n{$li_html}</ul>\n"; } } } function wp_dropdown_pages( $args = '' ) { $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID', ); $parsed_args = wp_parse_args( $args, $defaults ); $pages = get_pages( $parsed_args ); $output = ''; if ( empty( $parsed_args['id'] ) ) { $parsed_args['id'] = $parsed_args['name']; } if ( ! empty( $pages ) ) { $class = ''; if ( ! empty( $parsed_args['class'] ) ) { $class = " class='" . esc_attr( $parsed_args['class'] ) . "'"; } $output = "<select name='" . esc_attr( $parsed_args['name'] ) . "'" . $class . " id='" . esc_attr( $parsed_args['id'] ) . "'>\n"; if ( $parsed_args['show_option_no_change'] ) { $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n"; } if ( $parsed_args['show_option_none'] ) { $output .= "\t<option value=\"" . esc_attr( $parsed_args['option_none_value'] ) . '">' . $parsed_args['show_option_none'] . "</option>\n"; } $output .= walk_page_dropdown_tree( $pages, $parsed_args['depth'], $parsed_args ); $output .= "</select>\n"; } $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages ); if ( $parsed_args['echo'] ) { echo $html; } return $html; } function wp_list_pages( $args = '' ) { $defaults = array( 'depth' => 0, 'show_date' => '', 'date_format' => get_option( 'date_format' ), 'child_of' => 0, 'exclude' => '', 'title_li' => __( 'Pages' ), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '', ); $parsed_args = wp_parse_args( $args, $defaults ); if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { $parsed_args['item_spacing'] = $defaults['item_spacing']; } $output = ''; $current_page = 0; $parsed_args['exclude'] = preg_replace( '/[^0-9,]/', '', $parsed_args['exclude'] ); $exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array(); $parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); $parsed_args['hierarchical'] = 0; $pages = get_pages( $parsed_args ); if ( ! empty( $pages ) ) { if ( $parsed_args['title_li'] ) { $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>'; } global $wp_query; if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { $current_page = get_queried_object_id(); } elseif ( is_singular() ) { $queried_object = get_queried_object(); if ( is_post_type_hierarchical( $queried_object->post_type ) ) { $current_page = $queried_object->ID; } } $output .= walk_page_tree( $pages, $parsed_args['depth'], $current_page, $parsed_args ); if ( $parsed_args['title_li'] ) { $output .= '</ul></li>'; } } $html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages ); if ( $parsed_args['echo'] ) { echo $html; } else { return $html; } } function wp_page_menu( $args = array() ) { $defaults = array( 'sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '', ); $args = wp_parse_args( $args, $defaults ); if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { $args['item_spacing'] = $defaults['item_spacing']; } if ( 'preserve' === $args['item_spacing'] ) { $t = "\t"; $n = "\n"; } else { $t = ''; $n = ''; } $args = apply_filters( 'wp_page_menu_args', $args ); $menu = ''; $list_args = $args; if ( ! empty( $args['show_home'] ) ) { if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) { $text = __( 'Home' ); } else { $text = $args['show_home']; } $class = ''; if ( is_front_page() && ! is_paged() ) { $class = 'class="current_page_item"'; } $menu .= '<li ' . $class . '><a href="' . esc_url( home_url( '/' ) ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; if ( 'page' === get_option( 'show_on_front' ) ) { if ( ! empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; } else { $list_args['exclude'] = ''; } $list_args['exclude'] .= get_option( 'page_on_front' ); } } $list_args['echo'] = false; $list_args['title_li'] = ''; $menu .= wp_list_pages( $list_args ); $container = sanitize_text_field( $args['container'] ); if ( empty( $container ) ) { $container = 'div'; } if ( $menu ) { if ( isset( $args['fallback_cb'] ) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container ) { $args['before'] = "<ul>{$n}"; $args['after'] = '</ul>'; } $menu = $args['before'] . $menu . $args['after']; } $attrs = ''; if ( ! empty( $args['menu_id'] ) ) { $attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"'; } if ( ! empty( $args['menu_class'] ) ) { $attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"'; } $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}"; $menu = apply_filters( 'wp_page_menu', $menu, $args ); if ( $args['echo'] ) { echo $menu; } else { return $menu; } } function walk_page_tree( $pages, $depth, $current_page, $args ) { if ( empty( $args['walker'] ) ) { $walker = new Walker_Page(); } else { $walker = $args['walker']; } foreach ( (array) $pages as $page ) { if ( $page->post_parent ) { $args['pages_with_children'][ $page->post_parent ] = true; } } return $walker->walk( $pages, $depth, $args, $current_page ); } function walk_page_dropdown_tree( ...$args ) { if ( empty( $args[2]['walker'] ) ) { $walker = new Walker_PageDropdown(); } else { $walker = $args[2]['walker']; } return $walker->walk( ...$args ); } function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.5.0' ); } if ( $fullsize ) { echo wp_get_attachment_link( $post, 'full', $permalink ); } else { echo wp_get_attachment_link( $post, 'thumbnail', $permalink ); } } function wp_get_attachment_link( $post = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) { $_post = get_post( $post ); if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) { return __( 'Missing Attachment' ); } $url = wp_get_attachment_url( $_post->ID ); if ( $permalink ) { $url = get_attachment_link( $_post->ID ); } if ( $text ) { $link_text = $text; } elseif ( $size && 'none' !== $size ) { $link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr ); } else { $link_text = ''; } if ( '' === trim( $link_text ) ) { $link_text = $_post->post_title; } if ( '' === trim( $link_text ) ) { $link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) ); } $link_html = "<a href='" . esc_url( $url ) . "'>$link_text</a>"; return apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr ); } function prepend_attachment( $content ) { $post = get_post(); if ( empty( $post->post_type ) || 'attachment' !== $post->post_type ) { return $content; } if ( wp_attachment_is( 'video', $post ) ) { $meta = wp_get_attachment_metadata( get_the_ID() ); $atts = array( 'src' => wp_get_attachment_url() ); if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) { $atts['width'] = (int) $meta['width']; $atts['height'] = (int) $meta['height']; } if ( has_post_thumbnail() ) { $atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() ); } $p = wp_video_shortcode( $atts ); } elseif ( wp_attachment_is( 'audio', $post ) ) { $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); } else { $p = '<p class="attachment">'; $p .= wp_get_attachment_link( 0, 'medium', false ); $p .= '</p>'; } $p = apply_filters( 'prepend_attachment', $p ); return "$p\n$content"; } function get_the_password_form( $post = 0 ) { $post = get_post( $post ); $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post"> <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p> - <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form> + <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" spellcheck="false" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form> '; return apply_filters( 'the_password_form', $output, $post ); } function is_page_template( $template = '' ) { if ( ! is_singular() ) { return false; } $page_template = get_page_template_slug( get_queried_object_id() ); if ( empty( $template ) ) { return (bool) $page_template; } if ( $template == $page_template ) { return true; } if ( is_array( $template ) ) { if ( ( in_array( 'default', $template, true ) && ! $page_template ) || in_array( $page_template, $template, true ) ) { return true; } } return ( 'default' === $template && ! $page_template ); } function get_page_template_slug( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } $template = get_post_meta( $post->ID, '_wp_page_template', true ); if ( ! $template || 'default' === $template ) { return ''; } return $template; } function wp_post_revision_title( $revision, $link = true ) { $revision = get_post( $revision ); if ( ! $revision ) { return $revision; } if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { return false; } $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); $autosavef = __( '%s [Autosave]' ); $currentf = __( '%s [Current Revision]' ); $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); $edit_link = get_edit_post_link( $revision->ID ); if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) { $date = "<a href='$edit_link'>$date</a>"; } if ( ! wp_is_post_revision( $revision ) ) { $date = sprintf( $currentf, $date ); } elseif ( wp_is_post_autosave( $revision ) ) { $date = sprintf( $autosavef, $date ); } return $date; } function wp_post_revision_title_expanded( $revision, $link = true ) { $revision = get_post( $revision ); if ( ! $revision ) { return $revision; } if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) { return false; } $author = get_the_author_meta( 'display_name', $revision->post_author ); $datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); $gravatar = get_avatar( $revision->post_author, 24 ); $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); $edit_link = get_edit_post_link( $revision->ID ); if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) { $date = "<a href='$edit_link'>$date</a>"; } $revision_date_author = sprintf( __( '%1$s %2$s, %3$s ago (%4$s)' ), $gravatar, $author, human_time_diff( strtotime( $revision->post_modified_gmt ) ), $date ); $autosavef = __( '%s [Autosave]' ); $currentf = __( '%s [Current Revision]' ); if ( ! wp_is_post_revision( $revision ) ) { $revision_date_author = sprintf( $currentf, $revision_date_author ); } elseif ( wp_is_post_autosave( $revision ) ) { $revision_date_author = sprintf( $autosavef, $revision_date_author ); } return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link ); } function wp_list_post_revisions( $post = 0, $type = 'all' ) { $post = get_post( $post ); if ( ! $post ) { return; } if ( is_array( $type ) ) { $type = ! empty( $type['type'] ) ? $type['type'] : $type; _deprecated_argument( __FUNCTION__, '3.6.0' ); } $revisions = wp_get_post_revisions( $post->ID ); if ( ! $revisions ) { return; } $rows = ''; foreach ( $revisions as $revision ) { if ( ! current_user_can( 'read_post', $revision->ID ) ) { continue; } $is_autosave = wp_is_post_autosave( $revision ); if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) { continue; } $rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n"; } echo "<div class='hide-if-js'><p>" . __( 'JavaScript must be enabled to use this feature.' ) . "</p></div>\n"; echo "<ul class='post-revisions hide-if-no-js'>\n"; echo $rows; echo '</ul>'; } function get_post_parent( $post = null ) { $wp_post = get_post( $post ); return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null; } function has_post_parent( $post = null ) { return (bool) get_post_parent( $post ); } <?php - function has_post_thumbnail( $post = null ) { $thumbnail_id = get_post_thumbnail_id( $post ); $has_thumbnail = (bool) $thumbnail_id; return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id ); } function get_post_thumbnail_id( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } $thumbnail_id = (int) get_post_meta( $post->ID, '_thumbnail_id', true ); return (int) apply_filters( 'post_thumbnail_id', $thumbnail_id, $post ); } function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) { echo get_the_post_thumbnail( null, $size, $attr ); } function update_post_thumbnail_cache( $wp_query = null ) { if ( ! $wp_query ) { $wp_query = $GLOBALS['wp_query']; } if ( $wp_query->thumbnails_cached ) { return; } $thumb_ids = array(); foreach ( $wp_query->posts as $post ) { $id = get_post_thumbnail_id( $post->ID ); if ( $id ) { $thumb_ids[] = $id; } } if ( ! empty( $thumb_ids ) ) { _prime_post_caches( $thumb_ids, false, true ); } $wp_query->thumbnails_cached = true; } function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = '' ) { $post = get_post( $post ); if ( ! $post ) { return ''; } $post_thumbnail_id = get_post_thumbnail_id( $post ); $size = apply_filters( 'post_thumbnail_size', $size, $post->ID ); if ( $post_thumbnail_id ) { do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size ); if ( in_the_loop() ) { update_post_thumbnail_cache(); } $loading = wp_get_loading_attr_default( 'the_post_thumbnail' ); if ( empty( $attr ) ) { $attr = array( 'loading' => $loading ); } elseif ( is_array( $attr ) && ! array_key_exists( 'loading', $attr ) ) { $attr['loading'] = $loading; } elseif ( is_string( $attr ) && ! preg_match( '/(^|&)loading=/', $attr ) ) { $attr .= '&loading=' . $loading; } $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); do_action( 'end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size ); } else { $html = ''; } return apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr ); } function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) { $post_thumbnail_id = get_post_thumbnail_id( $post ); if ( ! $post_thumbnail_id ) { return false; } $thumbnail_url = wp_get_attachment_image_url( $post_thumbnail_id, $size ); return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size ); } function the_post_thumbnail_url( $size = 'post-thumbnail' ) { $url = get_the_post_thumbnail_url( null, $size ); if ( $url ) { echo esc_url( $url ); } } function get_the_post_thumbnail_caption( $post = null ) { $post_thumbnail_id = get_post_thumbnail_id( $post ); if ( ! $post_thumbnail_id ) { return ''; } $caption = wp_get_attachment_caption( $post_thumbnail_id ); if ( ! $caption ) { $caption = ''; } return $caption; } function the_post_thumbnail_caption( $post = null ) { echo apply_filters( 'the_post_thumbnail_caption', get_the_post_thumbnail_caption( $post ) ); } <?php + function has_post_thumbnail( $post = null ) { $thumbnail_id = get_post_thumbnail_id( $post ); $has_thumbnail = (bool) $thumbnail_id; return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id ); } function get_post_thumbnail_id( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } $thumbnail_id = (int) get_post_meta( $post->ID, '_thumbnail_id', true ); return (int) apply_filters( 'post_thumbnail_id', $thumbnail_id, $post ); } function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) { echo get_the_post_thumbnail( null, $size, $attr ); } function update_post_thumbnail_cache( $wp_query = null ) { if ( ! $wp_query ) { $wp_query = $GLOBALS['wp_query']; } if ( $wp_query->thumbnails_cached ) { return; } $thumb_ids = array(); foreach ( $wp_query->posts as $post ) { $id = get_post_thumbnail_id( $post->ID ); if ( $id ) { $thumb_ids[] = $id; } } if ( ! empty( $thumb_ids ) ) { _prime_post_caches( $thumb_ids, false, true ); } $wp_query->thumbnails_cached = true; } function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = '' ) { $post = get_post( $post ); if ( ! $post ) { return ''; } $post_thumbnail_id = get_post_thumbnail_id( $post ); $size = apply_filters( 'post_thumbnail_size', $size, $post->ID ); if ( $post_thumbnail_id ) { do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size ); if ( in_the_loop() ) { update_post_thumbnail_cache(); } if ( wp_lazy_loading_enabled( 'img', 'the_post_thumbnail' ) ) { $loading = wp_get_loading_attr_default( 'the_post_thumbnail' ); if ( empty( $attr ) ) { $attr = array( 'loading' => $loading ); } elseif ( is_array( $attr ) && ! array_key_exists( 'loading', $attr ) ) { $attr['loading'] = $loading; } elseif ( is_string( $attr ) && ! preg_match( '/(^|&)loading=/', $attr ) ) { $attr .= '&loading=' . $loading; } } $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); do_action( 'end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size ); } else { $html = ''; } return apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr ); } function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) { $post_thumbnail_id = get_post_thumbnail_id( $post ); if ( ! $post_thumbnail_id ) { return false; } $thumbnail_url = wp_get_attachment_image_url( $post_thumbnail_id, $size ); return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size ); } function the_post_thumbnail_url( $size = 'post-thumbnail' ) { $url = get_the_post_thumbnail_url( null, $size ); if ( $url ) { echo esc_url( $url ); } } function get_the_post_thumbnail_caption( $post = null ) { $post_thumbnail_id = get_post_thumbnail_id( $post ); if ( ! $post_thumbnail_id ) { return ''; } $caption = wp_get_attachment_caption( $post_thumbnail_id ); if ( ! $caption ) { $caption = ''; } return $caption; } function the_post_thumbnail_caption( $post = null ) { echo apply_filters( 'the_post_thumbnail_caption', get_the_post_thumbnail_caption( $post ) ); } <?php function create_initial_post_types() { WP_Post_Type::reset_default_labels(); register_post_type( 'post', array( 'labels' => array( 'name_admin_bar' => _x( 'Post', 'add new from admin bar' ), ), 'public' => true, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'map_meta_cap' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-admin-post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ), 'show_in_rest' => true, 'rest_base' => 'posts', 'rest_controller_class' => 'WP_REST_Posts_Controller', ) ); register_post_type( 'page', array( 'labels' => array( 'name_admin_bar' => _x( 'Page', 'add new from admin bar' ), ), 'public' => true, 'publicly_queryable' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'page', 'map_meta_cap' => true, 'menu_position' => 20, 'menu_icon' => 'dashicons-admin-page', 'hierarchical' => true, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ), 'show_in_rest' => true, 'rest_base' => 'pages', 'rest_controller_class' => 'WP_REST_Posts_Controller', ) ); register_post_type( 'attachment', array( 'labels' => array( 'name' => _x( 'Media', 'post type general name' ), 'name_admin_bar' => _x( 'Media', 'add new from admin bar' ), 'add_new' => _x( 'Add New', 'file' ), 'edit_item' => __( 'Edit Media' ), 'view_item' => __( 'View Attachment Page' ), 'attributes' => __( 'Attachment Attributes' ), ), 'public' => true, 'show_ui' => true, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => 'upload_files', ), 'map_meta_cap' => true, 'menu_icon' => 'dashicons-admin-media', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'show_in_nav_menus' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'author', 'comments' ), 'show_in_rest' => true, 'rest_base' => 'media', 'rest_controller_class' => 'WP_REST_Attachments_Controller', ) ); add_post_type_support( 'attachment:audio', 'thumbnail' ); add_post_type_support( 'attachment:video', 'thumbnail' ); register_post_type( 'revision', array( 'labels' => array( 'name' => __( 'Revisions' ), 'singular_name' => __( 'Revision' ), ), 'public' => false, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'can_export' => false, 'delete_with_user' => true, 'supports' => array( 'author' ), ) ); register_post_type( 'nav_menu_item', array( 'labels' => array( 'name' => __( 'Navigation Menu Items' ), 'singular_name' => __( 'Navigation Menu Item' ), ), 'public' => false, '_builtin' => true, 'hierarchical' => false, 'rewrite' => false, 'delete_with_user' => false, 'query_var' => false, 'map_meta_cap' => true, 'capability_type' => array( 'edit_theme_options', 'edit_theme_options' ), 'capabilities' => array( 'edit_post' => 'edit_post', 'read_post' => 'read_post', 'delete_post' => 'delete_post', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'delete_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read_private_posts' => 'edit_theme_options', 'read' => 'read', 'delete_private_posts' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', 'edit_private_posts' => 'edit_theme_options', 'edit_published_posts' => 'edit_theme_options', ), 'show_in_rest' => true, 'rest_base' => 'menu-items', 'rest_controller_class' => 'WP_REST_Menu_Items_Controller', ) ); register_post_type( 'custom_css', array( 'labels' => array( 'name' => __( 'Custom CSS' ), 'singular_name' => __( 'Custom CSS' ), ), 'public' => false, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => false, 'can_export' => true, '_builtin' => true, 'supports' => array( 'title', 'revisions' ), 'capabilities' => array( 'delete_posts' => 'edit_theme_options', 'delete_post' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'delete_private_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', 'edit_post' => 'edit_css', 'edit_posts' => 'edit_css', 'edit_others_posts' => 'edit_css', 'edit_published_posts' => 'edit_css', 'read_post' => 'read', 'read_private_posts' => 'read', 'publish_posts' => 'edit_theme_options', ), ) ); register_post_type( 'customize_changeset', array( 'labels' => array( 'name' => _x( 'Changesets', 'post type general name' ), 'singular_name' => _x( 'Changeset', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Customize Changeset' ), 'add_new_item' => __( 'Add New Changeset' ), 'new_item' => __( 'New Changeset' ), 'edit_item' => __( 'Edit Changeset' ), 'view_item' => __( 'View Changeset' ), 'all_items' => __( 'All Changesets' ), 'search_items' => __( 'Search Changesets' ), 'not_found' => __( 'No changesets found.' ), 'not_found_in_trash' => __( 'No changesets found in Trash.' ), ), 'public' => false, '_builtin' => true, 'map_meta_cap' => true, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'can_export' => false, 'delete_with_user' => false, 'supports' => array( 'title', 'author' ), 'capability_type' => 'customize_changeset', 'capabilities' => array( 'create_posts' => 'customize', 'delete_others_posts' => 'customize', 'delete_post' => 'customize', 'delete_posts' => 'customize', 'delete_private_posts' => 'customize', 'delete_published_posts' => 'customize', 'edit_others_posts' => 'customize', 'edit_post' => 'customize', 'edit_posts' => 'customize', 'edit_private_posts' => 'customize', 'edit_published_posts' => 'do_not_allow', 'publish_posts' => 'customize', 'read' => 'read', 'read_post' => 'customize', 'read_private_posts' => 'customize', ), ) ); register_post_type( 'oembed_cache', array( 'labels' => array( 'name' => __( 'oEmbed Responses' ), 'singular_name' => __( 'oEmbed Response' ), ), 'public' => false, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => false, 'can_export' => false, '_builtin' => true, 'supports' => array(), ) ); register_post_type( 'user_request', array( 'labels' => array( 'name' => __( 'User Requests' ), 'singular_name' => __( 'User Request' ), ), 'public' => false, '_builtin' => true, 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'can_export' => false, 'delete_with_user' => false, 'supports' => array(), ) ); register_post_type( 'wp_block', array( 'labels' => array( 'name' => _x( 'Reusable blocks', 'post type general name' ), 'singular_name' => _x( 'Reusable block', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Reusable block' ), 'add_new_item' => __( 'Add new Reusable block' ), 'new_item' => __( 'New Reusable block' ), 'edit_item' => __( 'Edit Reusable block' ), 'view_item' => __( 'View Reusable block' ), 'all_items' => __( 'All Reusable blocks' ), 'search_items' => __( 'Search Reusable blocks' ), 'not_found' => __( 'No reusable blocks found.' ), 'not_found_in_trash' => __( 'No reusable blocks found in Trash.' ), 'filter_items_list' => __( 'Filter reusable blocks list' ), 'items_list_navigation' => __( 'Reusable blocks list navigation' ), 'items_list' => __( 'Reusable blocks list' ), 'item_published' => __( 'Reusable block published.' ), 'item_published_privately' => __( 'Reusable block published privately.' ), 'item_reverted_to_draft' => __( 'Reusable block reverted to draft.' ), 'item_scheduled' => __( 'Reusable block scheduled.' ), 'item_updated' => __( 'Reusable block updated.' ), ), 'public' => false, '_builtin' => true, 'show_ui' => true, 'show_in_menu' => false, 'rewrite' => false, 'show_in_rest' => true, 'rest_base' => 'blocks', 'rest_controller_class' => 'WP_REST_Blocks_Controller', 'capability_type' => 'block', 'capabilities' => array( 'read' => 'edit_posts', 'create_posts' => 'publish_posts', 'edit_posts' => 'edit_posts', 'edit_published_posts' => 'edit_published_posts', 'delete_published_posts' => 'delete_published_posts', 'edit_others_posts' => 'edit_others_posts', 'delete_others_posts' => 'delete_others_posts', ), 'map_meta_cap' => true, 'supports' => array( 'title', 'editor', 'revisions', ), ) ); register_post_type( 'wp_template', array( 'labels' => array( 'name' => _x( 'Templates', 'post type general name' ), 'singular_name' => _x( 'Template', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Template' ), 'add_new_item' => __( 'Add New Template' ), 'new_item' => __( 'New Template' ), 'edit_item' => __( 'Edit Template' ), 'view_item' => __( 'View Template' ), 'all_items' => __( 'Templates' ), 'search_items' => __( 'Search Templates' ), 'parent_item_colon' => __( 'Parent Template:' ), 'not_found' => __( 'No templates found.' ), 'not_found_in_trash' => __( 'No templates found in Trash.' ), 'archives' => __( 'Template archives' ), 'insert_into_item' => __( 'Insert into template' ), 'uploaded_to_this_item' => __( 'Uploaded to this template' ), 'filter_items_list' => __( 'Filter templates list' ), 'items_list_navigation' => __( 'Templates list navigation' ), 'items_list' => __( 'Templates list' ), ), 'description' => __( 'Templates to include in your theme.' ), 'public' => false, '_builtin' => true, 'has_archive' => false, 'show_ui' => false, 'show_in_menu' => false, 'show_in_rest' => true, 'rewrite' => false, 'rest_base' => 'templates', 'rest_controller_class' => 'WP_REST_Templates_Controller', 'capability_type' => array( 'template', 'templates' ), 'capabilities' => array( 'create_posts' => 'edit_theme_options', 'delete_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', 'delete_private_posts' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'edit_private_posts' => 'edit_theme_options', 'edit_published_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read' => 'edit_theme_options', 'read_private_posts' => 'edit_theme_options', ), 'map_meta_cap' => true, 'supports' => array( 'title', 'slug', 'excerpt', 'editor', 'revisions', 'author', ), ) ); register_post_type( 'wp_template_part', array( 'labels' => array( 'name' => _x( 'Template Parts', 'post type general name' ), 'singular_name' => _x( 'Template Part', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Template Part' ), 'add_new_item' => __( 'Add New Template Part' ), 'new_item' => __( 'New Template Part' ), 'edit_item' => __( 'Edit Template Part' ), 'view_item' => __( 'View Template Part' ), 'all_items' => __( 'Template Parts' ), 'search_items' => __( 'Search Template Parts' ), 'parent_item_colon' => __( 'Parent Template Part:' ), 'not_found' => __( 'No template parts found.' ), 'not_found_in_trash' => __( 'No template parts found in Trash.' ), 'archives' => __( 'Template part archives' ), 'insert_into_item' => __( 'Insert into template part' ), 'uploaded_to_this_item' => __( 'Uploaded to this template part' ), 'filter_items_list' => __( 'Filter template parts list' ), 'items_list_navigation' => __( 'Template parts list navigation' ), 'items_list' => __( 'Template parts list' ), ), 'description' => __( 'Template parts to include in your templates.' ), 'public' => false, '_builtin' => true, 'has_archive' => false, 'show_ui' => false, 'show_in_menu' => false, 'show_in_rest' => true, 'rewrite' => false, 'rest_base' => 'template-parts', 'rest_controller_class' => 'WP_REST_Templates_Controller', 'map_meta_cap' => true, 'capabilities' => array( 'create_posts' => 'edit_theme_options', 'delete_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', 'delete_private_posts' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'edit_private_posts' => 'edit_theme_options', 'edit_published_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read' => 'edit_theme_options', 'read_private_posts' => 'edit_theme_options', ), 'supports' => array( 'title', 'slug', 'excerpt', 'editor', 'revisions', 'author', ), ) ); register_post_type( 'wp_global_styles', array( 'label' => _x( 'Global Styles', 'post type general name' ), 'description' => __( 'Global styles to include in themes.' ), 'public' => false, '_builtin' => true, 'show_ui' => false, 'show_in_rest' => false, 'rewrite' => false, 'capabilities' => array( 'read' => 'edit_theme_options', 'create_posts' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_published_posts' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', ), 'map_meta_cap' => true, 'supports' => array( 'title', 'editor', 'revisions', ), ) ); register_post_type( 'wp_navigation', array( 'labels' => array( 'name' => _x( 'Navigation Menus', 'post type general name' ), 'singular_name' => _x( 'Navigation Menu', 'post type singular name' ), 'add_new' => _x( 'Add New', 'Navigation Menu' ), 'add_new_item' => __( 'Add New Navigation Menu' ), 'new_item' => __( 'New Navigation Menu' ), 'edit_item' => __( 'Edit Navigation Menu' ), 'view_item' => __( 'View Navigation Menu' ), 'all_items' => __( 'Navigation Menus' ), 'search_items' => __( 'Search Navigation Menus' ), 'parent_item_colon' => __( 'Parent Navigation Menu:' ), 'not_found' => __( 'No Navigation Menu found.' ), 'not_found_in_trash' => __( 'No Navigation Menu found in Trash.' ), 'archives' => __( 'Navigation Menu archives' ), 'insert_into_item' => __( 'Insert into Navigation Menu' ), 'uploaded_to_this_item' => __( 'Uploaded to this Navigation Menu' ), 'filter_items_list' => __( 'Filter Navigation Menu list' ), 'items_list_navigation' => __( 'Navigation Menus list navigation' ), 'items_list' => __( 'Navigation Menus list' ), ), 'description' => __( 'Navigation menus that can be inserted into your site.' ), 'public' => false, '_builtin' => true, 'has_archive' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => false, 'show_in_rest' => true, 'rewrite' => false, 'map_meta_cap' => true, 'capabilities' => array( 'edit_others_posts' => 'edit_theme_options', 'delete_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'create_posts' => 'edit_theme_options', 'read_private_posts' => 'edit_theme_options', 'delete_private_posts' => 'edit_theme_options', 'delete_published_posts' => 'edit_theme_options', 'delete_others_posts' => 'edit_theme_options', 'edit_private_posts' => 'edit_theme_options', 'edit_published_posts' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', ), 'rest_base' => 'navigation', 'rest_controller_class' => 'WP_REST_Posts_Controller', 'supports' => array( 'title', 'editor', 'revisions', ), ) ); register_post_status( 'publish', array( 'label' => _x( 'Published', 'post status' ), 'public' => true, '_builtin' => true, 'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ), ) ); register_post_status( 'future', array( 'label' => _x( 'Scheduled', 'post status' ), 'protected' => true, '_builtin' => true, 'label_count' => _n_noop( 'Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ), ) ); register_post_status( 'draft', array( 'label' => _x( 'Draft', 'post status' ), 'protected' => true, '_builtin' => true, 'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ), 'date_floating' => true, ) ); register_post_status( 'pending', array( 'label' => _x( 'Pending', 'post status' ), 'protected' => true, '_builtin' => true, 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ), 'date_floating' => true, ) ); register_post_status( 'private', array( 'label' => _x( 'Private', 'post status' ), 'private' => true, '_builtin' => true, 'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ), ) ); register_post_status( 'trash', array( 'label' => _x( 'Trash', 'post status' ), 'internal' => true, '_builtin' => true, 'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ), 'show_in_admin_status_list' => true, ) ); register_post_status( 'auto-draft', array( 'label' => 'auto-draft', 'internal' => true, '_builtin' => true, 'date_floating' => true, ) ); register_post_status( 'inherit', array( 'label' => 'inherit', 'internal' => true, '_builtin' => true, 'exclude_from_search' => false, ) ); register_post_status( 'request-pending', array( 'label' => _x( 'Pending', 'request status' ), 'internal' => true, '_builtin' => true, 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ), 'exclude_from_search' => false, ) ); register_post_status( 'request-confirmed', array( 'label' => _x( 'Confirmed', 'request status' ), 'internal' => true, '_builtin' => true, 'label_count' => _n_noop( 'Confirmed <span class="count">(%s)</span>', 'Confirmed <span class="count">(%s)</span>' ), 'exclude_from_search' => false, ) ); register_post_status( 'request-failed', array( 'label' => _x( 'Failed', 'request status' ), 'internal' => true, '_builtin' => true, 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>' ), 'exclude_from_search' => false, ) ); register_post_status( 'request-completed', array( 'label' => _x( 'Completed', 'request status' ), 'internal' => true, '_builtin' => true, 'label_count' => _n_noop( 'Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>' ), 'exclude_from_search' => false, ) ); } function get_attached_file( $attachment_id, $unfiltered = false ) { $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) { $uploads = wp_get_upload_dir(); if ( false === $uploads['error'] ) { $file = $uploads['basedir'] . "/$file"; } } if ( $unfiltered ) { return $file; } return apply_filters( 'get_attached_file', $file, $attachment_id ); } function update_attached_file( $attachment_id, $file ) { if ( ! get_post( $attachment_id ) ) { return false; } $file = apply_filters( 'update_attached_file', $file, $attachment_id ); $file = _wp_relative_upload_path( $file ); if ( $file ) { return update_post_meta( $attachment_id, '_wp_attached_file', $file ); } else { return delete_post_meta( $attachment_id, '_wp_attached_file' ); } } function _wp_relative_upload_path( $path ) { $new_path = $path; $uploads = wp_get_upload_dir(); if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) { $new_path = str_replace( $uploads['basedir'], '', $new_path ); $new_path = ltrim( $new_path, '/' ); } return apply_filters( '_wp_relative_upload_path', $new_path, $path ); } function get_children( $args = '', $output = OBJECT ) { $kids = array(); if ( empty( $args ) ) { if ( isset( $GLOBALS['post'] ) ) { $args = array( 'post_parent' => (int) $GLOBALS['post']->post_parent ); } else { return $kids; } } elseif ( is_object( $args ) ) { $args = array( 'post_parent' => (int) $args->post_parent ); } elseif ( is_numeric( $args ) ) { $args = array( 'post_parent' => (int) $args ); } $defaults = array( 'numberposts' => -1, 'post_type' => 'any', 'post_status' => 'any', 'post_parent' => 0, ); $parsed_args = wp_parse_args( $args, $defaults ); $children = get_posts( $parsed_args ); if ( ! $children ) { return $kids; } if ( ! empty( $parsed_args['fields'] ) ) { return $children; } update_post_cache( $children ); foreach ( $children as $key => $child ) { $kids[ $child->ID ] = $children[ $key ]; } if ( OBJECT === $output ) { return $kids; } elseif ( ARRAY_A === $output ) { $weeuns = array(); foreach ( (array) $kids as $kid ) { $weeuns[ $kid->ID ] = get_object_vars( $kids[ $kid->ID ] ); } return $weeuns; } elseif ( ARRAY_N === $output ) { $babes = array(); foreach ( (array) $kids as $kid ) { $babes[ $kid->ID ] = array_values( get_object_vars( $kids[ $kid->ID ] ) ); } return $babes; } else { return $kids; } } function get_extended( $post ) { if ( preg_match( '/<!--more(.*?)?-->/', $post, $matches ) ) { list($main, $extended) = explode( $matches[0], $post, 2 ); $more_text = $matches[1]; } else { $main = $post; $extended = ''; $more_text = ''; } $main = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $main ); $extended = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $extended ); $more_text = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $more_text ); return array( 'main' => $main, 'extended' => $extended, 'more_text' => $more_text, ); } function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { if ( empty( $post ) && isset( $GLOBALS['post'] ) ) { $post = $GLOBALS['post']; } if ( $post instanceof WP_Post ) { $_post = $post; } elseif ( is_object( $post ) ) { if ( empty( $post->filter ) ) { $_post = sanitize_post( $post, 'raw' ); $_post = new WP_Post( $_post ); } elseif ( 'raw' === $post->filter ) { $_post = new WP_Post( $post ); } else { $_post = WP_Post::get_instance( $post->ID ); } } else { $_post = WP_Post::get_instance( $post ); } if ( ! $_post ) { return null; } $_post = $_post->filter( $filter ); if ( ARRAY_A === $output ) { return $_post->to_array(); } elseif ( ARRAY_N === $output ) { return array_values( $_post->to_array() ); } return $_post; } function get_post_ancestors( $post ) { $post = get_post( $post ); if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) { return array(); } $ancestors = array(); $id = $post->post_parent; $ancestors[] = $id; while ( $ancestor = get_post( $id ) ) { if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) { break; } $id = $ancestor->post_parent; $ancestors[] = $id; } return $ancestors; } function get_post_field( $field, $post = null, $context = 'display' ) { $post = get_post( $post ); if ( ! $post ) { return ''; } if ( ! isset( $post->$field ) ) { return ''; } return sanitize_post_field( $field, $post->$field, $post->ID, $context ); } function get_post_mime_type( $post = null ) { $post = get_post( $post ); if ( is_object( $post ) ) { return $post->post_mime_type; } return false; } function get_post_status( $post = null ) { $post = get_post( $post ); if ( ! is_object( $post ) ) { return false; } $post_status = $post->post_status; if ( 'attachment' === $post->post_type && 'inherit' === $post_status ) { if ( 0 === $post->post_parent || ! get_post( $post->post_parent ) || $post->ID === $post->post_parent ) { $post_status = 'publish'; } elseif ( 'trash' === get_post_status( $post->post_parent ) ) { $post_status = get_post_meta( $post->post_parent, '_wp_trash_meta_status', true ); if ( ! $post_status ) { $post_status = 'publish'; } } else { $post_status = get_post_status( $post->post_parent ); } } elseif ( 'attachment' === $post->post_type && ! in_array( $post_status, array( 'private', 'trash', 'auto-draft' ), true ) ) { $post_status = 'publish'; } return apply_filters( 'get_post_status', $post_status, $post ); } function get_post_statuses() { $status = array( 'draft' => __( 'Draft' ), 'pending' => __( 'Pending Review' ), 'private' => __( 'Private' ), 'publish' => __( 'Published' ), ); return $status; } function get_page_statuses() { $status = array( 'draft' => __( 'Draft' ), 'private' => __( 'Private' ), 'publish' => __( 'Published' ), ); return $status; } function _wp_privacy_statuses() { return array( 'request-pending' => _x( 'Pending', 'request status' ), 'request-confirmed' => _x( 'Confirmed', 'request status' ), 'request-failed' => _x( 'Failed', 'request status' ), 'request-completed' => _x( 'Completed', 'request status' ), ); } function register_post_status( $post_status, $args = array() ) { global $wp_post_statuses; if ( ! is_array( $wp_post_statuses ) ) { $wp_post_statuses = array(); } $defaults = array( 'label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'date_floating' => null, ); $args = wp_parse_args( $args, $defaults ); $args = (object) $args; $post_status = sanitize_key( $post_status ); $args->name = $post_status; if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) { $args->internal = true; } if ( null === $args->public ) { $args->public = false; } if ( null === $args->private ) { $args->private = false; } if ( null === $args->protected ) { $args->protected = false; } if ( null === $args->internal ) { $args->internal = false; } if ( null === $args->publicly_queryable ) { $args->publicly_queryable = $args->public; } if ( null === $args->exclude_from_search ) { $args->exclude_from_search = $args->internal; } if ( null === $args->show_in_admin_all_list ) { $args->show_in_admin_all_list = ! $args->internal; } if ( null === $args->show_in_admin_status_list ) { $args->show_in_admin_status_list = ! $args->internal; } if ( null === $args->date_floating ) { $args->date_floating = false; } if ( false === $args->label ) { $args->label = $post_status; } if ( false === $args->label_count ) { $args->label_count = _n_noop( $args->label, $args->label ); } $wp_post_statuses[ $post_status ] = $args; return $args; } function get_post_status_object( $post_status ) { global $wp_post_statuses; if ( empty( $wp_post_statuses[ $post_status ] ) ) { return null; } return $wp_post_statuses[ $post_status ]; } function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_statuses; $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field ); } function is_post_type_hierarchical( $post_type ) { if ( ! post_type_exists( $post_type ) ) { return false; } $post_type = get_post_type_object( $post_type ); return $post_type->hierarchical; } function post_type_exists( $post_type ) { return (bool) get_post_type_object( $post_type ); } function get_post_type( $post = null ) { $post = get_post( $post ); if ( $post ) { return $post->post_type; } return false; } function get_post_type_object( $post_type ) { global $wp_post_types; if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) { return null; } return $wp_post_types[ $post_type ]; } function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_types; $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_post_types, $args, $operator, $field ); } function register_post_type( $post_type, $args = array() ) { global $wp_post_types; if ( ! is_array( $wp_post_types ) ) { $wp_post_types = array(); } $post_type = sanitize_key( $post_type ); if ( empty( $post_type ) || strlen( $post_type ) > 20 ) { _doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2.0' ); return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) ); } $post_type_object = new WP_Post_Type( $post_type, $args ); $post_type_object->add_supports(); $post_type_object->add_rewrite_rules(); $post_type_object->register_meta_boxes(); $wp_post_types[ $post_type ] = $post_type_object; $post_type_object->add_hooks(); $post_type_object->register_taxonomies(); do_action( 'registered_post_type', $post_type, $post_type_object ); do_action( "registered_post_type_{$post_type}", $post_type, $post_type_object ); return $post_type_object; } function unregister_post_type( $post_type ) { global $wp_post_types; if ( ! post_type_exists( $post_type ) ) { return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) ); } $post_type_object = get_post_type_object( $post_type ); if ( $post_type_object->_builtin ) { return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) ); } $post_type_object->remove_supports(); $post_type_object->remove_rewrite_rules(); $post_type_object->unregister_meta_boxes(); $post_type_object->remove_hooks(); $post_type_object->unregister_taxonomies(); unset( $wp_post_types[ $post_type ] ); do_action( 'unregistered_post_type', $post_type ); return true; } function get_post_type_capabilities( $args ) { if ( ! is_array( $args->capability_type ) ) { $args->capability_type = array( $args->capability_type, $args->capability_type . 's' ); } list( $singular_base, $plural_base ) = $args->capability_type; $default_capabilities = array( 'edit_post' => 'edit_' . $singular_base, 'read_post' => 'read_' . $singular_base, 'delete_post' => 'delete_' . $singular_base, 'edit_posts' => 'edit_' . $plural_base, 'edit_others_posts' => 'edit_others_' . $plural_base, 'delete_posts' => 'delete_' . $plural_base, 'publish_posts' => 'publish_' . $plural_base, 'read_private_posts' => 'read_private_' . $plural_base, ); if ( $args->map_meta_cap ) { $default_capabilities_for_mapping = array( 'read' => 'read', 'delete_private_posts' => 'delete_private_' . $plural_base, 'delete_published_posts' => 'delete_published_' . $plural_base, 'delete_others_posts' => 'delete_others_' . $plural_base, 'edit_private_posts' => 'edit_private_' . $plural_base, 'edit_published_posts' => 'edit_published_' . $plural_base, ); $default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping ); } $capabilities = array_merge( $default_capabilities, $args->capabilities ); if ( ! isset( $capabilities['create_posts'] ) ) { $capabilities['create_posts'] = $capabilities['edit_posts']; } if ( $args->map_meta_cap ) { _post_type_meta_capabilities( $capabilities ); } return (object) $capabilities; } function _post_type_meta_capabilities( $capabilities = null ) { global $post_type_meta_caps; foreach ( $capabilities as $core => $custom ) { if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ), true ) ) { $post_type_meta_caps[ $custom ] = $core; } } } function get_post_type_labels( $post_type_object ) { $nohier_vs_hier_defaults = WP_Post_Type::get_default_labels(); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults ); $post_type = $post_type_object->name; $default_labels = clone $labels; $labels = apply_filters( "post_type_labels_{$post_type}", $labels ); $labels = (object) array_merge( (array) $default_labels, (array) $labels ); return $labels; } function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) { $data_object->labels = (array) $data_object->labels; if ( isset( $data_object->label ) && empty( $data_object->labels['name'] ) ) { $data_object->labels['name'] = $data_object->label; } if ( ! isset( $data_object->labels['singular_name'] ) && isset( $data_object->labels['name'] ) ) { $data_object->labels['singular_name'] = $data_object->labels['name']; } if ( ! isset( $data_object->labels['name_admin_bar'] ) ) { $data_object->labels['name_admin_bar'] = isset( $data_object->labels['singular_name'] ) ? $data_object->labels['singular_name'] : $data_object->name; } if ( ! isset( $data_object->labels['menu_name'] ) && isset( $data_object->labels['name'] ) ) { $data_object->labels['menu_name'] = $data_object->labels['name']; } if ( ! isset( $data_object->labels['all_items'] ) && isset( $data_object->labels['menu_name'] ) ) { $data_object->labels['all_items'] = $data_object->labels['menu_name']; } if ( ! isset( $data_object->labels['archives'] ) && isset( $data_object->labels['all_items'] ) ) { $data_object->labels['archives'] = $data_object->labels['all_items']; } $defaults = array(); foreach ( $nohier_vs_hier_defaults as $key => $value ) { $defaults[ $key ] = $data_object->hierarchical ? $value[1] : $value[0]; } $labels = array_merge( $defaults, $data_object->labels ); $data_object->labels = (object) $data_object->labels; return (object) $labels; } function _add_post_type_submenus() { foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) { $ptype_obj = get_post_type_object( $ptype ); if ( ! $ptype_obj->show_in_menu || true === $ptype_obj->show_in_menu ) { continue; } add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" ); } } function add_post_type_support( $post_type, $feature, ...$args ) { global $_wp_post_type_features; $features = (array) $feature; foreach ( $features as $feature ) { if ( $args ) { $_wp_post_type_features[ $post_type ][ $feature ] = $args; } else { $_wp_post_type_features[ $post_type ][ $feature ] = true; } } } function remove_post_type_support( $post_type, $feature ) { global $_wp_post_type_features; unset( $_wp_post_type_features[ $post_type ][ $feature ] ); } function get_all_post_type_supports( $post_type ) { global $_wp_post_type_features; if ( isset( $_wp_post_type_features[ $post_type ] ) ) { return $_wp_post_type_features[ $post_type ]; } return array(); } function post_type_supports( $post_type, $feature ) { global $_wp_post_type_features; return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) ); } function get_post_types_by_support( $feature, $operator = 'and' ) { global $_wp_post_type_features; $features = array_fill_keys( (array) $feature, true ); return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) ); } function set_post_type( $post_id = 0, $post_type = 'post' ) { global $wpdb; $post_type = sanitize_post_field( 'post_type', $post_type, $post_id, 'db' ); $return = $wpdb->update( $wpdb->posts, array( 'post_type' => $post_type ), array( 'ID' => $post_id ) ); clean_post_cache( $post_id ); return $return; } function is_post_type_viewable( $post_type ) { if ( is_scalar( $post_type ) ) { $post_type = get_post_type_object( $post_type ); if ( ! $post_type ) { return false; } } if ( ! is_object( $post_type ) ) { return false; } $is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type ); } function is_post_status_viewable( $post_status ) { if ( is_scalar( $post_status ) ) { $post_status = get_post_status_object( $post_status ); if ( ! $post_status ) { return false; } } if ( ! is_object( $post_status ) || $post_status->internal || $post_status->protected ) { return false; } $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status ); } function is_post_publicly_viewable( $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } $post_type = get_post_type( $post ); $post_status = get_post_status( $post ); return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status ); } function get_posts( $args = null ) { $defaults = array( 'numberposts' => 5, 'category' => 0, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'suppress_filters' => true, ); $parsed_args = wp_parse_args( $args, $defaults ); if ( empty( $parsed_args['post_status'] ) ) { $parsed_args['post_status'] = ( 'attachment' === $parsed_args['post_type'] ) ? 'inherit' : 'publish'; } if ( ! empty( $parsed_args['numberposts'] ) && empty( $parsed_args['posts_per_page'] ) ) { $parsed_args['posts_per_page'] = $parsed_args['numberposts']; } if ( ! empty( $parsed_args['category'] ) ) { $parsed_args['cat'] = $parsed_args['category']; } if ( ! empty( $parsed_args['include'] ) ) { $incposts = wp_parse_id_list( $parsed_args['include'] ); $parsed_args['posts_per_page'] = count( $incposts ); $parsed_args['post__in'] = $incposts; } elseif ( ! empty( $parsed_args['exclude'] ) ) { $parsed_args['post__not_in'] = wp_parse_id_list( $parsed_args['exclude'] ); } $parsed_args['ignore_sticky_posts'] = true; $parsed_args['no_found_rows'] = true; $get_posts = new WP_Query(); return $get_posts->query( $parsed_args ); } function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) { $the_post = wp_is_post_revision( $post_id ); if ( $the_post ) { $post_id = $the_post; } return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique ); } function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) { $the_post = wp_is_post_revision( $post_id ); if ( $the_post ) { $post_id = $the_post; } return delete_metadata( 'post', $post_id, $meta_key, $meta_value ); } function get_post_meta( $post_id, $key = '', $single = false ) { return get_metadata( 'post', $post_id, $key, $single ); } function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { $the_post = wp_is_post_revision( $post_id ); if ( $the_post ) { $post_id = $the_post; } return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value ); } function delete_post_meta_by_key( $post_meta_key ) { return delete_metadata( 'post', null, $post_meta_key, '', true ); } function register_post_meta( $post_type, $meta_key, array $args ) { $args['object_subtype'] = $post_type; return register_meta( 'post', $meta_key, $args ); } function unregister_post_meta( $post_type, $meta_key ) { return unregister_meta_key( 'post', $meta_key, $post_type ); } function get_post_custom( $post_id = 0 ) { $post_id = absint( $post_id ); if ( ! $post_id ) { $post_id = get_the_ID(); } return get_post_meta( $post_id ); } function get_post_custom_keys( $post_id = 0 ) { $custom = get_post_custom( $post_id ); if ( ! is_array( $custom ) ) { return; } $keys = array_keys( $custom ); if ( $keys ) { return $keys; } } function get_post_custom_values( $key = '', $post_id = 0 ) { if ( ! $key ) { return null; } $custom = get_post_custom( $post_id ); return isset( $custom[ $key ] ) ? $custom[ $key ] : null; } function is_sticky( $post_id = 0 ) { $post_id = absint( $post_id ); if ( ! $post_id ) { $post_id = get_the_ID(); } $stickies = get_option( 'sticky_posts' ); if ( is_array( $stickies ) ) { $stickies = array_map( 'intval', $stickies ); $is_sticky = in_array( $post_id, $stickies, true ); } else { $is_sticky = false; } return apply_filters( 'is_sticky', $is_sticky, $post_id ); } function sanitize_post( $post, $context = 'display' ) { if ( is_object( $post ) ) { if ( isset( $post->filter ) && $context == $post->filter ) { return $post; } if ( ! isset( $post->ID ) ) { $post->ID = 0; } foreach ( array_keys( get_object_vars( $post ) ) as $field ) { $post->$field = sanitize_post_field( $field, $post->$field, $post->ID, $context ); } $post->filter = $context; } elseif ( is_array( $post ) ) { if ( isset( $post['filter'] ) && $context == $post['filter'] ) { return $post; } if ( ! isset( $post['ID'] ) ) { $post['ID'] = 0; } foreach ( array_keys( $post ) as $field ) { $post[ $field ] = sanitize_post_field( $field, $post[ $field ], $post['ID'], $context ); } $post['filter'] = $context; } return $post; } function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { $int_fields = array( 'ID', 'post_parent', 'menu_order' ); if ( in_array( $field, $int_fields, true ) ) { $value = (int) $value; } $array_int_fields = array( 'ancestors' ); if ( in_array( $field, $array_int_fields, true ) ) { $value = array_map( 'absint', $value ); return $value; } if ( 'raw' === $context ) { return $value; } $prefixed = false; if ( false !== strpos( $field, 'post_' ) ) { $prefixed = true; $field_no_prefix = str_replace( 'post_', '', $field ); } if ( 'edit' === $context ) { $format_to_edit = array( 'post_content', 'post_excerpt', 'post_title', 'post_password' ); if ( $prefixed ) { $value = apply_filters( "edit_{$field}", $value, $post_id ); $value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id ); } else { $value = apply_filters( "edit_post_{$field}", $value, $post_id ); } if ( in_array( $field, $format_to_edit, true ) ) { if ( 'post_content' === $field ) { $value = format_to_edit( $value, user_can_richedit() ); } else { $value = format_to_edit( $value ); } } else { $value = esc_attr( $value ); } } elseif ( 'db' === $context ) { if ( $prefixed ) { $value = apply_filters( "pre_{$field}", $value ); $value = apply_filters( "{$field_no_prefix}_save_pre", $value ); } else { $value = apply_filters( "pre_post_{$field}", $value ); $value = apply_filters( "{$field}_pre", $value ); } } else { if ( $prefixed ) { $value = apply_filters( "{$field}", $value, $post_id, $context ); } else { $value = apply_filters( "post_{$field}", $value, $post_id, $context ); } if ( 'attribute' === $context ) { $value = esc_attr( $value ); } elseif ( 'js' === $context ) { $value = esc_js( $value ); } } if ( in_array( $field, $int_fields, true ) ) { $value = (int) $value; } return $value; } function stick_post( $post_id ) { $post_id = (int) $post_id; $stickies = get_option( 'sticky_posts' ); $updated = false; if ( ! is_array( $stickies ) ) { $stickies = array(); } else { $stickies = array_unique( array_map( 'intval', $stickies ) ); } if ( ! in_array( $post_id, $stickies, true ) ) { $stickies[] = $post_id; $updated = update_option( 'sticky_posts', array_values( $stickies ) ); } if ( $updated ) { do_action( 'post_stuck', $post_id ); } } function unstick_post( $post_id ) { $post_id = (int) $post_id; $stickies = get_option( 'sticky_posts' ); if ( ! is_array( $stickies ) ) { return; } $stickies = array_values( array_unique( array_map( 'intval', $stickies ) ) ); if ( ! in_array( $post_id, $stickies, true ) ) { return; } $offset = array_search( $post_id, $stickies, true ); if ( false === $offset ) { return; } array_splice( $stickies, $offset, 1 ); $updated = update_option( 'sticky_posts', $stickies ); if ( $updated ) { do_action( 'post_unstuck', $post_id ); } } function _count_posts_cache_key( $type = 'post', $perm = '' ) { $cache_key = 'posts-' . $type; if ( 'readable' === $perm && is_user_logged_in() ) { $post_type_object = get_post_type_object( $type ); if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) { $cache_key .= '_' . $perm . '_' . get_current_user_id(); } } return $cache_key; } function wp_count_posts( $type = 'post', $perm = '' ) { global $wpdb; if ( ! post_type_exists( $type ) ) { return new stdClass(); } $cache_key = _count_posts_cache_key( $type, $perm ); $counts = wp_cache_get( $cache_key, 'counts' ); if ( false !== $counts ) { foreach ( get_post_stati() as $status ) { if ( ! isset( $counts->{$status} ) ) { $counts->{$status} = 0; } } return apply_filters( 'wp_count_posts', $counts, $type, $perm ); } $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; if ( 'readable' === $perm && is_user_logged_in() ) { $post_type_object = get_post_type_object( $type ); if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) { $query .= $wpdb->prepare( " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", get_current_user_id() ); } } $query .= ' GROUP BY post_status'; $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); $counts = array_fill_keys( get_post_stati(), 0 ); foreach ( $results as $row ) { $counts[ $row['post_status'] ] = $row['num_posts']; } $counts = (object) $counts; wp_cache_set( $cache_key, $counts, 'counts' ); return apply_filters( 'wp_count_posts', $counts, $type, $perm ); } function wp_count_attachments( $mime_type = '' ) { global $wpdb; $cache_key = sprintf( 'attachments%s', ! empty( $mime_type ) ? ':' . str_replace( '/', '_', implode( '-', (array) $mime_type ) ) : '' ); $counts = wp_cache_get( $cache_key, 'counts' ); if ( false == $counts ) { $and = wp_post_mime_type_where( $mime_type ); $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A ); $counts = array(); foreach ( (array) $count as $row ) { $counts[ $row['post_mime_type'] ] = $row['num_posts']; } $counts['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and" ); wp_cache_set( $cache_key, (object) $counts, 'counts' ); } return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type ); } function get_post_mime_types() { $post_mime_types = array( 'image' => array( __( 'Images' ), __( 'Manage Images' ), _n_noop( 'Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>' ), ), 'audio' => array( _x( 'Audio', 'file type group' ), __( 'Manage Audio' ), _n_noop( 'Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>' ), ), 'video' => array( _x( 'Video', 'file type group' ), __( 'Manage Video' ), _n_noop( 'Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>' ), ), 'document' => array( __( 'Documents' ), __( 'Manage Documents' ), _n_noop( 'Document <span class="count">(%s)</span>', 'Documents <span class="count">(%s)</span>' ), ), 'spreadsheet' => array( __( 'Spreadsheets' ), __( 'Manage Spreadsheets' ), _n_noop( 'Spreadsheet <span class="count">(%s)</span>', 'Spreadsheets <span class="count">(%s)</span>' ), ), 'archive' => array( _x( 'Archives', 'file type group' ), __( 'Manage Archives' ), _n_noop( 'Archive <span class="count">(%s)</span>', 'Archives <span class="count">(%s)</span>' ), ), ); $ext_types = wp_get_ext_types(); $mime_types = wp_get_mime_types(); foreach ( $post_mime_types as $group => $labels ) { if ( in_array( $group, array( 'image', 'audio', 'video' ), true ) ) { continue; } if ( ! isset( $ext_types[ $group ] ) ) { unset( $post_mime_types[ $group ] ); continue; } $group_mime_types = array(); foreach ( $ext_types[ $group ] as $extension ) { foreach ( $mime_types as $exts => $mime ) { if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { $group_mime_types[] = $mime; break; } } } $group_mime_types = implode( ',', array_unique( $group_mime_types ) ); $post_mime_types[ $group_mime_types ] = $labels; unset( $post_mime_types[ $group ] ); } return apply_filters( 'post_mime_types', $post_mime_types ); } function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) { $matches = array(); if ( is_string( $wildcard_mime_types ) ) { $wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) ); } if ( is_string( $real_mime_types ) ) { $real_mime_types = array_map( 'trim', explode( ',', $real_mime_types ) ); } $patternses = array(); $wild = '[-._a-z0-9]*'; foreach ( (array) $wildcard_mime_types as $type ) { $mimes = array_map( 'trim', explode( ',', $type ) ); foreach ( $mimes as $mime ) { $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) ); $patternses[][ $type ] = "^$regex$"; if ( false === strpos( $mime, '/' ) ) { $patternses[][ $type ] = "^$regex/"; $patternses[][ $type ] = $regex; } } } asort( $patternses ); foreach ( $patternses as $patterns ) { foreach ( $patterns as $type => $pattern ) { foreach ( (array) $real_mime_types as $real ) { if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[ $type ] ) || false === array_search( $real, $matches[ $type ], true ) ) ) { $matches[ $type ][] = $real; } } } } return $matches; } function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) { $where = ''; $wildcards = array( '', '%', '%/%' ); if ( is_string( $post_mime_types ) ) { $post_mime_types = array_map( 'trim', explode( ',', $post_mime_types ) ); } $wheres = array(); foreach ( (array) $post_mime_types as $mime_type ) { $mime_type = preg_replace( '/\s/', '', $mime_type ); $slashpos = strpos( $mime_type, '/' ); if ( false !== $slashpos ) { $mime_group = preg_replace( '/[^-*.a-zA-Z0-9]/', '', substr( $mime_type, 0, $slashpos ) ); $mime_subgroup = preg_replace( '/[^-*.+a-zA-Z0-9]/', '', substr( $mime_type, $slashpos + 1 ) ); if ( empty( $mime_subgroup ) ) { $mime_subgroup = '*'; } else { $mime_subgroup = str_replace( '/', '', $mime_subgroup ); } $mime_pattern = "$mime_group/$mime_subgroup"; } else { $mime_pattern = preg_replace( '/[^-*.a-zA-Z0-9]/', '', $mime_type ); if ( false === strpos( $mime_pattern, '*' ) ) { $mime_pattern .= '/*'; } } $mime_pattern = preg_replace( '/\*+/', '%', $mime_pattern ); if ( in_array( $mime_type, $wildcards, true ) ) { return ''; } if ( false !== strpos( $mime_pattern, '%' ) ) { $wheres[] = empty( $table_alias ) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'"; } else { $wheres[] = empty( $table_alias ) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'"; } } if ( ! empty( $wheres ) ) { $where = ' AND (' . implode( ' OR ', $wheres ) . ') '; } return $where; } function wp_delete_post( $postid = 0, $force_delete = false ) { global $wpdb; $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $postid ) ); if ( ! $post ) { return $post; } $post = get_post( $post ); if ( ! $force_delete && ( 'post' === $post->post_type || 'page' === $post->post_type ) && 'trash' !== get_post_status( $postid ) && EMPTY_TRASH_DAYS ) { return wp_trash_post( $postid ); } if ( 'attachment' === $post->post_type ) { return wp_delete_attachment( $postid, $force_delete ); } $check = apply_filters( 'pre_delete_post', null, $post, $force_delete ); if ( null !== $check ) { return $check; } do_action( 'before_delete_post', $postid, $post ); delete_post_meta( $postid, '_wp_trash_meta_status' ); delete_post_meta( $postid, '_wp_trash_meta_time' ); wp_delete_object_term_relationships( $postid, get_object_taxonomies( $post->post_type ) ); $parent_data = array( 'post_parent' => $post->post_parent ); $parent_where = array( 'post_parent' => $postid ); if ( is_post_type_hierarchical( $post->post_type ) ) { $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type ); $children = $wpdb->get_results( $children_query ); if ( $children ) { $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) ); } } $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) ); foreach ( $revision_ids as $revision_id ) { wp_delete_post_revision( $revision_id ); } $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) ); wp_defer_comment_counting( true ); $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $postid ) ); foreach ( $comment_ids as $comment_id ) { wp_delete_comment( $comment_id, true ); } wp_defer_comment_counting( false ); $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ) ); foreach ( $post_meta_ids as $mid ) { delete_metadata_by_mid( 'post', $mid ); } do_action( 'delete_post', $postid, $post ); $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); if ( ! $result ) { return false; } do_action( 'deleted_post', $postid, $post ); clean_post_cache( $post ); if ( is_post_type_hierarchical( $post->post_type ) && $children ) { foreach ( $children as $child ) { clean_post_cache( $child ); } } wp_clear_scheduled_hook( 'publish_future_post', array( $postid ) ); do_action( 'after_delete_post', $postid, $post ); return $post; } function _reset_front_page_settings_for_post( $post_id ) { $post = get_post( $post_id ); if ( 'page' === $post->post_type ) { if ( get_option( 'page_on_front' ) == $post->ID ) { update_option( 'show_on_front', 'posts' ); update_option( 'page_on_front', 0 ); } if ( get_option( 'page_for_posts' ) == $post->ID ) { update_option( 'page_for_posts', 0 ); } } unstick_post( $post->ID ); } function wp_trash_post( $post_id = 0 ) { if ( ! EMPTY_TRASH_DAYS ) { return wp_delete_post( $post_id, true ); } $post = get_post( $post_id ); if ( ! $post ) { return $post; } if ( 'trash' === $post->post_status ) { return false; } $check = apply_filters( 'pre_trash_post', null, $post ); if ( null !== $check ) { return $check; } do_action( 'wp_trash_post', $post_id ); add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status ); add_post_meta( $post_id, '_wp_trash_meta_time', time() ); $post_updated = wp_update_post( array( 'ID' => $post_id, 'post_status' => 'trash', ) ); if ( ! $post_updated ) { return false; } wp_trash_post_comments( $post_id ); do_action( 'trashed_post', $post_id ); return $post; } function wp_untrash_post( $post_id = 0 ) { $post = get_post( $post_id ); if ( ! $post ) { return $post; } $post_id = $post->ID; if ( 'trash' !== $post->post_status ) { return false; } $previous_status = get_post_meta( $post_id, '_wp_trash_meta_status', true ); $check = apply_filters( 'pre_untrash_post', null, $post, $previous_status ); if ( null !== $check ) { return $check; } do_action( 'untrash_post', $post_id, $previous_status ); $new_status = ( 'attachment' === $post->post_type ) ? 'inherit' : 'draft'; $post_status = apply_filters( 'wp_untrash_post_status', $new_status, $post_id, $previous_status ); delete_post_meta( $post_id, '_wp_trash_meta_status' ); delete_post_meta( $post_id, '_wp_trash_meta_time' ); $post_updated = wp_update_post( array( 'ID' => $post_id, 'post_status' => $post_status, ) ); if ( ! $post_updated ) { return false; } wp_untrash_post_comments( $post_id ); do_action( 'untrashed_post', $post_id, $previous_status ); return $post; } function wp_trash_post_comments( $post = null ) { global $wpdb; $post = get_post( $post ); if ( ! $post ) { return; } $post_id = $post->ID; do_action( 'trash_post_comments', $post_id ); $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) ); if ( ! $comments ) { return; } $statuses = array(); foreach ( $comments as $comment ) { $statuses[ $comment->comment_ID ] = $comment->comment_approved; } add_post_meta( $post_id, '_wp_trash_meta_comments_status', $statuses ); $result = $wpdb->update( $wpdb->comments, array( 'comment_approved' => 'post-trashed' ), array( 'comment_post_ID' => $post_id ) ); clean_comment_cache( array_keys( $statuses ) ); do_action( 'trashed_post_comments', $post_id, $statuses ); return $result; } function wp_untrash_post_comments( $post = null ) { global $wpdb; $post = get_post( $post ); if ( ! $post ) { return; } $post_id = $post->ID; $statuses = get_post_meta( $post_id, '_wp_trash_meta_comments_status', true ); if ( ! $statuses ) { return true; } do_action( 'untrash_post_comments', $post_id ); $group_by_status = array(); foreach ( $statuses as $comment_id => $comment_status ) { $group_by_status[ $comment_status ][] = $comment_id; } foreach ( $group_by_status as $status => $comments ) { if ( 'post-trashed' === $status ) { $status = '0'; } $comments_in = implode( ', ', array_map( 'intval', $comments ) ); $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status ) ); } clean_comment_cache( array_keys( $statuses ) ); delete_post_meta( $post_id, '_wp_trash_meta_comments_status' ); do_action( 'untrashed_post_comments', $post_id ); } function wp_get_post_categories( $post_id = 0, $args = array() ) { $post_id = (int) $post_id; $defaults = array( 'fields' => 'ids' ); $args = wp_parse_args( $args, $defaults ); $cats = wp_get_object_terms( $post_id, 'category', $args ); return $cats; } function wp_get_post_tags( $post_id = 0, $args = array() ) { return wp_get_post_terms( $post_id, 'post_tag', $args ); } function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { $post_id = (int) $post_id; $defaults = array( 'fields' => 'all' ); $args = wp_parse_args( $args, $defaults ); $tags = wp_get_object_terms( $post_id, $taxonomy, $args ); return $tags; } function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) { if ( is_numeric( $args ) ) { _deprecated_argument( __FUNCTION__, '3.1.0', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) ); $args = array( 'numberposts' => absint( $args ) ); } $defaults = array( 'numberposts' => 10, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private', 'suppress_filters' => true, ); $parsed_args = wp_parse_args( $args, $defaults ); $results = get_posts( $parsed_args ); if ( ARRAY_A === $output ) { foreach ( $results as $key => $result ) { $results[ $key ] = get_object_vars( $result ); } return $results ? $results : array(); } return $results ? $results : false; } function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) { global $wpdb; $unsanitized_postarr = $postarr; $user_id = get_current_user_id(); $defaults = array( 'post_author' => $user_id, 'post_content' => '', 'post_content_filtered' => '', 'post_title' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => '', 'ping_status' => '', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => '', 'import_id' => 0, 'context' => '', 'post_date' => '', 'post_date_gmt' => '', ); $postarr = wp_parse_args( $postarr, $defaults ); unset( $postarr['filter'] ); $postarr = sanitize_post( $postarr, 'db' ); $post_ID = 0; $update = false; $guid = $postarr['guid']; if ( ! empty( $postarr['ID'] ) ) { $update = true; $post_ID = $postarr['ID']; $post_before = get_post( $post_ID ); if ( is_null( $post_before ) ) { if ( $wp_error ) { return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); } return 0; } $guid = get_post_field( 'guid', $post_ID ); $previous_status = get_post_field( 'post_status', $post_ID ); } else { $previous_status = 'new'; $post_before = null; } $post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type']; $post_title = $postarr['post_title']; $post_content = $postarr['post_content']; $post_excerpt = $postarr['post_excerpt']; if ( isset( $postarr['post_name'] ) ) { $post_name = $postarr['post_name']; } elseif ( $update ) { $post_name = $post_before->post_name; } $maybe_empty = 'attachment' !== $post_type && ! $post_content && ! $post_title && ! $post_excerpt && post_type_supports( $post_type, 'editor' ) && post_type_supports( $post_type, 'title' ) && post_type_supports( $post_type, 'excerpt' ); if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) { if ( $wp_error ) { return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) ); } else { return 0; } } $post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status']; if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash', 'auto-draft' ), true ) ) { $post_status = 'inherit'; } if ( ! empty( $postarr['post_category'] ) ) { $post_category = array_filter( $postarr['post_category'] ); } elseif ( $update && ! isset( $postarr['post_category'] ) ) { $post_category = $post_before->post_category; } if ( empty( $post_category ) || 0 === count( $post_category ) || ! is_array( $post_category ) ) { if ( 'post' === $post_type && 'auto-draft' !== $post_status ) { $post_category = array( get_option( 'default_category' ) ); } else { $post_category = array(); } } if ( 'pending' === $post_status ) { $post_type_object = get_post_type_object( $post_type ); if ( ! $update && $post_type_object && ! current_user_can( $post_type_object->cap->publish_posts ) ) { $post_name = ''; } elseif ( $update && ! current_user_can( 'publish_post', $post_ID ) ) { $post_name = ''; } } if ( empty( $post_name ) ) { if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) ) { $post_name = sanitize_title( $post_title ); } else { $post_name = ''; } } else { $check_name = sanitize_title( $post_name, '', 'old-save' ); if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) { $post_name = $check_name; } else { $post_name = sanitize_title( $post_name ); } } $post_date = wp_resolve_post_date( $postarr['post_date'], $postarr['post_date_gmt'] ); if ( ! $post_date ) { if ( $wp_error ) { return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); } else { return 0; } } if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' === $postarr['post_date_gmt'] ) { if ( ! in_array( $post_status, get_post_stati( array( 'date_floating' => true ) ), true ) ) { $post_date_gmt = get_gmt_from_date( $post_date ); } else { $post_date_gmt = '0000-00-00 00:00:00'; } } else { $post_date_gmt = $postarr['post_date_gmt']; } if ( $update || '0000-00-00 00:00:00' === $post_date ) { $post_modified = current_time( 'mysql' ); $post_modified_gmt = current_time( 'mysql', 1 ); } else { $post_modified = $post_date; $post_modified_gmt = $post_date_gmt; } if ( 'attachment' !== $post_type ) { $now = gmdate( 'Y-m-d H:i:s' ); if ( 'publish' === $post_status ) { if ( strtotime( $post_date_gmt ) - strtotime( $now ) >= MINUTE_IN_SECONDS ) { $post_status = 'future'; } } elseif ( 'future' === $post_status ) { if ( strtotime( $post_date_gmt ) - strtotime( $now ) < MINUTE_IN_SECONDS ) { $post_status = 'publish'; } } } if ( empty( $postarr['comment_status'] ) ) { if ( $update ) { $comment_status = 'closed'; } else { $comment_status = get_default_comment_status( $post_type ); } } else { $comment_status = $postarr['comment_status']; } $post_content_filtered = $postarr['post_content_filtered']; $post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id; $ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status']; $to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : ''; $pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : ''; $import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0; if ( isset( $postarr['menu_order'] ) ) { $menu_order = (int) $postarr['menu_order']; } else { $menu_order = 0; } $post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : ''; if ( 'private' === $post_status ) { $post_password = ''; } if ( isset( $postarr['post_parent'] ) ) { $post_parent = (int) $postarr['post_parent']; } else { $post_parent = 0; } $new_postarr = array_merge( array( 'ID' => $post_ID, ), compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) ) ); $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr ); if ( 'trash' === $previous_status && 'trash' !== $post_status ) { $desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true ); if ( $desired_post_slug ) { delete_post_meta( $post_ID, '_wp_desired_post_slug' ); $post_name = $desired_post_slug; } } if ( 'trash' !== $post_status && $post_name ) { $add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_ID ); if ( $add_trashed_suffix ) { wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID ); } } if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) { $post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID ); } $post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent ); $post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : ''; $data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ); $emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' ); foreach ( $emoji_fields as $emoji_field ) { if ( isset( $data[ $emoji_field ] ) ) { $charset = $wpdb->get_col_charset( $wpdb->posts, $emoji_field ); if ( 'utf8' === $charset ) { $data[ $emoji_field ] = wp_encode_emoji( $data[ $emoji_field ] ); } } } if ( 'attachment' === $post_type ) { $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr, $unsanitized_postarr, $update ); } else { $data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr, $update ); } $data = wp_unslash( $data ); $where = array( 'ID' => $post_ID ); if ( $update ) { do_action( 'pre_post_update', $post_ID, $data ); if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) { if ( $wp_error ) { if ( 'attachment' === $post_type ) { $message = __( 'Could not update attachment in the database.' ); } else { $message = __( 'Could not update post in the database.' ); } return new WP_Error( 'db_update_error', $message, $wpdb->last_error ); } else { return 0; } } } else { if ( ! empty( $import_id ) ) { $import_id = (int) $import_id; if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id ) ) ) { $data['ID'] = $import_id; } } if ( false === $wpdb->insert( $wpdb->posts, $data ) ) { if ( $wp_error ) { if ( 'attachment' === $post_type ) { $message = __( 'Could not insert attachment into the database.' ); } else { $message = __( 'Could not insert post into the database.' ); } return new WP_Error( 'db_insert_error', $message, $wpdb->last_error ); } else { return 0; } } $post_ID = (int) $wpdb->insert_id; $where = array( 'ID' => $post_ID ); } if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) { $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent ); $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); clean_post_cache( $post_ID ); } if ( is_object_in_taxonomy( $post_type, 'category' ) ) { wp_set_post_categories( $post_ID, $post_category ); } if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) { wp_set_post_tags( $post_ID, $postarr['tags_input'] ); } if ( 'auto-draft' !== $post_status ) { foreach ( get_object_taxonomies( $post_type, 'object' ) as $taxonomy => $tax_object ) { if ( ! empty( $tax_object->default_term ) ) { if ( isset( $postarr['tax_input'][ $taxonomy ] ) && is_array( $postarr['tax_input'][ $taxonomy ] ) ) { $postarr['tax_input'][ $taxonomy ] = array_filter( $postarr['tax_input'][ $taxonomy ] ); } $terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) ); if ( ! empty( $terms ) && empty( $postarr['tax_input'][ $taxonomy ] ) ) { $postarr['tax_input'][ $taxonomy ] = $terms; } if ( empty( $postarr['tax_input'][ $taxonomy ] ) ) { $default_term_id = get_option( 'default_term_' . $taxonomy ); if ( ! empty( $default_term_id ) ) { $postarr['tax_input'][ $taxonomy ] = array( (int) $default_term_id ); } } } } } if ( ! empty( $postarr['tax_input'] ) ) { foreach ( $postarr['tax_input'] as $taxonomy => $tags ) { $taxonomy_obj = get_taxonomy( $taxonomy ); if ( ! $taxonomy_obj ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid taxonomy: %s.' ), $taxonomy ), '4.4.0' ); continue; } if ( is_array( $tags ) ) { $tags = array_filter( $tags ); } if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) { wp_set_post_terms( $post_ID, $tags, $taxonomy ); } } } if ( ! empty( $postarr['meta_input'] ) ) { foreach ( $postarr['meta_input'] as $field => $value ) { update_post_meta( $post_ID, $field, $value ); } } $current_guid = get_post_field( 'guid', $post_ID ); if ( ! $update && '' === $current_guid ) { $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where ); } if ( 'attachment' === $postarr['post_type'] ) { if ( ! empty( $postarr['file'] ) ) { update_attached_file( $post_ID, $postarr['file'] ); } if ( ! empty( $postarr['context'] ) ) { add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true ); } } if ( isset( $postarr['_thumbnail_id'] ) ) { $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type; if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) { if ( wp_attachment_is( 'audio', $post_ID ) ) { $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); } elseif ( wp_attachment_is( 'video', $post_ID ) ) { $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); } } if ( $thumbnail_support ) { $thumbnail_id = (int) $postarr['_thumbnail_id']; if ( -1 === $thumbnail_id ) { delete_post_thumbnail( $post_ID ); } else { set_post_thumbnail( $post_ID, $thumbnail_id ); } } } clean_post_cache( $post_ID ); $post = get_post( $post_ID ); if ( ! empty( $postarr['page_template'] ) ) { $post->page_template = $postarr['page_template']; $page_templates = wp_get_theme()->get_page_templates( $post ); if ( 'default' !== $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) { if ( $wp_error ) { return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) ); } update_post_meta( $post_ID, '_wp_page_template', 'default' ); } else { update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] ); } } if ( 'attachment' !== $postarr['post_type'] ) { wp_transition_post_status( $data['post_status'], $previous_status, $post ); } else { if ( $update ) { do_action( 'edit_attachment', $post_ID ); $post_after = get_post( $post_ID ); do_action( 'attachment_updated', $post_ID, $post_after, $post_before ); } else { do_action( 'add_attachment', $post_ID ); } return $post_ID; } if ( $update ) { do_action( "edit_post_{$post->post_type}", $post_ID, $post ); do_action( 'edit_post', $post_ID, $post ); $post_after = get_post( $post_ID ); do_action( 'post_updated', $post_ID, $post_after, $post_before ); } do_action( "save_post_{$post->post_type}", $post_ID, $post, $update ); do_action( 'save_post', $post_ID, $post, $update ); do_action( 'wp_insert_post', $post_ID, $post, $update ); if ( $fire_after_hooks ) { wp_after_insert_post( $post, $update, $post_before ); } return $post_ID; } function wp_update_post( $postarr = array(), $wp_error = false, $fire_after_hooks = true ) { if ( is_object( $postarr ) ) { $postarr = get_object_vars( $postarr ); $postarr = wp_slash( $postarr ); } $post = get_post( $postarr['ID'], ARRAY_A ); if ( is_null( $post ) ) { if ( $wp_error ) { return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) ); } return 0; } $post = wp_slash( $post ); if ( isset( $postarr['post_category'] ) && is_array( $postarr['post_category'] ) && count( $postarr['post_category'] ) > 0 ) { $post_cats = $postarr['post_category']; } else { $post_cats = $post['post_category']; } if ( isset( $post['post_status'] ) && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) && empty( $postarr['edit_date'] ) && ( '0000-00-00 00:00:00' === $post['post_date_gmt'] ) ) { $clear_date = true; } else { $clear_date = false; } $postarr = array_merge( $post, $postarr ); $postarr['post_category'] = $post_cats; if ( $clear_date ) { $postarr['post_date'] = current_time( 'mysql' ); $postarr['post_date_gmt'] = ''; } if ( 'attachment' === $postarr['post_type'] ) { return wp_insert_attachment( $postarr, false, 0, $wp_error ); } if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $postarr['post_type'], 'post_tag' ) ) { $tags = get_the_terms( $postarr['ID'], 'post_tag' ); $tag_names = array(); if ( $tags && ! is_wp_error( $tags ) ) { $tag_names = wp_list_pluck( $tags, 'name' ); } if ( $postarr['tags_input'] === $tag_names ) { unset( $postarr['tags_input'] ); } } return wp_insert_post( $postarr, $wp_error, $fire_after_hooks ); } function wp_publish_post( $post ) { global $wpdb; $post = get_post( $post ); if ( ! $post ) { return; } if ( 'publish' === $post->post_status ) { return; } $post_before = get_post( $post->ID ); foreach ( get_object_taxonomies( $post->post_type, 'object' ) as $taxonomy => $tax_object ) { if ( 'category' !== $taxonomy && empty( $tax_object->default_term ) ) { continue; } if ( ! empty( get_the_terms( $post, $taxonomy ) ) ) { continue; } if ( 'category' === $taxonomy ) { $default_term_id = (int) get_option( 'default_category', 0 ); } else { $default_term_id = (int) get_option( 'default_term_' . $taxonomy, 0 ); } if ( ! $default_term_id ) { continue; } wp_set_post_terms( $post->ID, array( $default_term_id ), $taxonomy ); } $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $old_status = $post->post_status; $post->post_status = 'publish'; wp_transition_post_status( 'publish', $old_status, $post ); do_action( "edit_post_{$post->post_type}", $post->ID, $post ); do_action( 'edit_post', $post->ID, $post ); do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); do_action( 'save_post', $post->ID, $post, true ); do_action( 'wp_insert_post', $post->ID, $post, true ); wp_after_insert_post( $post, true, $post_before ); } function check_and_publish_future_post( $post ) { $post = get_post( $post ); if ( ! $post ) { return; } if ( 'future' !== $post->post_status ) { return; } $time = strtotime( $post->post_date_gmt . ' GMT' ); if ( $time > time() ) { wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); wp_schedule_single_event( $time, 'publish_future_post', array( $post->ID ) ); return; } wp_publish_post( $post->ID ); } function wp_resolve_post_date( $post_date = '', $post_date_gmt = '' ) { if ( empty( $post_date ) || '0000-00-00 00:00:00' === $post_date ) { if ( empty( $post_date_gmt ) || '0000-00-00 00:00:00' === $post_date_gmt ) { $post_date = current_time( 'mysql' ); } else { $post_date = get_date_from_gmt( $post_date_gmt ); } } $month = (int) substr( $post_date, 5, 2 ); $day = (int) substr( $post_date, 8, 2 ); $year = (int) substr( $post_date, 0, 4 ); $valid_date = wp_checkdate( $month, $day, $year, $post_date ); if ( ! $valid_date ) { return false; } return $post_date; } function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) || ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type ) { return $slug; } $override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_ID, $post_status, $post_type, $post_parent ); if ( null !== $override_slug ) { return $override_slug; } global $wpdb, $wp_rewrite; $original_slug = $slug; $feeds = $wp_rewrite->feeds; if ( ! is_array( $feeds ) ) { $feeds = array(); } if ( 'attachment' === $post_type ) { $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); $is_bad_attachment_slug = apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ); if ( $post_name_check || in_array( $slug, $feeds, true ) || 'embed' === $slug || $is_bad_attachment_slug ) { $suffix = 2; do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) ); $suffix++; } while ( $post_name_check ); $slug = $alt_post_name; } } elseif ( is_post_type_hierarchical( $post_type ) ) { if ( 'nav_menu_item' === $post_type ) { return $slug; } $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) ); $is_bad_hierarchical_slug = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ); if ( $post_name_check || in_array( $slug, $feeds, true ) || 'embed' === $slug || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || $is_bad_hierarchical_slug ) { $suffix = 2; do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) ); $suffix++; } while ( $post_name_check ); $slug = $alt_post_name; } } else { $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); $post = get_post( $post_ID ); $conflicts_with_date_archive = false; if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) { $slug_num = (int) $slug; if ( $slug_num ) { $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); $postname_index = array_search( '%postname%', $permastructs, true ); if ( 0 === $postname_index || ( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) || ( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num ) ) { $conflicts_with_date_archive = true; } } } $is_bad_flat_slug = apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ); if ( $post_name_check || in_array( $slug, $feeds, true ) || 'embed' === $slug || $conflicts_with_date_archive || $is_bad_flat_slug ) { $suffix = 2; do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); $suffix++; } while ( $post_name_check ); $slug = $alt_post_name; } } return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ); } function _truncate_post_slug( $slug, $length = 200 ) { if ( strlen( $slug ) > $length ) { $decoded_slug = urldecode( $slug ); if ( $decoded_slug === $slug ) { $slug = substr( $slug, 0, $length ); } else { $slug = utf8_uri_encode( $decoded_slug, $length, true ); } } return rtrim( $slug, '-' ); } function wp_add_post_tags( $post_id = 0, $tags = '' ) { return wp_set_post_tags( $post_id, $tags, true ); } function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { return wp_set_post_terms( $post_id, $tags, 'post_tag', $append ); } function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $append = false ) { $post_id = (int) $post_id; if ( ! $post_id ) { return false; } if ( empty( $terms ) ) { $terms = array(); } if ( ! is_array( $terms ) ) { $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { $terms = str_replace( $comma, ',', $terms ); } $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); } if ( is_taxonomy_hierarchical( $taxonomy ) ) { $terms = array_unique( array_map( 'intval', $terms ) ); } return wp_set_object_terms( $post_id, $terms, $taxonomy, $append ); } function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) { $post_ID = (int) $post_ID; $post_type = get_post_type( $post_ID ); $post_status = get_post_status( $post_ID ); $post_categories = (array) $post_categories; if ( empty( $post_categories ) ) { $default_category_post_types = apply_filters( 'default_category_post_types', array() ); $default_category_post_types = array_merge( $default_category_post_types, array( 'post' ) ); if ( in_array( $post_type, $default_category_post_types, true ) && is_object_in_taxonomy( $post_type, 'category' ) && 'auto-draft' !== $post_status ) { $post_categories = array( get_option( 'default_category' ) ); $append = false; } else { $post_categories = array(); } } elseif ( 1 === count( $post_categories ) && '' === reset( $post_categories ) ) { return true; } return wp_set_post_terms( $post_ID, $post_categories, 'category', $append ); } function wp_transition_post_status( $new_status, $old_status, $post ) { do_action( 'transition_post_status', $new_status, $old_status, $post ); do_action( "{$old_status}_to_{$new_status}", $post ); do_action( "{$new_status}_{$post->post_type}", $post->ID, $post, $old_status ); } function wp_after_insert_post( $post, $update, $post_before ) { $post = get_post( $post ); if ( ! $post ) { return; } $post_id = $post->ID; do_action( 'wp_after_insert_post', $post_id, $post, $update, $post_before ); } function add_ping( $post, $uri ) { global $wpdb; $post = get_post( $post ); if ( ! $post ) { return false; } $pung = trim( $post->pinged ); $pung = preg_split( '/\s/', $pung ); if ( is_array( $uri ) ) { $pung = array_merge( $pung, $uri ); } else { $pung[] = $uri; } $new = implode( "\n", $pung ); $new = apply_filters( 'add_ping', $new ); $return = $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); return $return; } function get_enclosed( $post_id ) { $custom_fields = get_post_custom( $post_id ); $pung = array(); if ( ! is_array( $custom_fields ) ) { return $pung; } foreach ( $custom_fields as $key => $val ) { if ( 'enclosure' !== $key || ! is_array( $val ) ) { continue; } foreach ( $val as $enc ) { $enclosure = explode( "\n", $enc ); $pung[] = trim( $enclosure[0] ); } } return apply_filters( 'get_enclosed', $pung, $post_id ); } function get_pung( $post ) { $post = get_post( $post ); if ( ! $post ) { return false; } $pung = trim( $post->pinged ); $pung = preg_split( '/\s/', $pung ); return apply_filters( 'get_pung', $pung ); } function get_to_ping( $post ) { $post = get_post( $post ); if ( ! $post ) { return false; } $to_ping = sanitize_trackback_urls( $post->to_ping ); $to_ping = preg_split( '/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY ); return apply_filters( 'get_to_ping', $to_ping ); } function trackback_url_list( $tb_list, $post_id ) { if ( ! empty( $tb_list ) ) { $postdata = get_post( $post_id, ARRAY_A ); $excerpt = strip_tags( $postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content'] ); if ( strlen( $excerpt ) > 255 ) { $excerpt = substr( $excerpt, 0, 252 ) . '…'; } $trackback_urls = explode( ',', $tb_list ); foreach ( (array) $trackback_urls as $tb_url ) { $tb_url = trim( $tb_url ); trackback( $tb_url, wp_unslash( $postdata['post_title'] ), $excerpt, $post_id ); } } } function get_all_page_ids() { global $wpdb; $page_ids = wp_cache_get( 'all_page_ids', 'posts' ); if ( ! is_array( $page_ids ) ) { $page_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = 'page'" ); wp_cache_add( 'all_page_ids', $page_ids, 'posts' ); } return $page_ids; } function get_page( $page, $output = OBJECT, $filter = 'raw' ) { return get_post( $page, $output, $filter ); } function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { global $wpdb; $last_changed = wp_cache_get_last_changed( 'posts' ); $hash = md5( $page_path . serialize( $post_type ) ); $cache_key = "get_page_by_path:$hash:$last_changed"; $cached = wp_cache_get( $cache_key, 'posts' ); if ( false !== $cached ) { if ( '0' === $cached || 0 === $cached ) { return; } else { return get_post( $cached, $output ); } } $page_path = rawurlencode( urldecode( $page_path ) ); $page_path = str_replace( '%2F', '/', $page_path ); $page_path = str_replace( '%20', ' ', $page_path ); $parts = explode( '/', trim( $page_path, '/' ) ); $parts = array_map( 'sanitize_title_for_query', $parts ); $escaped_parts = esc_sql( $parts ); $in_string = "'" . implode( "','", $escaped_parts ) . "'"; if ( is_array( $post_type ) ) { $post_types = $post_type; } else { $post_types = array( $post_type, 'attachment' ); } $post_types = esc_sql( $post_types ); $post_type_in_string = "'" . implode( "','", $post_types ) . "'"; $sql = " SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts @@ -31650,27 +34337,27 @@ All at ###SITENAME### define( 'REST_API_VERSION', '2.0' ); function register_rest_route( $route_namespace, $route, $args = array(), $override = false ) { if ( empty( $route_namespace ) ) { _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' ); return false; } elseif ( empty( $route ) ) { _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' ); return false; } $clean_namespace = trim( $route_namespace, '/' ); if ( $clean_namespace !== $route_namespace ) { _doing_it_wrong( __FUNCTION__, __( 'Namespace must not start or end with a slash.' ), '5.4.2' ); } if ( ! did_action( 'rest_api_init' ) ) { _doing_it_wrong( 'register_rest_route', sprintf( __( 'REST API routes must be registered on the %s action.' ), '<code>rest_api_init</code>' ), '5.1.0' ); } if ( isset( $args['args'] ) ) { $common_args = $args['args']; unset( $args['args'] ); } else { $common_args = array(); } if ( isset( $args['callback'] ) ) { $args = array( $args ); } $defaults = array( 'methods' => 'GET', 'callback' => null, 'args' => array(), ); foreach ( $args as $key => &$arg_group ) { if ( ! is_numeric( $key ) ) { continue; } $arg_group = array_merge( $defaults, $arg_group ); $arg_group['args'] = array_merge( $common_args, $arg_group['args'] ); if ( ! isset( $arg_group['permission_callback'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The REST API route definition for %1$s is missing the required %2$s argument. For REST API routes that are intended to be public, use %3$s as the permission callback.' ), '<code>' . $clean_namespace . '/' . trim( $route, '/' ) . '</code>', '<code>permission_callback</code>', '<code>__return_true</code>' ), '5.5.0' ); } foreach ( $arg_group['args'] as $arg ) { if ( ! is_array( $arg ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'REST API %1$s should be an array of arrays. Non-array value detected for %2$s.' ), '<code>$args</code>', '<code>' . $clean_namespace . '/' . trim( $route, '/' ) . '</code>' ), '6.1.0' ); break; } } } $full_route = '/' . $clean_namespace . '/' . trim( $route, '/' ); rest_get_server()->register_route( $clean_namespace, $full_route, $args, $override ); return true; } function register_rest_field( $object_type, $attribute, $args = array() ) { global $wp_rest_additional_fields; $defaults = array( 'get_callback' => null, 'update_callback' => null, 'schema' => null, ); $args = wp_parse_args( $args, $defaults ); $object_types = (array) $object_type; foreach ( $object_types as $object_type ) { $wp_rest_additional_fields[ $object_type ][ $attribute ] = $args; } } function rest_api_init() { rest_api_register_rewrites(); global $wp; $wp->add_query_var( 'rest_route' ); } function rest_api_register_rewrites() { global $wp_rewrite; add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' ); add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' ); add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' ); add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' ); } function rest_api_default_filters() { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 ); add_filter( 'deprecated_function_trigger_error', '__return_false' ); add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); add_filter( 'deprecated_argument_trigger_error', '__return_false' ); add_action( 'doing_it_wrong_run', 'rest_handle_doing_it_wrong', 10, 3 ); add_filter( 'doing_it_wrong_trigger_error', '__return_false' ); } add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 ); add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 ); add_filter( 'rest_index', 'rest_add_application_passwords_to_index' ); } function create_initial_rest_routes() { foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { $controller = $post_type->get_rest_controller(); if ( ! $controller ) { continue; } $controller->register_routes(); if ( post_type_supports( $post_type->name, 'revisions' ) ) { $revisions_controller = new WP_REST_Revisions_Controller( $post_type->name ); $revisions_controller->register_routes(); } if ( 'attachment' !== $post_type->name ) { $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name ); $autosaves_controller->register_routes(); } } $controller = new WP_REST_Post_Types_Controller(); $controller->register_routes(); $controller = new WP_REST_Post_Statuses_Controller(); $controller->register_routes(); $controller = new WP_REST_Taxonomies_Controller(); $controller->register_routes(); foreach ( get_taxonomies( array( 'show_in_rest' => true ), 'object' ) as $taxonomy ) { $controller = $taxonomy->get_rest_controller(); if ( ! $controller ) { continue; } $controller->register_routes(); } $controller = new WP_REST_Users_Controller(); $controller->register_routes(); $controller = new WP_REST_Application_Passwords_Controller(); $controller->register_routes(); $controller = new WP_REST_Comments_Controller(); $controller->register_routes(); $search_handlers = array( new WP_REST_Post_Search_Handler(), new WP_REST_Term_Search_Handler(), new WP_REST_Post_Format_Search_Handler(), ); $search_handlers = apply_filters( 'wp_rest_search_handlers', $search_handlers ); $controller = new WP_REST_Search_Controller( $search_handlers ); $controller->register_routes(); $controller = new WP_REST_Block_Renderer_Controller(); $controller->register_routes(); $controller = new WP_REST_Block_Types_Controller(); $controller->register_routes(); $controller = new WP_REST_Global_Styles_Controller(); $controller->register_routes(); $controller = new WP_REST_Settings_Controller(); $controller->register_routes(); $controller = new WP_REST_Themes_Controller(); $controller->register_routes(); $controller = new WP_REST_Plugins_Controller(); $controller->register_routes(); $controller = new WP_REST_Sidebars_Controller(); $controller->register_routes(); $controller = new WP_REST_Widget_Types_Controller(); $controller->register_routes(); $controller = new WP_REST_Widgets_Controller(); $controller->register_routes(); $controller = new WP_REST_Block_Directory_Controller(); $controller->register_routes(); $controller = new WP_REST_Pattern_Directory_Controller(); $controller->register_routes(); $controller = new WP_REST_Block_Patterns_Controller(); $controller->register_routes(); $controller = new WP_REST_Block_Pattern_Categories_Controller(); $controller->register_routes(); $site_health = WP_Site_Health::get_instance(); $controller = new WP_REST_Site_Health_Controller( $site_health ); $controller->register_routes(); $controller = new WP_REST_URL_Details_Controller(); $controller->register_routes(); $controller = new WP_REST_Menu_Locations_Controller(); $controller->register_routes(); $controller = new WP_REST_Edit_Site_Export_Controller(); $controller->register_routes(); } function rest_api_loaded() { if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) { return; } define( 'REST_REQUEST', true ); $server = rest_get_server(); $route = untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] ); if ( empty( $route ) ) { $route = '/'; } $server->serve_request( $route ); die(); } function rest_get_url_prefix() { return apply_filters( 'rest_url_prefix', 'wp-json' ); } function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { if ( empty( $path ) ) { $path = '/'; } $path = '/' . ltrim( $path, '/' ); if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) { global $wp_rewrite; if ( $wp_rewrite->using_index_permalinks() ) { $url = get_home_url( $blog_id, $wp_rewrite->index . '/' . rest_get_url_prefix(), $scheme ); } else { $url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme ); } $url .= $path; } else { $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) ); if ( 'index.php' !== substr( $url, 9 ) ) { $url .= 'index.php'; } $url = add_query_arg( 'rest_route', $path, $url ); } if ( is_ssl() && isset( $_SERVER['SERVER_NAME'] ) ) { if ( parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) === $_SERVER['SERVER_NAME'] ) { $url = set_url_scheme( $url, 'https' ); } } if ( is_admin() && force_ssl_admin() ) { $url = set_url_scheme( $url, 'https' ); } return apply_filters( 'rest_url', $url, $path, $blog_id, $scheme ); } function rest_url( $path = '', $scheme = 'rest' ) { return get_rest_url( null, $path, $scheme ); } function rest_do_request( $request ) { $request = rest_ensure_request( $request ); return rest_get_server()->dispatch( $request ); } function rest_get_server() { global $wp_rest_server; if ( empty( $wp_rest_server ) ) { $wp_rest_server_class = apply_filters( 'wp_rest_server_class', 'WP_REST_Server' ); $wp_rest_server = new $wp_rest_server_class(); do_action( 'rest_api_init', $wp_rest_server ); } return $wp_rest_server; } function rest_ensure_request( $request ) { if ( $request instanceof WP_REST_Request ) { return $request; } if ( is_string( $request ) ) { return new WP_REST_Request( 'GET', $request ); } return new WP_REST_Request( 'GET', '', $request ); } function rest_ensure_response( $response ) { if ( is_wp_error( $response ) ) { return $response; } if ( $response instanceof WP_REST_Response ) { return $response; } if ( $response instanceof WP_HTTP_Response ) { return new WP_REST_Response( $response->get_data(), $response->get_status(), $response->get_headers() ); } return new WP_REST_Response( $response ); } function rest_handle_deprecated_function( $function_name, $replacement, $version ) { if ( ! WP_DEBUG || headers_sent() ) { return; } if ( ! empty( $replacement ) ) { $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function_name, $version, $replacement ); } else { $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function_name, $version ); } header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) ); } function rest_handle_deprecated_argument( $function_name, $message, $version ) { if ( ! WP_DEBUG || headers_sent() ) { return; } if ( $message ) { $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function_name, $version, $message ); } else { $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function_name, $version ); } header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) ); } function rest_handle_doing_it_wrong( $function_name, $message, $version ) { if ( ! WP_DEBUG || headers_sent() ) { return; } if ( $version ) { $string = __( '%1$s (since %2$s; %3$s)' ); $string = sprintf( $string, $function_name, $version, $message ); } else { $string = __( '%1$s (%2$s)' ); $string = sprintf( $string, $function_name, $message ); } header( sprintf( 'X-WP-DoingItWrong: %s', $string ) ); } function rest_send_cors_headers( $value ) { $origin = get_http_origin(); if ( $origin ) { if ( 'null' !== $origin ) { $origin = sanitize_url( $origin ); } header( 'Access-Control-Allow-Origin: ' . $origin ); header( 'Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE' ); header( 'Access-Control-Allow-Credentials: true' ); header( 'Vary: Origin', false ); } elseif ( ! headers_sent() && 'GET' === $_SERVER['REQUEST_METHOD'] && ! is_user_logged_in() ) { header( 'Vary: Origin', false ); } return $value; } function rest_handle_options_request( $response, $handler, $request ) { if ( ! empty( $response ) || $request->get_method() !== 'OPTIONS' ) { return $response; } $response = new WP_REST_Response(); $data = array(); foreach ( $handler->get_routes() as $route => $endpoints ) { $match = preg_match( '@^' . $route . '$@i', $request->get_route(), $matches ); if ( ! $match ) { continue; } $args = array(); foreach ( $matches as $param => $value ) { if ( ! is_int( $param ) ) { $args[ $param ] = $value; } } foreach ( $endpoints as $endpoint ) { unset( $args[0] ); $request->set_url_params( $args ); $request->set_attributes( $endpoint ); } $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); $response->set_matched_route( $route ); break; } $response->set_data( $data ); return $response; } function rest_send_allow_header( $response, $server, $request ) { $matched_route = $response->get_matched_route(); if ( ! $matched_route ) { return $response; } $routes = $server->get_routes(); $allowed_methods = array(); foreach ( $routes[ $matched_route ] as $_handler ) { foreach ( $_handler['methods'] as $handler_method => $value ) { if ( ! empty( $_handler['permission_callback'] ) ) { $permission = call_user_func( $_handler['permission_callback'], $request ); $allowed_methods[ $handler_method ] = true === $permission; } else { $allowed_methods[ $handler_method ] = true; } } } $allowed_methods = array_filter( $allowed_methods ); if ( $allowed_methods ) { $response->header( 'Allow', implode( ', ', array_map( 'strtoupper', array_keys( $allowed_methods ) ) ) ); } return $response; } function _rest_array_intersect_key_recursive( $array1, $array2 ) { $array1 = array_intersect_key( $array1, $array2 ); foreach ( $array1 as $key => $value ) { if ( is_array( $value ) && is_array( $array2[ $key ] ) ) { $array1[ $key ] = _rest_array_intersect_key_recursive( $value, $array2[ $key ] ); } } return $array1; } function rest_filter_response_fields( $response, $server, $request ) { if ( ! isset( $request['_fields'] ) || $response->is_error() ) { return $response; } $data = $response->get_data(); $fields = wp_parse_list( $request['_fields'] ); if ( 0 === count( $fields ) ) { return $response; } $fields = array_map( 'trim', $fields ); $fields_as_keyed = array(); foreach ( $fields as $field ) { $parts = explode( '.', $field ); $ref = &$fields_as_keyed; while ( count( $parts ) > 1 ) { $next = array_shift( $parts ); if ( isset( $ref[ $next ] ) && true === $ref[ $next ] ) { break 2; } $ref[ $next ] = isset( $ref[ $next ] ) ? $ref[ $next ] : array(); $ref = &$ref[ $next ]; } $last = array_shift( $parts ); $ref[ $last ] = true; } if ( wp_is_numeric_array( $data ) ) { $new_data = array(); foreach ( $data as $item ) { $new_data[] = _rest_array_intersect_key_recursive( $item, $fields_as_keyed ); } } else { $new_data = _rest_array_intersect_key_recursive( $data, $fields_as_keyed ); } $response->set_data( $new_data ); return $response; } function rest_is_field_included( $field, $fields ) { if ( in_array( $field, $fields, true ) ) { return true; } foreach ( $fields as $accepted_field ) { if ( strpos( $accepted_field, "$field." ) === 0 ) { return true; } if ( strpos( $field, "$accepted_field." ) === 0 ) { return true; } } return false; } function rest_output_rsd() { $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; } ?> <api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url( $api_root ); ?>" /> <?php -} function rest_output_link_wp_head() { $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; } printf( '<link rel="https://api.w.org/" href="%s" />', esc_url( $api_root ) ); $resource = rest_get_queried_resource_route(); if ( $resource ) { printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) ); } } function rest_output_link_header() { if ( headers_sent() ) { return; } $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; } header( sprintf( 'Link: <%s>; rel="https://api.w.org/"', sanitize_url( $api_root ) ), false ); $resource = rest_get_queried_resource_route(); if ( $resource ) { header( sprintf( 'Link: <%s>; rel="alternate"; type="application/json"', sanitize_url( rest_url( $resource ) ) ), false ); } } function rest_cookie_check_errors( $result ) { if ( ! empty( $result ) ) { return $result; } global $wp_rest_auth_cookie; if ( true !== $wp_rest_auth_cookie && is_user_logged_in() ) { return $result; } $nonce = null; if ( isset( $_REQUEST['_wpnonce'] ) ) { $nonce = $_REQUEST['_wpnonce']; } elseif ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) { $nonce = $_SERVER['HTTP_X_WP_NONCE']; } if ( null === $nonce ) { wp_set_current_user( 0 ); return true; } $result = wp_verify_nonce( $nonce, 'wp_rest' ); if ( ! $result ) { return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie check failed' ), array( 'status' => 403 ) ); } rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) ); return true; } function rest_cookie_collect_status() { global $wp_rest_auth_cookie; $status_type = current_action(); if ( 'auth_cookie_valid' !== $status_type ) { $wp_rest_auth_cookie = substr( $status_type, 12 ); return; } $wp_rest_auth_cookie = true; } function rest_application_password_collect_status( $user_or_error, $app_password = array() ) { global $wp_rest_application_password_status, $wp_rest_application_password_uuid; $wp_rest_application_password_status = $user_or_error; if ( empty( $app_password['uuid'] ) ) { $wp_rest_application_password_uuid = null; } else { $wp_rest_application_password_uuid = $app_password['uuid']; } } function rest_get_authenticated_app_password() { global $wp_rest_application_password_uuid; return $wp_rest_application_password_uuid; } function rest_application_password_check_errors( $result ) { global $wp_rest_application_password_status; if ( ! empty( $result ) ) { return $result; } if ( is_wp_error( $wp_rest_application_password_status ) ) { $data = $wp_rest_application_password_status->get_error_data(); if ( ! isset( $data['status'] ) ) { $data['status'] = 401; } $wp_rest_application_password_status->add_data( $data ); return $wp_rest_application_password_status; } if ( $wp_rest_application_password_status instanceof WP_User ) { return true; } return $result; } function rest_add_application_passwords_to_index( $response ) { if ( ! wp_is_application_passwords_available() ) { return $response; } $response->data['authentication']['application-passwords'] = array( 'endpoints' => array( 'authorization' => admin_url( 'authorize-application.php' ), ), ); return $response; } function rest_get_avatar_urls( $id_or_email ) { $avatar_sizes = rest_get_avatar_sizes(); $urls = array(); foreach ( $avatar_sizes as $size ) { $urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) ); } return $urls; } function rest_get_avatar_sizes() { return apply_filters( 'rest_avatar_sizes', array( 24, 48, 96 ) ); } function rest_parse_date( $date, $force_utc = false ) { if ( $force_utc ) { $date = preg_replace( '/[+-]\d+:?\d+$/', '+00:00', $date ); } $regex = '#^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}(?::\d{2})?)?$#'; if ( ! preg_match( $regex, $date, $matches ) ) { return false; } return strtotime( $date ); } function rest_parse_hex_color( $color ) { $regex = '|^#([A-Fa-f0-9]{3}){1,2}$|'; if ( ! preg_match( $regex, $color, $matches ) ) { return false; } return $color; } function rest_get_date_with_gmt( $date, $is_utc = false ) { $has_timezone = preg_match( '#(Z|[+-]\d{2}(:\d{2})?)$#', $date ); $date = rest_parse_date( $date ); if ( empty( $date ) ) { return null; } if ( ! $is_utc && ! $has_timezone ) { $local = gmdate( 'Y-m-d H:i:s', $date ); $utc = get_gmt_from_date( $local ); } else { $utc = gmdate( 'Y-m-d H:i:s', $date ); $local = get_date_from_gmt( $utc ); } return array( $local, $utc ); } function rest_authorization_required_code() { return is_user_logged_in() ? 403 : 401; } function rest_validate_request_arg( $value, $request, $param ) { $attributes = $request->get_attributes(); if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) { return true; } $args = $attributes['args'][ $param ]; return rest_validate_value_from_schema( $value, $args, $param ); } function rest_sanitize_request_arg( $value, $request, $param ) { $attributes = $request->get_attributes(); if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) { return $value; } $args = $attributes['args'][ $param ]; return rest_sanitize_value_from_schema( $value, $args, $param ); } function rest_parse_request_arg( $value, $request, $param ) { $is_valid = rest_validate_request_arg( $value, $request, $param ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } $value = rest_sanitize_request_arg( $value, $request, $param ); return $value; } function rest_is_ip_address( $ip ) { $ipv4_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/'; if ( ! preg_match( $ipv4_pattern, $ip ) && ! WpOrg\Requests\Ipv6::check_ipv6( $ip ) ) { return false; } return $ip; } function rest_sanitize_boolean( $value ) { if ( is_string( $value ) ) { $value = strtolower( $value ); if ( in_array( $value, array( 'false', '0' ), true ) ) { $value = false; } } return (bool) $value; } function rest_is_boolean( $maybe_bool ) { if ( is_bool( $maybe_bool ) ) { return true; } if ( is_string( $maybe_bool ) ) { $maybe_bool = strtolower( $maybe_bool ); $valid_boolean_values = array( 'false', 'true', '0', '1', ); return in_array( $maybe_bool, $valid_boolean_values, true ); } if ( is_int( $maybe_bool ) ) { return in_array( $maybe_bool, array( 0, 1 ), true ); } return false; } function rest_is_integer( $maybe_integer ) { return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer; } function rest_is_array( $maybe_array ) { if ( is_scalar( $maybe_array ) ) { $maybe_array = wp_parse_list( $maybe_array ); } return wp_is_numeric_array( $maybe_array ); } function rest_sanitize_array( $maybe_array ) { if ( is_scalar( $maybe_array ) ) { return wp_parse_list( $maybe_array ); } if ( ! is_array( $maybe_array ) ) { return array(); } return array_values( $maybe_array ); } function rest_is_object( $maybe_object ) { if ( '' === $maybe_object ) { return true; } if ( $maybe_object instanceof stdClass ) { return true; } if ( $maybe_object instanceof JsonSerializable ) { $maybe_object = $maybe_object->jsonSerialize(); } return is_array( $maybe_object ); } function rest_sanitize_object( $maybe_object ) { if ( '' === $maybe_object ) { return array(); } if ( $maybe_object instanceof stdClass ) { return (array) $maybe_object; } if ( $maybe_object instanceof JsonSerializable ) { $maybe_object = $maybe_object->jsonSerialize(); } if ( ! is_array( $maybe_object ) ) { return array(); } return $maybe_object; } function rest_get_best_type_for_value( $value, $types ) { static $checks = array( 'array' => 'rest_is_array', 'object' => 'rest_is_object', 'integer' => 'rest_is_integer', 'number' => 'is_numeric', 'boolean' => 'rest_is_boolean', 'string' => 'is_string', 'null' => 'is_null', ); if ( '' === $value && in_array( 'string', $types, true ) ) { return 'string'; } foreach ( $types as $type ) { if ( isset( $checks[ $type ] ) && $checks[ $type ]( $value ) ) { return $type; } } return ''; } function rest_handle_multi_type_schema( $value, $args, $param = '' ) { $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); $invalid_types = array_diff( $args['type'], $allowed_types ); if ( $invalid_types ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only contain the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } $best_type = rest_get_best_type_for_value( $value, $args['type'] ); if ( ! $best_type ) { if ( ! $invalid_types ) { return ''; } $best_type = reset( $invalid_types ); } return $best_type; } function rest_validate_array_contains_unique_items( $input_array ) { $seen = array(); foreach ( $input_array as $item ) { $stabilized = rest_stabilize_value( $item ); $key = serialize( $stabilized ); if ( ! isset( $seen[ $key ] ) ) { $seen[ $key ] = true; continue; } return false; } return true; } function rest_stabilize_value( $value ) { if ( is_scalar( $value ) || is_null( $value ) ) { return $value; } if ( is_object( $value ) ) { _doing_it_wrong( __FUNCTION__, __( 'Cannot stabilize objects. Convert the object to an array first.' ), '5.5.0' ); return $value; } ksort( $value ); foreach ( $value as $k => $v ) { $value[ $k ] = rest_stabilize_value( $v ); } return $value; } function rest_validate_json_schema_pattern( $pattern, $value ) { $escaped_pattern = str_replace( '#', '\\#', $pattern ); return 1 === preg_match( '#' . $escaped_pattern . '#u', $value ); } function rest_find_matching_pattern_property_schema( $property, $args ) { if ( isset( $args['patternProperties'] ) ) { foreach ( $args['patternProperties'] as $pattern => $child_schema ) { if ( rest_validate_json_schema_pattern( $pattern, $property ) ) { return $child_schema; } } } return null; } function rest_format_combining_operation_error( $param, $error ) { $position = $error['index']; $reason = $error['error_object']->get_error_message(); if ( isset( $error['schema']['title'] ) ) { $title = $error['schema']['title']; return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ), array( 'position' => $position ) ); } return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ), array( 'position' => $position ) ); } function rest_get_combining_operation_error( $value, $param, $errors ) { if ( 1 === count( $errors ) ) { return rest_format_combining_operation_error( $param, $errors[0] ); } $filtered_errors = array(); foreach ( $errors as $error ) { $error_code = $error['error_object']->get_error_code(); $error_data = $error['error_object']->get_error_data(); if ( 'rest_invalid_type' !== $error_code || ( isset( $error_data['param'] ) && $param !== $error_data['param'] ) ) { $filtered_errors[] = $error; } } if ( 1 === count( $filtered_errors ) ) { return rest_format_combining_operation_error( $param, $filtered_errors[0] ); } if ( count( $filtered_errors ) > 1 && 'object' === $filtered_errors[0]['schema']['type'] ) { $result = null; $number = 0; foreach ( $filtered_errors as $error ) { if ( isset( $error['schema']['properties'] ) ) { $n = count( array_intersect_key( $error['schema']['properties'], $value ) ); if ( $n > $number ) { $result = $error; $number = $n; } } } if ( null !== $result ) { return rest_format_combining_operation_error( $param, $result ); } } $schema_titles = array(); foreach ( $errors as $error ) { if ( isset( $error['schema']['title'] ) ) { $schema_titles[] = $error['schema']['title']; } } if ( count( $schema_titles ) === count( $errors ) ) { return new WP_Error( 'rest_no_matching_schema', wp_sprintf( __( '%1$s is not a valid %2$l.' ), $param, $schema_titles ) ); } return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%s does not match any of the expected formats.' ), $param ) ); } function rest_find_any_matching_schema( $value, $args, $param ) { $errors = array(); foreach ( $args['anyOf'] as $index => $schema ) { if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) { $schema['type'] = $args['type']; } $is_valid = rest_validate_value_from_schema( $value, $schema, $param ); if ( ! is_wp_error( $is_valid ) ) { return $schema; } $errors[] = array( 'error_object' => $is_valid, 'schema' => $schema, 'index' => $index, ); } return rest_get_combining_operation_error( $value, $param, $errors ); } function rest_find_one_matching_schema( $value, $args, $param, $stop_after_first_match = false ) { $matching_schemas = array(); $errors = array(); foreach ( $args['oneOf'] as $index => $schema ) { if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) { $schema['type'] = $args['type']; } $is_valid = rest_validate_value_from_schema( $value, $schema, $param ); if ( ! is_wp_error( $is_valid ) ) { if ( $stop_after_first_match ) { return $schema; } $matching_schemas[] = array( 'schema_object' => $schema, 'index' => $index, ); } else { $errors[] = array( 'error_object' => $is_valid, 'schema' => $schema, 'index' => $index, ); } } if ( ! $matching_schemas ) { return rest_get_combining_operation_error( $value, $param, $errors ); } if ( count( $matching_schemas ) > 1 ) { $schema_positions = array(); $schema_titles = array(); foreach ( $matching_schemas as $schema ) { $schema_positions[] = $schema['index']; if ( isset( $schema['schema_object']['title'] ) ) { $schema_titles[] = $schema['schema_object']['title']; } } if ( count( $schema_titles ) === count( $matching_schemas ) ) { return new WP_Error( 'rest_one_of_multiple_matches', wp_sprintf( __( '%1$s matches %2$l, but should match only one.' ), $param, $schema_titles ), array( 'positions' => $schema_positions ) ); } return new WP_Error( 'rest_one_of_multiple_matches', sprintf( __( '%s matches more than one of the expected formats.' ), $param ), array( 'positions' => $schema_positions ) ); } return $matching_schemas[0]['schema_object']; } function rest_are_values_equal( $value1, $value2 ) { if ( is_array( $value1 ) && is_array( $value2 ) ) { if ( count( $value1 ) !== count( $value2 ) ) { return false; } foreach ( $value1 as $index => $value ) { if ( ! array_key_exists( $index, $value2 ) || ! rest_are_values_equal( $value, $value2[ $index ] ) ) { return false; } } return true; } if ( is_int( $value1 ) && is_float( $value2 ) || is_float( $value1 ) && is_int( $value2 ) ) { return (float) $value1 === (float) $value2; } return $value1 === $value2; } function rest_validate_enum( $value, $args, $param ) { $sanitized_value = rest_sanitize_value_from_schema( $value, $args, $param ); if ( is_wp_error( $sanitized_value ) ) { return $sanitized_value; } foreach ( $args['enum'] as $enum_value ) { if ( rest_are_values_equal( $sanitized_value, $enum_value ) ) { return true; } } $encoded_enum_values = array(); foreach ( $args['enum'] as $enum_value ) { $encoded_enum_values[] = is_scalar( $enum_value ) ? $enum_value : wp_json_encode( $enum_value ); } if ( count( $encoded_enum_values ) === 1 ) { return new WP_Error( 'rest_not_in_enum', wp_sprintf( __( '%1$s is not %2$s.' ), $param, $encoded_enum_values[0] ) ); } return new WP_Error( 'rest_not_in_enum', wp_sprintf( __( '%1$s is not one of %2$l.' ), $param, $encoded_enum_values ) ); } function rest_get_allowed_schema_keywords() { return array( 'title', 'description', 'default', 'type', 'format', 'enum', 'items', 'properties', 'additionalProperties', 'patternProperties', 'minProperties', 'maxProperties', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'multipleOf', 'minLength', 'maxLength', 'pattern', 'minItems', 'maxItems', 'uniqueItems', 'anyOf', 'oneOf', ); } function rest_validate_value_from_schema( $value, $args, $param = '' ) { if ( isset( $args['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) && isset( $matching_schema['type'] ) ) { $args['type'] = $matching_schema['type']; } } if ( isset( $args['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) && isset( $matching_schema['type'] ) ) { $args['type'] = $matching_schema['type']; } } $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); if ( ! isset( $args['type'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The "type" schema keyword for %s is required.' ), $param ), '5.5.0' ); } if ( is_array( $args['type'] ) ) { $best_type = rest_handle_multi_type_schema( $value, $args, $param ); if ( ! $best_type ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, implode( ',', $args['type'] ) ), array( 'param' => $param ) ); } $args['type'] = $best_type; } if ( ! in_array( $args['type'], $allowed_types, true ) ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } switch ( $args['type'] ) { case 'null': $is_valid = rest_validate_null_value_from_schema( $value, $param ); break; case 'boolean': $is_valid = rest_validate_boolean_value_from_schema( $value, $param ); break; case 'object': $is_valid = rest_validate_object_value_from_schema( $value, $args, $param ); break; case 'array': $is_valid = rest_validate_array_value_from_schema( $value, $args, $param ); break; case 'number': $is_valid = rest_validate_number_value_from_schema( $value, $args, $param ); break; case 'string': $is_valid = rest_validate_string_value_from_schema( $value, $args, $param ); break; case 'integer': $is_valid = rest_validate_integer_value_from_schema( $value, $args, $param ); break; default: $is_valid = true; break; } if ( is_wp_error( $is_valid ) ) { return $is_valid; } if ( ! empty( $args['enum'] ) ) { $enum_contains_value = rest_validate_enum( $value, $args, $param ); if ( is_wp_error( $enum_contains_value ) ) { return $enum_contains_value; } } if ( isset( $args['format'] ) && ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) ) ) { switch ( $args['format'] ) { case 'hex-color': if ( ! rest_parse_hex_color( $value ) ) { return new WP_Error( 'rest_invalid_hex_color', __( 'Invalid hex color.' ) ); } break; case 'date-time': if ( ! rest_parse_date( $value ) ) { return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) ); } break; case 'email': if ( ! is_email( $value ) ) { return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) ); } break; case 'ip': if ( ! rest_is_ip_address( $value ) ) { return new WP_Error( 'rest_invalid_ip', sprintf( __( '%s is not a valid IP address.' ), $param ) ); } break; case 'uuid': if ( ! wp_is_uuid( $value ) ) { return new WP_Error( 'rest_invalid_uuid', sprintf( __( '%s is not a valid UUID.' ), $param ) ); } break; } } return true; } function rest_validate_null_value_from_schema( $value, $param ) { if ( null !== $value ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'null' ), array( 'param' => $param ) ); } return true; } function rest_validate_boolean_value_from_schema( $value, $param ) { if ( ! rest_is_boolean( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'boolean' ), array( 'param' => $param ) ); } return true; } function rest_validate_object_value_from_schema( $value, $args, $param ) { if ( ! rest_is_object( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'object' ), array( 'param' => $param ) ); } $value = rest_sanitize_object( $value ); if ( isset( $args['required'] ) && is_array( $args['required'] ) ) { foreach ( $args['required'] as $name ) { if ( ! array_key_exists( $name, $value ) ) { return new WP_Error( 'rest_property_required', sprintf( __( '%1$s is a required property of %2$s.' ), $name, $param ) ); } } } elseif ( isset( $args['properties'] ) ) { foreach ( $args['properties'] as $name => $property ) { if ( isset( $property['required'] ) && true === $property['required'] && ! array_key_exists( $name, $value ) ) { return new WP_Error( 'rest_property_required', sprintf( __( '%1$s is a required property of %2$s.' ), $name, $param ) ); } } } foreach ( $value as $property => $v ) { if ( isset( $args['properties'][ $property ] ) ) { $is_valid = rest_validate_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } continue; } $pattern_property_schema = rest_find_matching_pattern_property_schema( $property, $args ); if ( null !== $pattern_property_schema ) { $is_valid = rest_validate_value_from_schema( $v, $pattern_property_schema, $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } continue; } if ( isset( $args['additionalProperties'] ) ) { if ( false === $args['additionalProperties'] ) { return new WP_Error( 'rest_additional_properties_forbidden', sprintf( __( '%1$s is not a valid property of Object.' ), $property ) ); } if ( is_array( $args['additionalProperties'] ) ) { $is_valid = rest_validate_value_from_schema( $v, $args['additionalProperties'], $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } } } } if ( isset( $args['minProperties'] ) && count( $value ) < $args['minProperties'] ) { return new WP_Error( 'rest_too_few_properties', sprintf( _n( '%1$s must contain at least %2$s property.', '%1$s must contain at least %2$s properties.', $args['minProperties'] ), $param, number_format_i18n( $args['minProperties'] ) ) ); } if ( isset( $args['maxProperties'] ) && count( $value ) > $args['maxProperties'] ) { return new WP_Error( 'rest_too_many_properties', sprintf( _n( '%1$s must contain at most %2$s property.', '%1$s must contain at most %2$s properties.', $args['maxProperties'] ), $param, number_format_i18n( $args['maxProperties'] ) ) ); } return true; } function rest_validate_array_value_from_schema( $value, $args, $param ) { if ( ! rest_is_array( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ), array( 'param' => $param ) ); } $value = rest_sanitize_array( $value ); if ( isset( $args['items'] ) ) { foreach ( $value as $index => $v ) { $is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } } } if ( isset( $args['minItems'] ) && count( $value ) < $args['minItems'] ) { return new WP_Error( 'rest_too_few_items', sprintf( _n( '%1$s must contain at least %2$s item.', '%1$s must contain at least %2$s items.', $args['minItems'] ), $param, number_format_i18n( $args['minItems'] ) ) ); } if ( isset( $args['maxItems'] ) && count( $value ) > $args['maxItems'] ) { return new WP_Error( 'rest_too_many_items', sprintf( _n( '%1$s must contain at most %2$s item.', '%1$s must contain at most %2$s items.', $args['maxItems'] ), $param, number_format_i18n( $args['maxItems'] ) ) ); } if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { return new WP_Error( 'rest_duplicate_items', sprintf( __( '%s has duplicate items.' ), $param ) ); } return true; } function rest_validate_number_value_from_schema( $value, $args, $param ) { if ( ! is_numeric( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ), array( 'param' => $param ) ); } if ( isset( $args['multipleOf'] ) && fmod( $value, $args['multipleOf'] ) !== 0.0 ) { return new WP_Error( 'rest_invalid_multiple', sprintf( __( '%1$s must be a multiple of %2$s.' ), $param, $args['multipleOf'] ) ); } if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) ); } if ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) ); } } if ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) { if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) ); } if ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) ); } } if ( isset( $args['minimum'], $args['maximum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) { if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { if ( $value > $args['maximum'] || $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( ! empty( $args['exclusiveMaximum'] ) && empty( $args['exclusiveMinimum'] ) ) { if ( $value >= $args['maximum'] || $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { if ( $value > $args['maximum'] || $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } } return true; } function rest_validate_string_value_from_schema( $value, $args, $param ) { if ( ! is_string( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ), array( 'param' => $param ) ); } if ( isset( $args['minLength'] ) && mb_strlen( $value ) < $args['minLength'] ) { return new WP_Error( 'rest_too_short', sprintf( _n( '%1$s must be at least %2$s character long.', '%1$s must be at least %2$s characters long.', $args['minLength'] ), $param, number_format_i18n( $args['minLength'] ) ) ); } if ( isset( $args['maxLength'] ) && mb_strlen( $value ) > $args['maxLength'] ) { return new WP_Error( 'rest_too_long', sprintf( _n( '%1$s must be at most %2$s character long.', '%1$s must be at most %2$s characters long.', $args['maxLength'] ), $param, number_format_i18n( $args['maxLength'] ) ) ); } if ( isset( $args['pattern'] ) && ! rest_validate_json_schema_pattern( $args['pattern'], $value ) ) { return new WP_Error( 'rest_invalid_pattern', sprintf( __( '%1$s does not match pattern %2$s.' ), $param, $args['pattern'] ) ); } return true; } function rest_validate_integer_value_from_schema( $value, $args, $param ) { $is_valid_number = rest_validate_number_value_from_schema( $value, $args, $param ); if ( is_wp_error( $is_valid_number ) ) { return $is_valid_number; } if ( ! rest_is_integer( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ), array( 'param' => $param ) ); } return true; } function rest_sanitize_value_from_schema( $value, $args, $param = '' ) { if ( isset( $args['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) ) { $args['type'] = $matching_schema['type']; } $value = rest_sanitize_value_from_schema( $value, $matching_schema, $param ); } if ( isset( $args['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) ) { $args['type'] = $matching_schema['type']; } $value = rest_sanitize_value_from_schema( $value, $matching_schema, $param ); } $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); if ( ! isset( $args['type'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The "type" schema keyword for %s is required.' ), $param ), '5.5.0' ); } if ( is_array( $args['type'] ) ) { $best_type = rest_handle_multi_type_schema( $value, $args, $param ); if ( ! $best_type ) { return null; } $args['type'] = $best_type; } if ( ! in_array( $args['type'], $allowed_types, true ) ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } if ( 'array' === $args['type'] ) { $value = rest_sanitize_array( $value ); if ( ! empty( $args['items'] ) ) { foreach ( $value as $index => $v ) { $value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' ); } } if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { return new WP_Error( 'rest_duplicate_items', sprintf( __( '%s has duplicate items.' ), $param ) ); } return $value; } if ( 'object' === $args['type'] ) { $value = rest_sanitize_object( $value ); foreach ( $value as $property => $v ) { if ( isset( $args['properties'][ $property ] ) ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' ); continue; } $pattern_property_schema = rest_find_matching_pattern_property_schema( $property, $args ); if ( null !== $pattern_property_schema ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $pattern_property_schema, $param . '[' . $property . ']' ); continue; } if ( isset( $args['additionalProperties'] ) ) { if ( false === $args['additionalProperties'] ) { unset( $value[ $property ] ); } elseif ( is_array( $args['additionalProperties'] ) ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $args['additionalProperties'], $param . '[' . $property . ']' ); } } } return $value; } if ( 'null' === $args['type'] ) { return null; } if ( 'integer' === $args['type'] ) { return (int) $value; } if ( 'number' === $args['type'] ) { return (float) $value; } if ( 'boolean' === $args['type'] ) { return rest_sanitize_boolean( $value ); } if ( isset( $args['format'] ) && ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) ) ) { switch ( $args['format'] ) { case 'hex-color': return (string) sanitize_hex_color( $value ); case 'date-time': return sanitize_text_field( $value ); case 'email': return sanitize_text_field( $value ); case 'uri': return sanitize_url( $value ); case 'ip': return sanitize_text_field( $value ); case 'uuid': return sanitize_text_field( $value ); case 'text-field': return sanitize_text_field( $value ); case 'textarea-field': return sanitize_textarea_field( $value ); } } if ( 'string' === $args['type'] ) { return (string) $value; } return $value; } function rest_preload_api_request( $memo, $path ) { if ( ! is_array( $memo ) ) { $memo = array(); } if ( empty( $path ) ) { return $memo; } $method = 'GET'; if ( is_array( $path ) && 2 === count( $path ) ) { $method = end( $path ); $path = reset( $path ); if ( ! in_array( $method, array( 'GET', 'OPTIONS' ), true ) ) { $method = 'GET'; } } $path = untrailingslashit( $path ); if ( empty( $path ) ) { $path = '/'; } $path_parts = parse_url( $path ); if ( false === $path_parts ) { return $memo; } $request = new WP_REST_Request( $method, $path_parts['path'] ); if ( ! empty( $path_parts['query'] ) ) { parse_str( $path_parts['query'], $query_params ); $request->set_query_params( $query_params ); } $response = rest_do_request( $request ); if ( 200 === $response->status ) { $server = rest_get_server(); $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request ); $embed = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false; $data = (array) $server->response_to_data( $response, $embed ); if ( 'OPTIONS' === $method ) { $memo[ $method ][ $path ] = array( 'body' => $data, 'headers' => $response->headers, ); } else { $memo[ $path ] = array( 'body' => $data, 'headers' => $response->headers, ); } } return $memo; } function rest_parse_embed_param( $embed ) { if ( ! $embed || 'true' === $embed || '1' === $embed ) { return true; } $rels = wp_parse_list( $embed ); if ( ! $rels ) { return true; } return $rels; } function rest_filter_response_by_context( $data, $schema, $context ) { if ( isset( $schema['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $data, $schema, '' ); if ( ! is_wp_error( $matching_schema ) ) { if ( ! isset( $schema['type'] ) ) { $schema['type'] = $matching_schema['type']; } $data = rest_filter_response_by_context( $data, $matching_schema, $context ); } } if ( isset( $schema['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $data, $schema, '', true ); if ( ! is_wp_error( $matching_schema ) ) { if ( ! isset( $schema['type'] ) ) { $schema['type'] = $matching_schema['type']; } $data = rest_filter_response_by_context( $data, $matching_schema, $context ); } } if ( ! is_array( $data ) && ! is_object( $data ) ) { return $data; } if ( isset( $schema['type'] ) ) { $type = $schema['type']; } elseif ( isset( $schema['properties'] ) ) { $type = 'object'; } else { return $data; } $is_array_type = 'array' === $type || ( is_array( $type ) && in_array( 'array', $type, true ) ); $is_object_type = 'object' === $type || ( is_array( $type ) && in_array( 'object', $type, true ) ); if ( $is_array_type && $is_object_type ) { if ( rest_is_array( $data ) ) { $is_object_type = false; } else { $is_array_type = false; } } $has_additional_properties = $is_object_type && isset( $schema['additionalProperties'] ) && is_array( $schema['additionalProperties'] ); foreach ( $data as $key => $value ) { $check = array(); if ( $is_array_type ) { $check = isset( $schema['items'] ) ? $schema['items'] : array(); } elseif ( $is_object_type ) { if ( isset( $schema['properties'][ $key ] ) ) { $check = $schema['properties'][ $key ]; } else { $pattern_property_schema = rest_find_matching_pattern_property_schema( $key, $schema ); if ( null !== $pattern_property_schema ) { $check = $pattern_property_schema; } elseif ( $has_additional_properties ) { $check = $schema['additionalProperties']; } } } if ( ! isset( $check['context'] ) ) { continue; } if ( ! in_array( $context, $check['context'], true ) ) { if ( $is_array_type ) { $data = array(); break; } if ( is_object( $data ) ) { unset( $data->$key ); } else { unset( $data[ $key ] ); } } elseif ( is_array( $value ) || is_object( $value ) ) { $new_value = rest_filter_response_by_context( $value, $check, $context ); if ( is_object( $data ) ) { $data->$key = $new_value; } else { $data[ $key ] = $new_value; } } } return $data; } function rest_default_additional_properties_to_false( $schema ) { $type = (array) $schema['type']; if ( in_array( 'object', $type, true ) ) { if ( isset( $schema['properties'] ) ) { foreach ( $schema['properties'] as $key => $child_schema ) { $schema['properties'][ $key ] = rest_default_additional_properties_to_false( $child_schema ); } } if ( isset( $schema['patternProperties'] ) ) { foreach ( $schema['patternProperties'] as $key => $child_schema ) { $schema['patternProperties'][ $key ] = rest_default_additional_properties_to_false( $child_schema ); } } if ( ! isset( $schema['additionalProperties'] ) ) { $schema['additionalProperties'] = false; } } if ( in_array( 'array', $type, true ) ) { if ( isset( $schema['items'] ) ) { $schema['items'] = rest_default_additional_properties_to_false( $schema['items'] ); } } return $schema; } function rest_get_route_for_post( $post ) { $post = get_post( $post ); if ( ! $post instanceof WP_Post ) { return ''; } $post_type_route = rest_get_route_for_post_type_items( $post->post_type ); if ( ! $post_type_route ) { return ''; } $route = sprintf( '%s/%d', $post_type_route, $post->ID ); return apply_filters( 'rest_route_for_post', $route, $post ); } function rest_get_route_for_post_type_items( $post_type ) { $post_type = get_post_type_object( $post_type ); if ( ! $post_type ) { return ''; } if ( ! $post_type->show_in_rest ) { return ''; } $namespace = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2'; $rest_base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; $route = sprintf( '/%s/%s', $namespace, $rest_base ); return apply_filters( 'rest_route_for_post_type_items', $route, $post_type ); } function rest_get_route_for_term( $term ) { $term = get_term( $term ); if ( ! $term instanceof WP_Term ) { return ''; } $taxonomy_route = rest_get_route_for_taxonomy_items( $term->taxonomy ); if ( ! $taxonomy_route ) { return ''; } $route = sprintf( '%s/%d', $taxonomy_route, $term->term_id ); return apply_filters( 'rest_route_for_term', $route, $term ); } function rest_get_route_for_taxonomy_items( $taxonomy ) { $taxonomy = get_taxonomy( $taxonomy ); if ( ! $taxonomy ) { return ''; } if ( ! $taxonomy->show_in_rest ) { return ''; } $namespace = ! empty( $taxonomy->rest_namespace ) ? $taxonomy->rest_namespace : 'wp/v2'; $rest_base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; $route = sprintf( '/%s/%s', $namespace, $rest_base ); return apply_filters( 'rest_route_for_taxonomy_items', $route, $taxonomy ); } function rest_get_queried_resource_route() { if ( is_singular() ) { $route = rest_get_route_for_post( get_queried_object() ); } elseif ( is_category() || is_tag() || is_tax() ) { $route = rest_get_route_for_term( get_queried_object() ); } elseif ( is_author() ) { $route = '/wp/v2/users/' . get_queried_object_id(); } else { $route = ''; } return apply_filters( 'rest_queried_resource_route', $route ); } function rest_get_endpoint_args_for_schema( $schema, $method = WP_REST_Server::CREATABLE ) { $schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array(); $endpoint_args = array(); $valid_schema_properties = rest_get_allowed_schema_keywords(); $valid_schema_properties = array_diff( $valid_schema_properties, array( 'default', 'required' ) ); foreach ( $schema_properties as $field_id => $params ) { if ( ! empty( $params['readonly'] ) ) { continue; } $endpoint_args[ $field_id ] = array( 'validate_callback' => 'rest_validate_request_arg', 'sanitize_callback' => 'rest_sanitize_request_arg', ); if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) { $endpoint_args[ $field_id ]['default'] = $params['default']; } if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) { $endpoint_args[ $field_id ]['required'] = true; } foreach ( $valid_schema_properties as $schema_prop ) { if ( isset( $params[ $schema_prop ] ) ) { $endpoint_args[ $field_id ][ $schema_prop ] = $params[ $schema_prop ]; } } if ( isset( $params['arg_options'] ) ) { if ( WP_REST_Server::CREATABLE !== $method ) { $params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '', ) ); } $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] ); } } return $endpoint_args; } function rest_convert_error_to_response( $error ) { $status = array_reduce( $error->get_all_error_data(), static function ( $status, $error_data ) { return is_array( $error_data ) && isset( $error_data['status'] ) ? $error_data['status'] : $status; }, 500 ); $errors = array(); foreach ( (array) $error->errors as $code => $messages ) { $all_data = $error->get_all_error_data( $code ); $last_data = array_pop( $all_data ); foreach ( (array) $messages as $message ) { $formatted = array( 'code' => $code, 'message' => $message, 'data' => $last_data, ); if ( $all_data ) { $formatted['additional_data'] = $all_data; } $errors[] = $formatted; } } $data = $errors[0]; if ( count( $errors ) > 1 ) { array_shift( $errors ); $data['additional_errors'] = $errors; } return new WP_REST_Response( $data, $status ); } <?php +} function rest_output_link_wp_head() { $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; } printf( '<link rel="https://api.w.org/" href="%s" />', esc_url( $api_root ) ); $resource = rest_get_queried_resource_route(); if ( $resource ) { printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) ); } } function rest_output_link_header() { if ( headers_sent() ) { return; } $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; } header( sprintf( 'Link: <%s>; rel="https://api.w.org/"', sanitize_url( $api_root ) ), false ); $resource = rest_get_queried_resource_route(); if ( $resource ) { header( sprintf( 'Link: <%s>; rel="alternate"; type="application/json"', sanitize_url( rest_url( $resource ) ) ), false ); } } function rest_cookie_check_errors( $result ) { if ( ! empty( $result ) ) { return $result; } global $wp_rest_auth_cookie; if ( true !== $wp_rest_auth_cookie && is_user_logged_in() ) { return $result; } $nonce = null; if ( isset( $_REQUEST['_wpnonce'] ) ) { $nonce = $_REQUEST['_wpnonce']; } elseif ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) { $nonce = $_SERVER['HTTP_X_WP_NONCE']; } if ( null === $nonce ) { wp_set_current_user( 0 ); return true; } $result = wp_verify_nonce( $nonce, 'wp_rest' ); if ( ! $result ) { return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie check failed' ), array( 'status' => 403 ) ); } rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) ); return true; } function rest_cookie_collect_status() { global $wp_rest_auth_cookie; $status_type = current_action(); if ( 'auth_cookie_valid' !== $status_type ) { $wp_rest_auth_cookie = substr( $status_type, 12 ); return; } $wp_rest_auth_cookie = true; } function rest_application_password_collect_status( $user_or_error, $app_password = array() ) { global $wp_rest_application_password_status, $wp_rest_application_password_uuid; $wp_rest_application_password_status = $user_or_error; if ( empty( $app_password['uuid'] ) ) { $wp_rest_application_password_uuid = null; } else { $wp_rest_application_password_uuid = $app_password['uuid']; } } function rest_get_authenticated_app_password() { global $wp_rest_application_password_uuid; return $wp_rest_application_password_uuid; } function rest_application_password_check_errors( $result ) { global $wp_rest_application_password_status; if ( ! empty( $result ) ) { return $result; } if ( is_wp_error( $wp_rest_application_password_status ) ) { $data = $wp_rest_application_password_status->get_error_data(); if ( ! isset( $data['status'] ) ) { $data['status'] = 401; } $wp_rest_application_password_status->add_data( $data ); return $wp_rest_application_password_status; } if ( $wp_rest_application_password_status instanceof WP_User ) { return true; } return $result; } function rest_add_application_passwords_to_index( $response ) { if ( ! wp_is_application_passwords_available() ) { return $response; } $response->data['authentication']['application-passwords'] = array( 'endpoints' => array( 'authorization' => admin_url( 'authorize-application.php' ), ), ); return $response; } function rest_get_avatar_urls( $id_or_email ) { $avatar_sizes = rest_get_avatar_sizes(); $urls = array(); foreach ( $avatar_sizes as $size ) { $urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) ); } return $urls; } function rest_get_avatar_sizes() { return apply_filters( 'rest_avatar_sizes', array( 24, 48, 96 ) ); } function rest_parse_date( $date, $force_utc = false ) { if ( $force_utc ) { $date = preg_replace( '/[+-]\d+:?\d+$/', '+00:00', $date ); } $regex = '#^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}(?::\d{2})?)?$#'; if ( ! preg_match( $regex, $date, $matches ) ) { return false; } return strtotime( $date ); } function rest_parse_hex_color( $color ) { $regex = '|^#([A-Fa-f0-9]{3}){1,2}$|'; if ( ! preg_match( $regex, $color, $matches ) ) { return false; } return $color; } function rest_get_date_with_gmt( $date, $is_utc = false ) { $has_timezone = preg_match( '#(Z|[+-]\d{2}(:\d{2})?)$#', $date ); $date = rest_parse_date( $date ); if ( empty( $date ) ) { return null; } if ( ! $is_utc && ! $has_timezone ) { $local = gmdate( 'Y-m-d H:i:s', $date ); $utc = get_gmt_from_date( $local ); } else { $utc = gmdate( 'Y-m-d H:i:s', $date ); $local = get_date_from_gmt( $utc ); } return array( $local, $utc ); } function rest_authorization_required_code() { return is_user_logged_in() ? 403 : 401; } function rest_validate_request_arg( $value, $request, $param ) { $attributes = $request->get_attributes(); if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) { return true; } $args = $attributes['args'][ $param ]; return rest_validate_value_from_schema( $value, $args, $param ); } function rest_sanitize_request_arg( $value, $request, $param ) { $attributes = $request->get_attributes(); if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) { return $value; } $args = $attributes['args'][ $param ]; return rest_sanitize_value_from_schema( $value, $args, $param ); } function rest_parse_request_arg( $value, $request, $param ) { $is_valid = rest_validate_request_arg( $value, $request, $param ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } $value = rest_sanitize_request_arg( $value, $request, $param ); return $value; } function rest_is_ip_address( $ip ) { $ipv4_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/'; if ( ! preg_match( $ipv4_pattern, $ip ) && ! WpOrg\Requests\Ipv6::check_ipv6( $ip ) ) { return false; } return $ip; } function rest_sanitize_boolean( $value ) { if ( is_string( $value ) ) { $value = strtolower( $value ); if ( in_array( $value, array( 'false', '0' ), true ) ) { $value = false; } } return (bool) $value; } function rest_is_boolean( $maybe_bool ) { if ( is_bool( $maybe_bool ) ) { return true; } if ( is_string( $maybe_bool ) ) { $maybe_bool = strtolower( $maybe_bool ); $valid_boolean_values = array( 'false', 'true', '0', '1', ); return in_array( $maybe_bool, $valid_boolean_values, true ); } if ( is_int( $maybe_bool ) ) { return in_array( $maybe_bool, array( 0, 1 ), true ); } return false; } function rest_is_integer( $maybe_integer ) { return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer; } function rest_is_array( $maybe_array ) { if ( is_scalar( $maybe_array ) ) { $maybe_array = wp_parse_list( $maybe_array ); } return wp_is_numeric_array( $maybe_array ); } function rest_sanitize_array( $maybe_array ) { if ( is_scalar( $maybe_array ) ) { return wp_parse_list( $maybe_array ); } if ( ! is_array( $maybe_array ) ) { return array(); } return array_values( $maybe_array ); } function rest_is_object( $maybe_object ) { if ( '' === $maybe_object ) { return true; } if ( $maybe_object instanceof stdClass ) { return true; } if ( $maybe_object instanceof JsonSerializable ) { $maybe_object = $maybe_object->jsonSerialize(); } return is_array( $maybe_object ); } function rest_sanitize_object( $maybe_object ) { if ( '' === $maybe_object ) { return array(); } if ( $maybe_object instanceof stdClass ) { return (array) $maybe_object; } if ( $maybe_object instanceof JsonSerializable ) { $maybe_object = $maybe_object->jsonSerialize(); } if ( ! is_array( $maybe_object ) ) { return array(); } return $maybe_object; } function rest_get_best_type_for_value( $value, $types ) { static $checks = array( 'array' => 'rest_is_array', 'object' => 'rest_is_object', 'integer' => 'rest_is_integer', 'number' => 'is_numeric', 'boolean' => 'rest_is_boolean', 'string' => 'is_string', 'null' => 'is_null', ); if ( '' === $value && in_array( 'string', $types, true ) ) { return 'string'; } foreach ( $types as $type ) { if ( isset( $checks[ $type ] ) && $checks[ $type ]( $value ) ) { return $type; } } return ''; } function rest_handle_multi_type_schema( $value, $args, $param = '' ) { $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); $invalid_types = array_diff( $args['type'], $allowed_types ); if ( $invalid_types ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only contain the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } $best_type = rest_get_best_type_for_value( $value, $args['type'] ); if ( ! $best_type ) { if ( ! $invalid_types ) { return ''; } $best_type = reset( $invalid_types ); } return $best_type; } function rest_validate_array_contains_unique_items( $input_array ) { $seen = array(); foreach ( $input_array as $item ) { $stabilized = rest_stabilize_value( $item ); $key = serialize( $stabilized ); if ( ! isset( $seen[ $key ] ) ) { $seen[ $key ] = true; continue; } return false; } return true; } function rest_stabilize_value( $value ) { if ( is_scalar( $value ) || is_null( $value ) ) { return $value; } if ( is_object( $value ) ) { _doing_it_wrong( __FUNCTION__, __( 'Cannot stabilize objects. Convert the object to an array first.' ), '5.5.0' ); return $value; } ksort( $value ); foreach ( $value as $k => $v ) { $value[ $k ] = rest_stabilize_value( $v ); } return $value; } function rest_validate_json_schema_pattern( $pattern, $value ) { $escaped_pattern = str_replace( '#', '\\#', $pattern ); return 1 === preg_match( '#' . $escaped_pattern . '#u', $value ); } function rest_find_matching_pattern_property_schema( $property, $args ) { if ( isset( $args['patternProperties'] ) ) { foreach ( $args['patternProperties'] as $pattern => $child_schema ) { if ( rest_validate_json_schema_pattern( $pattern, $property ) ) { return $child_schema; } } } return null; } function rest_format_combining_operation_error( $param, $error ) { $position = $error['index']; $reason = $error['error_object']->get_error_message(); if ( isset( $error['schema']['title'] ) ) { $title = $error['schema']['title']; return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ), array( 'position' => $position ) ); } return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ), array( 'position' => $position ) ); } function rest_get_combining_operation_error( $value, $param, $errors ) { if ( 1 === count( $errors ) ) { return rest_format_combining_operation_error( $param, $errors[0] ); } $filtered_errors = array(); foreach ( $errors as $error ) { $error_code = $error['error_object']->get_error_code(); $error_data = $error['error_object']->get_error_data(); if ( 'rest_invalid_type' !== $error_code || ( isset( $error_data['param'] ) && $param !== $error_data['param'] ) ) { $filtered_errors[] = $error; } } if ( 1 === count( $filtered_errors ) ) { return rest_format_combining_operation_error( $param, $filtered_errors[0] ); } if ( count( $filtered_errors ) > 1 && 'object' === $filtered_errors[0]['schema']['type'] ) { $result = null; $number = 0; foreach ( $filtered_errors as $error ) { if ( isset( $error['schema']['properties'] ) ) { $n = count( array_intersect_key( $error['schema']['properties'], $value ) ); if ( $n > $number ) { $result = $error; $number = $n; } } } if ( null !== $result ) { return rest_format_combining_operation_error( $param, $result ); } } $schema_titles = array(); foreach ( $errors as $error ) { if ( isset( $error['schema']['title'] ) ) { $schema_titles[] = $error['schema']['title']; } } if ( count( $schema_titles ) === count( $errors ) ) { return new WP_Error( 'rest_no_matching_schema', wp_sprintf( __( '%1$s is not a valid %2$l.' ), $param, $schema_titles ) ); } return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%s does not match any of the expected formats.' ), $param ) ); } function rest_find_any_matching_schema( $value, $args, $param ) { $errors = array(); foreach ( $args['anyOf'] as $index => $schema ) { if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) { $schema['type'] = $args['type']; } $is_valid = rest_validate_value_from_schema( $value, $schema, $param ); if ( ! is_wp_error( $is_valid ) ) { return $schema; } $errors[] = array( 'error_object' => $is_valid, 'schema' => $schema, 'index' => $index, ); } return rest_get_combining_operation_error( $value, $param, $errors ); } function rest_find_one_matching_schema( $value, $args, $param, $stop_after_first_match = false ) { $matching_schemas = array(); $errors = array(); foreach ( $args['oneOf'] as $index => $schema ) { if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) { $schema['type'] = $args['type']; } $is_valid = rest_validate_value_from_schema( $value, $schema, $param ); if ( ! is_wp_error( $is_valid ) ) { if ( $stop_after_first_match ) { return $schema; } $matching_schemas[] = array( 'schema_object' => $schema, 'index' => $index, ); } else { $errors[] = array( 'error_object' => $is_valid, 'schema' => $schema, 'index' => $index, ); } } if ( ! $matching_schemas ) { return rest_get_combining_operation_error( $value, $param, $errors ); } if ( count( $matching_schemas ) > 1 ) { $schema_positions = array(); $schema_titles = array(); foreach ( $matching_schemas as $schema ) { $schema_positions[] = $schema['index']; if ( isset( $schema['schema_object']['title'] ) ) { $schema_titles[] = $schema['schema_object']['title']; } } if ( count( $schema_titles ) === count( $matching_schemas ) ) { return new WP_Error( 'rest_one_of_multiple_matches', wp_sprintf( __( '%1$s matches %2$l, but should match only one.' ), $param, $schema_titles ), array( 'positions' => $schema_positions ) ); } return new WP_Error( 'rest_one_of_multiple_matches', sprintf( __( '%s matches more than one of the expected formats.' ), $param ), array( 'positions' => $schema_positions ) ); } return $matching_schemas[0]['schema_object']; } function rest_are_values_equal( $value1, $value2 ) { if ( is_array( $value1 ) && is_array( $value2 ) ) { if ( count( $value1 ) !== count( $value2 ) ) { return false; } foreach ( $value1 as $index => $value ) { if ( ! array_key_exists( $index, $value2 ) || ! rest_are_values_equal( $value, $value2[ $index ] ) ) { return false; } } return true; } if ( is_int( $value1 ) && is_float( $value2 ) || is_float( $value1 ) && is_int( $value2 ) ) { return (float) $value1 === (float) $value2; } return $value1 === $value2; } function rest_validate_enum( $value, $args, $param ) { $sanitized_value = rest_sanitize_value_from_schema( $value, $args, $param ); if ( is_wp_error( $sanitized_value ) ) { return $sanitized_value; } foreach ( $args['enum'] as $enum_value ) { if ( rest_are_values_equal( $sanitized_value, $enum_value ) ) { return true; } } $encoded_enum_values = array(); foreach ( $args['enum'] as $enum_value ) { $encoded_enum_values[] = is_scalar( $enum_value ) ? $enum_value : wp_json_encode( $enum_value ); } if ( count( $encoded_enum_values ) === 1 ) { return new WP_Error( 'rest_not_in_enum', wp_sprintf( __( '%1$s is not %2$s.' ), $param, $encoded_enum_values[0] ) ); } return new WP_Error( 'rest_not_in_enum', wp_sprintf( __( '%1$s is not one of %2$l.' ), $param, $encoded_enum_values ) ); } function rest_get_allowed_schema_keywords() { return array( 'title', 'description', 'default', 'type', 'format', 'enum', 'items', 'properties', 'additionalProperties', 'patternProperties', 'minProperties', 'maxProperties', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'multipleOf', 'minLength', 'maxLength', 'pattern', 'minItems', 'maxItems', 'uniqueItems', 'anyOf', 'oneOf', ); } function rest_validate_value_from_schema( $value, $args, $param = '' ) { if ( isset( $args['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) && isset( $matching_schema['type'] ) ) { $args['type'] = $matching_schema['type']; } } if ( isset( $args['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) && isset( $matching_schema['type'] ) ) { $args['type'] = $matching_schema['type']; } } $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); if ( ! isset( $args['type'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The "type" schema keyword for %s is required.' ), $param ), '5.5.0' ); } if ( is_array( $args['type'] ) ) { $best_type = rest_handle_multi_type_schema( $value, $args, $param ); if ( ! $best_type ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, implode( ',', $args['type'] ) ), array( 'param' => $param ) ); } $args['type'] = $best_type; } if ( ! in_array( $args['type'], $allowed_types, true ) ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } switch ( $args['type'] ) { case 'null': $is_valid = rest_validate_null_value_from_schema( $value, $param ); break; case 'boolean': $is_valid = rest_validate_boolean_value_from_schema( $value, $param ); break; case 'object': $is_valid = rest_validate_object_value_from_schema( $value, $args, $param ); break; case 'array': $is_valid = rest_validate_array_value_from_schema( $value, $args, $param ); break; case 'number': $is_valid = rest_validate_number_value_from_schema( $value, $args, $param ); break; case 'string': $is_valid = rest_validate_string_value_from_schema( $value, $args, $param ); break; case 'integer': $is_valid = rest_validate_integer_value_from_schema( $value, $args, $param ); break; default: $is_valid = true; break; } if ( is_wp_error( $is_valid ) ) { return $is_valid; } if ( ! empty( $args['enum'] ) ) { $enum_contains_value = rest_validate_enum( $value, $args, $param ); if ( is_wp_error( $enum_contains_value ) ) { return $enum_contains_value; } } if ( isset( $args['format'] ) && ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) ) ) { switch ( $args['format'] ) { case 'hex-color': if ( ! rest_parse_hex_color( $value ) ) { return new WP_Error( 'rest_invalid_hex_color', __( 'Invalid hex color.' ) ); } break; case 'date-time': if ( ! rest_parse_date( $value ) ) { return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) ); } break; case 'email': if ( ! is_email( $value ) ) { return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) ); } break; case 'ip': if ( ! rest_is_ip_address( $value ) ) { return new WP_Error( 'rest_invalid_ip', sprintf( __( '%s is not a valid IP address.' ), $param ) ); } break; case 'uuid': if ( ! wp_is_uuid( $value ) ) { return new WP_Error( 'rest_invalid_uuid', sprintf( __( '%s is not a valid UUID.' ), $param ) ); } break; } } return true; } function rest_validate_null_value_from_schema( $value, $param ) { if ( null !== $value ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'null' ), array( 'param' => $param ) ); } return true; } function rest_validate_boolean_value_from_schema( $value, $param ) { if ( ! rest_is_boolean( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'boolean' ), array( 'param' => $param ) ); } return true; } function rest_validate_object_value_from_schema( $value, $args, $param ) { if ( ! rest_is_object( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'object' ), array( 'param' => $param ) ); } $value = rest_sanitize_object( $value ); if ( isset( $args['required'] ) && is_array( $args['required'] ) ) { foreach ( $args['required'] as $name ) { if ( ! array_key_exists( $name, $value ) ) { return new WP_Error( 'rest_property_required', sprintf( __( '%1$s is a required property of %2$s.' ), $name, $param ) ); } } } elseif ( isset( $args['properties'] ) ) { foreach ( $args['properties'] as $name => $property ) { if ( isset( $property['required'] ) && true === $property['required'] && ! array_key_exists( $name, $value ) ) { return new WP_Error( 'rest_property_required', sprintf( __( '%1$s is a required property of %2$s.' ), $name, $param ) ); } } } foreach ( $value as $property => $v ) { if ( isset( $args['properties'][ $property ] ) ) { $is_valid = rest_validate_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } continue; } $pattern_property_schema = rest_find_matching_pattern_property_schema( $property, $args ); if ( null !== $pattern_property_schema ) { $is_valid = rest_validate_value_from_schema( $v, $pattern_property_schema, $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } continue; } if ( isset( $args['additionalProperties'] ) ) { if ( false === $args['additionalProperties'] ) { return new WP_Error( 'rest_additional_properties_forbidden', sprintf( __( '%1$s is not a valid property of Object.' ), $property ) ); } if ( is_array( $args['additionalProperties'] ) ) { $is_valid = rest_validate_value_from_schema( $v, $args['additionalProperties'], $param . '[' . $property . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } } } } if ( isset( $args['minProperties'] ) && count( $value ) < $args['minProperties'] ) { return new WP_Error( 'rest_too_few_properties', sprintf( _n( '%1$s must contain at least %2$s property.', '%1$s must contain at least %2$s properties.', $args['minProperties'] ), $param, number_format_i18n( $args['minProperties'] ) ) ); } if ( isset( $args['maxProperties'] ) && count( $value ) > $args['maxProperties'] ) { return new WP_Error( 'rest_too_many_properties', sprintf( _n( '%1$s must contain at most %2$s property.', '%1$s must contain at most %2$s properties.', $args['maxProperties'] ), $param, number_format_i18n( $args['maxProperties'] ) ) ); } return true; } function rest_validate_array_value_from_schema( $value, $args, $param ) { if ( ! rest_is_array( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ), array( 'param' => $param ) ); } $value = rest_sanitize_array( $value ); if ( isset( $args['items'] ) ) { foreach ( $value as $index => $v ) { $is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' ); if ( is_wp_error( $is_valid ) ) { return $is_valid; } } } if ( isset( $args['minItems'] ) && count( $value ) < $args['minItems'] ) { return new WP_Error( 'rest_too_few_items', sprintf( _n( '%1$s must contain at least %2$s item.', '%1$s must contain at least %2$s items.', $args['minItems'] ), $param, number_format_i18n( $args['minItems'] ) ) ); } if ( isset( $args['maxItems'] ) && count( $value ) > $args['maxItems'] ) { return new WP_Error( 'rest_too_many_items', sprintf( _n( '%1$s must contain at most %2$s item.', '%1$s must contain at most %2$s items.', $args['maxItems'] ), $param, number_format_i18n( $args['maxItems'] ) ) ); } if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { return new WP_Error( 'rest_duplicate_items', sprintf( __( '%s has duplicate items.' ), $param ) ); } return true; } function rest_validate_number_value_from_schema( $value, $args, $param ) { if ( ! is_numeric( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ), array( 'param' => $param ) ); } if ( isset( $args['multipleOf'] ) && fmod( $value, $args['multipleOf'] ) !== 0.0 ) { return new WP_Error( 'rest_invalid_multiple', sprintf( __( '%1$s must be a multiple of %2$s.' ), $param, $args['multipleOf'] ) ); } if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) ); } if ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) ); } } if ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) { if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) ); } if ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) ); } } if ( isset( $args['minimum'], $args['maximum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) { if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { if ( $value > $args['maximum'] || $value <= $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( ! empty( $args['exclusiveMaximum'] ) && empty( $args['exclusiveMinimum'] ) ) { if ( $value >= $args['maximum'] || $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } if ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { if ( $value > $args['maximum'] || $value < $args['minimum'] ) { return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); } } } return true; } function rest_validate_string_value_from_schema( $value, $args, $param ) { if ( ! is_string( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ), array( 'param' => $param ) ); } if ( isset( $args['minLength'] ) && mb_strlen( $value ) < $args['minLength'] ) { return new WP_Error( 'rest_too_short', sprintf( _n( '%1$s must be at least %2$s character long.', '%1$s must be at least %2$s characters long.', $args['minLength'] ), $param, number_format_i18n( $args['minLength'] ) ) ); } if ( isset( $args['maxLength'] ) && mb_strlen( $value ) > $args['maxLength'] ) { return new WP_Error( 'rest_too_long', sprintf( _n( '%1$s must be at most %2$s character long.', '%1$s must be at most %2$s characters long.', $args['maxLength'] ), $param, number_format_i18n( $args['maxLength'] ) ) ); } if ( isset( $args['pattern'] ) && ! rest_validate_json_schema_pattern( $args['pattern'], $value ) ) { return new WP_Error( 'rest_invalid_pattern', sprintf( __( '%1$s does not match pattern %2$s.' ), $param, $args['pattern'] ) ); } return true; } function rest_validate_integer_value_from_schema( $value, $args, $param ) { $is_valid_number = rest_validate_number_value_from_schema( $value, $args, $param ); if ( is_wp_error( $is_valid_number ) ) { return $is_valid_number; } if ( ! rest_is_integer( $value ) ) { return new WP_Error( 'rest_invalid_type', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ), array( 'param' => $param ) ); } return true; } function rest_sanitize_value_from_schema( $value, $args, $param = '' ) { if ( isset( $args['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) ) { $args['type'] = $matching_schema['type']; } $value = rest_sanitize_value_from_schema( $value, $matching_schema, $param ); } if ( isset( $args['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $value, $args, $param ); if ( is_wp_error( $matching_schema ) ) { return $matching_schema; } if ( ! isset( $args['type'] ) ) { $args['type'] = $matching_schema['type']; } $value = rest_sanitize_value_from_schema( $value, $matching_schema, $param ); } $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); if ( ! isset( $args['type'] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'The "type" schema keyword for %s is required.' ), $param ), '5.5.0' ); } if ( is_array( $args['type'] ) ) { $best_type = rest_handle_multi_type_schema( $value, $args, $param ); if ( ! $best_type ) { return null; } $args['type'] = $best_type; } if ( ! in_array( $args['type'], $allowed_types, true ) ) { _doing_it_wrong( __FUNCTION__, wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } if ( 'array' === $args['type'] ) { $value = rest_sanitize_array( $value ); if ( ! empty( $args['items'] ) ) { foreach ( $value as $index => $v ) { $value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' ); } } if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { return new WP_Error( 'rest_duplicate_items', sprintf( __( '%s has duplicate items.' ), $param ) ); } return $value; } if ( 'object' === $args['type'] ) { $value = rest_sanitize_object( $value ); foreach ( $value as $property => $v ) { if ( isset( $args['properties'][ $property ] ) ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' ); continue; } $pattern_property_schema = rest_find_matching_pattern_property_schema( $property, $args ); if ( null !== $pattern_property_schema ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $pattern_property_schema, $param . '[' . $property . ']' ); continue; } if ( isset( $args['additionalProperties'] ) ) { if ( false === $args['additionalProperties'] ) { unset( $value[ $property ] ); } elseif ( is_array( $args['additionalProperties'] ) ) { $value[ $property ] = rest_sanitize_value_from_schema( $v, $args['additionalProperties'], $param . '[' . $property . ']' ); } } } return $value; } if ( 'null' === $args['type'] ) { return null; } if ( 'integer' === $args['type'] ) { return (int) $value; } if ( 'number' === $args['type'] ) { return (float) $value; } if ( 'boolean' === $args['type'] ) { return rest_sanitize_boolean( $value ); } if ( isset( $args['format'] ) && ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) ) ) { switch ( $args['format'] ) { case 'hex-color': return (string) sanitize_hex_color( $value ); case 'date-time': return sanitize_text_field( $value ); case 'email': return sanitize_text_field( $value ); case 'uri': return sanitize_url( $value ); case 'ip': return sanitize_text_field( $value ); case 'uuid': return sanitize_text_field( $value ); case 'text-field': return sanitize_text_field( $value ); case 'textarea-field': return sanitize_textarea_field( $value ); } } if ( 'string' === $args['type'] ) { return (string) $value; } return $value; } function rest_preload_api_request( $memo, $path ) { if ( ! is_array( $memo ) ) { $memo = array(); } if ( empty( $path ) ) { return $memo; } $method = 'GET'; if ( is_array( $path ) && 2 === count( $path ) ) { $method = end( $path ); $path = reset( $path ); if ( ! in_array( $method, array( 'GET', 'OPTIONS' ), true ) ) { $method = 'GET'; } } $path = untrailingslashit( $path ); if ( empty( $path ) ) { $path = '/'; } $path_parts = parse_url( $path ); if ( false === $path_parts ) { return $memo; } $request = new WP_REST_Request( $method, $path_parts['path'] ); if ( ! empty( $path_parts['query'] ) ) { parse_str( $path_parts['query'], $query_params ); $request->set_query_params( $query_params ); } $response = rest_do_request( $request ); if ( 200 === $response->status ) { $server = rest_get_server(); $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request ); $embed = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false; $data = (array) $server->response_to_data( $response, $embed ); if ( 'OPTIONS' === $method ) { $memo[ $method ][ $path ] = array( 'body' => $data, 'headers' => $response->headers, ); } else { $memo[ $path ] = array( 'body' => $data, 'headers' => $response->headers, ); } } return $memo; } function rest_parse_embed_param( $embed ) { if ( ! $embed || 'true' === $embed || '1' === $embed ) { return true; } $rels = wp_parse_list( $embed ); if ( ! $rels ) { return true; } return $rels; } function rest_filter_response_by_context( $response_data, $schema, $context ) { if ( isset( $schema['anyOf'] ) ) { $matching_schema = rest_find_any_matching_schema( $response_data, $schema, '' ); if ( ! is_wp_error( $matching_schema ) ) { if ( ! isset( $schema['type'] ) ) { $schema['type'] = $matching_schema['type']; } $response_data = rest_filter_response_by_context( $response_data, $matching_schema, $context ); } } if ( isset( $schema['oneOf'] ) ) { $matching_schema = rest_find_one_matching_schema( $response_data, $schema, '', true ); if ( ! is_wp_error( $matching_schema ) ) { if ( ! isset( $schema['type'] ) ) { $schema['type'] = $matching_schema['type']; } $response_data = rest_filter_response_by_context( $response_data, $matching_schema, $context ); } } if ( ! is_array( $response_data ) && ! is_object( $response_data ) ) { return $response_data; } if ( isset( $schema['type'] ) ) { $type = $schema['type']; } elseif ( isset( $schema['properties'] ) ) { $type = 'object'; } else { return $response_data; } $is_array_type = 'array' === $type || ( is_array( $type ) && in_array( 'array', $type, true ) ); $is_object_type = 'object' === $type || ( is_array( $type ) && in_array( 'object', $type, true ) ); if ( $is_array_type && $is_object_type ) { if ( rest_is_array( $response_data ) ) { $is_object_type = false; } else { $is_array_type = false; } } $has_additional_properties = $is_object_type && isset( $schema['additionalProperties'] ) && is_array( $schema['additionalProperties'] ); foreach ( $response_data as $key => $value ) { $check = array(); if ( $is_array_type ) { $check = isset( $schema['items'] ) ? $schema['items'] : array(); } elseif ( $is_object_type ) { if ( isset( $schema['properties'][ $key ] ) ) { $check = $schema['properties'][ $key ]; } else { $pattern_property_schema = rest_find_matching_pattern_property_schema( $key, $schema ); if ( null !== $pattern_property_schema ) { $check = $pattern_property_schema; } elseif ( $has_additional_properties ) { $check = $schema['additionalProperties']; } } } if ( ! isset( $check['context'] ) ) { continue; } if ( ! in_array( $context, $check['context'], true ) ) { if ( $is_array_type ) { $response_data = array(); break; } if ( is_object( $response_data ) ) { unset( $response_data->$key ); } else { unset( $response_data[ $key ] ); } } elseif ( is_array( $value ) || is_object( $value ) ) { $new_value = rest_filter_response_by_context( $value, $check, $context ); if ( is_object( $response_data ) ) { $response_data->$key = $new_value; } else { $response_data[ $key ] = $new_value; } } } return $response_data; } function rest_default_additional_properties_to_false( $schema ) { $type = (array) $schema['type']; if ( in_array( 'object', $type, true ) ) { if ( isset( $schema['properties'] ) ) { foreach ( $schema['properties'] as $key => $child_schema ) { $schema['properties'][ $key ] = rest_default_additional_properties_to_false( $child_schema ); } } if ( isset( $schema['patternProperties'] ) ) { foreach ( $schema['patternProperties'] as $key => $child_schema ) { $schema['patternProperties'][ $key ] = rest_default_additional_properties_to_false( $child_schema ); } } if ( ! isset( $schema['additionalProperties'] ) ) { $schema['additionalProperties'] = false; } } if ( in_array( 'array', $type, true ) ) { if ( isset( $schema['items'] ) ) { $schema['items'] = rest_default_additional_properties_to_false( $schema['items'] ); } } return $schema; } function rest_get_route_for_post( $post ) { $post = get_post( $post ); if ( ! $post instanceof WP_Post ) { return ''; } $post_type_route = rest_get_route_for_post_type_items( $post->post_type ); if ( ! $post_type_route ) { return ''; } $route = sprintf( '%s/%d', $post_type_route, $post->ID ); return apply_filters( 'rest_route_for_post', $route, $post ); } function rest_get_route_for_post_type_items( $post_type ) { $post_type = get_post_type_object( $post_type ); if ( ! $post_type ) { return ''; } if ( ! $post_type->show_in_rest ) { return ''; } $namespace = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2'; $rest_base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; $route = sprintf( '/%s/%s', $namespace, $rest_base ); return apply_filters( 'rest_route_for_post_type_items', $route, $post_type ); } function rest_get_route_for_term( $term ) { $term = get_term( $term ); if ( ! $term instanceof WP_Term ) { return ''; } $taxonomy_route = rest_get_route_for_taxonomy_items( $term->taxonomy ); if ( ! $taxonomy_route ) { return ''; } $route = sprintf( '%s/%d', $taxonomy_route, $term->term_id ); return apply_filters( 'rest_route_for_term', $route, $term ); } function rest_get_route_for_taxonomy_items( $taxonomy ) { $taxonomy = get_taxonomy( $taxonomy ); if ( ! $taxonomy ) { return ''; } if ( ! $taxonomy->show_in_rest ) { return ''; } $namespace = ! empty( $taxonomy->rest_namespace ) ? $taxonomy->rest_namespace : 'wp/v2'; $rest_base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; $route = sprintf( '/%s/%s', $namespace, $rest_base ); return apply_filters( 'rest_route_for_taxonomy_items', $route, $taxonomy ); } function rest_get_queried_resource_route() { if ( is_singular() ) { $route = rest_get_route_for_post( get_queried_object() ); } elseif ( is_category() || is_tag() || is_tax() ) { $route = rest_get_route_for_term( get_queried_object() ); } elseif ( is_author() ) { $route = '/wp/v2/users/' . get_queried_object_id(); } else { $route = ''; } return apply_filters( 'rest_queried_resource_route', $route ); } function rest_get_endpoint_args_for_schema( $schema, $method = WP_REST_Server::CREATABLE ) { $schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array(); $endpoint_args = array(); $valid_schema_properties = rest_get_allowed_schema_keywords(); $valid_schema_properties = array_diff( $valid_schema_properties, array( 'default', 'required' ) ); foreach ( $schema_properties as $field_id => $params ) { if ( ! empty( $params['readonly'] ) ) { continue; } $endpoint_args[ $field_id ] = array( 'validate_callback' => 'rest_validate_request_arg', 'sanitize_callback' => 'rest_sanitize_request_arg', ); if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) { $endpoint_args[ $field_id ]['default'] = $params['default']; } if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) { $endpoint_args[ $field_id ]['required'] = true; } foreach ( $valid_schema_properties as $schema_prop ) { if ( isset( $params[ $schema_prop ] ) ) { $endpoint_args[ $field_id ][ $schema_prop ] = $params[ $schema_prop ]; } } if ( isset( $params['arg_options'] ) ) { if ( WP_REST_Server::CREATABLE !== $method ) { $params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '', ) ); } $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] ); } } return $endpoint_args; } function rest_convert_error_to_response( $error ) { $status = array_reduce( $error->get_all_error_data(), static function ( $status, $error_data ) { return is_array( $error_data ) && isset( $error_data['status'] ) ? $error_data['status'] : $status; }, 500 ); $errors = array(); foreach ( (array) $error->errors as $code => $messages ) { $all_data = $error->get_all_error_data( $code ); $last_data = array_pop( $all_data ); foreach ( (array) $messages as $message ) { $formatted = array( 'code' => $code, 'message' => $message, 'data' => $last_data, ); if ( $all_data ) { $formatted['additional_data'] = $all_data; } $errors[] = $formatted; } } $data = $errors[0]; if ( count( $errors ) > 1 ) { array_shift( $errors ); $data['additional_errors'] = $errors; } return new WP_REST_Response( $data, $status ); } <?php class WP_REST_Request implements ArrayAccess { protected $method = ''; protected $params; protected $headers = array(); protected $body = null; protected $route; protected $attributes = array(); protected $parsed_json = false; protected $parsed_body = false; public function __construct( $method = '', $route = '', $attributes = array() ) { $this->params = array( 'URL' => array(), 'GET' => array(), 'POST' => array(), 'FILES' => array(), 'JSON' => null, 'defaults' => array(), ); $this->set_method( $method ); $this->set_route( $route ); $this->set_attributes( $attributes ); } public function get_method() { return $this->method; } public function set_method( $method ) { $this->method = strtoupper( $method ); } public function get_headers() { return $this->headers; } public static function canonicalize_header_name( $key ) { $key = strtolower( $key ); $key = str_replace( '-', '_', $key ); return $key; } public function get_header( $key ) { $key = $this->canonicalize_header_name( $key ); if ( ! isset( $this->headers[ $key ] ) ) { return null; } return implode( ',', $this->headers[ $key ] ); } public function get_header_as_array( $key ) { $key = $this->canonicalize_header_name( $key ); if ( ! isset( $this->headers[ $key ] ) ) { return null; } return $this->headers[ $key ]; } public function set_header( $key, $value ) { $key = $this->canonicalize_header_name( $key ); $value = (array) $value; $this->headers[ $key ] = $value; } public function add_header( $key, $value ) { $key = $this->canonicalize_header_name( $key ); $value = (array) $value; if ( ! isset( $this->headers[ $key ] ) ) { $this->headers[ $key ] = array(); } $this->headers[ $key ] = array_merge( $this->headers[ $key ], $value ); } public function remove_header( $key ) { $key = $this->canonicalize_header_name( $key ); unset( $this->headers[ $key ] ); } public function set_headers( $headers, $override = true ) { if ( true === $override ) { $this->headers = array(); } foreach ( $headers as $key => $value ) { $this->set_header( $key, $value ); } } public function get_content_type() { $value = $this->get_header( 'content-type' ); if ( empty( $value ) ) { return null; } $parameters = ''; if ( strpos( $value, ';' ) ) { list( $value, $parameters ) = explode( ';', $value, 2 ); } $value = strtolower( $value ); if ( false === strpos( $value, '/' ) ) { return null; } list( $type, $subtype ) = explode( '/', $value, 2 ); $data = compact( 'value', 'type', 'subtype', 'parameters' ); $data = array_map( 'trim', $data ); return $data; } public function is_json_content_type() { $content_type = $this->get_content_type(); return isset( $content_type['value'] ) && wp_is_json_media_type( $content_type['value'] ); } protected function get_parameter_order() { $order = array(); if ( $this->is_json_content_type() ) { $order[] = 'JSON'; } $this->parse_json_params(); $body = $this->get_body(); if ( 'POST' !== $this->method && ! empty( $body ) ) { $this->parse_body_params(); } $accepts_body_data = array( 'POST', 'PUT', 'PATCH', 'DELETE' ); if ( in_array( $this->method, $accepts_body_data, true ) ) { $order[] = 'POST'; } $order[] = 'GET'; $order[] = 'URL'; $order[] = 'defaults'; return apply_filters( 'rest_request_parameter_order', $order, $this ); } public function get_param( $key ) { $order = $this->get_parameter_order(); foreach ( $order as $type ) { if ( isset( $this->params[ $type ][ $key ] ) ) { return $this->params[ $type ][ $key ]; } } return null; } public function has_param( $key ) { $order = $this->get_parameter_order(); foreach ( $order as $type ) { if ( is_array( $this->params[ $type ] ) && array_key_exists( $key, $this->params[ $type ] ) ) { return true; } } return false; } public function set_param( $key, $value ) { $order = $this->get_parameter_order(); $found_key = false; foreach ( $order as $type ) { if ( 'defaults' !== $type && is_array( $this->params[ $type ] ) && array_key_exists( $key, $this->params[ $type ] ) ) { $this->params[ $type ][ $key ] = $value; $found_key = true; } } if ( ! $found_key ) { $this->params[ $order[0] ][ $key ] = $value; } } public function get_params() { $order = $this->get_parameter_order(); $order = array_reverse( $order, true ); $params = array(); foreach ( $order as $type ) { foreach ( (array) $this->params[ $type ] as $key => $value ) { $params[ $key ] = $value; } } return $params; } public function get_url_params() { return $this->params['URL']; } public function set_url_params( $params ) { $this->params['URL'] = $params; } public function get_query_params() { return $this->params['GET']; } public function set_query_params( $params ) { $this->params['GET'] = $params; } public function get_body_params() { return $this->params['POST']; } public function set_body_params( $params ) { $this->params['POST'] = $params; } public function get_file_params() { return $this->params['FILES']; } public function set_file_params( $params ) { $this->params['FILES'] = $params; } public function get_default_params() { return $this->params['defaults']; } public function set_default_params( $params ) { $this->params['defaults'] = $params; } public function get_body() { return $this->body; } public function set_body( $data ) { $this->body = $data; $this->parsed_json = false; $this->parsed_body = false; $this->params['JSON'] = null; } public function get_json_params() { $this->parse_json_params(); return $this->params['JSON']; } protected function parse_json_params() { if ( $this->parsed_json ) { return true; } $this->parsed_json = true; if ( ! $this->is_json_content_type() ) { return true; } $body = $this->get_body(); if ( empty( $body ) ) { return true; } $params = json_decode( $body, true ); if ( null === $params && JSON_ERROR_NONE !== json_last_error() ) { $this->parsed_json = false; $error_data = array( 'status' => WP_Http::BAD_REQUEST, 'json_error_code' => json_last_error(), 'json_error_message' => json_last_error_msg(), ); return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data ); } $this->params['JSON'] = $params; return true; } protected function parse_body_params() { if ( $this->parsed_body ) { return; } $this->parsed_body = true; $content_type = $this->get_content_type(); if ( ! empty( $content_type ) && 'application/x-www-form-urlencoded' !== $content_type['value'] ) { return; } parse_str( $this->get_body(), $params ); $this->params['POST'] = array_merge( $params, $this->params['POST'] ); } public function get_route() { return $this->route; } public function set_route( $route ) { $this->route = $route; } public function get_attributes() { return $this->attributes; } public function set_attributes( $attributes ) { $this->attributes = $attributes; } public function sanitize_params() { $attributes = $this->get_attributes(); if ( empty( $attributes['args'] ) ) { return true; } $order = $this->get_parameter_order(); $invalid_params = array(); $invalid_details = array(); foreach ( $order as $type ) { if ( empty( $this->params[ $type ] ) ) { continue; } foreach ( $this->params[ $type ] as $key => $value ) { if ( ! isset( $attributes['args'][ $key ] ) ) { continue; } $param_args = $attributes['args'][ $key ]; if ( ! array_key_exists( 'sanitize_callback', $param_args ) && ! empty( $param_args['type'] ) ) { $param_args['sanitize_callback'] = 'rest_parse_request_arg'; } if ( empty( $param_args['sanitize_callback'] ) ) { continue; } $sanitized_value = call_user_func( $param_args['sanitize_callback'], $value, $this, $key ); if ( is_wp_error( $sanitized_value ) ) { $invalid_params[ $key ] = implode( ' ', $sanitized_value->get_error_messages() ); $invalid_details[ $key ] = rest_convert_error_to_response( $sanitized_value )->get_data(); } else { $this->params[ $type ][ $key ] = $sanitized_value; } } } if ( $invalid_params ) { return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params, 'details' => $invalid_details, ) ); } return true; } public function has_valid_params() { $json_error = $this->parse_json_params(); if ( is_wp_error( $json_error ) ) { return $json_error; } $attributes = $this->get_attributes(); $required = array(); $args = empty( $attributes['args'] ) ? array() : $attributes['args']; foreach ( $args as $key => $arg ) { $param = $this->get_param( $key ); if ( isset( $arg['required'] ) && true === $arg['required'] && null === $param ) { $required[] = $key; } } if ( ! empty( $required ) ) { return new WP_Error( 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required, ) ); } $invalid_params = array(); $invalid_details = array(); foreach ( $args as $key => $arg ) { $param = $this->get_param( $key ); if ( null !== $param && ! empty( $arg['validate_callback'] ) ) { $valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key ); if ( false === $valid_check ) { $invalid_params[ $key ] = __( 'Invalid parameter.' ); } if ( is_wp_error( $valid_check ) ) { $invalid_params[ $key ] = implode( ' ', $valid_check->get_error_messages() ); $invalid_details[ $key ] = rest_convert_error_to_response( $valid_check )->get_data(); } } } if ( $invalid_params ) { return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params, 'details' => $invalid_details, ) ); } if ( isset( $attributes['validate_callback'] ) ) { $valid_check = call_user_func( $attributes['validate_callback'], $this ); if ( is_wp_error( $valid_check ) ) { return $valid_check; } if ( false === $valid_check ) { return new WP_Error( 'rest_invalid_params', __( 'Invalid parameters.' ), array( 'status' => 400 ) ); } } return true; } public function offsetExists( $offset ) { $order = $this->get_parameter_order(); foreach ( $order as $type ) { if ( isset( $this->params[ $type ][ $offset ] ) ) { return true; } } return false; } public function offsetGet( $offset ) { return $this->get_param( $offset ); } public function offsetSet( $offset, $value ) { $this->set_param( $offset, $value ); } public function offsetUnset( $offset ) { $order = $this->get_parameter_order(); foreach ( $order as $type ) { unset( $this->params[ $type ][ $offset ] ); } } public static function from_url( $url ) { $bits = parse_url( $url ); $query_params = array(); if ( ! empty( $bits['query'] ) ) { wp_parse_str( $bits['query'], $query_params ); } $api_root = rest_url(); if ( get_option( 'permalink_structure' ) && 0 === strpos( $url, $api_root ) ) { $api_url_part = substr( $url, strlen( untrailingslashit( $api_root ) ) ); $route = parse_url( $api_url_part, PHP_URL_PATH ); } elseif ( ! empty( $query_params['rest_route'] ) ) { $route = $query_params['rest_route']; unset( $query_params['rest_route'] ); } $request = false; if ( ! empty( $route ) ) { $request = new WP_REST_Request( 'GET', $route ); $request->set_query_params( $query_params ); } return apply_filters( 'rest_request_from_url', $request, $url ); } } <?php class WP_REST_Response extends WP_HTTP_Response { protected $links = array(); protected $matched_route = ''; protected $matched_handler = null; public function add_link( $rel, $href, $attributes = array() ) { if ( empty( $this->links[ $rel ] ) ) { $this->links[ $rel ] = array(); } if ( isset( $attributes['href'] ) ) { unset( $attributes['href'] ); } $this->links[ $rel ][] = array( 'href' => $href, 'attributes' => $attributes, ); } public function remove_link( $rel, $href = null ) { if ( ! isset( $this->links[ $rel ] ) ) { return; } if ( $href ) { $this->links[ $rel ] = wp_list_filter( $this->links[ $rel ], array( 'href' => $href ), 'NOT' ); } else { $this->links[ $rel ] = array(); } if ( ! $this->links[ $rel ] ) { unset( $this->links[ $rel ] ); } } public function add_links( $links ) { foreach ( $links as $rel => $set ) { if ( isset( $set['href'] ) ) { $set = array( $set ); } foreach ( $set as $attributes ) { $this->add_link( $rel, $attributes['href'], $attributes ); } } } public function get_links() { return $this->links; } public function link_header( $rel, $link, $other = array() ) { $header = '<' . $link . '>; rel="' . $rel . '"'; foreach ( $other as $key => $value ) { if ( 'title' === $key ) { $value = '"' . $value . '"'; } $header .= '; ' . $key . '=' . $value; } $this->header( 'Link', $header, false ); } public function get_matched_route() { return $this->matched_route; } public function set_matched_route( $route ) { $this->matched_route = $route; } public function get_matched_handler() { return $this->matched_handler; } public function set_matched_handler( $handler ) { $this->matched_handler = $handler; } public function is_error() { return $this->get_status() >= 400; } public function as_error() { if ( ! $this->is_error() ) { return null; } $error = new WP_Error(); if ( is_array( $this->get_data() ) ) { $data = $this->get_data(); $error->add( $data['code'], $data['message'], $data['data'] ); if ( ! empty( $data['additional_errors'] ) ) { foreach ( $data['additional_errors'] as $err ) { $error->add( $err['code'], $err['message'], $err['data'] ); } } } else { $error->add( $this->get_status(), '', array( 'status' => $this->get_status() ) ); } return $error; } public function get_curies() { $curies = array( array( 'name' => 'wp', 'href' => 'https://api.w.org/{rel}', 'templated' => true, ), ); $additional = apply_filters( 'rest_response_link_curies', array() ); return array_merge( $curies, $additional ); } } <?php class WP_REST_Server { const READABLE = 'GET'; const CREATABLE = 'POST'; const EDITABLE = 'POST, PUT, PATCH'; const DELETABLE = 'DELETE'; const ALLMETHODS = 'GET, POST, PUT, PATCH, DELETE'; protected $namespaces = array(); protected $endpoints = array(); protected $route_options = array(); protected $embed_cache = array(); public function __construct() { $this->endpoints = array( '/' => array( 'callback' => array( $this, 'get_index' ), 'methods' => 'GET', 'args' => array( 'context' => array( 'default' => 'view', ), ), ), '/batch/v1' => array( 'callback' => array( $this, 'serve_batch_request_v1' ), 'methods' => 'POST', 'args' => array( 'validation' => array( 'type' => 'string', 'enum' => array( 'require-all-validate', 'normal' ), 'default' => 'normal', ), 'requests' => array( 'required' => true, 'type' => 'array', 'maxItems' => $this->get_max_batch_size(), 'items' => array( 'type' => 'object', 'properties' => array( 'method' => array( 'type' => 'string', 'enum' => array( 'POST', 'PUT', 'PATCH', 'DELETE' ), 'default' => 'POST', ), 'path' => array( 'type' => 'string', 'required' => true, ), 'body' => array( 'type' => 'object', 'properties' => array(), 'additionalProperties' => true, ), 'headers' => array( 'type' => 'object', 'properties' => array(), 'additionalProperties' => array( 'type' => array( 'string', 'array' ), 'items' => array( 'type' => 'string', ), ), ), ), ), ), ), ), ); } public function check_authentication() { return apply_filters( 'rest_authentication_errors', null ); } protected function error_to_response( $error ) { return rest_convert_error_to_response( $error ); } protected function json_error( $code, $message, $status = null ) { if ( $status ) { $this->set_status( $status ); } $error = compact( 'code', 'message' ); return wp_json_encode( $error ); } protected function get_json_encode_options( WP_REST_Request $request ) { $options = 0; if ( $request->has_param( '_pretty' ) ) { $options |= JSON_PRETTY_PRINT; } return apply_filters( 'rest_json_encode_options', $options, $request ); } public function serve_request( $path = null ) { global $current_user; if ( $current_user instanceof WP_User && ! $current_user->exists() ) { $current_user = null; } $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); $jsonp_callback = false; if ( isset( $_GET['_jsonp'] ) ) { $jsonp_callback = $_GET['_jsonp']; } $content_type = ( $jsonp_callback && $jsonp_enabled ) ? 'application/javascript' : 'application/json'; $this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) ); $this->send_header( 'X-Robots-Tag', 'noindex' ); $api_root = get_rest_url(); if ( ! empty( $api_root ) ) { $this->send_header( 'Link', '<' . sanitize_url( $api_root ) . '>; rel="https://api.w.org/"' ); } $this->send_header( 'X-Content-Type-Options', 'nosniff' ); $expose_headers = array( 'X-WP-Total', 'X-WP-TotalPages', 'Link' ); $expose_headers = apply_filters( 'rest_exposed_cors_headers', $expose_headers ); $this->send_header( 'Access-Control-Expose-Headers', implode( ', ', $expose_headers ) ); $allow_headers = array( 'Authorization', 'X-WP-Nonce', 'Content-Disposition', 'Content-MD5', 'Content-Type', ); $allow_headers = apply_filters( 'rest_allowed_cors_headers', $allow_headers ); $this->send_header( 'Access-Control-Allow-Headers', implode( ', ', $allow_headers ) ); $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); if ( $send_no_cache_headers ) { foreach ( wp_get_nocache_headers() as $header => $header_value ) { if ( empty( $header_value ) ) { $this->remove_header( $header ); } else { $this->send_header( $header, $header_value ); } } } apply_filters_deprecated( 'rest_enabled', array( true ), '4.7.0', 'rest_authentication_errors', sprintf( __( 'The REST API can no longer be completely disabled, the %s filter can be used to restrict access to the API, instead.' ), 'rest_authentication_errors' ) ); if ( $jsonp_callback ) { if ( ! $jsonp_enabled ) { echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 ); return false; } if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { echo $this->json_error( 'rest_callback_invalid', __( 'Invalid JSONP callback function.' ), 400 ); return false; } } if ( empty( $path ) ) { if ( isset( $_SERVER['PATH_INFO'] ) ) { $path = $_SERVER['PATH_INFO']; } else { $path = '/'; } } $request = new WP_REST_Request( $_SERVER['REQUEST_METHOD'], $path ); $request->set_query_params( wp_unslash( $_GET ) ); $request->set_body_params( wp_unslash( $_POST ) ); $request->set_file_params( $_FILES ); $request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) ); $request->set_body( self::get_raw_data() ); if ( isset( $_GET['_method'] ) ) { $request->set_method( $_GET['_method'] ); } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); } $result = $this->check_authentication(); if ( ! is_wp_error( $result ) ) { $result = $this->dispatch( $request ); } $result = rest_ensure_response( $result ); if ( is_wp_error( $result ) ) { $result = $this->error_to_response( $result ); } $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request ); if ( isset( $_GET['_envelope'] ) ) { $embed = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false; $result = $this->envelope_response( $result, $embed ); } $headers = $result->get_headers(); $this->send_headers( $headers ); $code = $result->get_status(); $this->set_status( $code ); $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); if ( ! $served ) { if ( 'HEAD' === $request->get_method() ) { return null; } $embed = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false; $result = $this->response_to_data( $result, $embed ); $result = apply_filters( 'rest_pre_echo_response', $result, $this, $request ); if ( 204 === $code || null === $result ) { return null; } $result = wp_json_encode( $result, $this->get_json_encode_options( $request ) ); $json_error_message = $this->get_json_last_error(); if ( $json_error_message ) { $this->set_status( 500 ); $json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) ); $result = $this->error_to_response( $json_error_obj ); $result = wp_json_encode( $result->data, $this->get_json_encode_options( $request ) ); } if ( $jsonp_callback ) { echo '/**/' . $jsonp_callback . '(' . $result . ')'; } else { echo $result; } } return null; } public function response_to_data( $response, $embed ) { $data = $response->get_data(); $links = self::get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } if ( $embed ) { $this->embed_cache = array(); if ( wp_is_numeric_array( $data ) ) { foreach ( $data as $key => $item ) { $data[ $key ] = $this->embed_links( $item, $embed ); } } else { $data = $this->embed_links( $data, $embed ); } $this->embed_cache = array(); } return $data; } public static function get_response_links( $response ) { $links = $response->get_links(); if ( empty( $links ) ) { return array(); } $data = array(); foreach ( $links as $rel => $items ) { $data[ $rel ] = array(); foreach ( $items as $item ) { $attributes = $item['attributes']; $attributes['href'] = $item['href']; $data[ $rel ][] = $attributes; } } return $data; } public static function get_compact_response_links( $response ) { $links = self::get_response_links( $response ); if ( empty( $links ) ) { return array(); } $curies = $response->get_curies(); $used_curies = array(); foreach ( $links as $rel => $items ) { foreach ( $curies as $curie ) { $href_prefix = substr( $curie['href'], 0, strpos( $curie['href'], '{rel}' ) ); if ( strpos( $rel, $href_prefix ) !== 0 ) { continue; } $rel_regex = str_replace( '\{rel\}', '(.+)', preg_quote( $curie['href'], '!' ) ); preg_match( '!' . $rel_regex . '!', $rel, $matches ); if ( $matches ) { $new_rel = $curie['name'] . ':' . $matches[1]; $used_curies[ $curie['name'] ] = $curie; $links[ $new_rel ] = $items; unset( $links[ $rel ] ); break; } } } if ( $used_curies ) { $links['curies'] = array_values( $used_curies ); } return $links; } protected function embed_links( $data, $embed = true ) { if ( empty( $data['_links'] ) ) { return $data; } $embedded = array(); foreach ( $data['_links'] as $rel => $links ) { if ( is_array( $embed ) && ! in_array( $rel, $embed, true ) ) { continue; } $embeds = array(); foreach ( $links as $item ) { if ( empty( $item['embeddable'] ) ) { $embeds[] = array(); continue; } if ( ! array_key_exists( $item['href'], $this->embed_cache ) ) { $request = WP_REST_Request::from_url( $item['href'] ); if ( ! $request ) { $embeds[] = array(); continue; } if ( empty( $request['context'] ) ) { $request['context'] = 'embed'; } $response = $this->dispatch( $request ); $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request ); $this->embed_cache[ $item['href'] ] = $this->response_to_data( $response, false ); } $embeds[] = $this->embed_cache[ $item['href'] ]; } $has_links = count( array_filter( $embeds ) ); if ( $has_links ) { $embedded[ $rel ] = $embeds; } } if ( ! empty( $embedded ) ) { $data['_embedded'] = $embedded; } return $data; } public function envelope_response( $response, $embed ) { $envelope = array( 'body' => $this->response_to_data( $response, $embed ), 'status' => $response->get_status(), 'headers' => $response->get_headers(), ); $envelope = apply_filters( 'rest_envelope_response', $envelope, $response ); return rest_ensure_response( $envelope ); } public function register_route( $route_namespace, $route, $route_args, $override = false ) { if ( ! isset( $this->namespaces[ $route_namespace ] ) ) { $this->namespaces[ $route_namespace ] = array(); $this->register_route( $route_namespace, '/' . $route_namespace, array( array( 'methods' => self::READABLE, 'callback' => array( $this, 'get_namespace_index' ), 'args' => array( 'namespace' => array( 'default' => $route_namespace, ), 'context' => array( 'default' => 'view', ), ), ), ) ); } $this->namespaces[ $route_namespace ][ $route ] = true; $route_args['namespace'] = $route_namespace; if ( $override || empty( $this->endpoints[ $route ] ) ) { $this->endpoints[ $route ] = $route_args; } else { $this->endpoints[ $route ] = array_merge( $this->endpoints[ $route ], $route_args ); } } public function get_routes( $route_namespace = '' ) { $endpoints = $this->endpoints; if ( $route_namespace ) { $endpoints = wp_list_filter( $endpoints, array( 'namespace' => $route_namespace ) ); } $endpoints = apply_filters( 'rest_endpoints', $endpoints ); $defaults = array( 'methods' => '', 'accept_json' => false, 'accept_raw' => false, 'show_in_index' => true, 'args' => array(), ); foreach ( $endpoints as $route => &$handlers ) { if ( isset( $handlers['callback'] ) ) { $handlers = array( $handlers ); } if ( ! isset( $this->route_options[ $route ] ) ) { $this->route_options[ $route ] = array(); } foreach ( $handlers as $key => &$handler ) { if ( ! is_numeric( $key ) ) { $this->route_options[ $route ][ $key ] = $handler; unset( $handlers[ $key ] ); continue; } $handler = wp_parse_args( $handler, $defaults ); if ( is_string( $handler['methods'] ) ) { $methods = explode( ',', $handler['methods'] ); } elseif ( is_array( $handler['methods'] ) ) { $methods = $handler['methods']; } else { $methods = array(); } $handler['methods'] = array(); foreach ( $methods as $method ) { $method = strtoupper( trim( $method ) ); $handler['methods'][ $method ] = true; } } } return $endpoints; } public function get_namespaces() { return array_keys( $this->namespaces ); } public function get_route_options( $route ) { if ( ! isset( $this->route_options[ $route ] ) ) { return null; } return $this->route_options[ $route ]; } public function dispatch( $request ) { $result = apply_filters( 'rest_pre_dispatch', null, $this, $request ); if ( ! empty( $result ) ) { return $result; } $error = null; $matched = $this->match_request_to_handler( $request ); if ( is_wp_error( $matched ) ) { return $this->error_to_response( $matched ); } list( $route, $handler ) = $matched; if ( ! is_callable( $handler['callback'] ) ) { $error = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid.' ), array( 'status' => 500 ) ); } if ( ! is_wp_error( $error ) ) { $check_required = $request->has_valid_params(); if ( is_wp_error( $check_required ) ) { $error = $check_required; } else { $check_sanitized = $request->sanitize_params(); if ( is_wp_error( $check_sanitized ) ) { $error = $check_sanitized; } } } return $this->respond_to_request( $request, $route, $handler, $error ); } protected function match_request_to_handler( $request ) { $method = $request->get_method(); $path = $request->get_route(); $with_namespace = array(); foreach ( $this->get_namespaces() as $namespace ) { if ( 0 === strpos( trailingslashit( ltrim( $path, '/' ) ), $namespace ) ) { $with_namespace[] = $this->get_routes( $namespace ); } } if ( $with_namespace ) { $routes = array_merge( ...$with_namespace ); } else { $routes = $this->get_routes(); } foreach ( $routes as $route => $handlers ) { $match = preg_match( '@^' . $route . '$@i', $path, $matches ); if ( ! $match ) { continue; } $args = array(); foreach ( $matches as $param => $value ) { if ( ! is_int( $param ) ) { $args[ $param ] = $value; } } foreach ( $handlers as $handler ) { $callback = $handler['callback']; $response = null; $checked_method = $method; if ( 'HEAD' === $method && empty( $handler['methods']['HEAD'] ) ) { $checked_method = 'GET'; } if ( empty( $handler['methods'][ $checked_method ] ) ) { continue; } if ( ! is_callable( $callback ) ) { return array( $route, $handler ); } $request->set_url_params( $args ); $request->set_attributes( $handler ); $defaults = array(); foreach ( $handler['args'] as $arg => $options ) { if ( isset( $options['default'] ) ) { $defaults[ $arg ] = $options['default']; } } $request->set_default_params( $defaults ); return array( $route, $handler ); } } return new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method.' ), array( 'status' => 404 ) ); } protected function respond_to_request( $request, $route, $handler, $response ) { $response = apply_filters( 'rest_request_before_callbacks', $response, $handler, $request ); if ( ! is_wp_error( $response ) && ! empty( $handler['permission_callback'] ) ) { $permission = call_user_func( $handler['permission_callback'], $request ); if ( is_wp_error( $permission ) ) { $response = $permission; } elseif ( false === $permission || null === $permission ) { $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => rest_authorization_required_code() ) ); } } if ( ! is_wp_error( $response ) ) { $dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler ); if ( null !== $dispatch_result ) { $response = $dispatch_result; } else { $response = call_user_func( $handler['callback'], $request ); } } $response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request ); if ( is_wp_error( $response ) ) { $response = $this->error_to_response( $response ); } else { $response = rest_ensure_response( $response ); } $response->set_matched_route( $route ); $response->set_matched_handler( $handler ); return $response; } protected function get_json_last_error() { $last_error_code = json_last_error(); if ( JSON_ERROR_NONE === $last_error_code || empty( $last_error_code ) ) { return false; } return json_last_error_msg(); } public function get_index( $request ) { $available = array( 'name' => get_option( 'blogname' ), 'description' => get_option( 'blogdescription' ), 'url' => get_option( 'siteurl' ), 'home' => home_url(), 'gmt_offset' => get_option( 'gmt_offset' ), 'timezone_string' => get_option( 'timezone_string' ), 'namespaces' => array_keys( $this->namespaces ), 'authentication' => array(), 'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ), ); $response = new WP_REST_Response( $available ); $response->add_link( 'help', 'https://developer.wordpress.org/rest-api/' ); $this->add_active_theme_link_to_index( $response ); $this->add_site_logo_to_index( $response ); $this->add_site_icon_to_index( $response ); return apply_filters( 'rest_index', $response, $request ); } protected function add_active_theme_link_to_index( WP_REST_Response $response ) { $should_add = current_user_can( 'switch_themes' ) || current_user_can( 'manage_network_themes' ); if ( ! $should_add && current_user_can( 'edit_posts' ) ) { $should_add = true; } if ( ! $should_add ) { foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { $should_add = true; break; } } } if ( $should_add ) { $theme = wp_get_theme(); $response->add_link( 'https://api.w.org/active-theme', rest_url( 'wp/v2/themes/' . $theme->get_stylesheet() ) ); } } protected function add_site_logo_to_index( WP_REST_Response $response ) { $site_logo_id = get_theme_mod( 'custom_logo', 0 ); $this->add_image_to_index( $response, $site_logo_id, 'site_logo' ); } protected function add_site_icon_to_index( WP_REST_Response $response ) { $site_icon_id = get_option( 'site_icon', 0 ); $this->add_image_to_index( $response, $site_icon_id, 'site_icon' ); $response->data['site_icon_url'] = get_site_icon_url(); } protected function add_image_to_index( WP_REST_Response $response, $image_id, $type ) { $response->data[ $type ] = (int) $image_id; if ( $image_id ) { $response->add_link( 'https://api.w.org/featuredmedia', rest_url( rest_get_route_for_post( $image_id ) ), array( 'embeddable' => true, 'type' => $type, ) ); } } public function get_namespace_index( $request ) { $namespace = $request['namespace']; if ( ! isset( $this->namespaces[ $namespace ] ) ) { return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) ); } $routes = $this->namespaces[ $namespace ]; $endpoints = array_intersect_key( $this->get_routes(), $routes ); $data = array( 'namespace' => $namespace, 'routes' => $this->get_data_for_routes( $endpoints, $request['context'] ), ); $response = rest_ensure_response( $data ); $response->add_link( 'up', rest_url( '/' ) ); return apply_filters( 'rest_namespace_index', $response, $request ); } public function get_data_for_routes( $routes, $context = 'view' ) { $available = array(); foreach ( $routes as $route => $callbacks ) { $data = $this->get_data_for_route( $route, $callbacks, $context ); if ( empty( $data ) ) { continue; } $available[ $route ] = apply_filters( 'rest_endpoints_description', $data ); } return apply_filters( 'rest_route_data', $available, $routes ); } public function get_data_for_route( $route, $callbacks, $context = 'view' ) { $data = array( 'namespace' => '', 'methods' => array(), 'endpoints' => array(), ); $allow_batch = false; if ( isset( $this->route_options[ $route ] ) ) { $options = $this->route_options[ $route ]; if ( isset( $options['namespace'] ) ) { $data['namespace'] = $options['namespace']; } $allow_batch = isset( $options['allow_batch'] ) ? $options['allow_batch'] : false; if ( isset( $options['schema'] ) && 'help' === $context ) { $data['schema'] = call_user_func( $options['schema'] ); } } $allowed_schema_keywords = array_flip( rest_get_allowed_schema_keywords() ); $route = preg_replace( '#\(\?P<(\w+?)>.*?\)#', '{$1}', $route ); foreach ( $callbacks as $callback ) { if ( empty( $callback['show_in_index'] ) ) { continue; } $data['methods'] = array_merge( $data['methods'], array_keys( $callback['methods'] ) ); $endpoint_data = array( 'methods' => array_keys( $callback['methods'] ), ); $callback_batch = isset( $callback['allow_batch'] ) ? $callback['allow_batch'] : $allow_batch; if ( $callback_batch ) { $endpoint_data['allow_batch'] = $callback_batch; } if ( isset( $callback['args'] ) ) { $endpoint_data['args'] = array(); foreach ( $callback['args'] as $key => $opts ) { if ( is_string( $opts ) ) { $opts = array( $opts => 0 ); } elseif ( ! is_array( $opts ) ) { $opts = array(); } $arg_data = array_intersect_key( $opts, $allowed_schema_keywords ); $arg_data['required'] = ! empty( $opts['required'] ); $endpoint_data['args'][ $key ] = $arg_data; } } $data['endpoints'][] = $endpoint_data; if ( strpos( $route, '{' ) === false ) { $data['_links'] = array( 'self' => array( array( 'href' => rest_url( $route ), ), ), ); } } if ( empty( $data['methods'] ) ) { return null; } return $data; } protected function get_max_batch_size() { return apply_filters( 'rest_get_max_batch_size', 25 ); } public function serve_batch_request_v1( WP_REST_Request $batch_request ) { $requests = array(); foreach ( $batch_request['requests'] as $args ) { $parsed_url = wp_parse_url( $args['path'] ); if ( false === $parsed_url ) { $requests[] = new WP_Error( 'parse_path_failed', __( 'Could not parse the path.' ), array( 'status' => 400 ) ); continue; } $single_request = new WP_REST_Request( isset( $args['method'] ) ? $args['method'] : 'POST', $parsed_url['path'] ); if ( ! empty( $parsed_url['query'] ) ) { $query_args = null; wp_parse_str( $parsed_url['query'], $query_args ); $single_request->set_query_params( $query_args ); } if ( ! empty( $args['body'] ) ) { $single_request->set_body_params( $args['body'] ); } if ( ! empty( $args['headers'] ) ) { $single_request->set_headers( $args['headers'] ); } $requests[] = $single_request; } $matches = array(); $validation = array(); $has_error = false; foreach ( $requests as $single_request ) { $match = $this->match_request_to_handler( $single_request ); $matches[] = $match; $error = null; if ( is_wp_error( $match ) ) { $error = $match; } if ( ! $error ) { list( $route, $handler ) = $match; if ( isset( $handler['allow_batch'] ) ) { $allow_batch = $handler['allow_batch']; } else { $route_options = $this->get_route_options( $route ); $allow_batch = isset( $route_options['allow_batch'] ) ? $route_options['allow_batch'] : false; } if ( ! is_array( $allow_batch ) || empty( $allow_batch['v1'] ) ) { $error = new WP_Error( 'rest_batch_not_allowed', __( 'The requested route does not support batch requests.' ), array( 'status' => 400 ) ); } } if ( ! $error ) { $check_required = $single_request->has_valid_params(); if ( is_wp_error( $check_required ) ) { $error = $check_required; } } if ( ! $error ) { $check_sanitized = $single_request->sanitize_params(); if ( is_wp_error( $check_sanitized ) ) { $error = $check_sanitized; } } if ( $error ) { $has_error = true; $validation[] = $error; } else { $validation[] = true; } } $responses = array(); if ( $has_error && 'require-all-validate' === $batch_request['validation'] ) { foreach ( $validation as $valid ) { if ( is_wp_error( $valid ) ) { $responses[] = $this->envelope_response( $this->error_to_response( $valid ), false )->get_data(); } else { $responses[] = null; } } return new WP_REST_Response( array( 'failed' => 'validation', 'responses' => $responses, ), WP_Http::MULTI_STATUS ); } foreach ( $requests as $i => $single_request ) { $clean_request = clone $single_request; $clean_request->set_url_params( array() ); $clean_request->set_attributes( array() ); $clean_request->set_default_params( array() ); $result = apply_filters( 'rest_pre_dispatch', null, $this, $clean_request ); if ( empty( $result ) ) { $match = $matches[ $i ]; $error = null; if ( is_wp_error( $validation[ $i ] ) ) { $error = $validation[ $i ]; } if ( is_wp_error( $match ) ) { $result = $this->error_to_response( $match ); } else { list( $route, $handler ) = $match; if ( ! $error && ! is_callable( $handler['callback'] ) ) { $error = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) ); } $result = $this->respond_to_request( $single_request, $route, $handler, $error ); } } $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $single_request ); $responses[] = $this->envelope_response( $result, false )->get_data(); } return new WP_REST_Response( array( 'responses' => $responses ), WP_Http::MULTI_STATUS ); } protected function set_status( $code ) { status_header( $code ); } public function send_header( $key, $value ) { $value = preg_replace( '/\s+/', ' ', $value ); header( sprintf( '%s: %s', $key, $value ) ); } public function send_headers( $headers ) { foreach ( $headers as $key => $value ) { $this->send_header( $key, $value ); } } public function remove_header( $key ) { header_remove( $key ); } public static function get_raw_data() { global $HTTP_RAW_POST_DATA; if ( ! isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); } return $HTTP_RAW_POST_DATA; } public function get_headers( $server ) { $headers = array(); $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true, ); foreach ( $server as $key => $value ) { if ( strpos( $key, 'HTTP_' ) === 0 ) { $headers[ substr( $key, 5 ) ] = $value; } elseif ( 'REDIRECT_HTTP_AUTHORIZATION' === $key && empty( $server['HTTP_AUTHORIZATION'] ) ) { $headers['AUTHORIZATION'] = $value; } elseif ( isset( $additional[ $key ] ) ) { $headers[ $key ] = $value; } } return $headers; } } <?php class WP_REST_Application_Passwords_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'users/(?P<user_id>(?:[\d]+|me))/application-passwords'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema(), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_items' ), 'permission_callback' => array( $this, 'delete_items_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/introspect', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_current_item' ), 'permission_callback' => array( $this, 'get_current_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<uuid>[\w\-]+)', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_item' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ), 'permission_callback' => array( $this, 'delete_item_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'list_app_passwords', $user->ID ) ) { return new WP_Error( 'rest_cannot_list_application_passwords', __( 'Sorry, you are not allowed to list application passwords for this user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $passwords = WP_Application_Passwords::get_user_application_passwords( $user->ID ); $response = array(); foreach ( $passwords as $password ) { $response[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $password, $request ) ); } return new WP_REST_Response( $response ); } public function get_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'read_app_password', $user->ID, $request['uuid'] ) ) { return new WP_Error( 'rest_cannot_read_application_password', __( 'Sorry, you are not allowed to read this application password.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_item( $request ) { $password = $this->get_application_password( $request ); if ( is_wp_error( $password ) ) { return $password; } return $this->prepare_item_for_response( $password, $request ); } public function create_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'create_app_password', $user->ID ) ) { return new WP_Error( 'rest_cannot_create_application_passwords', __( 'Sorry, you are not allowed to create application passwords for this user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function create_item( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $prepared = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared ) ) { return $prepared; } $created = WP_Application_Passwords::create_new_application_password( $user->ID, wp_slash( (array) $prepared ) ); if ( is_wp_error( $created ) ) { return $created; } $password = $created[0]; $item = WP_Application_Passwords::get_user_application_password( $user->ID, $created[1]['uuid'] ); $item['new_password'] = WP_Application_Passwords::chunk_password( $password ); $fields_update = $this->update_additional_fields_for_object( $item, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } do_action( 'rest_after_insert_application_password', $item, $request, true ); $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $item, $request ); $response->set_status( 201 ); $response->header( 'Location', $response->get_links()['self'][0]['href'] ); return $response; } public function update_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'edit_app_password', $user->ID, $request['uuid'] ) ) { return new WP_Error( 'rest_cannot_edit_application_password', __( 'Sorry, you are not allowed to edit this application password.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function update_item( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $item = $this->get_application_password( $request ); if ( is_wp_error( $item ) ) { return $item; } $prepared = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared ) ) { return $prepared; } $saved = WP_Application_Passwords::update_application_password( $user->ID, $item['uuid'], wp_slash( (array) $prepared ) ); if ( is_wp_error( $saved ) ) { return $saved; } $fields_update = $this->update_additional_fields_for_object( $item, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $item = WP_Application_Passwords::get_user_application_password( $user->ID, $item['uuid'] ); do_action( 'rest_after_insert_application_password', $item, $request, false ); $request->set_param( 'context', 'edit' ); return $this->prepare_item_for_response( $item, $request ); } public function delete_items_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'delete_app_passwords', $user->ID ) ) { return new WP_Error( 'rest_cannot_delete_application_passwords', __( 'Sorry, you are not allowed to delete application passwords for this user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function delete_items( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $deleted = WP_Application_Passwords::delete_all_application_passwords( $user->ID ); if ( is_wp_error( $deleted ) ) { return $deleted; } return new WP_REST_Response( array( 'deleted' => true, 'count' => $deleted, ) ); } public function delete_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'delete_app_password', $user->ID, $request['uuid'] ) ) { return new WP_Error( 'rest_cannot_delete_application_password', __( 'Sorry, you are not allowed to delete this application password.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function delete_item( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $password = $this->get_application_password( $request ); if ( is_wp_error( $password ) ) { return $password; } $request->set_param( 'context', 'edit' ); $previous = $this->prepare_item_for_response( $password, $request ); $deleted = WP_Application_Passwords::delete_application_password( $user->ID, $password['uuid'] ); if ( is_wp_error( $deleted ) ) { return $deleted; } return new WP_REST_Response( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); } public function get_current_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( get_current_user_id() !== $user->ID ) { return new WP_Error( 'rest_cannot_introspect_app_password_for_non_authenticated_user', __( 'The authenticated application password can only be introspected for the current user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_current_item( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $uuid = rest_get_authenticated_app_password(); if ( ! $uuid ) { return new WP_Error( 'rest_no_authenticated_app_password', __( 'Cannot introspect application password.' ), array( 'status' => 404 ) ); } $password = WP_Application_Passwords::get_user_application_password( $user->ID, $uuid ); if ( ! $password ) { return new WP_Error( 'rest_application_password_not_found', __( 'Application password not found.' ), array( 'status' => 500 ) ); } return $this->prepare_item_for_response( $password, $request ); } protected function do_permissions_check( $request ) { _deprecated_function( __METHOD__, '5.7.0' ); $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( ! current_user_can( 'edit_user', $user->ID ) ) { return new WP_Error( 'rest_cannot_manage_application_passwords', __( 'Sorry, you are not allowed to manage application passwords for this user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } protected function prepare_item_for_database( $request ) { $prepared = (object) array( 'name' => $request['name'], ); if ( $request['app_id'] && ! $request['uuid'] ) { $prepared->app_id = $request['app_id']; } return apply_filters( 'rest_pre_insert_application_password', $prepared, $request ); } public function prepare_item_for_response( $item, $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $fields = $this->get_fields_for_response( $request ); $prepared = array( 'uuid' => $item['uuid'], 'app_id' => empty( $item['app_id'] ) ? '' : $item['app_id'], 'name' => $item['name'], 'created' => gmdate( 'Y-m-d\TH:i:s', $item['created'] ), 'last_used' => $item['last_used'] ? gmdate( 'Y-m-d\TH:i:s', $item['last_used'] ) : null, 'last_ip' => $item['last_ip'] ? $item['last_ip'] : null, ); if ( isset( $item['new_password'] ) ) { $prepared['password'] = $item['new_password']; } $prepared = $this->add_additional_fields_to_object( $prepared, $request ); $prepared = $this->filter_response_by_context( $prepared, $request['context'] ); $response = new WP_REST_Response( $prepared ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $user, $item ) ); } return apply_filters( 'rest_prepare_application_password', $response, $item, $request ); } protected function prepare_links( WP_User $user, $item ) { return array( 'self' => array( 'href' => rest_url( sprintf( '%s/users/%d/application-passwords/%s', $this->namespace, $user->ID, $item['uuid'] ) ), ), ); } protected function get_user( $request ) { if ( ! wp_is_application_passwords_available() ) { return new WP_Error( 'application_passwords_disabled', __( 'Application passwords are not available.' ), array( 'status' => 501 ) ); } $error = new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); $id = $request['user_id']; if ( 'me' === $id ) { if ( ! is_user_logged_in() ) { return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) ); } $user = wp_get_current_user(); } else { $id = (int) $id; if ( $id <= 0 ) { return $error; } $user = get_userdata( $id ); } if ( empty( $user ) || ! $user->exists() ) { return $error; } if ( is_multisite() && ! user_can( $user->ID, 'manage_sites' ) && ! is_user_member_of_blog( $user->ID ) ) { return $error; } if ( ! wp_is_application_passwords_available_for_user( $user ) ) { return new WP_Error( 'application_passwords_disabled_for_user', __( 'Application passwords are not available for your account. Please contact the site administrator for assistance.' ), array( 'status' => 501 ) ); } return $user; } protected function get_application_password( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } $password = WP_Application_Passwords::get_user_application_password( $user->ID, $request['uuid'] ); if ( ! $password ) { return new WP_Error( 'rest_application_password_not_found', __( 'Application password not found.' ), array( 'status' => 404 ) ); } return $password; } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'application-password', 'type' => 'object', 'properties' => array( 'uuid' => array( 'description' => __( 'The unique identifier for the application password.' ), 'type' => 'string', 'format' => 'uuid', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'app_id' => array( 'description' => __( 'A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace.' ), 'type' => 'string', 'format' => 'uuid', 'context' => array( 'view', 'edit', 'embed' ), ), 'name' => array( 'description' => __( 'The name of the application password.' ), 'type' => 'string', 'required' => true, 'context' => array( 'view', 'edit', 'embed' ), 'minLength' => 1, 'pattern' => '.*\S.*', ), 'password' => array( 'description' => __( 'The generated password. Only available after adding an application.' ), 'type' => 'string', 'context' => array( 'edit' ), 'readonly' => true, ), 'created' => array( 'description' => __( 'The GMT date the application password was created.' ), 'type' => 'string', 'format' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'last_used' => array( 'description' => __( 'The GMT date the application password was last used.' ), 'type' => array( 'string', 'null' ), 'format' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'last_ip' => array( 'description' => __( 'The IP address the application password was last used by.' ), 'type' => array( 'string', 'null' ), 'format' => 'ip', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), ), ); return $this->add_additional_fields_schema( $this->schema ); } } <?php class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { protected $allow_batch = false; public function register_routes() { parent::register_routes(); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)/post-process', array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'post_process_item' ), 'permission_callback' => array( $this, 'post_process_item_permissions_check' ), 'args' => array( 'id' => array( 'description' => __( 'Unique identifier for the attachment.' ), 'type' => 'integer', ), 'action' => array( 'type' => 'string', 'enum' => array( 'create-image-subsizes' ), 'required' => true, ), ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)/edit', array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'edit_media_item' ), 'permission_callback' => array( $this, 'edit_media_item_permissions_check' ), 'args' => $this->get_edit_media_item_args(), ) ); } protected function prepare_items_query( $prepared_args = array(), $request = null ) { $query_args = parent::prepare_items_query( $prepared_args, $request ); if ( empty( $query_args['post_status'] ) ) { $query_args['post_status'] = 'inherit'; } $media_types = $this->get_media_types(); if ( ! empty( $request['media_type'] ) && isset( $media_types[ $request['media_type'] ] ) ) { $query_args['post_mime_type'] = $media_types[ $request['media_type'] ]; } if ( ! empty( $request['mime_type'] ) ) { $parts = explode( '/', $request['mime_type'] ); if ( isset( $media_types[ $parts[0] ] ) && in_array( $request['mime_type'], $media_types[ $parts[0] ], true ) ) { $query_args['post_mime_type'] = $request['mime_type']; } } if ( isset( $query_args['s'] ) ) { add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' ); } return $query_args; } public function create_item_permissions_check( $request ) { $ret = parent::create_item_permissions_check( $request ); if ( ! $ret || is_wp_error( $ret ) ) { return $ret; } if ( ! current_user_can( 'upload_files' ) ) { return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) ); } if ( ! empty( $request['post'] ) && ! current_user_can( 'edit_post', (int) $request['post'] ) ) { return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function create_item( $request ) { if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) { return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) ); } $insert = $this->insert_attachment( $request ); if ( is_wp_error( $insert ) ) { return $insert; } $schema = $this->get_item_schema(); $attachment_id = $insert['attachment_id']; $file = $insert['file']; if ( isset( $request['alt_text'] ) ) { update_post_meta( $attachment_id, '_wp_attachment_image_alt', sanitize_text_field( $request['alt_text'] ) ); } if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $attachment_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $attachment = get_post( $attachment_id ); $fields_update = $this->update_additional_fields_for_object( $attachment, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'edit' ); do_action( 'rest_after_insert_attachment', $attachment, $request, true ); wp_after_insert_post( $attachment, false, null ); if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); } require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); $response = $this->prepare_item_for_response( $attachment, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $attachment_id ) ) ); return $response; } protected function insert_attachment( $request ) { $files = $request->get_file_params(); $headers = $request->get_headers(); if ( ! empty( $files ) ) { $file = $this->upload_from_file( $files, $headers ); } else { $file = $this->upload_from_data( $request->get_body(), $headers ); } if ( is_wp_error( $file ) ) { return $file; } $name = wp_basename( $file['file'] ); $name_parts = pathinfo( $name ); $name = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) ); $url = $file['url']; $type = $file['type']; $file = $file['file']; require_once ABSPATH . 'wp-admin/includes/image.php'; $image_meta = wp_read_image_metadata( $file ); if ( ! empty( $image_meta ) ) { if ( empty( $request['title'] ) && trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { $request['title'] = $image_meta['title']; } if ( empty( $request['caption'] ) && trim( $image_meta['caption'] ) ) { $request['caption'] = $image_meta['caption']; } } $attachment = $this->prepare_item_for_database( $request ); $attachment->post_mime_type = $type; $attachment->guid = $url; if ( empty( $attachment->post_title ) ) { $attachment->post_title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) ); } $id = wp_insert_attachment( wp_slash( (array) $attachment ), $file, 0, true, false ); if ( is_wp_error( $id ) ) { if ( 'db_update_error' === $id->get_error_code() ) { $id->add_data( array( 'status' => 500 ) ); } else { $id->add_data( array( 'status' => 400 ) ); } return $id; } $attachment = get_post( $id ); do_action( 'rest_insert_attachment', $attachment, $request, true ); return array( 'attachment_id' => $id, 'file' => $file, ); } public function update_item( $request ) { if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) { return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) ); } $attachment_before = get_post( $request['id'] ); $response = parent::update_item( $request ); if ( is_wp_error( $response ) ) { return $response; } $response = rest_ensure_response( $response ); $data = $response->get_data(); if ( isset( $request['alt_text'] ) ) { update_post_meta( $data['id'], '_wp_attachment_image_alt', $request['alt_text'] ); } $attachment = get_post( $request['id'] ); $fields_update = $this->update_additional_fields_for_object( $attachment, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'edit' ); do_action( 'rest_after_insert_attachment', $attachment, $request, false ); wp_after_insert_post( $attachment, true, $attachment_before ); $response = $this->prepare_item_for_response( $attachment, $request ); $response = rest_ensure_response( $response ); return $response; } public function post_process_item( $request ) { switch ( $request['action'] ) { case 'create-image-subsizes': require_once ABSPATH . 'wp-admin/includes/image.php'; wp_update_image_subsizes( $request['id'] ); break; } $request['context'] = 'edit'; return $this->prepare_item_for_response( get_post( $request['id'] ), $request ); } public function post_process_item_permissions_check( $request ) { return $this->update_item_permissions_check( $request ); } public function edit_media_item_permissions_check( $request ) { if ( ! current_user_can( 'upload_files' ) ) { return new WP_Error( 'rest_cannot_edit_image', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => rest_authorization_required_code() ) ); } return $this->update_item_permissions_check( $request ); } public function edit_media_item( $request ) { require_once ABSPATH . 'wp-admin/includes/image.php'; $attachment_id = $request['id']; $image_file = wp_get_original_image_path( $attachment_id ); $image_meta = wp_get_attachment_metadata( $attachment_id ); if ( ! $image_meta || ! $image_file || ! wp_image_file_matches_image_meta( $request['src'], $image_meta, $attachment_id ) ) { return new WP_Error( 'rest_unknown_attachment', __( 'Unable to get meta information for file.' ), array( 'status' => 404 ) ); } $supported_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' ); $mime_type = get_post_mime_type( $attachment_id ); if ( ! in_array( $mime_type, $supported_types, true ) ) { return new WP_Error( 'rest_cannot_edit_file_type', __( 'This type of file cannot be edited.' ), array( 'status' => 400 ) ); } if ( isset( $request['modifiers'] ) ) { $modifiers = $request['modifiers']; } else { $modifiers = array(); if ( ! empty( $request['rotation'] ) ) { $modifiers[] = array( 'type' => 'rotate', 'args' => array( 'angle' => $request['rotation'], ), ); } if ( isset( $request['x'], $request['y'], $request['width'], $request['height'] ) ) { $modifiers[] = array( 'type' => 'crop', 'args' => array( 'left' => $request['x'], 'top' => $request['y'], 'width' => $request['width'], 'height' => $request['height'], ), ); } if ( 0 === count( $modifiers ) ) { return new WP_Error( 'rest_image_not_edited', __( 'The image was not edited. Edit the image before applying the changes.' ), array( 'status' => 400 ) ); } } $image_file_to_edit = $image_file; if ( ! file_exists( $image_file_to_edit ) ) { $image_file_to_edit = _load_image_to_edit_path( $attachment_id ); } $image_editor = wp_get_image_editor( $image_file_to_edit ); if ( is_wp_error( $image_editor ) ) { return new WP_Error( 'rest_unknown_image_file_type', __( 'Unable to edit this image.' ), array( 'status' => 500 ) ); } foreach ( $modifiers as $modifier ) { $args = $modifier['args']; switch ( $modifier['type'] ) { case 'rotate': $rotate = 0 - $args['angle']; if ( 0 !== $rotate ) { $result = $image_editor->rotate( $rotate ); if ( is_wp_error( $result ) ) { return new WP_Error( 'rest_image_rotation_failed', __( 'Unable to rotate this image.' ), array( 'status' => 500 ) ); } } break; case 'crop': $size = $image_editor->get_size(); $crop_x = round( ( $size['width'] * $args['left'] ) / 100.0 ); $crop_y = round( ( $size['height'] * $args['top'] ) / 100.0 ); $width = round( ( $size['width'] * $args['width'] ) / 100.0 ); $height = round( ( $size['height'] * $args['height'] ) / 100.0 ); if ( $size['width'] !== $width && $size['height'] !== $height ) { $result = $image_editor->crop( $crop_x, $crop_y, $width, $height ); if ( is_wp_error( $result ) ) { return new WP_Error( 'rest_image_crop_failed', __( 'Unable to crop this image.' ), array( 'status' => 500 ) ); } } break; } } $image_ext = pathinfo( $image_file, PATHINFO_EXTENSION ); $image_name = wp_basename( $image_file, ".{$image_ext}" ); if ( preg_match( '/-edited(-\d+)?$/', $image_name ) ) { $image_name = preg_replace( '/-edited(-\d+)?$/', '-edited', $image_name ); } else { $image_name .= '-edited'; } $filename = "{$image_name}.{$image_ext}"; $uploads = wp_upload_dir(); $filename = wp_unique_filename( $uploads['path'], $filename ); $saved = $image_editor->save( $uploads['path'] . "/$filename" ); if ( is_wp_error( $saved ) ) { return $saved; } $new_attachment_post = array( 'post_mime_type' => $saved['mime-type'], 'guid' => $uploads['url'] . "/$filename", 'post_title' => $image_name, 'post_content' => '', ); $attachment_post = get_post( $attachment_id ); if ( $attachment_post ) { $new_attachment_post['post_content'] = $attachment_post->post_content; $new_attachment_post['post_excerpt'] = $attachment_post->post_excerpt; $new_attachment_post['post_title'] = $attachment_post->post_title; } $new_attachment_id = wp_insert_attachment( wp_slash( $new_attachment_post ), $saved['path'], 0, true ); if ( is_wp_error( $new_attachment_id ) ) { if ( 'db_update_error' === $new_attachment_id->get_error_code() ) { $new_attachment_id->add_data( array( 'status' => 500 ) ); } else { $new_attachment_id->add_data( array( 'status' => 400 ) ); } return $new_attachment_id; } $image_alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); if ( ! empty( $image_alt ) ) { update_post_meta( $new_attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); } if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { header( 'X-WP-Upload-Attachment-ID: ' . $new_attachment_id ); } $new_image_meta = wp_generate_attachment_metadata( $new_attachment_id, $saved['path'] ); if ( isset( $image_meta['image_meta'] ) && isset( $new_image_meta['image_meta'] ) && is_array( $new_image_meta['image_meta'] ) ) { foreach ( (array) $image_meta['image_meta'] as $key => $value ) { if ( empty( $new_image_meta['image_meta'][ $key ] ) && ! empty( $value ) ) { $new_image_meta['image_meta'][ $key ] = $value; } } } if ( ! empty( $new_image_meta['image_meta']['orientation'] ) ) { $new_image_meta['image_meta']['orientation'] = 1; } $new_image_meta['parent_image'] = array( 'attachment_id' => $attachment_id, 'file' => _wp_relative_upload_path( $image_file ), ); $new_image_meta = apply_filters( 'wp_edited_image_metadata', $new_image_meta, $new_attachment_id, $attachment_id ); wp_update_attachment_metadata( $new_attachment_id, $new_image_meta ); $response = $this->prepare_item_for_response( get_post( $new_attachment_id ), $request ); $response->set_status( 201 ); $response->header( 'Location', rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $new_attachment_id ) ) ); return $response; } protected function prepare_item_for_database( $request ) { $prepared_attachment = parent::prepare_item_for_database( $request ); if ( isset( $request['caption'] ) ) { if ( is_string( $request['caption'] ) ) { $prepared_attachment->post_excerpt = $request['caption']; } elseif ( isset( $request['caption']['raw'] ) ) { $prepared_attachment->post_excerpt = $request['caption']['raw']; } } if ( isset( $request['description'] ) ) { if ( is_string( $request['description'] ) ) { $prepared_attachment->post_content = $request['description']; } elseif ( isset( $request['description']['raw'] ) ) { $prepared_attachment->post_content = $request['description']['raw']; } } if ( isset( $request['post'] ) ) { $prepared_attachment->post_parent = (int) $request['post']; } return $prepared_attachment; } public function prepare_item_for_response( $item, $request ) { $post = $item; $response = parent::prepare_item_for_response( $post, $request ); $fields = $this->get_fields_for_response( $request ); $data = $response->get_data(); if ( in_array( 'description', $fields, true ) ) { $data['description'] = array( 'raw' => $post->post_content, 'rendered' => apply_filters( 'the_content', $post->post_content ), ); } if ( in_array( 'caption', $fields, true ) ) { $caption = apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); $caption = apply_filters( 'the_excerpt', $caption ); $data['caption'] = array( 'raw' => $post->post_excerpt, 'rendered' => $caption, ); } if ( in_array( 'alt_text', $fields, true ) ) { $data['alt_text'] = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); } if ( in_array( 'media_type', $fields, true ) ) { $data['media_type'] = wp_attachment_is_image( $post->ID ) ? 'image' : 'file'; } if ( in_array( 'mime_type', $fields, true ) ) { $data['mime_type'] = $post->post_mime_type; } if ( in_array( 'media_details', $fields, true ) ) { $data['media_details'] = wp_get_attachment_metadata( $post->ID ); if ( empty( $data['media_details'] ) ) { $data['media_details'] = new stdClass(); } elseif ( ! empty( $data['media_details']['sizes'] ) ) { foreach ( $data['media_details']['sizes'] as $size => &$size_data ) { if ( isset( $size_data['mime-type'] ) ) { $size_data['mime_type'] = $size_data['mime-type']; unset( $size_data['mime-type'] ); } $image_src = wp_get_attachment_image_src( $post->ID, $size ); if ( ! $image_src ) { continue; } $size_data['source_url'] = $image_src[0]; } $full_src = wp_get_attachment_image_src( $post->ID, 'full' ); if ( ! empty( $full_src ) ) { $data['media_details']['sizes']['full'] = array( 'file' => wp_basename( $full_src[0] ), 'width' => $full_src[1], 'height' => $full_src[2], 'mime_type' => $post->post_mime_type, 'source_url' => $full_src[0], ); } } else { $data['media_details']['sizes'] = new stdClass(); } } if ( in_array( 'post', $fields, true ) ) { $data['post'] = ! empty( $post->post_parent ) ? (int) $post->post_parent : null; } if ( in_array( 'source_url', $fields, true ) ) { $data['source_url'] = wp_get_attachment_url( $post->ID ); } if ( in_array( 'missing_image_sizes', $fields, true ) ) { require_once ABSPATH . 'wp-admin/includes/image.php'; $data['missing_image_sizes'] = array_keys( wp_get_missing_image_subsizes( $post->ID ) ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->filter_response_by_context( $data, $context ); $links = $response->get_links(); $response = rest_ensure_response( $data ); foreach ( $links as $rel => $rel_links ) { foreach ( $rel_links as $link ) { $response->add_link( $rel, $link['href'], $link['attributes'] ); } } return apply_filters( 'rest_prepare_attachment', $response, $post, $request ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = parent::get_item_schema(); $schema['properties']['alt_text'] = array( 'description' => __( 'Alternative text to display when attachment is not displayed.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ); $schema['properties']['caption'] = array( 'description' => __( 'The attachment caption.' ), 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => null, 'validate_callback' => null, ), 'properties' => array( 'raw' => array( 'description' => __( 'Caption for the attachment, as it exists in the database.' ), 'type' => 'string', 'context' => array( 'edit' ), ), 'rendered' => array( 'description' => __( 'HTML caption for the attachment, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ); $schema['properties']['description'] = array( 'description' => __( 'The attachment description.' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'sanitize_callback' => null, 'validate_callback' => null, ), 'properties' => array( 'raw' => array( 'description' => __( 'Description for the attachment, as it exists in the database.' ), 'type' => 'string', 'context' => array( 'edit' ), ), 'rendered' => array( 'description' => __( 'HTML description for the attachment, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), ), ); $schema['properties']['media_type'] = array( 'description' => __( 'Attachment type.' ), 'type' => 'string', 'enum' => array( 'image', 'file' ), 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['mime_type'] = array( 'description' => __( 'The attachment MIME type.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['media_details'] = array( 'description' => __( 'Details about the media file, specific to its type.' ), 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['post'] = array( 'description' => __( 'The ID for the associated post of the attachment.' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ); $schema['properties']['source_url'] = array( 'description' => __( 'URL to the original attachment file.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['missing_image_sizes'] = array( 'description' => __( 'List of the missing image sizes of the attachment.' ), 'type' => 'array', 'items' => array( 'type' => 'string' ), 'context' => array( 'edit' ), 'readonly' => true, ); unset( $schema['properties']['password'] ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } protected function upload_from_data( $data, $headers ) { if ( empty( $data ) ) { return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) ); } if ( empty( $headers['content_type'] ) ) { return new WP_Error( 'rest_upload_no_content_type', __( 'No Content-Type supplied.' ), array( 'status' => 400 ) ); } if ( empty( $headers['content_disposition'] ) ) { return new WP_Error( 'rest_upload_no_content_disposition', __( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) ); } $filename = self::get_filename_from_disposition( $headers['content_disposition'] ); if ( empty( $filename ) ) { return new WP_Error( 'rest_upload_invalid_disposition', __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) ); } if ( ! empty( $headers['content_md5'] ) ) { $content_md5 = array_shift( $headers['content_md5'] ); $expected = trim( $content_md5 ); $actual = md5( $data ); if ( $expected !== $actual ) { return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) ); } } $type = array_shift( $headers['content_type'] ); require_once ABSPATH . 'wp-admin/includes/file.php'; $tmpfname = wp_tempnam( $filename ); $fp = fopen( $tmpfname, 'w+' ); if ( ! $fp ) { return new WP_Error( 'rest_upload_file_error', __( 'Could not open file handle.' ), array( 'status' => 500 ) ); } fwrite( $fp, $data ); fclose( $fp ); $file_data = array( 'error' => null, 'tmp_name' => $tmpfname, 'name' => $filename, 'type' => $type, ); $size_check = self::check_upload_size( $file_data ); if ( is_wp_error( $size_check ) ) { return $size_check; } $overrides = array( 'test_form' => false, ); $sideloaded = wp_handle_sideload( $file_data, $overrides ); if ( isset( $sideloaded['error'] ) ) { @unlink( $tmpfname ); return new WP_Error( 'rest_upload_sideload_error', $sideloaded['error'], array( 'status' => 500 ) ); } return $sideloaded; } public static function get_filename_from_disposition( $disposition_header ) { $filename = null; foreach ( $disposition_header as $value ) { $value = trim( $value ); if ( strpos( $value, ';' ) === false ) { continue; } list( $type, $attr_parts ) = explode( ';', $value, 2 ); $attr_parts = explode( ';', $attr_parts ); $attributes = array(); foreach ( $attr_parts as $part ) { if ( strpos( $part, '=' ) === false ) { continue; } list( $key, $value ) = explode( '=', $part, 2 ); $attributes[ trim( $key ) ] = trim( $value ); } if ( empty( $attributes['filename'] ) ) { continue; } $filename = trim( $attributes['filename'] ); if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) { $filename = substr( $filename, 1, -1 ); } } return $filename; } public function get_collection_params() { $params = parent::get_collection_params(); $params['status']['default'] = 'inherit'; $params['status']['items']['enum'] = array( 'inherit', 'private', 'trash' ); $media_types = $this->get_media_types(); $params['media_type'] = array( 'default' => null, 'description' => __( 'Limit result set to attachments of a particular media type.' ), 'type' => 'string', 'enum' => array_keys( $media_types ), ); $params['mime_type'] = array( 'default' => null, 'description' => __( 'Limit result set to attachments of a particular MIME type.' ), 'type' => 'string', ); return $params; } protected function upload_from_file( $files, $headers ) { if ( empty( $files ) ) { return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) ); } if ( ! empty( $headers['content_md5'] ) ) { $content_md5 = array_shift( $headers['content_md5'] ); $expected = trim( $content_md5 ); $actual = md5_file( $files['file']['tmp_name'] ); if ( $expected !== $actual ) { return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) ); } } $overrides = array( 'test_form' => false, ); if ( defined( 'DIR_TESTDATA' ) && DIR_TESTDATA ) { $overrides['action'] = 'wp_handle_mock_upload'; } $size_check = self::check_upload_size( $files['file'] ); if ( is_wp_error( $size_check ) ) { return $size_check; } require_once ABSPATH . 'wp-admin/includes/file.php'; $file = wp_handle_upload( $files['file'], $overrides ); if ( isset( $file['error'] ) ) { return new WP_Error( 'rest_upload_unknown_error', $file['error'], array( 'status' => 500 ) ); } return $file; } protected function get_media_types() { $media_types = array(); foreach ( get_allowed_mime_types() as $mime_type ) { $parts = explode( '/', $mime_type ); if ( ! isset( $media_types[ $parts[0] ] ) ) { $media_types[ $parts[0] ] = array(); } $media_types[ $parts[0] ][] = $mime_type; } return $media_types; } protected function check_upload_size( $file ) { if ( ! is_multisite() ) { return true; } if ( get_site_option( 'upload_space_check_disabled' ) ) { return true; } $space_left = get_upload_space_available(); $file_size = filesize( $file['tmp_name'] ); if ( $space_left < $file_size ) { return new WP_Error( 'rest_upload_limited_space', sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ), array( 'status' => 400 ) ); } if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { return new WP_Error( 'rest_upload_file_too_big', sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ), array( 'status' => 400 ) ); } require_once ABSPATH . 'wp-admin/includes/ms.php'; if ( upload_is_user_over_quota( false ) ) { return new WP_Error( 'rest_upload_user_quota_exceeded', __( 'You have used your space quota. Please delete files before uploading.' ), array( 'status' => 400 ) ); } return true; } protected function get_edit_media_item_args() { return array( 'src' => array( 'description' => __( 'URL to the edited image file.' ), 'type' => 'string', 'format' => 'uri', 'required' => true, ), 'modifiers' => array( 'description' => __( 'Array of image edits.' ), 'type' => 'array', 'minItems' => 1, 'items' => array( 'description' => __( 'Image edit.' ), 'type' => 'object', 'required' => array( 'type', 'args', ), 'oneOf' => array( array( 'title' => __( 'Rotation' ), 'properties' => array( 'type' => array( 'description' => __( 'Rotation type.' ), 'type' => 'string', 'enum' => array( 'rotate' ), ), 'args' => array( 'description' => __( 'Rotation arguments.' ), 'type' => 'object', 'required' => array( 'angle', ), 'properties' => array( 'angle' => array( 'description' => __( 'Angle to rotate clockwise in degrees.' ), 'type' => 'number', ), ), ), ), ), array( 'title' => __( 'Crop' ), 'properties' => array( 'type' => array( 'description' => __( 'Crop type.' ), 'type' => 'string', 'enum' => array( 'crop' ), ), 'args' => array( 'description' => __( 'Crop arguments.' ), 'type' => 'object', 'required' => array( 'left', 'top', 'width', 'height', ), 'properties' => array( 'left' => array( 'description' => __( 'Horizontal position from the left to begin the crop as a percentage of the image width.' ), 'type' => 'number', ), 'top' => array( 'description' => __( 'Vertical position from the top to begin the crop as a percentage of the image height.' ), 'type' => 'number', ), 'width' => array( 'description' => __( 'Width of the crop as a percentage of the image width.' ), 'type' => 'number', ), 'height' => array( 'description' => __( 'Height of the crop as a percentage of the image height.' ), 'type' => 'number', ), ), ), ), ), ), ), ), 'rotation' => array( 'description' => __( 'The amount to rotate the image clockwise in degrees. DEPRECATED: Use `modifiers` instead.' ), 'type' => 'integer', 'minimum' => 0, 'exclusiveMinimum' => true, 'maximum' => 360, 'exclusiveMaximum' => true, ), 'x' => array( 'description' => __( 'As a percentage of the image, the x position to start the crop from. DEPRECATED: Use `modifiers` instead.' ), 'type' => 'number', 'minimum' => 0, 'maximum' => 100, ), 'y' => array( 'description' => __( 'As a percentage of the image, the y position to start the crop from. DEPRECATED: Use `modifiers` instead.' ), 'type' => 'number', 'minimum' => 0, 'maximum' => 100, ), 'width' => array( 'description' => __( 'As a percentage of the image, the width to crop the image to. DEPRECATED: Use `modifiers` instead.' ), 'type' => 'number', 'minimum' => 0, 'maximum' => 100, ), 'height' => array( 'description' => __( 'As a percentage of the image, the height to crop the image to. DEPRECATED: Use `modifiers` instead.' ), 'type' => 'number', 'minimum' => 0, 'maximum' => 100, ), ); } } <?php - class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { private $parent_post_type; private $parent_controller; private $revisions_controller; private $parent_base; public function __construct( $parent_post_type ) { $this->parent_post_type = $parent_post_type; $post_type_object = get_post_type_object( $parent_post_type ); $parent_controller = $post_type_object->get_rest_controller(); if ( ! $parent_controller ) { $parent_controller = new WP_REST_Posts_Controller( $parent_post_type ); } $this->parent_controller = $parent_controller; $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type ); $this->rest_base = 'autosaves'; $this->namespace = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2'; $this->parent_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base, array( 'args' => array( 'parent' => array( 'description' => __( 'The ID for the parent of the autosave.' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->parent_controller->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', array( 'args' => array( 'parent' => array( 'description' => __( 'The ID for the parent of the autosave.' ), 'type' => 'integer', ), 'id' => array( 'description' => __( 'The ID for the autosave.' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this->revisions_controller, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } protected function get_parent( $parent_id ) { return $this->revisions_controller->get_parent( $parent_id ); } public function get_items_permissions_check( $request ) { $parent = $this->get_parent( $request['id'] ); if ( is_wp_error( $parent ) ) { return $parent; } if ( ! current_user_can( 'edit_post', $parent->ID ) ) { return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view autosaves of this post.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function create_item_permissions_check( $request ) { $id = $request->get_param( 'id' ); if ( empty( $id ) ) { return new WP_Error( 'rest_post_invalid_id', __( 'Invalid item ID.' ), array( 'status' => 404 ) ); } return $this->parent_controller->update_item_permissions_check( $request ); } public function create_item( $request ) { if ( ! defined( 'DOING_AUTOSAVE' ) ) { define( 'DOING_AUTOSAVE', true ); } $post = get_post( $request['id'] ); if ( is_wp_error( $post ) ) { return $post; } $prepared_post = $this->parent_controller->prepare_item_for_database( $request ); $prepared_post->ID = $post->ID; $user_id = get_current_user_id(); if ( ! function_exists( 'wp_check_post_lock' ) ) { require_once ABSPATH . 'wp-admin/includes/post.php'; } $post_lock = wp_check_post_lock( $post->ID ); $is_draft = 'draft' === $post->post_status || 'auto-draft' === $post->post_status; if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock ) { $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true ); } else { $autosave_id = $this->create_post_autosave( (array) $prepared_post ); } if ( is_wp_error( $autosave_id ) ) { return $autosave_id; } $autosave = get_post( $autosave_id ); $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $autosave, $request ); $response = rest_ensure_response( $response ); return $response; } public function get_item( $request ) { $parent_id = (int) $request->get_param( 'parent' ); if ( $parent_id <= 0 ) { return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); } $autosave = wp_get_post_autosave( $parent_id ); if ( ! $autosave ) { return new WP_Error( 'rest_post_no_autosave', __( 'There is no autosave revision for this post.' ), array( 'status' => 404 ) ); } $response = $this->prepare_item_for_response( $autosave, $request ); return $response; } public function get_items( $request ) { $parent = $this->get_parent( $request['id'] ); if ( is_wp_error( $parent ) ) { return $parent; } $response = array(); $parent_id = $parent->ID; $revisions = wp_get_post_revisions( $parent_id, array( 'check_enabled' => false ) ); foreach ( $revisions as $revision ) { if ( false !== strpos( $revision->post_name, "{$parent_id}-autosave" ) ) { $data = $this->prepare_item_for_response( $revision, $request ); $response[] = $this->prepare_response_for_collection( $data ); } } return rest_ensure_response( $response ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = $this->revisions_controller->get_item_schema(); $schema['properties']['preview_link'] = array( 'description' => __( 'Preview link for the post.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'edit' ), 'readonly' => true, ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function create_post_autosave( $post_data ) { $post_id = (int) $post_data['ID']; $post = get_post( $post_id ); if ( is_wp_error( $post ) ) { return $post; } $user_id = get_current_user_id(); $old_autosave = wp_get_post_autosave( $post_id, $user_id ); if ( $old_autosave ) { $new_autosave = _wp_post_revision_data( $post_data, true ); $new_autosave['ID'] = $old_autosave->ID; $new_autosave['post_author'] = $user_id; $autosave_is_different = false; foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { $autosave_is_different = true; break; } } if ( ! $autosave_is_different ) { wp_delete_post_revision( $old_autosave->ID ); return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.' ), array( 'status' => 400 ) ); } do_action( 'wp_creating_autosave', $new_autosave ); return wp_update_post( wp_slash( $new_autosave ) ); } return _wp_put_post_revision( $post_data, true ); } public function prepare_item_for_response( $item, $request ) { $post = $item; $response = $this->revisions_controller->prepare_item_for_response( $post, $request ); $fields = $this->get_fields_for_response( $request ); if ( in_array( 'preview_link', $fields, true ) ) { $parent_id = wp_is_post_autosave( $post ); $preview_post_id = false === $parent_id ? $post->ID : $parent_id; $preview_query_args = array(); if ( false !== $parent_id ) { $preview_query_args['preview_id'] = $parent_id; $preview_query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $parent_id ); } $response->data['preview_link'] = get_preview_post_link( $preview_post_id, $preview_query_args ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $response->data = $this->add_additional_fields_to_object( $response->data, $request ); $response->data = $this->filter_response_by_context( $response->data, $context ); return apply_filters( 'rest_prepare_autosave', $response, $post, $request ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } } <?php + class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { private $parent_post_type; private $parent_controller; private $revisions_controller; private $parent_base; public function __construct( $parent_post_type ) { $this->parent_post_type = $parent_post_type; $post_type_object = get_post_type_object( $parent_post_type ); $parent_controller = $post_type_object->get_rest_controller(); if ( ! $parent_controller ) { $parent_controller = new WP_REST_Posts_Controller( $parent_post_type ); } $this->parent_controller = $parent_controller; $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type ); $this->rest_base = 'autosaves'; $this->namespace = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2'; $this->parent_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base, array( 'args' => array( 'parent' => array( 'description' => __( 'The ID for the parent of the autosave.' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->parent_controller->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', array( 'args' => array( 'parent' => array( 'description' => __( 'The ID for the parent of the autosave.' ), 'type' => 'integer', ), 'id' => array( 'description' => __( 'The ID for the autosave.' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this->revisions_controller, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } protected function get_parent( $parent_id ) { return $this->revisions_controller->get_parent( $parent_id ); } public function get_items_permissions_check( $request ) { $parent = $this->get_parent( $request['id'] ); if ( is_wp_error( $parent ) ) { return $parent; } if ( ! current_user_can( 'edit_post', $parent->ID ) ) { return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view autosaves of this post.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function create_item_permissions_check( $request ) { $id = $request->get_param( 'id' ); if ( empty( $id ) ) { return new WP_Error( 'rest_post_invalid_id', __( 'Invalid item ID.' ), array( 'status' => 404 ) ); } return $this->parent_controller->update_item_permissions_check( $request ); } public function create_item( $request ) { if ( ! defined( 'DOING_AUTOSAVE' ) ) { define( 'DOING_AUTOSAVE', true ); } $post = get_post( $request['id'] ); if ( is_wp_error( $post ) ) { return $post; } $prepared_post = $this->parent_controller->prepare_item_for_database( $request ); $prepared_post->ID = $post->ID; $user_id = get_current_user_id(); if ( ! function_exists( 'wp_check_post_lock' ) ) { require_once ABSPATH . 'wp-admin/includes/post.php'; } $post_lock = wp_check_post_lock( $post->ID ); $is_draft = 'draft' === $post->post_status || 'auto-draft' === $post->post_status; if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock ) { $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true ); } else { $autosave_id = $this->create_post_autosave( (array) $prepared_post ); } if ( is_wp_error( $autosave_id ) ) { return $autosave_id; } $autosave = get_post( $autosave_id ); $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $autosave, $request ); $response = rest_ensure_response( $response ); return $response; } public function get_item( $request ) { $parent_id = (int) $request->get_param( 'parent' ); if ( $parent_id <= 0 ) { return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); } $autosave = wp_get_post_autosave( $parent_id ); if ( ! $autosave ) { return new WP_Error( 'rest_post_no_autosave', __( 'There is no autosave revision for this post.' ), array( 'status' => 404 ) ); } $response = $this->prepare_item_for_response( $autosave, $request ); return $response; } public function get_items( $request ) { $parent = $this->get_parent( $request['id'] ); if ( is_wp_error( $parent ) ) { return $parent; } $response = array(); $parent_id = $parent->ID; $revisions = wp_get_post_revisions( $parent_id, array( 'check_enabled' => false ) ); foreach ( $revisions as $revision ) { if ( false !== strpos( $revision->post_name, "{$parent_id}-autosave" ) ) { $data = $this->prepare_item_for_response( $revision, $request ); $response[] = $this->prepare_response_for_collection( $data ); } } return rest_ensure_response( $response ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = $this->revisions_controller->get_item_schema(); $schema['properties']['preview_link'] = array( 'description' => __( 'Preview link for the post.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'edit' ), 'readonly' => true, ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function create_post_autosave( $post_data ) { $post_id = (int) $post_data['ID']; $post = get_post( $post_id ); if ( is_wp_error( $post ) ) { return $post; } $autosave_is_different = false; $new_autosave = _wp_post_revision_data( $post_data, true ); foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { $autosave_is_different = true; break; } } if ( ! $autosave_is_different ) { return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.' ), array( 'status' => 400 ) ); } $user_id = get_current_user_id(); $old_autosave = wp_get_post_autosave( $post_id, $user_id ); if ( $old_autosave ) { $new_autosave['ID'] = $old_autosave->ID; $new_autosave['post_author'] = $user_id; do_action( 'wp_creating_autosave', $new_autosave ); return wp_update_post( wp_slash( $new_autosave ) ); } return _wp_put_post_revision( $post_data, true ); } public function prepare_item_for_response( $item, $request ) { $post = $item; $response = $this->revisions_controller->prepare_item_for_response( $post, $request ); $fields = $this->get_fields_for_response( $request ); if ( in_array( 'preview_link', $fields, true ) ) { $parent_id = wp_is_post_autosave( $post ); $preview_post_id = false === $parent_id ? $post->ID : $parent_id; $preview_query_args = array(); if ( false !== $parent_id ) { $preview_query_args['preview_id'] = $parent_id; $preview_query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $parent_id ); } $response->data['preview_link'] = get_preview_post_link( $preview_post_id, $preview_query_args ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $response->data = $this->add_additional_fields_to_object( $response->data, $request ); $response->data = $this->filter_response_by_context( $response->data, $context ); return apply_filters( 'rest_prepare_autosave', $response, $post, $request ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } } <?php class WP_REST_Block_Directory_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-directory'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/search', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_block_directory_cannot_view', __( 'Sorry, you are not allowed to browse the block directory.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php'; $response = plugins_api( 'query_plugins', array( 'block' => $request['term'], 'per_page' => $request['per_page'], 'page' => $request['page'], ) ); if ( is_wp_error( $response ) ) { $response->add_data( array( 'status' => 500 ) ); return $response; } $result = array(); foreach ( $response->plugins as $plugin ) { if ( empty( $plugin['blocks'] ) ) { continue; } $data = $this->prepare_item_for_response( $plugin, $request ); $result[] = $this->prepare_response_for_collection( $data ); } return rest_ensure_response( $result ); } public function prepare_item_for_response( $item, $request ) { $plugin = $item; $fields = $this->get_fields_for_response( $request ); $block_data = reset( $plugin['blocks'] ); $block = array( 'name' => $block_data['name'], 'title' => ( $block_data['title'] ? $block_data['title'] : $plugin['name'] ), 'description' => wp_trim_words( $plugin['short_description'], 30, '...' ), 'id' => $plugin['slug'], 'rating' => $plugin['rating'] / 20, 'rating_count' => (int) $plugin['num_ratings'], 'active_installs' => (int) $plugin['active_installs'], 'author_block_rating' => $plugin['author_block_rating'] / 20, 'author_block_count' => (int) $plugin['author_block_count'], 'author' => wp_strip_all_tags( $plugin['author'] ), 'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ), 'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ), 'humanized_updated' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $plugin['last_updated'] ) ) ), ); $this->add_additional_fields_to_object( $block, $request ); $response = new WP_REST_Response( $block ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $plugin ) ); } return $response; } protected function prepare_links( $plugin ) { $links = array( 'https://api.w.org/install-plugin' => array( 'href' => add_query_arg( 'slug', urlencode( $plugin['slug'] ), rest_url( 'wp/v2/plugins' ) ), ), ); $plugin_file = $this->find_plugin_for_slug( $plugin['slug'] ); if ( $plugin_file ) { $links['https://api.w.org/plugin'] = array( 'href' => rest_url( 'wp/v2/plugins/' . substr( $plugin_file, 0, - 4 ) ), 'embeddable' => true, ); } return $links; } protected function find_plugin_for_slug( $slug ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugin_files = get_plugins( '/' . $slug ); if ( ! $plugin_files ) { return ''; } $plugin_files = array_keys( $plugin_files ); return $slug . '/' . reset( $plugin_files ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-directory-item', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The block name, in namespace/block-name format.' ), 'type' => 'string', 'context' => array( 'view' ), ), 'title' => array( 'description' => __( 'The block title, in human readable format.' ), 'type' => 'string', 'context' => array( 'view' ), ), 'description' => array( 'description' => __( 'A short description of the block, in human readable format.' ), 'type' => 'string', 'context' => array( 'view' ), ), 'id' => array( 'description' => __( 'The block slug.' ), 'type' => 'string', 'context' => array( 'view' ), ), 'rating' => array( 'description' => __( 'The star rating of the block.' ), 'type' => 'number', 'context' => array( 'view' ), ), 'rating_count' => array( 'description' => __( 'The number of ratings.' ), 'type' => 'integer', 'context' => array( 'view' ), ), 'active_installs' => array( 'description' => __( 'The number sites that have activated this block.' ), 'type' => 'integer', 'context' => array( 'view' ), ), 'author_block_rating' => array( 'description' => __( 'The average rating of blocks published by the same author.' ), 'type' => 'number', 'context' => array( 'view' ), ), 'author_block_count' => array( 'description' => __( 'The number of blocks published by the same author.' ), 'type' => 'integer', 'context' => array( 'view' ), ), 'author' => array( 'description' => __( 'The WordPress.org username of the block author.' ), 'type' => 'string', 'context' => array( 'view' ), ), 'icon' => array( 'description' => __( 'The block icon.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view' ), ), 'last_updated' => array( 'description' => __( 'The date when the block was last updated.' ), 'type' => 'string', 'format' => 'date-time', 'context' => array( 'view' ), ), 'humanized_updated' => array( 'description' => __( 'The date when the block was last updated, in fuzzy human readable format.' ), 'type' => 'string', 'context' => array( 'view' ), ), ), ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['context']['default'] = 'view'; $query_params['term'] = array( 'description' => __( 'Limit result set to blocks matching the search term.' ), 'type' => 'string', 'required' => true, 'minLength' => 1, ); unset( $query_params['search'] ); return apply_filters( 'rest_block_directory_collection_params', $query_params ); } } <?php - class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-patterns/categories'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view the registered block pattern categories.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { $response = array(); $categories = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(); foreach ( $categories as $category ) { $prepared_category = $this->prepare_item_for_response( $category, $request ); $response[] = $this->prepare_response_for_collection( $prepared_category ); } return rest_ensure_response( $response ); } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $keys = array( 'name', 'label' ); $data = array(); foreach ( $keys as $key ) { if ( rest_is_field_included( $key, $fields ) ) { $data[ $key ] = $item[ $key ]; } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); return rest_ensure_response( $data ); } public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-pattern-category', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The category name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'label' => array( 'description' => __( 'The category label, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $schema ); } } <?php - class WP_REST_Block_Patterns_Controller extends WP_REST_Controller { private $remote_patterns_loaded; public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-patterns/patterns'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view the registered block patterns.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { if ( ! $this->remote_patterns_loaded ) { _load_remote_block_patterns(); _load_remote_featured_patterns(); _register_remote_theme_patterns(); $this->remote_patterns_loaded = true; } $response = array(); $patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered(); foreach ( $patterns as $pattern ) { $prepared_pattern = $this->prepare_item_for_response( $pattern, $request ); $response[] = $this->prepare_response_for_collection( $prepared_pattern ); } return rest_ensure_response( $response ); } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $keys = array( 'name' => 'name', 'title' => 'title', 'description' => 'description', 'viewportWidth' => 'viewport_width', 'blockTypes' => 'block_types', 'postTypes' => 'post_types', 'categories' => 'categories', 'keywords' => 'keywords', 'content' => 'content', 'inserter' => 'inserter', ); $data = array(); foreach ( $keys as $item_key => $rest_key ) { if ( isset( $item[ $item_key ] ) && rest_is_field_included( $rest_key, $fields ) ) { $data[ $rest_key ] = $item[ $item_key ]; } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); return rest_ensure_response( $data ); } public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-pattern', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The pattern name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'title' => array( 'description' => __( 'The pattern title, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'description' => array( 'description' => __( 'The pattern detailed description.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'viewport_width' => array( 'description' => __( 'The pattern viewport width for inserter preview.' ), 'type' => 'number', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'block_types' => array( 'description' => __( 'Block types that the pattern is intended to be used with.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'post_types' => array( 'description' => __( 'An array of post types that the pattern is restricted to be used with.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'categories' => array( 'description' => __( 'The pattern category slugs.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'keywords' => array( 'description' => __( 'The pattern keywords.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'content' => array( 'description' => __( 'The pattern content.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'inserter' => array( 'description' => __( 'Determines whether the pattern is visible in inserter.' ), 'type' => 'boolean', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $schema ); } } <?php + class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-patterns/categories'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view the registered block pattern categories.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { $response = array(); $categories = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(); foreach ( $categories as $category ) { $prepared_category = $this->prepare_item_for_response( $category, $request ); $response[] = $this->prepare_response_for_collection( $prepared_category ); } return rest_ensure_response( $response ); } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $keys = array( 'name', 'label', 'description' ); $data = array(); foreach ( $keys as $key ) { if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) { $data[ $key ] = $item[ $key ]; } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); return rest_ensure_response( $data ); } public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-pattern-category', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The category name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'label' => array( 'description' => __( 'The category label, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'description' => array( 'description' => __( 'The category description, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $schema ); } } <?php + class WP_REST_Block_Patterns_Controller extends WP_REST_Controller { private $remote_patterns_loaded; protected static $categories_migration = array( 'buttons' => 'call-to-action', 'columns' => 'text', 'query' => 'posts', ); public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-patterns/patterns'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view the registered block patterns.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { if ( ! $this->remote_patterns_loaded ) { _load_remote_block_patterns(); _load_remote_featured_patterns(); _register_remote_theme_patterns(); $this->remote_patterns_loaded = true; } $response = array(); $patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered(); foreach ( $patterns as $pattern ) { $migrated_pattern = $this->migrate_pattern_categories( $pattern ); $prepared_pattern = $this->prepare_item_for_response( $migrated_pattern, $request ); $response[] = $this->prepare_response_for_collection( $prepared_pattern ); } return rest_ensure_response( $response ); } protected function migrate_pattern_categories( $pattern ) { if ( ! isset( $pattern['categories'] ) || ! is_array( $pattern['categories'] ) ) { return $pattern; } foreach ( $pattern['categories'] as $index => $category ) { if ( isset( static::$categories_migration[ $category ] ) ) { $pattern['categories'][ $index ] = static::$categories_migration[ $category ]; } } return $pattern; } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $keys = array( 'name' => 'name', 'title' => 'title', 'description' => 'description', 'viewportWidth' => 'viewport_width', 'blockTypes' => 'block_types', 'postTypes' => 'post_types', 'categories' => 'categories', 'keywords' => 'keywords', 'content' => 'content', 'inserter' => 'inserter', ); $data = array(); foreach ( $keys as $item_key => $rest_key ) { if ( isset( $item[ $item_key ] ) && rest_is_field_included( $rest_key, $fields ) ) { $data[ $rest_key ] = $item[ $item_key ]; } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); return rest_ensure_response( $data ); } public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-pattern', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The pattern name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'title' => array( 'description' => __( 'The pattern title, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'description' => array( 'description' => __( 'The pattern detailed description.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'viewport_width' => array( 'description' => __( 'The pattern viewport width for inserter preview.' ), 'type' => 'number', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'block_types' => array( 'description' => __( 'Block types that the pattern is intended to be used with.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'post_types' => array( 'description' => __( 'An array of post types that the pattern is restricted to be used with.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'categories' => array( 'description' => __( 'The pattern category slugs.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'keywords' => array( 'description' => __( 'The pattern keywords.' ), 'type' => 'array', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'content' => array( 'description' => __( 'The pattern content.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'inserter' => array( 'description' => __( 'Determines whether the pattern is visible in inserter.' ), 'type' => 'boolean', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $schema ); } } <?php class WP_REST_Block_Renderer_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-renderer'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<name>[a-z0-9-]+/[a-z0-9-]+)', array( 'args' => array( 'name' => array( 'description' => __( 'Unique registered name for the block.' ), 'type' => 'string', ), ), array( 'methods' => array( WP_REST_Server::READABLE, WP_REST_Server::CREATABLE ), 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'attributes' => array( 'description' => __( 'Attributes for the block.' ), 'type' => 'object', 'default' => array(), 'validate_callback' => static function ( $value, $request ) { $block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] ); if ( ! $block ) { return true; } $schema = array( 'type' => 'object', 'properties' => $block->get_attributes(), 'additionalProperties' => false, ); return rest_validate_value_from_schema( $value, $schema ); }, 'sanitize_callback' => static function ( $value, $request ) { $block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] ); if ( ! $block ) { return true; } $schema = array( 'type' => 'object', 'properties' => $block->get_attributes(), 'additionalProperties' => false, ); return rest_sanitize_value_from_schema( $value, $schema ); }, ), 'post_id' => array( 'description' => __( 'ID of the post context.' ), 'type' => 'integer', ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_item_permissions_check( $request ) { global $post; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { return new WP_Error( 'block_cannot_read', __( 'Sorry, you are not allowed to read blocks of this post.' ), array( 'status' => rest_authorization_required_code(), ) ); } } else { if ( ! current_user_can( 'edit_posts' ) ) { return new WP_Error( 'block_cannot_read', __( 'Sorry, you are not allowed to read blocks as this user.' ), array( 'status' => rest_authorization_required_code(), ) ); } } return true; } public function get_item( $request ) { global $post; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0; if ( $post_id > 0 ) { $post = get_post( $post_id ); setup_postdata( $post ); } $registry = WP_Block_Type_Registry::get_instance(); $registered = $registry->get_registered( $request['name'] ); if ( null === $registered || ! $registered->is_dynamic() ) { return new WP_Error( 'block_invalid', __( 'Invalid block.' ), array( 'status' => 404, ) ); } $attributes = $request->get_param( 'attributes' ); $block = array( 'blockName' => $request['name'], 'attrs' => $attributes, 'innerHTML' => '', 'innerContent' => array(), ); $data = array( 'rendered' => render_block( $block ), ); return rest_ensure_response( $data ); } public function get_item_schema() { if ( $this->schema ) { return $this->schema; } $this->schema = array( '$schema' => 'http://json-schema.org/schema#', 'title' => 'rendered-block', 'type' => 'object', 'properties' => array( 'rendered' => array( 'description' => __( 'The rendered block.' ), 'type' => 'string', 'required' => true, 'context' => array( 'edit' ), ), ), ); return $this->schema; } } <?php class WP_REST_Block_Types_Controller extends WP_REST_Controller { protected $block_registry; protected $style_registry; public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'block-types'; $this->block_registry = WP_Block_Type_Registry::get_instance(); $this->style_registry = WP_Block_Styles_Registry::get_instance(); } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<namespace>[a-zA-Z0-9_-]+)', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<namespace>[a-zA-Z0-9_-]+)/(?P<name>[a-zA-Z0-9_-]+)', array( 'args' => array( 'name' => array( 'description' => __( 'Block name.' ), 'type' => 'string', ), 'namespace' => array( 'description' => __( 'Block namespace.' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { return $this->check_read_permission(); } public function get_items( $request ) { $data = array(); $block_types = $this->block_registry->get_all_registered(); $registered = $this->get_collection_params(); $namespace = ''; if ( isset( $registered['namespace'] ) && ! empty( $request['namespace'] ) ) { $namespace = $request['namespace']; } foreach ( $block_types as $slug => $obj ) { if ( $namespace ) { list ( $block_namespace ) = explode( '/', $obj->name ); if ( $namespace !== $block_namespace ) { continue; } } $block_type = $this->prepare_item_for_response( $obj, $request ); $data[] = $this->prepare_response_for_collection( $block_type ); } return rest_ensure_response( $data ); } public function get_item_permissions_check( $request ) { $check = $this->check_read_permission(); if ( is_wp_error( $check ) ) { return $check; } $block_name = sprintf( '%s/%s', $request['namespace'], $request['name'] ); $block_type = $this->get_block( $block_name ); if ( is_wp_error( $block_type ) ) { return $block_type; } return true; } protected function check_read_permission() { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_block_type_cannot_view', __( 'Sorry, you are not allowed to manage block types.' ), array( 'status' => rest_authorization_required_code() ) ); } protected function get_block( $name ) { $block_type = $this->block_registry->get_registered( $name ); if ( empty( $block_type ) ) { return new WP_Error( 'rest_block_type_invalid', __( 'Invalid block type.' ), array( 'status' => 404 ) ); } return $block_type; } public function get_item( $request ) { $block_name = sprintf( '%s/%s', $request['namespace'], $request['name'] ); $block_type = $this->get_block( $block_name ); if ( is_wp_error( $block_type ) ) { return $block_type; } $data = $this->prepare_item_for_response( $block_type, $request ); return rest_ensure_response( $data ); } public function prepare_item_for_response( $item, $request ) { $block_type = $item; $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'attributes', $fields ) ) { $data['attributes'] = $block_type->get_attributes(); } if ( rest_is_field_included( 'is_dynamic', $fields ) ) { $data['is_dynamic'] = $block_type->is_dynamic(); } $schema = $this->get_item_schema(); $deprecated_fields = array( 'editor_script', 'script', 'view_script', 'editor_style', 'style', ); $extra_fields = array_merge( array( 'api_version', 'name', 'title', 'description', 'icon', 'category', 'keywords', 'parent', 'ancestor', 'provides_context', 'uses_context', 'supports', 'styles', 'textdomain', 'example', 'editor_script_handles', 'script_handles', 'view_script_handles', 'editor_style_handles', 'style_handles', 'variations', ), $deprecated_fields ); foreach ( $extra_fields as $extra_field ) { if ( rest_is_field_included( $extra_field, $fields ) ) { if ( isset( $block_type->$extra_field ) ) { $field = $block_type->$extra_field; if ( in_array( $extra_field, $deprecated_fields, true ) && is_array( $field ) ) { $field = ! empty( $field ) ? array_shift( $field ) : ''; } } elseif ( array_key_exists( 'default', $schema['properties'][ $extra_field ] ) ) { $field = $schema['properties'][ $extra_field ]['default']; } else { $field = ''; } $data[ $extra_field ] = rest_sanitize_value_from_schema( $field, $schema['properties'][ $extra_field ] ); } } if ( rest_is_field_included( 'styles', $fields ) ) { $styles = $this->style_registry->get_registered_styles_for_block( $block_type->name ); $styles = array_values( $styles ); $data['styles'] = wp_parse_args( $styles, $data['styles'] ); $data['styles'] = array_filter( $data['styles'] ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $block_type ) ); } return apply_filters( 'rest_prepare_block_type', $response, $block_type, $request ); } protected function prepare_links( $block_type ) { list( $namespace ) = explode( '/', $block_type->name ); $links = array( 'collection' => array( 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), ), 'self' => array( 'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $block_type->name ) ), ), 'up' => array( 'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $namespace ) ), ), ); if ( $block_type->is_dynamic() ) { $links['https://api.w.org/render-block'] = array( 'href' => add_query_arg( 'context', 'edit', rest_url( sprintf( '%s/%s/%s', 'wp/v2', 'block-renderer', $block_type->name ) ) ), ); } return $links; } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $inner_blocks_definition = array( 'description' => __( 'The list of inner blocks used in the example.' ), 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The name of the inner block.' ), 'type' => 'string', ), 'attributes' => array( 'description' => __( 'The attributes of the inner block.' ), 'type' => 'object', ), 'innerBlocks' => array( 'description' => __( "A list of the inner block's own inner blocks. This is a recursive definition following the parent innerBlocks schema." ), 'type' => 'array', ), ), ), ); $example_definition = array( 'description' => __( 'Block example.' ), 'type' => array( 'object', 'null' ), 'default' => null, 'properties' => array( 'attributes' => array( 'description' => __( 'The attributes used in the example.' ), 'type' => 'object', ), 'innerBlocks' => $inner_blocks_definition, ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ); $keywords_definition = array( 'description' => __( 'Block keywords.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'default' => array(), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ); $icon_definition = array( 'description' => __( 'Icon of block type.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ); $category_definition = array( 'description' => __( 'Block category.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ); $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'block-type', 'type' => 'object', 'properties' => array( 'api_version' => array( 'description' => __( 'Version of block API.' ), 'type' => 'integer', 'default' => 1, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'title' => array( 'description' => __( 'Title of block type.' ), 'type' => 'string', 'default' => '', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'name' => array( 'description' => __( 'Unique name identifying the block type.' ), 'type' => 'string', 'default' => '', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'description' => array( 'description' => __( 'Description of block type.' ), 'type' => 'string', 'default' => '', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'icon' => $icon_definition, 'attributes' => array( 'description' => __( 'Block attributes.' ), 'type' => array( 'object', 'null' ), 'properties' => array(), 'default' => null, 'additionalProperties' => array( 'type' => 'object', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'provides_context' => array( 'description' => __( 'Context provided by blocks of this type.' ), 'type' => 'object', 'properties' => array(), 'additionalProperties' => array( 'type' => 'string', ), 'default' => array(), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'uses_context' => array( 'description' => __( 'Context values inherited by blocks of this type.' ), 'type' => 'array', 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'supports' => array( 'description' => __( 'Block supports.' ), 'type' => 'object', 'default' => array(), 'properties' => array(), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'category' => $category_definition, 'is_dynamic' => array( 'description' => __( 'Is the block dynamically rendered.' ), 'type' => 'boolean', 'default' => false, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'editor_script_handles' => array( 'description' => __( 'Editor script handles.' ), 'type' => array( 'array' ), 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'script_handles' => array( 'description' => __( 'Public facing and editor script handles.' ), 'type' => array( 'array' ), 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'view_script_handles' => array( 'description' => __( 'Public facing script handles.' ), 'type' => array( 'array' ), 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'editor_style_handles' => array( 'description' => __( 'Editor style handles.' ), 'type' => array( 'array' ), 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'style_handles' => array( 'description' => __( 'Public facing and editor style handles.' ), 'type' => array( 'array' ), 'default' => array(), 'items' => array( 'type' => 'string', ), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'styles' => array( 'description' => __( 'Block style variations.' ), 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'Unique name identifying the style.' ), 'type' => 'string', 'required' => true, ), 'label' => array( 'description' => __( 'The human-readable label for the style.' ), 'type' => 'string', ), 'inline_style' => array( 'description' => __( 'Inline CSS code that registers the CSS class required for the style.' ), 'type' => 'string', ), 'style_handle' => array( 'description' => __( 'Contains the handle that defines the block style.' ), 'type' => 'string', ), ), ), 'default' => array(), 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'variations' => array( 'description' => __( 'Block variations.' ), 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The unique and machine-readable name.' ), 'type' => 'string', 'required' => true, ), 'title' => array( 'description' => __( 'A human-readable variation title.' ), 'type' => 'string', 'required' => true, ), 'description' => array( 'description' => __( 'A detailed variation description.' ), 'type' => 'string', 'required' => false, ), 'category' => $category_definition, 'icon' => $icon_definition, 'isDefault' => array( 'description' => __( 'Indicates whether the current variation is the default one.' ), 'type' => 'boolean', 'required' => false, 'default' => false, ), 'attributes' => array( 'description' => __( 'The initial values for attributes.' ), 'type' => 'object', ), 'innerBlocks' => $inner_blocks_definition, 'example' => $example_definition, 'scope' => array( 'description' => __( 'The list of scopes where the variation is applicable. When not provided, it assumes all available scopes.' ), 'type' => array( 'array', 'null' ), 'default' => null, 'items' => array( 'type' => 'string', 'enum' => array( 'block', 'inserter', 'transform' ), ), 'readonly' => true, ), 'keywords' => $keywords_definition, ), ), 'readonly' => true, 'context' => array( 'embed', 'view', 'edit' ), 'default' => null, ), 'textdomain' => array( 'description' => __( 'Public text domain.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'parent' => array( 'description' => __( 'Parent blocks.' ), 'type' => array( 'array', 'null' ), 'items' => array( 'type' => 'string', ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'ancestor' => array( 'description' => __( 'Ancestor blocks.' ), 'type' => array( 'array', 'null' ), 'items' => array( 'type' => 'string', ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'keywords' => $keywords_definition, 'example' => $example_definition, ), ); $deprecated_properties = array( 'editor_script' => array( 'description' => __( 'Editor script handle. DEPRECATED: Use `editor_script_handles` instead.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'script' => array( 'description' => __( 'Public facing and editor script handle. DEPRECATED: Use `script_handles` instead.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'view_script' => array( 'description' => __( 'Public facing script handle. DEPRECATED: Use `view_script_handles` instead.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'editor_style' => array( 'description' => __( 'Editor style handle. DEPRECATED: Use `editor_style_handles` instead.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'style' => array( 'description' => __( 'Public facing and editor style handle. DEPRECATED: Use `style_handles` instead.' ), 'type' => array( 'string', 'null' ), 'default' => null, 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), ); $this->schema['properties'] = array_merge( $this->schema['properties'], $deprecated_properties ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'namespace' => array( 'description' => __( 'Block namespace.' ), 'type' => 'string', ), ); } } <?php class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller { public function check_read_permission( $post ) { if ( ! current_user_can( 'read_post', $post->ID ) ) { return false; } return parent::check_read_permission( $post ); } public function filter_response_by_context( $data, $context ) { $data = parent::filter_response_by_context( $data, $context ); unset( $data['title']['rendered'] ); unset( $data['content']['rendered'] ); return $data; } public function get_item_schema() { $schema = parent::get_item_schema(); $schema['properties']['title']['properties']['raw']['context'] = array( 'view', 'edit' ); $schema['properties']['content']['properties']['raw']['context'] = array( 'view', 'edit' ); unset( $schema['properties']['title']['properties']['rendered'] ); unset( $schema['properties']['content']['properties']['rendered'] ); return $schema; } } <?php class WP_REST_Comments_Controller extends WP_REST_Controller { protected $meta; public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'comments'; $this->meta = new WP_REST_Comment_Meta_Fields(); } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( 'args' => array( 'id' => array( 'description' => __( 'Unique identifier for the comment.' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'password' => array( 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ), 'type' => 'string', ), ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_item' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ), 'permission_callback' => array( $this, 'delete_item_permissions_check' ), 'args' => array( 'force' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Whether to bypass Trash and force deletion.' ), ), 'password' => array( 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ), 'type' => 'string', ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( ! empty( $request['post'] ) ) { foreach ( (array) $request['post'] as $post_id ) { $post = get_post( $post_id ); if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post, $request ) ) { return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) { return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) ); } } } if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( ! current_user_can( 'edit_posts' ) ) { $protected_params = array( 'author', 'author_exclude', 'author_email', 'type', 'status' ); $forbidden_params = array(); foreach ( $protected_params as $param ) { if ( 'status' === $param ) { if ( 'approve' !== $request[ $param ] ) { $forbidden_params[] = $param; } } elseif ( 'type' === $param ) { if ( 'comment' !== $request[ $param ] ) { $forbidden_params[] = $param; } } elseif ( ! empty( $request[ $param ] ) ) { $forbidden_params[] = $param; } } if ( ! empty( $forbidden_params ) ) { return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) ); } } return true; } public function get_items( $request ) { $registered = $this->get_collection_params(); $parameter_mappings = array( 'author' => 'author__in', 'author_email' => 'author_email', 'author_exclude' => 'author__not_in', 'exclude' => 'comment__not_in', 'include' => 'comment__in', 'offset' => 'offset', 'order' => 'order', 'parent' => 'parent__in', 'parent_exclude' => 'parent__not_in', 'per_page' => 'number', 'post' => 'post__in', 'search' => 'search', 'status' => 'status', 'type' => 'type', ); $prepared_args = array(); foreach ( $parameter_mappings as $api_param => $wp_param ) { if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) { $prepared_args[ $wp_param ] = $request[ $api_param ]; } } foreach ( array( 'author_email', 'search' ) as $param ) { if ( ! isset( $prepared_args[ $param ] ) ) { $prepared_args[ $param ] = ''; } } if ( isset( $registered['orderby'] ) ) { $prepared_args['orderby'] = $this->normalize_query_param( $request['orderby'] ); } $prepared_args['no_found_rows'] = false; $prepared_args['update_comment_post_cache'] = true; $prepared_args['date_query'] = array(); if ( isset( $registered['before'], $request['before'] ) ) { $prepared_args['date_query'][0]['before'] = $request['before']; } if ( isset( $registered['after'], $request['after'] ) ) { $prepared_args['date_query'][0]['after'] = $request['after']; } if ( isset( $registered['page'] ) && empty( $request['offset'] ) ) { $prepared_args['offset'] = $prepared_args['number'] * ( absint( $request['page'] ) - 1 ); } $prepared_args = apply_filters( 'rest_comment_query', $prepared_args, $request ); $query = new WP_Comment_Query(); $query_result = $query->query( $prepared_args ); $comments = array(); foreach ( $query_result as $comment ) { if ( ! $this->check_read_permission( $comment, $request ) ) { continue; } $data = $this->prepare_item_for_response( $comment, $request ); $comments[] = $this->prepare_response_for_collection( $data ); } $total_comments = (int) $query->found_comments; $max_pages = (int) $query->max_num_pages; if ( $total_comments < 1 ) { unset( $prepared_args['number'], $prepared_args['offset'] ); $query = new WP_Comment_Query(); $prepared_args['count'] = true; $total_comments = $query->query( $prepared_args ); $max_pages = ceil( $total_comments / $request['per_page'] ); } $response = rest_ensure_response( $comments ); $response->header( 'X-WP-Total', $total_comments ); $response->header( 'X-WP-TotalPages', $max_pages ); $base = add_query_arg( urlencode_deep( $request->get_query_params() ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); if ( $request['page'] > 1 ) { $prev_page = $request['page'] - 1; if ( $prev_page > $max_pages ) { $prev_page = $max_pages; } $prev_link = add_query_arg( 'page', $prev_page, $base ); $response->link_header( 'prev', $prev_link ); } if ( $max_pages > $request['page'] ) { $next_page = $request['page'] + 1; $next_link = add_query_arg( 'page', $next_page, $base ); $response->link_header( 'next', $next_link ); } return $response; } protected function get_comment( $id ) { $error = new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) ); if ( (int) $id <= 0 ) { return $error; } $id = (int) $id; $comment = get_comment( $id ); if ( empty( $comment ) ) { return $error; } if ( ! empty( $comment->comment_post_ID ) ) { $post = get_post( (int) $comment->comment_post_ID ); if ( empty( $post ) ) { return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) ); } } return $comment; } public function get_item_permissions_check( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) ); } $post = get_post( $comment->comment_post_ID ); if ( ! $this->check_read_permission( $comment, $request ) ) { return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( $post && ! $this->check_read_post_permission( $post, $request ) ) { return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_item( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } $data = $this->prepare_item_for_response( $comment, $request ); $response = rest_ensure_response( $data ); return $response; } public function create_item_permissions_check( $request ) { if ( ! is_user_logged_in() ) { if ( get_option( 'comment_registration' ) ) { return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) ); } $allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request ); if ( ! $allow_anonymous ) { return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) ); } } if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) { return new WP_Error( 'rest_comment_invalid_author', sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ), array( 'status' => rest_authorization_required_code() ) ); } if ( isset( $request['author_ip'] ) && ! current_user_can( 'moderate_comments' ) ) { if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) { return new WP_Error( 'rest_comment_invalid_author_ip', sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ), array( 'status' => rest_authorization_required_code() ) ); } } if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) { return new WP_Error( 'rest_comment_invalid_status', sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ), array( 'status' => rest_authorization_required_code() ) ); } if ( empty( $request['post'] ) ) { return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) ); } $post = get_post( (int) $request['post'] ); if ( ! $post ) { return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) ); } if ( 'draft' === $post->post_status ) { return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) ); } if ( 'trash' === $post->post_status ) { return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) ); } if ( ! $this->check_read_post_permission( $post, $request ) ) { return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( ! comments_open( $post->ID ) ) { return new WP_Error( 'rest_comment_closed', __( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) ); } return true; } public function create_item( $request ) { if ( ! empty( $request['id'] ) ) { return new WP_Error( 'rest_comment_exists', __( 'Cannot create existing comment.' ), array( 'status' => 400 ) ); } if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) { return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) ); } $prepared_comment = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared_comment ) ) { return $prepared_comment; } $prepared_comment['comment_type'] = 'comment'; if ( ! isset( $prepared_comment['comment_content'] ) ) { $prepared_comment['comment_content'] = ''; } if ( ! $this->check_is_comment_content_allowed( $prepared_comment ) ) { return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) ); } if ( ! isset( $prepared_comment['comment_date_gmt'] ) ) { $prepared_comment['comment_date_gmt'] = current_time( 'mysql', true ); } $missing_author = empty( $prepared_comment['user_id'] ) && empty( $prepared_comment['comment_author'] ) && empty( $prepared_comment['comment_author_email'] ) && empty( $prepared_comment['comment_author_url'] ); if ( is_user_logged_in() && $missing_author ) { $user = wp_get_current_user(); $prepared_comment['user_id'] = $user->ID; $prepared_comment['comment_author'] = $user->display_name; $prepared_comment['comment_author_email'] = $user->user_email; $prepared_comment['comment_author_url'] = $user->user_url; } if ( get_option( 'require_name_email' ) ) { if ( empty( $prepared_comment['comment_author'] ) || empty( $prepared_comment['comment_author_email'] ) ) { return new WP_Error( 'rest_comment_author_data_required', __( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) ); } } if ( ! isset( $prepared_comment['comment_author_email'] ) ) { $prepared_comment['comment_author_email'] = ''; } if ( ! isset( $prepared_comment['comment_author_url'] ) ) { $prepared_comment['comment_author_url'] = ''; } if ( ! isset( $prepared_comment['comment_agent'] ) ) { $prepared_comment['comment_agent'] = ''; } $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_comment ); if ( is_wp_error( $check_comment_lengths ) ) { $error_code = $check_comment_lengths->get_error_code(); return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) ); } $prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true ); if ( is_wp_error( $prepared_comment['comment_approved'] ) ) { $error_code = $prepared_comment['comment_approved']->get_error_code(); $error_message = $prepared_comment['comment_approved']->get_error_message(); if ( 'comment_duplicate' === $error_code ) { return new WP_Error( $error_code, $error_message, array( 'status' => 409 ) ); } if ( 'comment_flood' === $error_code ) { return new WP_Error( $error_code, $error_message, array( 'status' => 400 ) ); } return $prepared_comment['comment_approved']; } $prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request ); if ( is_wp_error( $prepared_comment ) ) { return $prepared_comment; } $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) ); if ( ! $comment_id ) { return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) ); } if ( isset( $request['status'] ) ) { $this->handle_status_param( $request['status'], $comment_id ); } $comment = get_comment( $comment_id ); do_action( 'rest_insert_comment', $comment, $request, true ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $comment_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object( $comment, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $context = current_user_can( 'moderate_comments' ) ? 'edit' : 'view'; $request->set_param( 'context', $context ); do_action( 'rest_after_insert_comment', $comment, $request, true ); $response = $this->prepare_item_for_response( $comment, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) ); return $response; } public function update_item_permissions_check( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } if ( ! $this->check_edit_permission( $comment ) ) { return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function update_item( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } $id = $comment->comment_ID; if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) { return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) ); } $prepared_args = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared_args ) ) { return $prepared_args; } if ( ! empty( $prepared_args['comment_post_ID'] ) ) { $post = get_post( $prepared_args['comment_post_ID'] ); if ( empty( $post ) ) { return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) ); } } if ( empty( $prepared_args ) && isset( $request['status'] ) ) { $change = $this->handle_status_param( $request['status'], $id ); if ( ! $change ) { return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment status failed.' ), array( 'status' => 500 ) ); } } elseif ( ! empty( $prepared_args ) ) { if ( is_wp_error( $prepared_args ) ) { return $prepared_args; } if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) { return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) ); } $prepared_args['comment_ID'] = $id; $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args ); if ( is_wp_error( $check_comment_lengths ) ) { $error_code = $check_comment_lengths->get_error_code(); return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) ); } $updated = wp_update_comment( wp_slash( (array) $prepared_args ), true ); if ( is_wp_error( $updated ) ) { return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) ); } if ( isset( $request['status'] ) ) { $this->handle_status_param( $request['status'], $id ); } } $comment = get_comment( $id ); do_action( 'rest_insert_comment', $comment, $request, false ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object( $comment, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'edit' ); do_action( 'rest_after_insert_comment', $comment, $request, false ); $response = $this->prepare_item_for_response( $comment, $request ); return rest_ensure_response( $response ); } public function delete_item_permissions_check( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } if ( ! $this->check_edit_permission( $comment ) ) { return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function delete_item( $request ) { $comment = $this->get_comment( $request['id'] ); if ( is_wp_error( $comment ) ) { return $comment; } $force = isset( $request['force'] ) ? (bool) $request['force'] : false; $supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment ); $request->set_param( 'context', 'edit' ); if ( $force ) { $previous = $this->prepare_item_for_response( $comment, $request ); $result = wp_delete_comment( $comment->comment_ID, true ); $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); } else { if ( ! $supports_trash ) { return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); } if ( 'trash' === $comment->comment_approved ) { return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) ); } $result = wp_trash_comment( $comment->comment_ID ); $comment = get_comment( $comment->comment_ID ); $response = $this->prepare_item_for_response( $comment, $request ); } if ( ! $result ) { return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) ); } do_action( 'rest_delete_comment', $comment, $response, $request ); return $response; } public function prepare_item_for_response( $item, $request ) { $comment = $item; $fields = $this->get_fields_for_response( $request ); $data = array(); if ( in_array( 'id', $fields, true ) ) { $data['id'] = (int) $comment->comment_ID; } if ( in_array( 'post', $fields, true ) ) { $data['post'] = (int) $comment->comment_post_ID; } if ( in_array( 'parent', $fields, true ) ) { $data['parent'] = (int) $comment->comment_parent; } if ( in_array( 'author', $fields, true ) ) { $data['author'] = (int) $comment->user_id; } if ( in_array( 'author_name', $fields, true ) ) { $data['author_name'] = $comment->comment_author; } if ( in_array( 'author_email', $fields, true ) ) { $data['author_email'] = $comment->comment_author_email; } if ( in_array( 'author_url', $fields, true ) ) { $data['author_url'] = $comment->comment_author_url; } if ( in_array( 'author_ip', $fields, true ) ) { $data['author_ip'] = $comment->comment_author_IP; } if ( in_array( 'author_user_agent', $fields, true ) ) { $data['author_user_agent'] = $comment->comment_agent; } if ( in_array( 'date', $fields, true ) ) { $data['date'] = mysql_to_rfc3339( $comment->comment_date ); } if ( in_array( 'date_gmt', $fields, true ) ) { $data['date_gmt'] = mysql_to_rfc3339( $comment->comment_date_gmt ); } if ( in_array( 'content', $fields, true ) ) { $data['content'] = array( 'rendered' => apply_filters( 'comment_text', $comment->comment_content, $comment ), 'raw' => $comment->comment_content, ); } if ( in_array( 'link', $fields, true ) ) { $data['link'] = get_comment_link( $comment ); } if ( in_array( 'status', $fields, true ) ) { $data['status'] = $this->prepare_status_response( $comment->comment_approved ); } if ( in_array( 'type', $fields, true ) ) { $data['type'] = get_comment_type( $comment->comment_ID ); } if ( in_array( 'author_avatar_urls', $fields, true ) ) { $data['author_avatar_urls'] = rest_get_avatar_urls( $comment ); } if ( in_array( 'meta', $fields, true ) ) { $data['meta'] = $this->meta->get_value( $comment->comment_ID, $request ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $comment ) ); } return apply_filters( 'rest_prepare_comment', $response, $comment, $request ); } protected function prepare_links( $comment ) { $links = array( 'self' => array( 'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID ) ), ), 'collection' => array( 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), ), ); if ( 0 !== (int) $comment->user_id ) { $links['author'] = array( 'href' => rest_url( 'wp/v2/users/' . $comment->user_id ), 'embeddable' => true, ); } if ( 0 !== (int) $comment->comment_post_ID ) { $post = get_post( $comment->comment_post_ID ); $post_route = rest_get_route_for_post( $post ); if ( ! empty( $post->ID ) && $post_route ) { $links['up'] = array( 'href' => rest_url( $post_route ), 'embeddable' => true, 'post_type' => $post->post_type, ); } } if ( 0 !== (int) $comment->comment_parent ) { $links['in-reply-to'] = array( 'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_parent ) ), 'embeddable' => true, ); } $comment_children = $comment->get_children( array( 'number' => 1, 'count' => true, ) ); if ( ! empty( $comment_children ) ) { $args = array( 'parent' => $comment->comment_ID, ); $rest_url = add_query_arg( $args, rest_url( $this->namespace . '/' . $this->rest_base ) ); $links['children'] = array( 'href' => $rest_url, 'embeddable' => true, ); } return $links; } protected function normalize_query_param( $query_param ) { $prefix = 'comment_'; switch ( $query_param ) { case 'id': $normalized = $prefix . 'ID'; break; case 'post': $normalized = $prefix . 'post_ID'; break; case 'parent': $normalized = $prefix . 'parent'; break; case 'include': $normalized = 'comment__in'; break; default: $normalized = $prefix . $query_param; break; } return $normalized; } protected function prepare_status_response( $comment_approved ) { switch ( $comment_approved ) { case 'hold': case '0': $status = 'hold'; break; case 'approve': case '1': $status = 'approved'; break; case 'spam': case 'trash': default: $status = $comment_approved; break; } return $status; } protected function prepare_item_for_database( $request ) { $prepared_comment = array(); if ( isset( $request['content'] ) && is_string( $request['content'] ) ) { $prepared_comment['comment_content'] = trim( $request['content'] ); } elseif ( isset( $request['content']['raw'] ) && is_string( $request['content']['raw'] ) ) { $prepared_comment['comment_content'] = trim( $request['content']['raw'] ); } if ( isset( $request['post'] ) ) { $prepared_comment['comment_post_ID'] = (int) $request['post']; } if ( isset( $request['parent'] ) ) { $prepared_comment['comment_parent'] = $request['parent']; } if ( isset( $request['author'] ) ) { $user = new WP_User( $request['author'] ); if ( $user->exists() ) { $prepared_comment['user_id'] = $user->ID; $prepared_comment['comment_author'] = $user->display_name; $prepared_comment['comment_author_email'] = $user->user_email; $prepared_comment['comment_author_url'] = $user->user_url; } else { return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) ); } } if ( isset( $request['author_name'] ) ) { $prepared_comment['comment_author'] = $request['author_name']; } if ( isset( $request['author_email'] ) ) { $prepared_comment['comment_author_email'] = $request['author_email']; } if ( isset( $request['author_url'] ) ) { $prepared_comment['comment_author_url'] = $request['author_url']; } if ( isset( $request['author_ip'] ) && current_user_can( 'moderate_comments' ) ) { $prepared_comment['comment_author_IP'] = $request['author_ip']; } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) && rest_is_ip_address( $_SERVER['REMOTE_ADDR'] ) ) { $prepared_comment['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; } else { $prepared_comment['comment_author_IP'] = '127.0.0.1'; } if ( ! empty( $request['author_user_agent'] ) ) { $prepared_comment['comment_agent'] = $request['author_user_agent']; } elseif ( $request->get_header( 'user_agent' ) ) { $prepared_comment['comment_agent'] = $request->get_header( 'user_agent' ); } if ( ! empty( $request['date'] ) ) { $date_data = rest_get_date_with_gmt( $request['date'] ); if ( ! empty( $date_data ) ) { list( $prepared_comment['comment_date'], $prepared_comment['comment_date_gmt'] ) = $date_data; } } elseif ( ! empty( $request['date_gmt'] ) ) { $date_data = rest_get_date_with_gmt( $request['date_gmt'], true ); if ( ! empty( $date_data ) ) { list( $prepared_comment['comment_date'], $prepared_comment['comment_date_gmt'] ) = $date_data; } } return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'comment', 'type' => 'object', 'properties' => array( 'id' => array( 'description' => __( 'Unique identifier for the comment.' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'author' => array( 'description' => __( 'The ID of the user object, if author was a user.' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), ), 'author_email' => array( 'description' => __( 'Email address for the comment author.' ), 'type' => 'string', 'format' => 'email', 'context' => array( 'edit' ), 'arg_options' => array( 'sanitize_callback' => array( $this, 'check_comment_author_email' ), 'validate_callback' => null, ), ), 'author_ip' => array( 'description' => __( 'IP address for the comment author.' ), 'type' => 'string', 'format' => 'ip', 'context' => array( 'edit' ), ), 'author_name' => array( 'description' => __( 'Display name for the comment author.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), 'author_url' => array( 'description' => __( 'URL for the comment author.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view', 'edit', 'embed' ), ), 'author_user_agent' => array( 'description' => __( 'User agent for the comment author.' ), 'type' => 'string', 'context' => array( 'edit' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), 'content' => array( 'description' => __( 'The content for the comment.' ), 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => null, 'validate_callback' => null, ), 'properties' => array( 'raw' => array( 'description' => __( 'Content for the comment, as it exists in the database.' ), 'type' => 'string', 'context' => array( 'edit' ), ), 'rendered' => array( 'description' => __( 'HTML content for the comment, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ), 'date' => array( 'description' => __( "The date the comment was published, in the site's timezone." ), 'type' => 'string', 'format' => 'date-time', 'context' => array( 'view', 'edit', 'embed' ), ), 'date_gmt' => array( 'description' => __( 'The date the comment was published, as GMT.' ), 'type' => 'string', 'format' => 'date-time', 'context' => array( 'view', 'edit' ), ), 'link' => array( 'description' => __( 'URL to the comment.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'parent' => array( 'description' => __( 'The ID for the parent of the comment.' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), 'default' => 0, ), 'post' => array( 'description' => __( 'The ID of the associated post object.' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'default' => 0, ), 'status' => array( 'description' => __( 'State of the comment.' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_key', ), ), 'type' => array( 'description' => __( 'Type of the comment.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ); if ( get_option( 'show_avatars' ) ) { $avatar_properties = array(); $avatar_sizes = rest_get_avatar_sizes(); foreach ( $avatar_sizes as $size ) { $avatar_properties[ $size ] = array( 'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'embed', 'view', 'edit' ), ); } $schema['properties']['author_avatar_urls'] = array( 'description' => __( 'Avatar URLs for the comment author.' ), 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, 'properties' => $avatar_properties, ); } $schema['properties']['meta'] = $this->meta->get_field_schema(); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['context']['default'] = 'view'; $query_params['after'] = array( 'description' => __( 'Limit response to comments published after a given ISO8601 compliant date.' ), 'type' => 'string', 'format' => 'date-time', ); $query_params['author'] = array( 'description' => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), ); $query_params['author_exclude'] = array( 'description' => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), ); $query_params['author_email'] = array( 'default' => null, 'description' => __( 'Limit result set to that from a specific author email. Requires authorization.' ), 'format' => 'email', 'type' => 'string', ); $query_params['before'] = array( 'description' => __( 'Limit response to comments published before a given ISO8601 compliant date.' ), 'type' => 'string', 'format' => 'date-time', ); $query_params['exclude'] = array( 'description' => __( 'Ensure result set excludes specific IDs.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), 'default' => array(), ); $query_params['include'] = array( 'description' => __( 'Limit result set to specific IDs.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), 'default' => array(), ); $query_params['offset'] = array( 'description' => __( 'Offset the result set by a specific number of items.' ), 'type' => 'integer', ); $query_params['order'] = array( 'description' => __( 'Order sort attribute ascending or descending.' ), 'type' => 'string', 'default' => 'desc', 'enum' => array( 'asc', 'desc', ), ); $query_params['orderby'] = array( 'description' => __( 'Sort collection by comment attribute.' ), 'type' => 'string', 'default' => 'date_gmt', 'enum' => array( 'date', 'date_gmt', 'id', 'include', 'post', 'parent', 'type', ), ); $query_params['parent'] = array( 'default' => array(), 'description' => __( 'Limit result set to comments of specific parent IDs.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), ); $query_params['parent_exclude'] = array( 'default' => array(), 'description' => __( 'Ensure result set excludes specific parent IDs.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), ); $query_params['post'] = array( 'default' => array(), 'description' => __( 'Limit result set to comments assigned to specific post IDs.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), ); $query_params['status'] = array( 'default' => 'approve', 'description' => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg', ); $query_params['type'] = array( 'default' => 'comment', 'description' => __( 'Limit result set to comments assigned a specific type. Requires authorization.' ), 'sanitize_callback' => 'sanitize_key', 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg', ); $query_params['password'] = array( 'description' => __( 'The password for the post if it is password protected.' ), 'type' => 'string', ); return apply_filters( 'rest_comment_collection_params', $query_params ); } protected function handle_status_param( $new_status, $comment_id ) { $old_status = wp_get_comment_status( $comment_id ); if ( $new_status === $old_status ) { return false; } switch ( $new_status ) { case 'approved': case 'approve': case '1': $changed = wp_set_comment_status( $comment_id, 'approve' ); break; case 'hold': case '0': $changed = wp_set_comment_status( $comment_id, 'hold' ); break; case 'spam': $changed = wp_spam_comment( $comment_id ); break; case 'unspam': $changed = wp_unspam_comment( $comment_id ); break; case 'trash': $changed = wp_trash_comment( $comment_id ); break; case 'untrash': $changed = wp_untrash_comment( $comment_id ); break; default: $changed = false; break; } return $changed; } protected function check_read_post_permission( $post, $request ) { $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type ) { return false; } $posts_controller = $post_type->get_rest_controller(); if ( ! $posts_controller instanceof WP_REST_Posts_Controller ) { $posts_controller = new WP_REST_Posts_Controller( $post->post_type ); } $has_password_filter = false; $requested_post = ! empty( $request['post'] ) && ( ! is_array( $request['post'] ) || 1 === count( $request['post'] ) ); $requested_comment = ! empty( $request['id'] ); if ( ( $requested_post || $requested_comment ) && $posts_controller->can_access_password_content( $post, $request ) ) { add_filter( 'post_password_required', '__return_false' ); $has_password_filter = true; } if ( post_password_required( $post ) ) { $result = current_user_can( 'edit_post', $post->ID ); } else { $result = $posts_controller->check_read_permission( $post ); } if ( $has_password_filter ) { remove_filter( 'post_password_required', '__return_false' ); } return $result; } protected function check_read_permission( $comment, $request ) { if ( ! empty( $comment->comment_post_ID ) ) { $post = get_post( $comment->comment_post_ID ); if ( $post ) { if ( $this->check_read_post_permission( $post, $request ) && 1 === (int) $comment->comment_approved ) { return true; } } } if ( 0 === get_current_user_id() ) { return false; } if ( empty( $comment->comment_post_ID ) && ! current_user_can( 'moderate_comments' ) ) { return false; } if ( ! empty( $comment->user_id ) && get_current_user_id() === (int) $comment->user_id ) { return true; } return current_user_can( 'edit_comment', $comment->comment_ID ); } protected function check_edit_permission( $comment ) { if ( 0 === (int) get_current_user_id() ) { return false; } if ( current_user_can( 'moderate_comments' ) ) { return true; } return current_user_can( 'edit_comment', $comment->comment_ID ); } public function check_comment_author_email( $value, $request, $param ) { $email = (string) $value; if ( empty( $email ) ) { return $email; } $check_email = rest_validate_request_arg( $email, $request, $param ); if ( is_wp_error( $check_email ) ) { return $check_email; } return $email; } protected function check_is_comment_content_allowed( $prepared_comment ) { $check = wp_parse_args( $prepared_comment, array( 'comment_post_ID' => 0, 'comment_author' => null, 'comment_author_email' => null, 'comment_author_url' => null, 'comment_parent' => 0, 'user_id' => 0, ) ); $allow_empty = apply_filters( 'allow_empty_comment', false, $check ); if ( $allow_empty ) { return true; } return '' !== $check['comment_content']; } } <?php - abstract class WP_REST_Controller { protected $namespace; protected $rest_base; protected $schema; public function register_routes() { _doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), '4.7.0' ); } public function get_items_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_items( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function create_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function create_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function update_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function update_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function delete_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function delete_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } protected function prepare_item_for_database( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function prepare_item_for_response( $item, $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function prepare_response_for_collection( $response ) { if ( ! ( $response instanceof WP_REST_Response ) ) { return $response; } $data = (array) $response->get_data(); $server = rest_get_server(); $links = $server::get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } return $data; } public function filter_response_by_context( $data, $context ) { $schema = $this->get_item_schema(); return rest_filter_response_by_context( $data, $schema, $context ); } public function get_item_schema() { return $this->add_additional_fields_schema( array() ); } public function get_public_item_schema() { $schema = $this->get_item_schema(); if ( ! empty( $schema['properties'] ) ) { foreach ( $schema['properties'] as &$property ) { unset( $property['arg_options'] ); } } return $schema; } public function get_collection_params() { return array( 'context' => $this->get_context_param(), 'page' => array( 'description' => __( 'Current page of the collection.' ), 'type' => 'integer', 'default' => 1, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', 'minimum' => 1, ), 'per_page' => array( 'description' => __( 'Maximum number of items to be returned in result set.' ), 'type' => 'integer', 'default' => 10, 'minimum' => 1, 'maximum' => 100, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', ), 'search' => array( 'description' => __( 'Limit results to those matching a string.' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), ); } public function get_context_param( $args = array() ) { $param_details = array( 'description' => __( 'Scope under which the request is made; determines fields present in response.' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg', ); $schema = $this->get_item_schema(); if ( empty( $schema['properties'] ) ) { return array_merge( $param_details, $args ); } $contexts = array(); foreach ( $schema['properties'] as $attributes ) { if ( ! empty( $attributes['context'] ) ) { $contexts = array_merge( $contexts, $attributes['context'] ); } } if ( ! empty( $contexts ) ) { $param_details['enum'] = array_unique( $contexts ); rsort( $param_details['enum'] ); } return array_merge( $param_details, $args ); } protected function add_additional_fields_to_object( $prepared, $request ) { $additional_fields = $this->get_additional_fields(); $requested_fields = $this->get_fields_for_response( $request ); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['get_callback'] ) { continue; } if ( ! rest_is_field_included( $field_name, $requested_fields ) ) { continue; } $prepared[ $field_name ] = call_user_func( $field_options['get_callback'], $prepared, $field_name, $request, $this->get_object_type() ); } return $prepared; } protected function update_additional_fields_for_object( $data_object, $request ) { $additional_fields = $this->get_additional_fields(); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['update_callback'] ) { continue; } if ( ! isset( $request[ $field_name ] ) ) { continue; } $result = call_user_func( $field_options['update_callback'], $request[ $field_name ], $data_object, $field_name, $request, $this->get_object_type() ); if ( is_wp_error( $result ) ) { return $result; } } return true; } protected function add_additional_fields_schema( $schema ) { if ( empty( $schema['title'] ) ) { return $schema; } $object_type = $schema['title']; $additional_fields = $this->get_additional_fields( $object_type ); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['schema'] ) { continue; } $schema['properties'][ $field_name ] = $field_options['schema']; } return $schema; } protected function get_additional_fields( $object_type = null ) { global $wp_rest_additional_fields; if ( ! $object_type ) { $object_type = $this->get_object_type(); } if ( ! $object_type ) { return array(); } if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) { return array(); } return $wp_rest_additional_fields[ $object_type ]; } protected function get_object_type() { $schema = $this->get_item_schema(); if ( ! $schema || ! isset( $schema['title'] ) ) { return null; } return $schema['title']; } public function get_fields_for_response( $request ) { $schema = $this->get_item_schema(); $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); $additional_fields = $this->get_additional_fields(); foreach ( $additional_fields as $field_name => $field_options ) { if ( is_null( $field_options['schema'] ) ) { $properties[ $field_name ] = $field_options; } } $context = $request['context']; if ( $context ) { foreach ( $properties as $name => $options ) { if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { unset( $properties[ $name ] ); } } } $fields = array_keys( $properties ); $fields[] = '_links'; if ( $request->has_param( '_embed' ) ) { $fields[] = '_embedded'; } $fields = array_unique( $fields ); if ( ! isset( $request['_fields'] ) ) { return $fields; } $requested_fields = wp_parse_list( $request['_fields'] ); if ( 0 === count( $requested_fields ) ) { return $fields; } $requested_fields = array_map( 'trim', $requested_fields ); if ( in_array( 'id', $fields, true ) ) { $requested_fields[] = 'id'; } return array_reduce( $requested_fields, static function( $response_fields, $field ) use ( $fields ) { if ( in_array( $field, $fields, true ) ) { $response_fields[] = $field; return $response_fields; } $nested_fields = explode( '.', $field ); if ( in_array( $nested_fields[0], $fields, true ) ) { $response_fields[] = $field; } return $response_fields; }, array() ); } public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { return rest_get_endpoint_args_for_schema( $this->get_item_schema(), $method ); } public function sanitize_slug( $slug ) { return sanitize_title( $slug ); } } <?php + abstract class WP_REST_Controller { protected $namespace; protected $rest_base; protected $schema; public function register_routes() { _doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), '4.7.0' ); } public function get_items_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_items( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function get_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function create_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function create_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function update_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function update_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function delete_item_permissions_check( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function delete_item( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } protected function prepare_item_for_database( $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function prepare_item_for_response( $item, $request ) { return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); } public function prepare_response_for_collection( $response ) { if ( ! ( $response instanceof WP_REST_Response ) ) { return $response; } $data = (array) $response->get_data(); $server = rest_get_server(); $links = $server::get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } return $data; } public function filter_response_by_context( $response_data, $context ) { $schema = $this->get_item_schema(); return rest_filter_response_by_context( $response_data, $schema, $context ); } public function get_item_schema() { return $this->add_additional_fields_schema( array() ); } public function get_public_item_schema() { $schema = $this->get_item_schema(); if ( ! empty( $schema['properties'] ) ) { foreach ( $schema['properties'] as &$property ) { unset( $property['arg_options'] ); } } return $schema; } public function get_collection_params() { return array( 'context' => $this->get_context_param(), 'page' => array( 'description' => __( 'Current page of the collection.' ), 'type' => 'integer', 'default' => 1, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', 'minimum' => 1, ), 'per_page' => array( 'description' => __( 'Maximum number of items to be returned in result set.' ), 'type' => 'integer', 'default' => 10, 'minimum' => 1, 'maximum' => 100, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', ), 'search' => array( 'description' => __( 'Limit results to those matching a string.' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), ); } public function get_context_param( $args = array() ) { $param_details = array( 'description' => __( 'Scope under which the request is made; determines fields present in response.' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg', ); $schema = $this->get_item_schema(); if ( empty( $schema['properties'] ) ) { return array_merge( $param_details, $args ); } $contexts = array(); foreach ( $schema['properties'] as $attributes ) { if ( ! empty( $attributes['context'] ) ) { $contexts = array_merge( $contexts, $attributes['context'] ); } } if ( ! empty( $contexts ) ) { $param_details['enum'] = array_unique( $contexts ); rsort( $param_details['enum'] ); } return array_merge( $param_details, $args ); } protected function add_additional_fields_to_object( $response_data, $request ) { $additional_fields = $this->get_additional_fields(); $requested_fields = $this->get_fields_for_response( $request ); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['get_callback'] ) { continue; } if ( ! rest_is_field_included( $field_name, $requested_fields ) ) { continue; } $response_data[ $field_name ] = call_user_func( $field_options['get_callback'], $response_data, $field_name, $request, $this->get_object_type() ); } return $response_data; } protected function update_additional_fields_for_object( $data_object, $request ) { $additional_fields = $this->get_additional_fields(); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['update_callback'] ) { continue; } if ( ! isset( $request[ $field_name ] ) ) { continue; } $result = call_user_func( $field_options['update_callback'], $request[ $field_name ], $data_object, $field_name, $request, $this->get_object_type() ); if ( is_wp_error( $result ) ) { return $result; } } return true; } protected function add_additional_fields_schema( $schema ) { if ( empty( $schema['title'] ) ) { return $schema; } $object_type = $schema['title']; $additional_fields = $this->get_additional_fields( $object_type ); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['schema'] ) { continue; } $schema['properties'][ $field_name ] = $field_options['schema']; } return $schema; } protected function get_additional_fields( $object_type = null ) { global $wp_rest_additional_fields; if ( ! $object_type ) { $object_type = $this->get_object_type(); } if ( ! $object_type ) { return array(); } if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) { return array(); } return $wp_rest_additional_fields[ $object_type ]; } protected function get_object_type() { $schema = $this->get_item_schema(); if ( ! $schema || ! isset( $schema['title'] ) ) { return null; } return $schema['title']; } public function get_fields_for_response( $request ) { $schema = $this->get_item_schema(); $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); $additional_fields = $this->get_additional_fields(); foreach ( $additional_fields as $field_name => $field_options ) { if ( is_null( $field_options['schema'] ) ) { $properties[ $field_name ] = $field_options; } } $context = $request['context']; if ( $context ) { foreach ( $properties as $name => $options ) { if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { unset( $properties[ $name ] ); } } } $fields = array_keys( $properties ); $fields[] = '_links'; if ( $request->has_param( '_embed' ) ) { $fields[] = '_embedded'; } $fields = array_unique( $fields ); if ( ! isset( $request['_fields'] ) ) { return $fields; } $requested_fields = wp_parse_list( $request['_fields'] ); if ( 0 === count( $requested_fields ) ) { return $fields; } $requested_fields = array_map( 'trim', $requested_fields ); if ( in_array( 'id', $fields, true ) ) { $requested_fields[] = 'id'; } return array_reduce( $requested_fields, static function( $response_fields, $field ) use ( $fields ) { if ( in_array( $field, $fields, true ) ) { $response_fields[] = $field; return $response_fields; } $nested_fields = explode( '.', $field ); if ( in_array( $nested_fields[0], $fields, true ) ) { $response_fields[] = $field; } return $response_fields; }, array() ); } public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { return rest_get_endpoint_args_for_schema( $this->get_item_schema(), $method ); } public function sanitize_slug( $slug ) { return sanitize_title( $slug ); } } <?php class WP_REST_Edit_Site_Export_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp-block-editor/v1'; $this->rest_base = 'export'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'export' ), 'permission_callback' => array( $this, 'permissions_check' ), ), ) ); } public function permissions_check() { if ( current_user_can( 'edit_theme_options' ) ) { return true; } return new WP_Error( 'rest_cannot_export_templates', __( 'Sorry, you are not allowed to export templates and template parts.' ), array( 'status' => rest_authorization_required_code() ) ); } public function export() { $filename = wp_generate_block_templates_export_file(); if ( is_wp_error( $filename ) ) { $filename->add_data( array( 'status' => 500 ) ); return $filename; } $theme_name = basename( get_stylesheet() ); header( 'Content-Type: application/zip' ); header( 'Content-Disposition: attachment; filename=' . $theme_name . '.zip' ); header( 'Content-Length: ' . filesize( $filename ) ); flush(); readfile( $filename ); unlink( $filename ); exit; } } <?php class WP_REST_Global_Styles_Controller extends WP_REST_Controller { protected $post_type; public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'global-styles'; $this->post_type = 'wp_global_styles'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/themes/(?P<stylesheet>[\/\s%\w\.\(\)\[\]\@_\-]+)/variations', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_theme_items' ), 'permission_callback' => array( $this, 'get_theme_items_permissions_check' ), 'args' => array( 'stylesheet' => array( 'description' => __( 'The theme identifier' ), 'type' => 'string', ), ), ), ) ); register_rest_route( $this->namespace, sprintf( '/%s/themes/(?P<stylesheet>%s)', $this->rest_base, '[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?' ), array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_theme_item' ), 'permission_callback' => array( $this, 'get_theme_item_permissions_check' ), 'args' => array( 'stylesheet' => array( 'description' => __( 'The theme identifier' ), 'type' => 'string', 'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ), ), ), ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\/\w-]+)', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'id' => array( 'description' => __( 'The id of a template' ), 'type' => 'string', 'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ), ), ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_item' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function _sanitize_global_styles_callback( $id_or_stylesheet ) { return urldecode( $id_or_stylesheet ); } protected function get_post( $id ) { $error = new WP_Error( 'rest_global_styles_not_found', __( 'No global styles config exist with that id.' ), array( 'status' => 404 ) ); $id = (int) $id; if ( $id <= 0 ) { return $error; } $post = get_post( $id ); if ( empty( $post ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { return $error; } return $post; } public function get_item_permissions_check( $request ) { $post = $this->get_post( $request['id'] ); if ( is_wp_error( $post ) ) { return $post; } if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) { return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this global style.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( ! $this->check_read_permission( $post ) ) { return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view this global style.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } protected function check_read_permission( $post ) { return current_user_can( 'read_post', $post->ID ); } public function get_item( $request ) { $post = $this->get_post( $request['id'] ); if ( is_wp_error( $post ) ) { return $post; } return $this->prepare_item_for_response( $post, $request ); } public function update_item_permissions_check( $request ) { $post = $this->get_post( $request['id'] ); if ( is_wp_error( $post ) ) { return $post; } if ( $post && ! $this->check_update_permission( $post ) ) { return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this global style.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } protected function check_update_permission( $post ) { return current_user_can( 'edit_post', $post->ID ); } public function update_item( $request ) { $post_before = $this->get_post( $request['id'] ); if ( is_wp_error( $post_before ) ) { return $post_before; } $changes = $this->prepare_item_for_database( $request ); $result = wp_update_post( wp_slash( (array) $changes ), true, false ); if ( is_wp_error( $result ) ) { return $result; } $post = get_post( $request['id'] ); $fields_update = $this->update_additional_fields_for_object( $post, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } wp_after_insert_post( $post, true, $post_before ); $response = $this->prepare_item_for_response( $post, $request ); return rest_ensure_response( $response ); } protected function prepare_item_for_database( $request ) { $changes = new stdClass(); $changes->ID = $request['id']; $post = get_post( $request['id'] ); $existing_config = array(); if ( $post ) { $existing_config = json_decode( $post->post_content, true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE !== $json_decoding_error || ! isset( $existing_config['isGlobalStylesUserThemeJSON'] ) || ! $existing_config['isGlobalStylesUserThemeJSON'] ) { $existing_config = array(); } } if ( isset( $request['styles'] ) || isset( $request['settings'] ) ) { $config = array(); if ( isset( $request['styles'] ) ) { $config['styles'] = $request['styles']; } elseif ( isset( $existing_config['styles'] ) ) { $config['styles'] = $existing_config['styles']; } if ( isset( $request['settings'] ) ) { $config['settings'] = $request['settings']; } elseif ( isset( $existing_config['settings'] ) ) { $config['settings'] = $existing_config['settings']; } $config['isGlobalStylesUserThemeJSON'] = true; $config['version'] = WP_Theme_JSON::LATEST_SCHEMA; $changes->post_content = wp_json_encode( $config ); } if ( isset( $request['title'] ) ) { if ( is_string( $request['title'] ) ) { $changes->post_title = $request['title']; } elseif ( ! empty( $request['title']['raw'] ) ) { $changes->post_title = $request['title']['raw']; } } return $changes; } public function prepare_item_for_response( $post, $request ) { $raw_config = json_decode( $post->post_content, true ); $is_global_styles_user_theme_json = isset( $raw_config['isGlobalStylesUserThemeJSON'] ) && true === $raw_config['isGlobalStylesUserThemeJSON']; $config = array(); if ( $is_global_styles_user_theme_json ) { $config = ( new WP_Theme_JSON( $raw_config, 'custom' ) )->get_raw_data(); } $data = array(); $fields = $this->get_fields_for_response( $request ); if ( rest_is_field_included( 'id', $fields ) ) { $data['id'] = $post->ID; } if ( rest_is_field_included( 'title', $fields ) ) { $data['title'] = array(); } if ( rest_is_field_included( 'title.raw', $fields ) ) { $data['title']['raw'] = $post->post_title; } if ( rest_is_field_included( 'title.rendered', $fields ) ) { add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); $data['title']['rendered'] = get_the_title( $post->ID ); remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); } if ( rest_is_field_included( 'settings', $fields ) ) { $data['settings'] = ! empty( $config['settings'] ) && $is_global_styles_user_theme_json ? $config['settings'] : new stdClass(); } if ( rest_is_field_included( 'styles', $fields ) ) { $data['styles'] = ! empty( $config['styles'] ) && $is_global_styles_user_theme_json ? $config['styles'] : new stdClass(); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = $this->prepare_links( $post->ID ); $response->add_links( $links ); if ( ! empty( $links['self']['href'] ) ) { $actions = $this->get_available_actions(); $self = $links['self']['href']; foreach ( $actions as $rel ) { $response->add_link( $rel, $self ); } } } return $response; } protected function prepare_links( $id ) { $base = sprintf( '%s/%s', $this->namespace, $this->rest_base ); $links = array( 'self' => array( 'href' => rest_url( trailingslashit( $base ) . $id ), ), ); return $links; } protected function get_available_actions() { $rels = array(); $post_type = get_post_type_object( $this->post_type ); if ( current_user_can( $post_type->cap->publish_posts ) ) { $rels[] = 'https://api.w.org/action-publish'; } return $rels; } public function protected_title_format() { return '%s'; } public function get_collection_params() { return array(); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, 'type' => 'object', 'properties' => array( 'id' => array( 'description' => __( 'ID of global styles config.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'styles' => array( 'description' => __( 'Global styles.' ), 'type' => array( 'object' ), 'context' => array( 'view', 'edit' ), ), 'settings' => array( 'description' => __( 'Global settings.' ), 'type' => array( 'object' ), 'context' => array( 'view', 'edit' ), ), 'title' => array( 'description' => __( 'Title of the global styles variation.' ), 'type' => array( 'object', 'string' ), 'default' => '', 'context' => array( 'embed', 'view', 'edit' ), 'properties' => array( 'raw' => array( 'description' => __( 'Title for the global styles variation, as it exists in the database.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), ), 'rendered' => array( 'description' => __( 'HTML title for the post, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ), ), ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function get_theme_item_permissions_check( $request ) { if ( ! current_user_can( 'edit_theme_options' ) ) { return new WP_Error( 'rest_cannot_manage_global_styles', __( 'Sorry, you are not allowed to access the global styles on this site.' ), array( 'status' => rest_authorization_required_code(), ) ); } return true; } public function get_theme_item( $request ) { if ( get_stylesheet() !== $request['stylesheet'] ) { return new WP_Error( 'rest_theme_not_found', __( 'Theme not found.' ), array( 'status' => 404 ) ); } $theme = WP_Theme_JSON_Resolver::get_merged_data( 'theme' ); $data = array(); $fields = $this->get_fields_for_response( $request ); if ( rest_is_field_included( 'settings', $fields ) ) { $data['settings'] = $theme->get_settings(); } if ( rest_is_field_included( 'styles', $fields ) ) { $raw_data = $theme->get_raw_data(); $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array(); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = array( 'self' => array( 'href' => rest_url( sprintf( '%s/%s/themes/%s', $this->namespace, $this->rest_base, $request['stylesheet'] ) ), ), ); $response->add_links( $links ); } return $response; } public function get_theme_items_permissions_check( $request ) { if ( ! current_user_can( 'edit_theme_options' ) ) { return new WP_Error( 'rest_cannot_manage_global_styles', __( 'Sorry, you are not allowed to access the global styles on this site.' ), array( 'status' => rest_authorization_required_code(), ) ); } return true; } public function get_theme_items( $request ) { if ( get_stylesheet() !== $request['stylesheet'] ) { return new WP_Error( 'rest_theme_not_found', __( 'Theme not found.' ), array( 'status' => 404 ) ); } $variations = WP_Theme_JSON_Resolver::get_style_variations(); $response = rest_ensure_response( $variations ); return $response; } } <?php class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller { protected function get_nav_menu_item( $id ) { $post = $this->get_post( $id ); if ( is_wp_error( $post ) ) { return $post; } return wp_setup_nav_menu_item( $post ); } public function get_items_permissions_check( $request ) { $has_permission = parent::get_items_permissions_check( $request ); if ( true !== $has_permission ) { return $has_permission; } return $this->check_has_read_only_access( $request ); } public function get_item_permissions_check( $request ) { $permission_check = parent::get_item_permissions_check( $request ); if ( true !== $permission_check ) { return $permission_check; } return $this->check_has_read_only_access( $request ); } protected function check_has_read_only_access( $request ) { if ( current_user_can( 'edit_theme_options' ) ) { return true; } if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view menu items.' ), array( 'status' => rest_authorization_required_code() ) ); } public function create_item( $request ) { if ( ! empty( $request['id'] ) ) { return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) ); } $prepared_nav_item = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared_nav_item ) ) { return $prepared_nav_item; } $prepared_nav_item = (array) $prepared_nav_item; $nav_menu_item_id = wp_update_nav_menu_item( $prepared_nav_item['menu-id'], $prepared_nav_item['menu-item-db-id'], wp_slash( $prepared_nav_item ), false ); if ( is_wp_error( $nav_menu_item_id ) ) { if ( 'db_insert_error' === $nav_menu_item_id->get_error_code() ) { $nav_menu_item_id->add_data( array( 'status' => 500 ) ); } else { $nav_menu_item_id->add_data( array( 'status' => 400 ) ); } return $nav_menu_item_id; } $nav_menu_item = $this->get_nav_menu_item( $nav_menu_item_id ); if ( is_wp_error( $nav_menu_item ) ) { $nav_menu_item->add_data( array( 'status' => 404 ) ); return $nav_menu_item; } do_action( 'rest_insert_nav_menu_item', $nav_menu_item, $request, true ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $nav_menu_item_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $nav_menu_item = $this->get_nav_menu_item( $nav_menu_item_id ); $fields_update = $this->update_additional_fields_for_object( $nav_menu_item, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'edit' ); do_action( 'rest_after_insert_nav_menu_item', $nav_menu_item, $request, true ); $post = get_post( $nav_menu_item_id ); wp_after_insert_post( $post, false, null ); $response = $this->prepare_item_for_response( $post, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $nav_menu_item_id ) ) ); return $response; } public function update_item( $request ) { $valid_check = $this->get_nav_menu_item( $request['id'] ); if ( is_wp_error( $valid_check ) ) { return $valid_check; } $post_before = get_post( $request['id'] ); $prepared_nav_item = $this->prepare_item_for_database( $request ); if ( is_wp_error( $prepared_nav_item ) ) { return $prepared_nav_item; } $prepared_nav_item = (array) $prepared_nav_item; $nav_menu_item_id = wp_update_nav_menu_item( $prepared_nav_item['menu-id'], $prepared_nav_item['menu-item-db-id'], wp_slash( $prepared_nav_item ), false ); if ( is_wp_error( $nav_menu_item_id ) ) { if ( 'db_update_error' === $nav_menu_item_id->get_error_code() ) { $nav_menu_item_id->add_data( array( 'status' => 500 ) ); } else { $nav_menu_item_id->add_data( array( 'status' => 400 ) ); } return $nav_menu_item_id; } $nav_menu_item = $this->get_nav_menu_item( $nav_menu_item_id ); if ( is_wp_error( $nav_menu_item ) ) { $nav_menu_item->add_data( array( 'status' => 404 ) ); return $nav_menu_item; } do_action( 'rest_insert_nav_menu_item', $nav_menu_item, $request, false ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $nav_menu_item->ID ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $post = get_post( $nav_menu_item_id ); $nav_menu_item = $this->get_nav_menu_item( $nav_menu_item_id ); $fields_update = $this->update_additional_fields_for_object( $nav_menu_item, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'edit' ); do_action( 'rest_after_insert_nav_menu_item', $nav_menu_item, $request, false ); wp_after_insert_post( $post, true, $post_before ); $response = $this->prepare_item_for_response( get_post( $nav_menu_item_id ), $request ); return rest_ensure_response( $response ); } public function delete_item( $request ) { $menu_item = $this->get_nav_menu_item( $request['id'] ); if ( is_wp_error( $menu_item ) ) { return $menu_item; } if ( ! $request['force'] ) { return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Menu items do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); } $previous = $this->prepare_item_for_response( get_post( $request['id'] ), $request ); $result = wp_delete_post( $request['id'], true ); if ( ! $result ) { return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) ); } $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); do_action( 'rest_delete_nav_menu_item', $menu_item, $response, $request ); return $response; } protected function prepare_item_for_database( $request ) { $menu_item_db_id = $request['id']; $menu_item_obj = $this->get_nav_menu_item( $menu_item_db_id ); if ( ! is_wp_error( $menu_item_obj ) ) { $position = ( 0 === $menu_item_obj->menu_order ) ? 1 : $menu_item_obj->menu_order; $prepared_nav_item = array( 'menu-item-db-id' => $menu_item_db_id, 'menu-item-object-id' => $menu_item_obj->object_id, 'menu-item-object' => $menu_item_obj->object, 'menu-item-parent-id' => $menu_item_obj->menu_item_parent, 'menu-item-position' => $position, 'menu-item-type' => $menu_item_obj->type, 'menu-item-title' => $menu_item_obj->title, 'menu-item-url' => $menu_item_obj->url, 'menu-item-description' => $menu_item_obj->description, 'menu-item-attr-title' => $menu_item_obj->attr_title, 'menu-item-target' => $menu_item_obj->target, 'menu-item-classes' => $menu_item_obj->classes, 'menu-item-xfn' => explode( ' ', $menu_item_obj->xfn ), 'menu-item-status' => $menu_item_obj->post_status, 'menu-id' => $this->get_menu_id( $menu_item_db_id ), ); } else { $prepared_nav_item = array( 'menu-id' => 0, 'menu-item-db-id' => 0, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 1, 'menu-item-type' => 'custom', 'menu-item-title' => '', 'menu-item-url' => '', 'menu-item-description' => '', 'menu-item-attr-title' => '', 'menu-item-target' => '', 'menu-item-classes' => array(), 'menu-item-xfn' => array(), 'menu-item-status' => 'publish', ); } $mapping = array( 'menu-item-db-id' => 'id', 'menu-item-object-id' => 'object_id', 'menu-item-object' => 'object', 'menu-item-parent-id' => 'parent', 'menu-item-position' => 'menu_order', 'menu-item-type' => 'type', 'menu-item-url' => 'url', 'menu-item-description' => 'description', 'menu-item-attr-title' => 'attr_title', 'menu-item-target' => 'target', 'menu-item-classes' => 'classes', 'menu-item-xfn' => 'xfn', 'menu-item-status' => 'status', ); $schema = $this->get_item_schema(); foreach ( $mapping as $original => $api_request ) { if ( isset( $request[ $api_request ] ) ) { $prepared_nav_item[ $original ] = $request[ $api_request ]; } } $taxonomy = get_taxonomy( 'nav_menu' ); $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; if ( ! empty( $request[ $base ] ) ) { $prepared_nav_item['menu-id'] = absint( $request[ $base ] ); } if ( ! empty( $schema['properties']['title'] ) && isset( $request['title'] ) ) { if ( is_string( $request['title'] ) ) { $prepared_nav_item['menu-item-title'] = $request['title']; } elseif ( ! empty( $request['title']['raw'] ) ) { $prepared_nav_item['menu-item-title'] = $request['title']['raw']; } } $error = new WP_Error(); if ( ! $prepared_nav_item['menu-item-object'] ) { if ( 'taxonomy' === $prepared_nav_item['menu-item-type'] ) { $original = get_term( absint( $prepared_nav_item['menu-item-object-id'] ) ); if ( empty( $original ) || is_wp_error( $original ) ) { $error->add( 'rest_term_invalid_id', __( 'Invalid term ID.' ), array( 'status' => 400 ) ); } else { $prepared_nav_item['menu-item-object'] = get_term_field( 'taxonomy', $original ); } } elseif ( 'post_type' === $prepared_nav_item['menu-item-type'] ) { $original = get_post( absint( $prepared_nav_item['menu-item-object-id'] ) ); if ( empty( $original ) ) { $error->add( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 400 ) ); } else { $prepared_nav_item['menu-item-object'] = get_post_type( $original ); } } } if ( 'post_type_archive' === $prepared_nav_item['menu-item-type'] ) { $post_type = $prepared_nav_item['menu-item-object'] ? $prepared_nav_item['menu-item-object'] : false; $original = get_post_type_object( $post_type ); if ( ! $original ) { $error->add( 'rest_post_invalid_type', __( 'Invalid post type.' ), array( 'status' => 400 ) ); } } if ( 'custom' === $prepared_nav_item['menu-item-type'] ) { if ( '' === $prepared_nav_item['menu-item-title'] ) { $error->add( 'rest_title_required', __( 'The title is required when using a custom menu item type.' ), array( 'status' => 400 ) ); } if ( empty( $prepared_nav_item['menu-item-url'] ) ) { $error->add( 'rest_url_required', __( 'The url is required when using a custom menu item type.' ), array( 'status' => 400 ) ); } } if ( $error->has_errors() ) { return $error; } foreach ( array( 'menu-item-xfn', 'menu-item-classes' ) as $key ) { $prepared_nav_item[ $key ] = implode( ' ', $prepared_nav_item[ $key ] ); } if ( 'publish' !== $prepared_nav_item['menu-item-status'] ) { $prepared_nav_item['menu-item-status'] = 'draft'; } $prepared_nav_item = (object) $prepared_nav_item; return apply_filters( 'rest_pre_insert_nav_menu_item', $prepared_nav_item, $request ); } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $menu_item = $this->get_nav_menu_item( $item->ID ); $data = array(); if ( rest_is_field_included( 'id', $fields ) ) { $data['id'] = $menu_item->ID; } if ( rest_is_field_included( 'title', $fields ) ) { $data['title'] = array(); } if ( rest_is_field_included( 'title.raw', $fields ) ) { $data['title']['raw'] = $menu_item->title; } if ( rest_is_field_included( 'title.rendered', $fields ) ) { add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID ); $data['title']['rendered'] = $title; remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); } if ( rest_is_field_included( 'status', $fields ) ) { $data['status'] = $menu_item->post_status; } if ( rest_is_field_included( 'url', $fields ) ) { $data['url'] = $menu_item->url; } if ( rest_is_field_included( 'attr_title', $fields ) ) { $data['attr_title'] = $menu_item->attr_title; } if ( rest_is_field_included( 'description', $fields ) ) { $data['description'] = $menu_item->description; } if ( rest_is_field_included( 'type', $fields ) ) { $data['type'] = $menu_item->type; } if ( rest_is_field_included( 'type_label', $fields ) ) { $data['type_label'] = $menu_item->type_label; } if ( rest_is_field_included( 'object', $fields ) ) { $data['object'] = $menu_item->object; } if ( rest_is_field_included( 'object_id', $fields ) ) { $data['object_id'] = absint( $menu_item->object_id ); } if ( rest_is_field_included( 'parent', $fields ) ) { $data['parent'] = (int) $menu_item->menu_item_parent; } if ( rest_is_field_included( 'menu_order', $fields ) ) { $data['menu_order'] = (int) $menu_item->menu_order; } if ( rest_is_field_included( 'target', $fields ) ) { $data['target'] = $menu_item->target; } if ( rest_is_field_included( 'classes', $fields ) ) { $data['classes'] = (array) $menu_item->classes; } if ( rest_is_field_included( 'xfn', $fields ) ) { $data['xfn'] = array_map( 'sanitize_html_class', explode( ' ', $menu_item->xfn ) ); } if ( rest_is_field_included( 'invalid', $fields ) ) { $data['invalid'] = (bool) $menu_item->_invalid; } if ( rest_is_field_included( 'meta', $fields ) ) { $data['meta'] = $this->meta->get_value( $menu_item->ID, $request ); } $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); foreach ( $taxonomies as $taxonomy ) { $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; if ( rest_is_field_included( $base, $fields ) ) { $terms = get_the_terms( $item, $taxonomy->name ); if ( ! is_array( $terms ) ) { continue; } $term_ids = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array(); if ( 'nav_menu' === $taxonomy->name ) { $data[ $base ] = $term_ids ? array_shift( $term_ids ) : 0; } else { $data[ $base ] = $term_ids; } } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = $this->prepare_links( $item ); $response->add_links( $links ); if ( ! empty( $links['self']['href'] ) ) { $actions = $this->get_available_actions( $item, $request ); $self = $links['self']['href']; foreach ( $actions as $rel ) { $response->add_link( $rel, $self ); } } } return apply_filters( 'rest_prepare_nav_menu_item', $response, $menu_item, $request ); } protected function prepare_links( $post ) { $links = parent::prepare_links( $post ); $menu_item = $this->get_nav_menu_item( $post->ID ); if ( empty( $menu_item->object_id ) ) { return $links; } $path = ''; $type = ''; $key = $menu_item->type; if ( 'post_type' === $menu_item->type ) { $path = rest_get_route_for_post( $menu_item->object_id ); $type = get_post_type( $menu_item->object_id ); } elseif ( 'taxonomy' === $menu_item->type ) { $path = rest_get_route_for_term( $menu_item->object_id ); $type = get_term_field( 'taxonomy', $menu_item->object_id ); } if ( $path && $type ) { $links['https://api.w.org/menu-item-object'][] = array( 'href' => rest_url( $path ), $key => $type, 'embeddable' => true, ); } return $links; } protected function get_schema_links() { $links = parent::get_schema_links(); $href = rest_url( "{$this->namespace}/{$this->rest_base}/{id}" ); $links[] = array( 'rel' => 'https://api.w.org/menu-item-object', 'title' => __( 'Get linked object.' ), 'href' => $href, 'targetSchema' => array( 'type' => 'object', 'properties' => array( 'object' => array( 'type' => 'integer', ), ), ), ); return $links; } public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, 'type' => 'object', ); $schema['properties']['title'] = array( 'description' => __( 'The title for the object.' ), 'type' => array( 'string', 'object' ), 'context' => array( 'view', 'edit', 'embed' ), 'properties' => array( 'raw' => array( 'description' => __( 'Title for the object, as it exists in the database.' ), 'type' => 'string', 'context' => array( 'edit' ), ), 'rendered' => array( 'description' => __( 'HTML title for the object, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ); $schema['properties']['id'] = array( 'description' => __( 'Unique identifier for the object.' ), 'type' => 'integer', 'default' => 0, 'minimum' => 0, 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['type_label'] = array( 'description' => __( 'The singular label used to describe this type of menu item.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ); $schema['properties']['type'] = array( 'description' => __( 'The family of objects originally represented, such as "post_type" or "taxonomy".' ), 'type' => 'string', 'enum' => array( 'taxonomy', 'post_type', 'post_type_archive', 'custom' ), 'context' => array( 'view', 'edit', 'embed' ), 'default' => 'custom', ); $schema['properties']['status'] = array( 'description' => __( 'A named status for the object.' ), 'type' => 'string', 'enum' => array_keys( get_post_stati( array( 'internal' => false ) ) ), 'default' => 'publish', 'context' => array( 'view', 'edit', 'embed' ), ); $schema['properties']['parent'] = array( 'description' => __( 'The ID for the parent of the object.' ), 'type' => 'integer', 'minimum' => 0, 'default' => 0, 'context' => array( 'view', 'edit', 'embed' ), ); $schema['properties']['attr_title'] = array( 'description' => __( 'Text for the title attribute of the link element for this menu item.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ); $schema['properties']['classes'] = array( 'description' => __( 'Class names for the link element of this menu item.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => function ( $value ) { return array_map( 'sanitize_html_class', wp_parse_list( $value ) ); }, ), ); $schema['properties']['description'] = array( 'description' => __( 'The description of this menu item.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ); $schema['properties']['menu_order'] = array( 'description' => __( 'The DB ID of the nav_menu_item that is this item\'s menu parent, if any, otherwise 0.' ), 'context' => array( 'view', 'edit', 'embed' ), 'type' => 'integer', 'minimum' => 1, 'default' => 1, ); $schema['properties']['object'] = array( 'description' => __( 'The type of object originally represented, such as "category", "post", or "attachment".' ), 'context' => array( 'view', 'edit', 'embed' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_key', ), ); $schema['properties']['object_id'] = array( 'description' => __( 'The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories.' ), 'context' => array( 'view', 'edit', 'embed' ), 'type' => 'integer', 'minimum' => 0, 'default' => 0, ); $schema['properties']['target'] = array( 'description' => __( 'The target attribute of the link element for this menu item.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'enum' => array( '_blank', '', ), ); $schema['properties']['url'] = array( 'description' => __( 'The URL to which this menu item points.' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'validate_callback' => static function ( $url ) { if ( '' === $url ) { return true; } if ( sanitize_url( $url ) ) { return true; } return new WP_Error( 'rest_invalid_url', __( 'Invalid URL.' ) ); }, ), ); $schema['properties']['xfn'] = array( 'description' => __( 'The XFN relationship expressed in the link of this menu item.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( 'sanitize_callback' => function ( $value ) { return array_map( 'sanitize_html_class', wp_parse_list( $value ) ); }, ), ); $schema['properties']['invalid'] = array( 'description' => __( 'Whether the menu item represents an object that no longer exists.' ), 'context' => array( 'view', 'edit', 'embed' ), 'type' => 'boolean', 'readonly' => true, ); $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); foreach ( $taxonomies as $taxonomy ) { $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; $schema['properties'][ $base ] = array( 'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), 'context' => array( 'view', 'edit' ), ); if ( 'nav_menu' === $taxonomy->name ) { $schema['properties'][ $base ]['type'] = 'integer'; unset( $schema['properties'][ $base ]['items'] ); } } $schema['properties']['meta'] = $this->meta->get_field_schema(); $schema_links = $this->get_schema_links(); if ( $schema_links ) { $schema['links'] = $schema_links; } return $this->add_additional_fields_schema( $schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['menu_order'] = array( 'description' => __( 'Limit result set to posts with a specific menu_order value.' ), 'type' => 'integer', ); $query_params['order'] = array( 'description' => __( 'Order sort attribute ascending or descending.' ), 'type' => 'string', 'default' => 'asc', 'enum' => array( 'asc', 'desc' ), ); $query_params['orderby'] = array( 'description' => __( 'Sort collection by object attribute.' ), 'type' => 'string', 'default' => 'menu_order', 'enum' => array( 'author', 'date', 'id', 'include', 'modified', 'parent', 'relevance', 'slug', 'include_slugs', 'title', 'menu_order', ), ); $query_params['per_page']['default'] = 100; return $query_params; } protected function prepare_items_query( $prepared_args = array(), $request = null ) { $query_args = parent::prepare_items_query( $prepared_args, $request ); if ( isset( $query_args['orderby'], $request['orderby'] ) ) { $orderby_mappings = array( 'id' => 'ID', 'include' => 'post__in', 'slug' => 'post_name', 'include_slugs' => 'post_name__in', 'menu_order' => 'menu_order', ); if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) { $query_args['orderby'] = $orderby_mappings[ $request['orderby'] ]; } } $query_args['update_menu_item_cache'] = true; return $query_args; } protected function get_menu_id( $menu_item_id ) { $menu_ids = wp_get_post_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) ); $menu_id = 0; if ( $menu_ids && ! is_wp_error( $menu_ids ) ) { $menu_id = array_shift( $menu_ids ); } return $menu_id; } } <?php class WP_REST_Menu_Locations_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'menu-locations'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<location>[\w-]+)', array( 'args' => array( 'location' => array( 'description' => __( 'An alphanumeric identifier for the menu location.' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( ! current_user_can( 'edit_theme_options' ) ) { return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view menu locations.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { $data = array(); foreach ( get_registered_nav_menus() as $name => $description ) { $location = new stdClass(); $location->name = $name; $location->description = $description; $location = $this->prepare_item_for_response( $location, $request ); $data[ $name ] = $this->prepare_response_for_collection( $location ); } return rest_ensure_response( $data ); } public function get_item_permissions_check( $request ) { if ( ! current_user_can( 'edit_theme_options' ) ) { return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view menu locations.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_item( $request ) { $registered_menus = get_registered_nav_menus(); if ( ! array_key_exists( $request['location'], $registered_menus ) ) { return new WP_Error( 'rest_menu_location_invalid', __( 'Invalid menu location.' ), array( 'status' => 404 ) ); } $location = new stdClass(); $location->name = $request['location']; $location->description = $registered_menus[ $location->name ]; $data = $this->prepare_item_for_response( $location, $request ); return rest_ensure_response( $data ); } public function prepare_item_for_response( $item, $request ) { $location = $item; $locations = get_nav_menu_locations(); $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'name', $fields ) ) { $data['name'] = $location->name; } if ( rest_is_field_included( 'description', $fields ) ) { $data['description'] = $location->description; } if ( rest_is_field_included( 'menu', $fields ) ) { $data['menu'] = (int) $menu; } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $location ) ); } return apply_filters( 'rest_prepare_menu_location', $response, $location, $request ); } protected function prepare_links( $location ) { $base = sprintf( '%s/%s', $this->namespace, $this->rest_base ); $links = array( 'self' => array( 'href' => rest_url( trailingslashit( $base ) . $location->name ), ), 'collection' => array( 'href' => rest_url( $base ), ), ); $locations = get_nav_menu_locations(); $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; if ( $menu ) { $path = rest_get_route_for_term( $menu ); if ( $path ) { $url = rest_url( $path ); $links['https://api.w.org/menu'][] = array( 'href' => $url, 'embeddable' => true, ); } } return $links; } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'menu-location', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The name of the menu location.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'description' => array( 'description' => __( 'The description of the menu location.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'menu' => array( 'description' => __( 'The ID of the assigned menu.' ), 'type' => 'integer', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), ), ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } } <?php class WP_REST_Menus_Controller extends WP_REST_Terms_Controller { public function get_items_permissions_check( $request ) { $has_permission = parent::get_items_permissions_check( $request ); if ( true !== $has_permission ) { return $has_permission; } return $this->check_has_read_only_access( $request ); } public function get_item_permissions_check( $request ) { $has_permission = parent::get_item_permissions_check( $request ); if ( true !== $has_permission ) { return $has_permission; } return $this->check_has_read_only_access( $request ); } protected function get_term( $id ) { $term = parent::get_term( $id ); if ( is_wp_error( $term ) ) { return $term; } $nav_term = wp_get_nav_menu_object( $term ); $nav_term->auto_add = $this->get_menu_auto_add( $nav_term->term_id ); return $nav_term; } protected function check_has_read_only_access( $request ) { if ( current_user_can( 'edit_theme_options' ) ) { return true; } if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to view menus.' ), array( 'status' => rest_authorization_required_code() ) ); } public function prepare_item_for_response( $term, $request ) { $nav_menu = wp_get_nav_menu_object( $term ); $response = parent::prepare_item_for_response( $nav_menu, $request ); $fields = $this->get_fields_for_response( $request ); $data = $response->get_data(); if ( rest_is_field_included( 'locations', $fields ) ) { $data['locations'] = $this->get_menu_locations( $nav_menu->term_id ); } if ( rest_is_field_included( 'auto_add', $fields ) ) { $data['auto_add'] = $this->get_menu_auto_add( $nav_menu->term_id ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $term ) ); } return apply_filters( "rest_prepare_{$this->taxonomy}", $response, $term, $request ); } protected function prepare_links( $term ) { $links = parent::prepare_links( $term ); $locations = $this->get_menu_locations( $term->term_id ); foreach ( $locations as $location ) { $url = rest_url( sprintf( 'wp/v2/menu-locations/%s', $location ) ); $links['https://api.w.org/menu-location'][] = array( 'href' => $url, 'embeddable' => true, ); } return $links; } public function prepare_item_for_database( $request ) { $prepared_term = parent::prepare_item_for_database( $request ); $schema = $this->get_item_schema(); if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) { $prepared_term->{'menu-name'} = $request['name']; } return $prepared_term; } public function create_item( $request ) { if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); } $parent = wp_get_nav_menu_object( (int) $request['parent'] ); if ( ! $parent ) { return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); } } $prepared_term = $this->prepare_item_for_database( $request ); $term = wp_update_nav_menu_object( 0, wp_slash( (array) $prepared_term ) ); if ( is_wp_error( $term ) ) { if ( in_array( 'menu_exists', $term->get_error_codes(), true ) ) { $existing_term = get_term_by( 'name', $prepared_term->{'menu-name'}, $this->taxonomy ); $term->add_data( $existing_term->term_id, 'menu_exists' ); $term->add_data( array( 'status' => 400, 'term_id' => $existing_term->term_id, ) ); } else { $term->add_data( array( 'status' => 400 ) ); } return $term; } $term = $this->get_term( $term ); do_action( "rest_insert_{$this->taxonomy}", $term, $request, true ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $term->term_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $locations_update = $this->handle_locations( $term->term_id, $request ); if ( is_wp_error( $locations_update ) ) { return $locations_update; } $this->handle_auto_add( $term->term_id, $request ); $fields_update = $this->update_additional_fields_for_object( $term, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'view' ); do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, true ); $response = $this->prepare_item_for_response( $term, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); $response->header( 'Location', rest_url( $this->namespace . '/' . $this->rest_base . '/' . $term->term_id ) ); return $response; } public function update_item( $request ) { $term = $this->get_term( $request['id'] ); if ( is_wp_error( $term ) ) { return $term; } if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); } $parent = get_term( (int) $request['parent'], $this->taxonomy ); if ( ! $parent ) { return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); } } $prepared_term = $this->prepare_item_for_database( $request ); if ( ! empty( $prepared_term ) ) { if ( ! isset( $prepared_term->{'menu-name'} ) ) { $prepared_term->{'menu-name'} = $term->name; } $update = wp_update_nav_menu_object( $term->term_id, wp_slash( (array) $prepared_term ) ); if ( is_wp_error( $update ) ) { return $update; } } $term = get_term( $term->term_id, $this->taxonomy ); do_action( "rest_insert_{$this->taxonomy}", $term, $request, false ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $term->term_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $locations_update = $this->handle_locations( $term->term_id, $request ); if ( is_wp_error( $locations_update ) ) { return $locations_update; } $this->handle_auto_add( $term->term_id, $request ); $fields_update = $this->update_additional_fields_for_object( $term, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'view' ); do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, false ); $response = $this->prepare_item_for_response( $term, $request ); return rest_ensure_response( $response ); } public function delete_item( $request ) { $term = $this->get_term( $request['id'] ); if ( is_wp_error( $term ) ) { return $term; } if ( ! $request['force'] ) { return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Menus do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); } $request->set_param( 'context', 'view' ); $previous = $this->prepare_item_for_response( $term, $request ); $result = wp_delete_nav_menu( $term ); if ( ! $result || is_wp_error( $result ) ) { return new WP_Error( 'rest_cannot_delete', __( 'The menu cannot be deleted.' ), array( 'status' => 500 ) ); } $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); do_action( "rest_delete_{$this->taxonomy}", $term, $response, $request ); return $response; } protected function get_menu_auto_add( $menu_id ) { $nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); return in_array( $menu_id, $nav_menu_option['auto_add'], true ); } protected function handle_auto_add( $menu_id, $request ) { if ( ! isset( $request['auto_add'] ) ) { return true; } $nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); if ( ! isset( $nav_menu_option['auto_add'] ) ) { $nav_menu_option['auto_add'] = array(); } $auto_add = $request['auto_add']; $i = array_search( $menu_id, $nav_menu_option['auto_add'], true ); if ( $auto_add && false === $i ) { $nav_menu_option['auto_add'][] = $menu_id; } elseif ( ! $auto_add && false !== $i ) { array_splice( $nav_menu_option['auto_add'], $i, 1 ); } $update = update_option( 'nav_menu_options', $nav_menu_option ); do_action( 'wp_update_nav_menu', $menu_id ); return $update; } protected function get_menu_locations( $menu_id ) { $locations = get_nav_menu_locations(); $menu_locations = array(); foreach ( $locations as $location => $assigned_menu_id ) { if ( $menu_id === $assigned_menu_id ) { $menu_locations[] = $location; } } return $menu_locations; } protected function handle_locations( $menu_id, $request ) { if ( ! isset( $request['locations'] ) ) { return true; } $menu_locations = get_registered_nav_menus(); $menu_locations = array_keys( $menu_locations ); $new_locations = array(); foreach ( $request['locations'] as $location ) { if ( ! in_array( $location, $menu_locations, true ) ) { return new WP_Error( 'rest_invalid_menu_location', __( 'Invalid menu location.' ), array( 'status' => 400, 'location' => $location, ) ); } $new_locations[ $location ] = $menu_id; } $assigned_menu = get_nav_menu_locations(); foreach ( $assigned_menu as $location => $term_id ) { if ( $term_id === $menu_id ) { unset( $assigned_menu[ $location ] ); } } $new_assignments = array_merge( $assigned_menu, $new_locations ); set_theme_mod( 'nav_menu_locations', $new_assignments ); return true; } public function get_item_schema() { $schema = parent::get_item_schema(); unset( $schema['properties']['count'], $schema['properties']['link'], $schema['properties']['taxonomy'] ); $schema['properties']['locations'] = array( 'description' => __( 'The locations assigned to the menu.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'validate_callback' => function ( $locations, $request, $param ) { $valid = rest_validate_request_arg( $locations, $request, $param ); if ( true !== $valid ) { return $valid; } $locations = rest_sanitize_request_arg( $locations, $request, $param ); foreach ( $locations as $location ) { if ( ! array_key_exists( $location, get_registered_nav_menus() ) ) { return new WP_Error( 'rest_invalid_menu_location', __( 'Invalid menu location.' ), array( 'location' => $location, ) ); } } return true; }, ), ); $schema['properties']['auto_add'] = array( 'description' => __( 'Whether to automatically add top level pages to this menu.' ), 'context' => array( 'view', 'edit' ), 'type' => 'boolean', ); return $schema; } } <?php - class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'pattern-directory'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/patterns', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_pattern_directory_cannot_view', __( 'Sorry, you are not allowed to browse the local block pattern directory.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { require ABSPATH . WPINC . '/version.php'; $query_args = array( 'locale' => get_user_locale(), 'wp-version' => $wp_version, ); $category_id = $request['category']; $keyword_id = $request['keyword']; $search_term = $request['search']; $slug = $request['slug']; if ( $category_id ) { $query_args['pattern-categories'] = $category_id; } if ( $keyword_id ) { $query_args['pattern-keywords'] = $keyword_id; } if ( $search_term ) { $query_args['search'] = $search_term; } if ( $slug ) { $query_args['slug'] = $slug; } $transient_key = $this->get_transient_key( $query_args ); $raw_patterns = get_site_transient( $transient_key ); if ( ! $raw_patterns ) { $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args ); if ( wp_http_supports( array( 'ssl' ) ) ) { $api_url = set_url_scheme( $api_url, 'https' ); } $cache_ttl = 5; $wporg_response = wp_remote_get( $api_url ); $raw_patterns = json_decode( wp_remote_retrieve_body( $wporg_response ) ); if ( is_wp_error( $wporg_response ) ) { $raw_patterns = $wporg_response; } elseif ( ! is_array( $raw_patterns ) ) { $raw_patterns = new WP_Error( 'pattern_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ), array( 'response' => wp_remote_retrieve_body( $wporg_response ), ) ); } else { $cache_ttl = HOUR_IN_SECONDS; } set_site_transient( $transient_key, $raw_patterns, $cache_ttl ); } if ( is_wp_error( $raw_patterns ) ) { $raw_patterns->add_data( array( 'status' => 500 ) ); return $raw_patterns; } $response = array(); if ( $raw_patterns ) { foreach ( $raw_patterns as $pattern ) { $response[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $pattern, $request ) ); } } return new WP_REST_Response( $response ); } public function prepare_item_for_response( $item, $request ) { $raw_pattern = $item; $prepared_pattern = array( 'id' => absint( $raw_pattern->id ), 'title' => sanitize_text_field( $raw_pattern->title->rendered ), 'content' => wp_kses_post( $raw_pattern->pattern_content ), 'categories' => array_map( 'sanitize_title', $raw_pattern->category_slugs ), 'keywords' => array_map( 'sanitize_text_field', explode( ',', $raw_pattern->meta->wpop_keywords ) ), 'description' => sanitize_text_field( $raw_pattern->meta->wpop_description ), 'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ), ); $prepared_pattern = $this->add_additional_fields_to_object( $prepared_pattern, $request ); $response = new WP_REST_Response( $prepared_pattern ); return apply_filters( 'rest_prepare_block_pattern', $response, $raw_pattern, $request ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'pattern-directory-item', 'type' => 'object', 'properties' => array( 'id' => array( 'description' => __( 'The pattern ID.' ), 'type' => 'integer', 'minimum' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'title' => array( 'description' => __( 'The pattern title, in human readable format.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'content' => array( 'description' => __( 'The pattern content.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'categories' => array( 'description' => __( "The pattern's category slugs." ), 'type' => 'array', 'uniqueItems' => true, 'items' => array( 'type' => 'string' ), 'context' => array( 'view', 'edit', 'embed' ), ), 'keywords' => array( 'description' => __( "The pattern's keywords." ), 'type' => 'array', 'uniqueItems' => true, 'items' => array( 'type' => 'string' ), 'context' => array( 'view', 'edit', 'embed' ), ), 'description' => array( 'description' => __( 'A description of the pattern.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'viewport_width' => array( 'description' => __( 'The preferred width of the viewport when previewing a pattern, in pixels.' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); unset( $query_params['page'] ); unset( $query_params['per_page'] ); $query_params['search']['minLength'] = 1; $query_params['context']['default'] = 'view'; $query_params['category'] = array( 'description' => __( 'Limit results to those matching a category ID.' ), 'type' => 'integer', 'minimum' => 1, ); $query_params['keyword'] = array( 'description' => __( 'Limit results to those matching a keyword ID.' ), 'type' => 'integer', 'minimum' => 1, ); $query_params['slug'] = array( 'description' => __( 'Limit results to those matching a pattern (slug).' ), 'type' => 'array', ); return apply_filters( 'rest_pattern_directory_collection_params', $query_params ); } protected function get_transient_key( $query_args ) { if ( isset( $query_args['slug'] ) ) { $query_args['slug'] = wp_parse_list( $query_args['slug'] ); if ( empty( $query_args['slug'] ) ) { unset( $query_args['slug'] ); } else { sort( $query_args['slug'] ); } } return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) ); } } <?php + class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'pattern-directory'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/patterns', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( current_user_can( 'edit_posts' ) ) { return true; } foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_pattern_directory_cannot_view', __( 'Sorry, you are not allowed to browse the local block pattern directory.' ), array( 'status' => rest_authorization_required_code() ) ); } public function get_items( $request ) { require ABSPATH . WPINC . '/version.php'; $valid_query_args = array( 'offset' => true, 'order' => true, 'orderby' => true, 'page' => true, 'per_page' => true, 'search' => true, 'slug' => true, ); $query_args = array_intersect_key( $request->get_params(), $valid_query_args ); $query_args['locale'] = get_user_locale(); $query_args['wp-version'] = $wp_version; $query_args['pattern-categories'] = isset( $request['category'] ) ? $request['category'] : false; $query_args['pattern-keywords'] = isset( $request['keyword'] ) ? $request['keyword'] : false; $query_args = array_filter( $query_args ); $transient_key = $this->get_transient_key( $query_args ); $raw_patterns = get_site_transient( $transient_key ); if ( ! $raw_patterns ) { $api_url = 'http://api.wordpress.org/patterns/1.0/?' . build_query( $query_args ); if ( wp_http_supports( array( 'ssl' ) ) ) { $api_url = set_url_scheme( $api_url, 'https' ); } $cache_ttl = 5; $wporg_response = wp_remote_get( $api_url ); $raw_patterns = json_decode( wp_remote_retrieve_body( $wporg_response ) ); if ( is_wp_error( $wporg_response ) ) { $raw_patterns = $wporg_response; } elseif ( ! is_array( $raw_patterns ) ) { $raw_patterns = new WP_Error( 'pattern_api_failed', sprintf( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ), array( 'response' => wp_remote_retrieve_body( $wporg_response ), ) ); } else { $cache_ttl = HOUR_IN_SECONDS; } set_site_transient( $transient_key, $raw_patterns, $cache_ttl ); } if ( is_wp_error( $raw_patterns ) ) { $raw_patterns->add_data( array( 'status' => 500 ) ); return $raw_patterns; } $response = array(); if ( $raw_patterns ) { foreach ( $raw_patterns as $pattern ) { $response[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $pattern, $request ) ); } } return new WP_REST_Response( $response ); } public function prepare_item_for_response( $item, $request ) { $raw_pattern = $item; $prepared_pattern = array( 'id' => absint( $raw_pattern->id ), 'title' => sanitize_text_field( $raw_pattern->title->rendered ), 'content' => wp_kses_post( $raw_pattern->pattern_content ), 'categories' => array_map( 'sanitize_title', $raw_pattern->category_slugs ), 'keywords' => array_map( 'sanitize_text_field', explode( ',', $raw_pattern->meta->wpop_keywords ) ), 'description' => sanitize_text_field( $raw_pattern->meta->wpop_description ), 'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ), ); $prepared_pattern = $this->add_additional_fields_to_object( $prepared_pattern, $request ); $response = new WP_REST_Response( $prepared_pattern ); return apply_filters( 'rest_prepare_block_pattern', $response, $raw_pattern, $request ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'pattern-directory-item', 'type' => 'object', 'properties' => array( 'id' => array( 'description' => __( 'The pattern ID.' ), 'type' => 'integer', 'minimum' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'title' => array( 'description' => __( 'The pattern title, in human readable format.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'content' => array( 'description' => __( 'The pattern content.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'categories' => array( 'description' => __( "The pattern's category slugs." ), 'type' => 'array', 'uniqueItems' => true, 'items' => array( 'type' => 'string' ), 'context' => array( 'view', 'edit', 'embed' ), ), 'keywords' => array( 'description' => __( "The pattern's keywords." ), 'type' => 'array', 'uniqueItems' => true, 'items' => array( 'type' => 'string' ), 'context' => array( 'view', 'edit', 'embed' ), ), 'description' => array( 'description' => __( 'A description of the pattern.' ), 'type' => 'string', 'minLength' => 1, 'context' => array( 'view', 'edit', 'embed' ), ), 'viewport_width' => array( 'description' => __( 'The preferred width of the viewport when previewing a pattern, in pixels.' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), ), ), ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['per_page']['default'] = 100; $query_params['search']['minLength'] = 1; $query_params['context']['default'] = 'view'; $query_params['category'] = array( 'description' => __( 'Limit results to those matching a category ID.' ), 'type' => 'integer', 'minimum' => 1, ); $query_params['keyword'] = array( 'description' => __( 'Limit results to those matching a keyword ID.' ), 'type' => 'integer', 'minimum' => 1, ); $query_params['slug'] = array( 'description' => __( 'Limit results to those matching a pattern (slug).' ), 'type' => 'array', ); $query_params['offset'] = array( 'description' => __( 'Offset the result set by a specific number of items.' ), 'type' => 'integer', ); $query_params['order'] = array( 'description' => __( 'Order sort attribute ascending or descending.' ), 'type' => 'string', 'default' => 'desc', 'enum' => array( 'asc', 'desc' ), ); $query_params['orderby'] = array( 'description' => __( 'Sort collection by post attribute.' ), 'type' => 'string', 'default' => 'date', 'enum' => array( 'author', 'date', 'id', 'include', 'modified', 'parent', 'relevance', 'slug', 'include_slugs', 'title', 'favorite_count', ), ); return apply_filters( 'rest_pattern_directory_collection_params', $query_params ); } protected function get_transient_key( $query_args ) { if ( isset( $query_args['slug'] ) ) { $query_args['slug'] = wp_parse_list( $query_args['slug'] ); if ( empty( $query_args['slug'] ) ) { unset( $query_args['slug'] ); } else { sort( $query_args['slug'] ); } } return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) ); } } <?php class WP_REST_Plugins_Controller extends WP_REST_Controller { const PATTERN = '[^.\/]+(?:\/[^.\/]+)?'; public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'plugins'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => array( 'slug' => array( 'type' => 'string', 'required' => true, 'description' => __( 'WordPress.org plugin directory slug.' ), 'pattern' => '[\w\-]+', ), 'status' => array( 'description' => __( 'The plugin activation status.' ), 'type' => 'string', 'enum' => is_multisite() ? array( 'inactive', 'active', 'network-active' ) : array( 'inactive', 'active' ), 'default' => 'inactive', ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<plugin>' . self::PATTERN . ')', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_item' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ), 'permission_callback' => array( $this, 'delete_item_permissions_check' ), ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'plugin' => array( 'type' => 'string', 'pattern' => self::PATTERN, 'validate_callback' => array( $this, 'validate_plugin_param' ), 'sanitize_callback' => array( $this, 'sanitize_plugin_param' ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_cannot_view_plugins', __( 'Sorry, you are not allowed to manage plugins for this site.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugins = array(); foreach ( get_plugins() as $file => $data ) { if ( is_wp_error( $this->check_read_permission( $file ) ) ) { continue; } $data['_file'] = $file; if ( ! $this->does_plugin_match_request( $request, $data ) ) { continue; } $plugins[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $data, $request ) ); } return new WP_REST_Response( $plugins ); } public function get_item_permissions_check( $request ) { if ( ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_cannot_view_plugin', __( 'Sorry, you are not allowed to manage plugins for this site.' ), array( 'status' => rest_authorization_required_code() ) ); } $can_read = $this->check_read_permission( $request['plugin'] ); if ( is_wp_error( $can_read ) ) { return $can_read; } return true; } public function get_item( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $data = $this->get_plugin_data( $request['plugin'] ); if ( is_wp_error( $data ) ) { return $data; } return $this->prepare_item_for_response( $data, $request ); } protected function check_read_permission( $plugin ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( ! $this->is_plugin_installed( $plugin ) ) { return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) ); } if ( ! is_multisite() ) { return true; } if ( ! is_network_only_plugin( $plugin ) || is_plugin_active( $plugin ) || current_user_can( 'manage_network_plugins' ) ) { return true; } return new WP_Error( 'rest_cannot_view_plugin', __( 'Sorry, you are not allowed to manage this plugin.' ), array( 'status' => rest_authorization_required_code() ) ); } public function create_item_permissions_check( $request ) { if ( ! current_user_can( 'install_plugins' ) ) { return new WP_Error( 'rest_cannot_install_plugin', __( 'Sorry, you are not allowed to install plugins on this site.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( 'inactive' !== $request['status'] && ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_cannot_activate_plugin', __( 'Sorry, you are not allowed to activate plugins.' ), array( 'status' => rest_authorization_required_code(), ) ); } return true; } public function create_item( $request ) { global $wp_filesystem; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $slug = $request['slug']; $filesystem_available = $this->is_filesystem_available(); if ( is_wp_error( $filesystem_available ) ) { return $filesystem_available; } $api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false, 'language_packs' => true, ), ) ); if ( is_wp_error( $api ) ) { if ( false !== strpos( $api->get_error_message(), 'Plugin not found.' ) ) { $api->add_data( array( 'status' => 404 ) ); } else { $api->add_data( array( 'status' => 500 ) ); } return $api; } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( is_wp_error( $result ) ) { $result->add_data( array( 'status' => 500 ) ); return $result; } if ( is_wp_error( $skin->result ) ) { $skin->result->add_data( array( 'status' => 500 ) ); return $skin->result; } if ( $skin->get_errors()->has_errors() ) { $error = $skin->get_errors(); $error->add_data( array( 'status' => 500 ) ); return $error; } if ( is_null( $result ) ) { if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { return new WP_Error( 'unable_to_connect_to_filesystem', $wp_filesystem->errors->get_error_message(), array( 'status' => 500 ) ); } return new WP_Error( 'unable_to_connect_to_filesystem', __( 'Unable to connect to the filesystem. Please confirm your credentials.' ), array( 'status' => 500 ) ); } $file = $upgrader->plugin_info(); if ( ! $file ) { return new WP_Error( 'unable_to_determine_installed_plugin', __( 'Unable to determine what plugin was installed.' ), array( 'status' => 500 ) ); } if ( 'inactive' !== $request['status'] ) { $can_change_status = $this->plugin_status_permission_check( $file, $request['status'], 'inactive' ); if ( is_wp_error( $can_change_status ) ) { return $can_change_status; } $changed_status = $this->handle_plugin_status( $file, $request['status'], 'inactive' ); if ( is_wp_error( $changed_status ) ) { return $changed_status; } } $installed_locales = array_values( get_available_languages() ); $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); $language_packs = array_map( static function( $item ) { return (object) $item; }, $api->language_packs ); $language_packs = array_filter( $language_packs, static function( $pack ) use ( $installed_locales ) { return in_array( $pack->language, $installed_locales, true ); } ); if ( $language_packs ) { $lp_upgrader = new Language_Pack_Upgrader( $skin ); $lp_upgrader->bulk_upgrade( $language_packs ); } $path = WP_PLUGIN_DIR . '/' . $file; $data = get_plugin_data( $path, false, false ); $data['_file'] = $file; $response = $this->prepare_item_for_response( $data, $request ); $response->set_status( 201 ); $response->header( 'Location', rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, substr( $file, 0, - 4 ) ) ) ); return $response; } public function update_item_permissions_check( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_cannot_manage_plugins', __( 'Sorry, you are not allowed to manage plugins for this site.' ), array( 'status' => rest_authorization_required_code() ) ); } $can_read = $this->check_read_permission( $request['plugin'] ); if ( is_wp_error( $can_read ) ) { return $can_read; } $status = $this->get_plugin_status( $request['plugin'] ); if ( $request['status'] && $status !== $request['status'] ) { $can_change_status = $this->plugin_status_permission_check( $request['plugin'], $request['status'], $status ); if ( is_wp_error( $can_change_status ) ) { return $can_change_status; } } return true; } public function update_item( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $data = $this->get_plugin_data( $request['plugin'] ); if ( is_wp_error( $data ) ) { return $data; } $status = $this->get_plugin_status( $request['plugin'] ); if ( $request['status'] && $status !== $request['status'] ) { $handled = $this->handle_plugin_status( $request['plugin'], $request['status'], $status ); if ( is_wp_error( $handled ) ) { return $handled; } } $this->update_additional_fields_for_object( $data, $request ); $request['context'] = 'edit'; return $this->prepare_item_for_response( $data, $request ); } public function delete_item_permissions_check( $request ) { if ( ! current_user_can( 'activate_plugins' ) ) { return new WP_Error( 'rest_cannot_manage_plugins', __( 'Sorry, you are not allowed to manage plugins for this site.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( ! current_user_can( 'delete_plugins' ) ) { return new WP_Error( 'rest_cannot_manage_plugins', __( 'Sorry, you are not allowed to delete plugins for this site.' ), array( 'status' => rest_authorization_required_code() ) ); } $can_read = $this->check_read_permission( $request['plugin'] ); if ( is_wp_error( $can_read ) ) { return $can_read; } return true; } public function delete_item( $request ) { require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php'; $data = $this->get_plugin_data( $request['plugin'] ); if ( is_wp_error( $data ) ) { return $data; } if ( is_plugin_active( $request['plugin'] ) ) { return new WP_Error( 'rest_cannot_delete_active_plugin', __( 'Cannot delete an active plugin. Please deactivate it first.' ), array( 'status' => 400 ) ); } $filesystem_available = $this->is_filesystem_available(); if ( is_wp_error( $filesystem_available ) ) { return $filesystem_available; } $prepared = $this->prepare_item_for_response( $data, $request ); $deleted = delete_plugins( array( $request['plugin'] ) ); if ( is_wp_error( $deleted ) ) { $deleted->add_data( array( 'status' => 500 ) ); return $deleted; } return new WP_REST_Response( array( 'deleted' => true, 'previous' => $prepared->get_data(), ) ); } public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $item = _get_plugin_data_markup_translate( $item['_file'], $item, false ); $marked = _get_plugin_data_markup_translate( $item['_file'], $item, true ); $data = array( 'plugin' => substr( $item['_file'], 0, - 4 ), 'status' => $this->get_plugin_status( $item['_file'] ), 'name' => $item['Name'], 'plugin_uri' => $item['PluginURI'], 'author' => $item['Author'], 'author_uri' => $item['AuthorURI'], 'description' => array( 'raw' => $item['Description'], 'rendered' => $marked['Description'], ), 'version' => $item['Version'], 'network_only' => $item['Network'], 'requires_wp' => $item['RequiresWP'], 'requires_php' => $item['RequiresPHP'], 'textdomain' => $item['TextDomain'], ); $data = $this->add_additional_fields_to_object( $data, $request ); $response = new WP_REST_Response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $item ) ); } return apply_filters( 'rest_prepare_plugin', $response, $item, $request ); } protected function prepare_links( $item ) { return array( 'self' => array( 'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, substr( $item['_file'], 0, - 4 ) ) ), ), ); } protected function get_plugin_data( $plugin ) { $plugins = get_plugins(); if ( ! isset( $plugins[ $plugin ] ) ) { return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) ); } $data = $plugins[ $plugin ]; $data['_file'] = $plugin; return $data; } protected function get_plugin_status( $plugin ) { if ( is_plugin_active_for_network( $plugin ) ) { return 'network-active'; } if ( is_plugin_active( $plugin ) ) { return 'active'; } return 'inactive'; } protected function plugin_status_permission_check( $plugin, $new_status, $current_status ) { if ( is_multisite() && ( 'network-active' === $current_status || 'network-active' === $new_status ) && ! current_user_can( 'manage_network_plugins' ) ) { return new WP_Error( 'rest_cannot_manage_network_plugins', __( 'Sorry, you are not allowed to manage network plugins.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( ( 'active' === $new_status || 'network-active' === $new_status ) && ! current_user_can( 'activate_plugin', $plugin ) ) { return new WP_Error( 'rest_cannot_activate_plugin', __( 'Sorry, you are not allowed to activate this plugin.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( 'inactive' === $new_status && ! current_user_can( 'deactivate_plugin', $plugin ) ) { return new WP_Error( 'rest_cannot_deactivate_plugin', __( 'Sorry, you are not allowed to deactivate this plugin.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } protected function handle_plugin_status( $plugin, $new_status, $current_status ) { if ( 'inactive' === $new_status ) { deactivate_plugins( $plugin, false, 'network-active' === $current_status ); return true; } if ( 'active' === $new_status && 'network-active' === $current_status ) { return true; } $network_activate = 'network-active' === $new_status; if ( is_multisite() && ! $network_activate && is_network_only_plugin( $plugin ) ) { return new WP_Error( 'rest_network_only_plugin', __( 'Network only plugin must be network activated.' ), array( 'status' => 400 ) ); } $activated = activate_plugin( $plugin, '', $network_activate ); if ( is_wp_error( $activated ) ) { $activated->add_data( array( 'status' => 500 ) ); return $activated; } return true; } public function validate_plugin_param( $file ) { if ( ! is_string( $file ) || ! preg_match( '/' . self::PATTERN . '/u', $file ) ) { return false; } $validated = validate_file( plugin_basename( $file ) ); return 0 === $validated; } public function sanitize_plugin_param( $file ) { return plugin_basename( sanitize_text_field( $file . '.php' ) ); } protected function does_plugin_match_request( $request, $item ) { $search = $request['search']; if ( $search ) { $matched_search = false; foreach ( $item as $field ) { if ( is_string( $field ) && false !== strpos( strip_tags( $field ), $search ) ) { $matched_search = true; break; } } if ( ! $matched_search ) { return false; } } $status = $request['status']; if ( $status && ! in_array( $this->get_plugin_status( $item['_file'] ), $status, true ) ) { return false; } return true; } protected function is_plugin_installed( $plugin ) { return file_exists( WP_PLUGIN_DIR . '/' . $plugin ); } protected function is_filesystem_available() { $filesystem_method = get_filesystem_method(); if ( 'direct' === $filesystem_method ) { return true; } ob_start(); $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); ob_end_clean(); if ( $filesystem_credentials_are_stored ) { return true; } return new WP_Error( 'fs_unavailable', __( 'The filesystem is currently unavailable for managing plugins.' ), array( 'status' => 500 ) ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'plugin', 'type' => 'object', 'properties' => array( 'plugin' => array( 'description' => __( 'The plugin file.' ), 'type' => 'string', 'pattern' => self::PATTERN, 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'status' => array( 'description' => __( 'The plugin activation status.' ), 'type' => 'string', 'enum' => is_multisite() ? array( 'inactive', 'active', 'network-active' ) : array( 'inactive', 'active' ), 'context' => array( 'view', 'edit', 'embed' ), ), 'name' => array( 'description' => __( 'The plugin name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'plugin_uri' => array( 'description' => __( 'The plugin\'s website address.' ), 'type' => 'string', 'format' => 'uri', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), 'author' => array( 'description' => __( 'The plugin author.' ), 'type' => 'object', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), 'author_uri' => array( 'description' => __( 'Plugin author\'s website address.' ), 'type' => 'string', 'format' => 'uri', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), 'description' => array( 'description' => __( 'The plugin description.' ), 'type' => 'object', 'readonly' => true, 'context' => array( 'view', 'edit' ), 'properties' => array( 'raw' => array( 'description' => __( 'The raw plugin description.' ), 'type' => 'string', ), 'rendered' => array( 'description' => __( 'The plugin description formatted for display.' ), 'type' => 'string', ), ), ), 'version' => array( 'description' => __( 'The plugin version number.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), 'network_only' => array( 'description' => __( 'Whether the plugin can only be activated network-wide.' ), 'type' => 'boolean', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'requires_wp' => array( 'description' => __( 'Minimum required version of WordPress.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'requires_php' => array( 'description' => __( 'Minimum required version of PHP.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), 'textdomain' => array( 'description' => __( 'The plugin\'s text domain.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), ), ); return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['context']['default'] = 'view'; $query_params['status'] = array( 'description' => __( 'Limits results to plugins with the given status.' ), 'type' => 'array', 'items' => array( 'type' => 'string', 'enum' => is_multisite() ? array( 'inactive', 'active', 'network-active' ) : array( 'inactive', 'active' ), ), ); unset( $query_params['page'], $query_params['per_page'] ); return $query_params; } } <?php class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'statuses'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array( 'args' => array( 'status' => array( 'description' => __( 'An alphanumeric identifier for the status.' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( 'edit' === $request['context'] ) { $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); foreach ( $types as $type ) { if ( current_user_can( $type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage post statuses.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { $data = array(); $statuses = get_post_stati( array( 'internal' => false ), 'object' ); $statuses['trash'] = get_post_status_object( 'trash' ); foreach ( $statuses as $slug => $obj ) { $ret = $this->check_read_permission( $obj ); if ( ! $ret ) { continue; } $status = $this->prepare_item_for_response( $obj, $request ); $data[ $obj->name ] = $this->prepare_response_for_collection( $status ); } return rest_ensure_response( $data ); } public function get_item_permissions_check( $request ) { $status = get_post_status_object( $request['status'] ); if ( empty( $status ) ) { return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); } $check = $this->check_read_permission( $status ); if ( ! $check ) { return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } protected function check_read_permission( $status ) { if ( true === $status->public ) { return true; } if ( false === $status->internal || 'trash' === $status->name ) { $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); foreach ( $types as $type ) { if ( current_user_can( $type->cap->edit_posts ) ) { return true; } } } return false; } public function get_item( $request ) { $obj = get_post_status_object( $request['status'] ); if ( empty( $obj ) ) { return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); } $data = $this->prepare_item_for_response( $obj, $request ); return rest_ensure_response( $data ); } public function prepare_item_for_response( $item, $request ) { $status = $item; $fields = $this->get_fields_for_response( $request ); $data = array(); if ( in_array( 'name', $fields, true ) ) { $data['name'] = $status->label; } if ( in_array( 'private', $fields, true ) ) { $data['private'] = (bool) $status->private; } if ( in_array( 'protected', $fields, true ) ) { $data['protected'] = (bool) $status->protected; } if ( in_array( 'public', $fields, true ) ) { $data['public'] = (bool) $status->public; } if ( in_array( 'queryable', $fields, true ) ) { $data['queryable'] = (bool) $status->publicly_queryable; } if ( in_array( 'show_in_list', $fields, true ) ) { $data['show_in_list'] = (bool) $status->show_in_admin_all_list; } if ( in_array( 'slug', $fields, true ) ) { $data['slug'] = $status->name; } if ( in_array( 'date_floating', $fields, true ) ) { $data['date_floating'] = $status->date_floating; } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $rest_url = rest_url( rest_get_route_for_post_type_items( 'post' ) ); if ( 'publish' === $status->name ) { $response->add_link( 'archives', $rest_url ); } else { $response->add_link( 'archives', add_query_arg( 'status', $status->name, $rest_url ) ); } return apply_filters( 'rest_prepare_status', $response, $status, $request ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'status', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The title for the status.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'private' => array( 'description' => __( 'Whether posts with this status should be private.' ), 'type' => 'boolean', 'context' => array( 'edit' ), 'readonly' => true, ), 'protected' => array( 'description' => __( 'Whether posts with this status should be protected.' ), 'type' => 'boolean', 'context' => array( 'edit' ), 'readonly' => true, ), 'public' => array( 'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'queryable' => array( 'description' => __( 'Whether posts with this status should be publicly-queryable.' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'show_in_list' => array( 'description' => __( 'Whether to include posts in the edit listing for their post type.' ), 'type' => 'boolean', 'context' => array( 'edit' ), 'readonly' => true, ), 'slug' => array( 'description' => __( 'An alphanumeric identifier for the status.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'date_floating' => array( 'description' => __( 'Whether posts of this status may have floating published dates.' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), ), ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } } <?php class WP_REST_Post_Types_Controller extends WP_REST_Controller { public function __construct() { $this->namespace = 'wp/v2'; $this->rest_base = 'types'; } public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => $this->get_collection_params(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<type>[\w-]+)', array( 'args' => array( 'type' => array( 'description' => __( 'An alphanumeric identifier for the post type.' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => '__return_true', 'args' => array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } public function get_items_permissions_check( $request ) { if ( 'edit' === $request['context'] ) { $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); foreach ( $types as $type ) { if ( current_user_can( $type->cap->edit_posts ) ) { return true; } } return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } public function get_items( $request ) { $data = array(); $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); foreach ( $types as $type ) { if ( 'edit' === $request['context'] && ! current_user_can( $type->cap->edit_posts ) ) { continue; } $post_type = $this->prepare_item_for_response( $type, $request ); $data[ $type->name ] = $this->prepare_response_for_collection( $post_type ); } return rest_ensure_response( $data ); } public function get_item( $request ) { $obj = get_post_type_object( $request['type'] ); if ( empty( $obj ) ) { return new WP_Error( 'rest_type_invalid', __( 'Invalid post type.' ), array( 'status' => 404 ) ); } if ( empty( $obj->show_in_rest ) ) { return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) ); } if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) { return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); } $data = $this->prepare_item_for_response( $obj, $request ); return rest_ensure_response( $data ); } public function prepare_item_for_response( $item, $request ) { $post_type = $item; $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) ); $taxonomies = wp_list_pluck( $taxonomies, 'name' ); $base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name; $namespace = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2'; $supports = get_all_post_type_supports( $post_type->name ); $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'capabilities', $fields ) ) { $data['capabilities'] = $post_type->cap; } if ( rest_is_field_included( 'description', $fields ) ) { $data['description'] = $post_type->description; } if ( rest_is_field_included( 'hierarchical', $fields ) ) { $data['hierarchical'] = $post_type->hierarchical; } if ( rest_is_field_included( 'has_archive', $fields ) ) { $data['has_archive'] = $post_type->has_archive; } if ( rest_is_field_included( 'visibility', $fields ) ) { $data['visibility'] = array( 'show_in_nav_menus' => (bool) $post_type->show_in_nav_menus, 'show_ui' => (bool) $post_type->show_ui, ); } if ( rest_is_field_included( 'viewable', $fields ) ) { $data['viewable'] = is_post_type_viewable( $post_type ); } if ( rest_is_field_included( 'labels', $fields ) ) { $data['labels'] = $post_type->labels; } if ( rest_is_field_included( 'name', $fields ) ) { $data['name'] = $post_type->label; } if ( rest_is_field_included( 'slug', $fields ) ) { $data['slug'] = $post_type->name; } if ( rest_is_field_included( 'icon', $fields ) ) { $data['icon'] = $post_type->menu_icon; } if ( rest_is_field_included( 'supports', $fields ) ) { $data['supports'] = $supports; } if ( rest_is_field_included( 'taxonomies', $fields ) ) { $data['taxonomies'] = array_values( $taxonomies ); } if ( rest_is_field_included( 'rest_base', $fields ) ) { $data['rest_base'] = $base; } if ( rest_is_field_included( 'rest_namespace', $fields ) ) { $data['rest_namespace'] = $namespace; } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $response->add_links( $this->prepare_links( $post_type ) ); } return apply_filters( 'rest_prepare_post_type', $response, $post_type, $request ); } protected function prepare_links( $post_type ) { return array( 'collection' => array( 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), ), 'https://api.w.org/items' => array( 'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ), ), ); } public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'type', 'type' => 'object', 'properties' => array( 'capabilities' => array( 'description' => __( 'All capabilities used by the post type.' ), 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, ), 'description' => array( 'description' => __( 'A human-readable description of the post type.' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'hierarchical' => array( 'description' => __( 'Whether or not the post type should have children.' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'viewable' => array( 'description' => __( 'Whether or not the post type can be viewed.' ), 'type' => 'boolean', 'context' => array( 'edit' ), 'readonly' => true, ), 'labels' => array( 'description' => __( 'Human-readable labels for the post type for various contexts.' ), 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, ), 'name' => array( 'description' => __( 'The title for the post type.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'slug' => array( 'description' => __( 'An alphanumeric identifier for the post type.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'supports' => array( 'description' => __( 'All features, supported by the post type.' ), 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, ), 'has_archive' => array( 'description' => __( 'If the value is a string, the value will be used as the archive slug. If the value is false the post type has no archive.' ), 'type' => array( 'string', 'boolean' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'taxonomies' => array( 'description' => __( 'Taxonomies associated with post type.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'rest_base' => array( 'description' => __( 'REST base route for the post type.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'rest_namespace' => array( 'description' => __( 'REST route\'s namespace for the post type.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'visibility' => array( 'description' => __( 'The visibility settings for the post type.' ), 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, 'properties' => array( 'show_ui' => array( 'description' => __( 'Whether to generate a default UI for managing this post type.' ), 'type' => 'boolean', ), 'show_in_nav_menus' => array( 'description' => __( 'Whether to make the post type available for selection in navigation menus.' ), 'type' => 'boolean', ), ), ), 'icon' => array( 'description' => __( 'The icon for the post type.' ), 'type' => array( 'string', 'null' ), 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), ), ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } } <?php @@ -31737,7 +34424,7 @@ All at ###SITENAME### function wp_robots() { $robots = apply_filters( 'wp_robots', array() ); $robots_strings = array(); foreach ( $robots as $directive => $value ) { if ( is_string( $value ) ) { $robots_strings[] = "{$directive}:{$value}"; } elseif ( $value ) { $robots_strings[] = $directive; } } if ( empty( $robots_strings ) ) { return; } echo "<meta name='robots' content='" . esc_attr( implode( ', ', $robots_strings ) ) . "' />\n"; } function wp_robots_noindex( array $robots ) { if ( ! get_option( 'blog_public' ) ) { return wp_robots_no_robots( $robots ); } return $robots; } function wp_robots_noindex_embeds( array $robots ) { if ( is_embed() ) { return wp_robots_no_robots( $robots ); } return $robots; } function wp_robots_noindex_search( array $robots ) { if ( is_search() ) { return wp_robots_no_robots( $robots ); } return $robots; } function wp_robots_no_robots( array $robots ) { $robots['noindex'] = true; if ( get_option( 'blog_public' ) ) { $robots['follow'] = true; } else { $robots['nofollow'] = true; } return $robots; } function wp_robots_sensitive_page( array $robots ) { $robots['noindex'] = true; $robots['noarchive'] = true; return $robots; } function wp_robots_max_image_preview_large( array $robots ) { if ( get_option( 'blog_public' ) ) { $robots['max-image-preview'] = 'large'; } return $robots; } <?php if ( ! defined( 'ABSPATH' ) ) { exit(); } _deprecated_file( basename( __FILE__ ), '2.1.0', WPINC . '/rss.php' ); require_once ABSPATH . WPINC . '/rss.php'; <?php _deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/class-simplepie.php' ); do_action( 'load_feed_engine' ); define('RSS', 'RSS'); define('ATOM', 'Atom'); define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']); class MagpieRSS { var $parser; var $current_item = array(); var $items = array(); var $channel = array(); var $textinput = array(); var $image = array(); var $feed_type; var $feed_version; var $stack = array(); var $inchannel = false; var $initem = false; var $incontent = false; var $intextinput = false; var $inimage = false; var $current_field = ''; var $current_namespace = false; var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); function __construct( $source ) { if ( ! function_exists('xml_parser_create') ) { return trigger_error( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ); } $parser = xml_parser_create(); $this->parser = $parser; xml_set_object( $this->parser, $this ); xml_set_element_handler($this->parser, 'feed_start_element', 'feed_end_element' ); xml_set_character_data_handler( $this->parser, 'feed_cdata' ); $status = xml_parse( $this->parser, $source ); if (! $status ) { $errorcode = xml_get_error_code( $this->parser ); if ( $errorcode != XML_ERROR_NONE ) { $xml_error = xml_error_string( $errorcode ); $error_line = xml_get_current_line_number($this->parser); $error_col = xml_get_current_column_number($this->parser); $errormsg = "$xml_error at line $error_line, column $error_col"; $this->error( $errormsg ); } } xml_parser_free( $this->parser ); unset( $this->parser ); $this->normalize(); } public function MagpieRSS( $source ) { self::__construct( $source ); } function feed_start_element($p, $element, &$attrs) { $el = $element = strtolower($element); $attrs = array_change_key_case($attrs, CASE_LOWER); $ns = false; if ( strpos( $element, ':' ) ) { list($ns, $el) = explode( ':', $element, 2); } if ( $ns and $ns != 'rdf' ) { $this->current_namespace = $ns; } if (!isset($this->feed_type) ) { if ( $el == 'rdf' ) { $this->feed_type = RSS; $this->feed_version = '1.0'; } elseif ( $el == 'rss' ) { $this->feed_type = RSS; $this->feed_version = $attrs['version']; } elseif ( $el == 'feed' ) { $this->feed_type = ATOM; $this->feed_version = $attrs['version']; $this->inchannel = true; } return; } if ( $el == 'channel' ) { $this->inchannel = true; } elseif ($el == 'item' or $el == 'entry' ) { $this->initem = true; if ( isset($attrs['rdf:about']) ) { $this->current_item['about'] = $attrs['rdf:about']; } } elseif ( $this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) { $this->intextinput = true; } elseif ( $this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) { $this->inimage = true; } elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { if ($el == 'content' ) { $el = 'atom_content'; } $this->incontent = $el; } elseif ($this->feed_type == ATOM and $this->incontent ) { $attrs_str = join(' ', array_map(array('MagpieRSS', 'map_attrs'), array_keys($attrs), array_values($attrs) ) ); $this->append_content( "<$element $attrs_str>" ); array_unshift( $this->stack, $el ); } elseif ($this->feed_type == ATOM and $el == 'link' ) { if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) { $link_el = 'link'; } else { $link_el = 'link_' . $attrs['rel']; } $this->append($link_el, $attrs['href']); } else { array_unshift($this->stack, $el); } } function feed_cdata ($p, $text) { if ($this->feed_type == ATOM and $this->incontent) { $this->append_content( $text ); } else { $current_el = join('_', array_reverse($this->stack)); $this->append($current_el, $text); } } function feed_end_element ($p, $el) { $el = strtolower($el); if ( $el == 'item' or $el == 'entry' ) { $this->items[] = $this->current_item; $this->current_item = array(); $this->initem = false; } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) { $this->intextinput = false; } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) { $this->inimage = false; } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { $this->incontent = false; } elseif ($el == 'channel' or $el == 'feed' ) { $this->inchannel = false; } elseif ($this->feed_type == ATOM and $this->incontent ) { if ( $this->stack[0] == $el ) { $this->append_content("</$el>"); } else { $this->append_content("<$el />"); } array_shift( $this->stack ); } else { array_shift( $this->stack ); } $this->current_namespace = false; } function concat (&$str1, $str2="") { if (!isset($str1) ) { $str1=""; } $str1 .= $str2; } function append_content($text) { if ( $this->initem ) { $this->concat( $this->current_item[ $this->incontent ], $text ); } elseif ( $this->inchannel ) { $this->concat( $this->channel[ $this->incontent ], $text ); } } function append($el, $text) { if (!$el) { return; } if ( $this->current_namespace ) { if ( $this->initem ) { $this->concat( $this->current_item[ $this->current_namespace ][ $el ], $text); } elseif ($this->inchannel) { $this->concat( $this->channel[ $this->current_namespace][ $el ], $text ); } elseif ($this->intextinput) { $this->concat( $this->textinput[ $this->current_namespace][ $el ], $text ); } elseif ($this->inimage) { $this->concat( $this->image[ $this->current_namespace ][ $el ], $text ); } } else { if ( $this->initem ) { $this->concat( $this->current_item[ $el ], $text); } elseif ($this->intextinput) { $this->concat( $this->textinput[ $el ], $text ); } elseif ($this->inimage) { $this->concat( $this->image[ $el ], $text ); } elseif ($this->inchannel) { $this->concat( $this->channel[ $el ], $text ); } } } function normalize () { if ( $this->is_atom() ) { $this->channel['descripton'] = $this->channel['tagline']; for ( $i = 0; $i < count($this->items); $i++) { $item = $this->items[$i]; if ( isset($item['summary']) ) $item['description'] = $item['summary']; if ( isset($item['atom_content'])) $item['content']['encoded'] = $item['atom_content']; $this->items[$i] = $item; } } elseif ( $this->is_rss() ) { $this->channel['tagline'] = $this->channel['description']; for ( $i = 0; $i < count($this->items); $i++) { $item = $this->items[$i]; if ( isset($item['description'])) $item['summary'] = $item['description']; if ( isset($item['content']['encoded'] ) ) $item['atom_content'] = $item['content']['encoded']; $this->items[$i] = $item; } } } function is_rss () { if ( $this->feed_type == RSS ) { return $this->feed_version; } else { return false; } } function is_atom() { if ( $this->feed_type == ATOM ) { return $this->feed_version; } else { return false; } } function map_attrs($k, $v) { return "$k=\"$v\""; } function error( $errormsg, $lvl = E_USER_WARNING ) { if ( MAGPIE_DEBUG ) { trigger_error( $errormsg, $lvl); } else { error_log( $errormsg, 0); } } } if ( !function_exists('fetch_rss') ) : function fetch_rss ($url) { init(); if ( !isset($url) ) { return false; } if ( !MAGPIE_CACHE_ON ) { $resp = _fetch_remote_file( $url ); if ( is_success( $resp->status ) ) { return _response_to_rss( $resp ); } else { return false; } } else { $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); if (MAGPIE_DEBUG and $cache->ERROR) { debug($cache->ERROR, E_USER_WARNING); } $cache_status = 0; $request_headers = array(); $rss = 0; $errormsg = 0; if (!$cache->ERROR) { $cache_status = $cache->check_cache( $url ); } if ( $cache_status == 'HIT' ) { $rss = $cache->get( $url ); if ( isset($rss) and $rss ) { $rss->from_cache = 1; if ( MAGPIE_DEBUG > 1) { debug("MagpieRSS: Cache HIT", E_USER_NOTICE); } return $rss; } } if ( $cache_status == 'STALE' ) { $rss = $cache->get( $url ); if ( isset($rss->etag) and $rss->last_modified ) { $request_headers['If-None-Match'] = $rss->etag; $request_headers['If-Last-Modified'] = $rss->last_modified; } } $resp = _fetch_remote_file( $url, $request_headers ); if (isset($resp) and $resp) { if ($resp->status == '304' ) { if ( MAGPIE_DEBUG > 1) { debug("Got 304 for $url"); } $cache->set($url, $rss); return $rss; } elseif ( is_success( $resp->status ) ) { $rss = _response_to_rss( $resp ); if ( $rss ) { if (MAGPIE_DEBUG > 1) { debug("Fetch successful"); } $cache->set( $url, $rss ); return $rss; } } else { $errormsg = "Failed to fetch $url. "; if ( $resp->error ) { $http_error = substr($resp->error, 0, -2); $errormsg .= "(HTTP Error: $http_error)"; } else { $errormsg .= "(HTTP Response: " . $resp->response_code .')'; } } } else { $errormsg = "Unable to retrieve RSS file for unknown reasons."; } if ($rss) { if ( MAGPIE_DEBUG ) { debug("Returning STALE object for $url"); } return $rss; } return false; } } endif; function _fetch_remote_file($url, $headers = "" ) { $resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) ); if ( is_wp_error($resp) ) { $error = array_shift($resp->errors); $resp = new stdClass; $resp->status = 500; $resp->response_code = 500; $resp->error = $error[0] . "\n"; return $resp; } $return_headers = array(); foreach ( wp_remote_retrieve_headers( $resp ) as $key => $value ) { if ( !is_array($value) ) { $return_headers[] = "$key: $value"; } else { foreach ( $value as $v ) $return_headers[] = "$key: $v"; } } $response = new stdClass; $response->status = wp_remote_retrieve_response_code( $resp ); $response->response_code = wp_remote_retrieve_response_code( $resp ); $response->headers = $return_headers; $response->results = wp_remote_retrieve_body( $resp ); return $response; } function _response_to_rss ($resp) { $rss = new MagpieRSS( $resp->results ); if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) { foreach ( (array) $resp->headers as $h) { if (strpos($h, ": ")) { list($field, $val) = explode(": ", $h, 2); } else { $field = $h; $val = ""; } if ( $field == 'etag' ) { $rss->etag = $val; } if ( $field == 'last-modified' ) { $rss->last_modified = $val; } } return $rss; } else { $errormsg = "Failed to parse RSS file."; if ($rss) { $errormsg .= " (" . $rss->ERROR . ")"; } return false; } } function init () { if ( defined('MAGPIE_INITALIZED') ) { return; } else { define('MAGPIE_INITALIZED', 1); } if ( !defined('MAGPIE_CACHE_ON') ) { define('MAGPIE_CACHE_ON', 1); } if ( !defined('MAGPIE_CACHE_DIR') ) { define('MAGPIE_CACHE_DIR', './cache'); } if ( !defined('MAGPIE_CACHE_AGE') ) { define('MAGPIE_CACHE_AGE', 60*60); } if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { define('MAGPIE_CACHE_FRESH_ONLY', 0); } if ( !defined('MAGPIE_DEBUG') ) { define('MAGPIE_DEBUG', 0); } if ( !defined('MAGPIE_USER_AGENT') ) { $ua = 'WordPress/' . $GLOBALS['wp_version']; if ( MAGPIE_CACHE_ON ) { $ua = $ua . ')'; } else { $ua = $ua . '; No cache)'; } define('MAGPIE_USER_AGENT', $ua); } if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { define('MAGPIE_FETCH_TIME_OUT', 2); } if ( !defined('MAGPIE_USE_GZIP') ) { define('MAGPIE_USE_GZIP', true); } } function is_info ($sc) { return $sc >= 100 && $sc < 200; } function is_success ($sc) { return $sc >= 200 && $sc < 300; } function is_redirect ($sc) { return $sc >= 300 && $sc < 400; } function is_error ($sc) { return $sc >= 400 && $sc < 600; } function is_client_error ($sc) { return $sc >= 400 && $sc < 500; } function is_server_error ($sc) { return $sc >= 500 && $sc < 600; } class RSSCache { var $BASE_CACHE; var $MAX_AGE = 43200; var $ERROR = ''; function __construct( $base = '', $age = '' ) { $this->BASE_CACHE = WP_CONTENT_DIR . '/cache'; if ( $base ) { $this->BASE_CACHE = $base; } if ( $age ) { $this->MAX_AGE = $age; } } public function RSSCache( $base = '', $age = '' ) { self::__construct( $base, $age ); } function set ($url, $rss) { $cache_option = 'rss_' . $this->file_name( $url ); set_transient($cache_option, $rss, $this->MAX_AGE); return $cache_option; } function get ($url) { $this->ERROR = ""; $cache_option = 'rss_' . $this->file_name( $url ); if ( ! $rss = get_transient( $cache_option ) ) { $this->debug( "Cache does not contain: $url (cache option: $cache_option)" ); return 0; } return $rss; } function check_cache ( $url ) { $this->ERROR = ""; $cache_option = 'rss_' . $this->file_name( $url ); if ( get_transient($cache_option) ) { return 'HIT'; } else { return 'MISS'; } } function serialize ( $rss ) { return serialize( $rss ); } function unserialize ( $data ) { return unserialize( $data ); } function file_name ($url) { return md5( $url ); } function error ($errormsg, $lvl=E_USER_WARNING) { $this->ERROR = $errormsg; if ( MAGPIE_DEBUG ) { trigger_error( $errormsg, $lvl); } else { error_log( $errormsg, 0); } } function debug ($debugmsg, $lvl=E_USER_NOTICE) { if ( MAGPIE_DEBUG ) { $this->error("MagpieRSS [debug] $debugmsg", $lvl); } } } if ( !function_exists('parse_w3cdtf') ) : function parse_w3cdtf ( $date_str ) { $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; if ( preg_match( $pat, $date_str, $match ) ) { list( $year, $month, $day, $hours, $minutes, $seconds) = array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]); $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); $offset = 0; if ( $match[11] == 'Z' ) { } else { list( $tz_mod, $tz_hour, $tz_min ) = array( $match[8], $match[9], $match[10]); if ( ! $tz_hour ) { $tz_hour = 0; } if ( ! $tz_min ) { $tz_min = 0; } $offset_secs = (($tz_hour*60)+$tz_min)*60; if ( $tz_mod == '+' ) { $offset_secs = $offset_secs * -1; } $offset = $offset_secs; } $epoch = $epoch + $offset; return $epoch; } else { return -1; } } endif; if ( !function_exists('wp_rss') ) : function wp_rss( $url, $num_items = -1 ) { if ( $rss = fetch_rss( $url ) ) { echo '<ul>'; if ( $num_items !== -1 ) { $rss->items = array_slice( $rss->items, 0, $num_items ); } foreach ( (array) $rss->items as $item ) { printf( '<li><a href="%1$s" title="%2$s">%3$s</a></li>', esc_url( $item['link'] ), esc_attr( strip_tags( $item['description'] ) ), esc_html( $item['title'] ) ); } echo '</ul>'; } else { _e( 'An error has occurred, which probably means the feed is down. Try again later.' ); } } endif; if ( !function_exists('get_rss') ) : function get_rss ($url, $num_items = 5) { $rss = fetch_rss($url); if ( $rss ) { $rss->items = array_slice($rss->items, 0, $num_items); foreach ( (array) $rss->items as $item ) { echo "<li>\n"; echo "<a href='$item[link]' title='$item[description]'>"; echo esc_html($item['title']); echo "</a><br />\n"; echo "</li>\n"; } } else { return false; } } endif; <?php - require ABSPATH . WPINC . '/class-wp-dependency.php'; require ABSPATH . WPINC . '/class-wp-dependencies.php'; require ABSPATH . WPINC . '/class-wp-scripts.php'; require ABSPATH . WPINC . '/functions.wp-scripts.php'; require ABSPATH . WPINC . '/class-wp-styles.php'; require ABSPATH . WPINC . '/functions.wp-styles.php'; function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) { global $tinymce_version, $concatenate_scripts, $compress_scripts; $suffix = wp_scripts_get_suffix(); $dev_suffix = wp_scripts_get_suffix( 'dev' ); script_concat_settings(); $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed; if ( $compressed ) { $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version ); } else { $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version ); $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); } $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version ); } function wp_default_packages_vendor( $scripts ) { global $wp_locale; $suffix = wp_scripts_get_suffix(); $vendor_scripts = array( 'react' => array( 'wp-polyfill' ), 'react-dom' => array( 'react' ), 'regenerator-runtime', 'moment', 'lodash', 'wp-polyfill-fetch', 'wp-polyfill-formdata', 'wp-polyfill-node-contains', 'wp-polyfill-url', 'wp-polyfill-dom-rect', 'wp-polyfill-element-closest', 'wp-polyfill-object-fit', 'wp-polyfill' => array( 'regenerator-runtime' ), ); $vendor_scripts_versions = array( 'react' => '17.0.1', 'react-dom' => '17.0.1', 'regenerator-runtime' => '0.13.9', 'moment' => '2.29.4', 'lodash' => '4.17.19', 'wp-polyfill-fetch' => '3.6.2', 'wp-polyfill-formdata' => '4.0.10', 'wp-polyfill-node-contains' => '4.4.0', 'wp-polyfill-url' => '3.6.4', 'wp-polyfill-dom-rect' => '4.4.0', 'wp-polyfill-element-closest' => '2.0.2', 'wp-polyfill-object-fit' => '2.3.5', 'wp-polyfill' => '3.15.0', ); foreach ( $vendor_scripts as $handle => $dependencies ) { if ( is_string( $dependencies ) ) { $handle = $dependencies; $dependencies = array(); } $path = "/wp-includes/js/dist/vendor/$handle$suffix.js"; $version = $vendor_scripts_versions[ $handle ]; $scripts->add( $handle, $path, $dependencies, $version, 1 ); } did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' ); did_action( 'init' ) && $scripts->add_inline_script( 'moment', sprintf( "moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode( array( 'months' => array_values( $wp_locale->month ), 'monthsShort' => array_values( $wp_locale->month_abbrev ), 'weekdays' => array_values( $wp_locale->weekday ), 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ), 'week' => array( 'dow' => (int) get_option( 'start_of_week', 0 ), ), 'longDateFormat' => array( 'LT' => get_option( 'time_format', __( 'g:i a' ) ), 'LTS' => null, 'L' => null, 'LL' => get_option( 'date_format', __( 'F j, Y' ) ), 'LLL' => __( 'F j, Y g:i a' ), 'LLLL' => null, ), ) ) ), 'after' ); } function wp_get_script_polyfill( $scripts, $tests ) { $polyfill = ''; foreach ( $tests as $test => $handle ) { if ( ! array_key_exists( $handle, $scripts->registered ) ) { continue; } $src = $scripts->registered[ $handle ]->src; $ver = $scripts->registered[ $handle ]->ver; if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) { $src = $scripts->base_url . $src; } if ( ! empty( $ver ) ) { $src = add_query_arg( 'ver', $ver, $src ); } $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); if ( ! $src ) { continue; } $polyfill .= ( '( ' . $test . ' ) || ' . 'document.write( \'<script src="' . $src . '"></scr\' + \'ipt>\' );' ); } return $polyfill; } function wp_register_development_scripts( $scripts ) { if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG || empty( $scripts->registered['react'] ) || defined( 'WP_RUN_CORE_TESTS' ) ) { return; } $development_scripts = array( 'react-refresh-entry', 'react-refresh-runtime', ); foreach ( $development_scripts as $script_name ) { $assets = include ABSPATH . WPINC . '/assets/script-loader-' . $script_name . '.php'; if ( ! is_array( $assets ) ) { return; } $scripts->add( 'wp-' . $script_name, '/wp-includes/js/dist/development/' . $script_name . '.js', $assets['dependencies'], $assets['version'] ); } $scripts->registered['react']->deps[] = 'wp-react-refresh-entry'; } function wp_default_packages_scripts( $scripts ) { $suffix = defined( 'WP_RUN_CORE_TESTS' ) ? '.min' : wp_scripts_get_suffix(); $assets = include ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php"; foreach ( $assets as $file_name => $package_data ) { $basename = str_replace( $suffix . '.js', '', basename( $file_name ) ); $handle = 'wp-' . $basename; $path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; if ( ! empty( $package_data['dependencies'] ) ) { $dependencies = $package_data['dependencies']; } else { $dependencies = array(); } switch ( $handle ) { case 'wp-block-library': array_push( $dependencies, 'editor' ); break; case 'wp-edit-post': array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' ); break; case 'wp-preferences': array_push( $dependencies, 'wp-preferences-persistence' ); break; } $scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 ); if ( in_array( 'wp-i18n', $dependencies, true ) ) { $scripts->set_translations( $handle ); } if ( 'wp-i18n' === $handle ) { $ltr = _x( 'ltr', 'text direction' ); $script = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] } );", $ltr ); $scripts->add_inline_script( $handle, $script, 'after' ); } } } function wp_default_packages_inline_scripts( $scripts ) { global $wp_locale, $wpdb; if ( isset( $scripts->registered['wp-api-fetch'] ) ) { $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks'; } $scripts->add_inline_script( 'wp-api-fetch', sprintf( 'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );', sanitize_url( get_rest_url() ) ), 'after' ); $scripts->add_inline_script( 'wp-api-fetch', implode( "\n", array( sprintf( 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', wp_installing() ? '' : wp_create_nonce( 'wp_rest' ) ), 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );', 'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );', sprintf( 'wp.apiFetch.nonceEndpoint = "%s";', admin_url( 'admin-ajax.php?action=rest-nonce' ) ), ) ), 'after' ); $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences'; $user_id = get_current_user_id(); $preload_data = get_user_meta( $user_id, $meta_key, true ); $scripts->add_inline_script( 'wp-preferences', sprintf( '( function() { + require ABSPATH . WPINC . '/class-wp-dependency.php'; require ABSPATH . WPINC . '/class-wp-dependencies.php'; require ABSPATH . WPINC . '/class-wp-scripts.php'; require ABSPATH . WPINC . '/functions.wp-scripts.php'; require ABSPATH . WPINC . '/class-wp-styles.php'; require ABSPATH . WPINC . '/functions.wp-styles.php'; function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) { global $tinymce_version, $concatenate_scripts, $compress_scripts; $suffix = wp_scripts_get_suffix(); $dev_suffix = wp_scripts_get_suffix( 'dev' ); script_concat_settings(); $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed; if ( $compressed ) { $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version ); } else { $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version ); $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); } $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version ); } function wp_default_packages_vendor( $scripts ) { global $wp_locale; $suffix = wp_scripts_get_suffix(); $vendor_scripts = array( 'react' => array( 'wp-polyfill' ), 'react-dom' => array( 'react' ), 'regenerator-runtime', 'moment', 'lodash', 'wp-polyfill-fetch', 'wp-polyfill-formdata', 'wp-polyfill-node-contains', 'wp-polyfill-url', 'wp-polyfill-dom-rect', 'wp-polyfill-element-closest', 'wp-polyfill-object-fit', 'wp-polyfill-inert', 'wp-polyfill' => array( 'wp-polyfill-inert', 'regenerator-runtime' ), ); $vendor_scripts_versions = array( 'react' => '17.0.1', 'react-dom' => '17.0.1', 'regenerator-runtime' => '0.13.9', 'moment' => '2.29.4', 'lodash' => '4.17.19', 'wp-polyfill-fetch' => '3.6.2', 'wp-polyfill-formdata' => '4.0.10', 'wp-polyfill-node-contains' => '4.4.0', 'wp-polyfill-url' => '3.6.4', 'wp-polyfill-dom-rect' => '4.4.0', 'wp-polyfill-element-closest' => '2.0.2', 'wp-polyfill-object-fit' => '2.3.5', 'wp-polyfill-inert' => '3.1.2', 'wp-polyfill' => '3.15.0', ); foreach ( $vendor_scripts as $handle => $dependencies ) { if ( is_string( $dependencies ) ) { $handle = $dependencies; $dependencies = array(); } $path = "/wp-includes/js/dist/vendor/$handle$suffix.js"; $version = $vendor_scripts_versions[ $handle ]; $scripts->add( $handle, $path, $dependencies, $version, 1 ); } did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' ); did_action( 'init' ) && $scripts->add_inline_script( 'moment', sprintf( "moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode( array( 'months' => array_values( $wp_locale->month ), 'monthsShort' => array_values( $wp_locale->month_abbrev ), 'weekdays' => array_values( $wp_locale->weekday ), 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ), 'week' => array( 'dow' => (int) get_option( 'start_of_week', 0 ), ), 'longDateFormat' => array( 'LT' => get_option( 'time_format', __( 'g:i a' ) ), 'LTS' => null, 'L' => null, 'LL' => get_option( 'date_format', __( 'F j, Y' ) ), 'LLL' => __( 'F j, Y g:i a' ), 'LLLL' => null, ), ) ) ), 'after' ); } function wp_get_script_polyfill( $scripts, $tests ) { $polyfill = ''; foreach ( $tests as $test => $handle ) { if ( ! array_key_exists( $handle, $scripts->registered ) ) { continue; } $src = $scripts->registered[ $handle ]->src; $ver = $scripts->registered[ $handle ]->ver; if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) { $src = $scripts->base_url . $src; } if ( ! empty( $ver ) ) { $src = add_query_arg( 'ver', $ver, $src ); } $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); if ( ! $src ) { continue; } $polyfill .= ( '( ' . $test . ' ) || ' . 'document.write( \'<script src="' . $src . '"></scr\' + \'ipt>\' );' ); } return $polyfill; } function wp_register_development_scripts( $scripts ) { if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG || empty( $scripts->registered['react'] ) || defined( 'WP_RUN_CORE_TESTS' ) ) { return; } $development_scripts = array( 'react-refresh-entry', 'react-refresh-runtime', ); foreach ( $development_scripts as $script_name ) { $assets = include ABSPATH . WPINC . '/assets/script-loader-' . $script_name . '.php'; if ( ! is_array( $assets ) ) { return; } $scripts->add( 'wp-' . $script_name, '/wp-includes/js/dist/development/' . $script_name . '.js', $assets['dependencies'], $assets['version'] ); } $scripts->registered['react']->deps[] = 'wp-react-refresh-entry'; } function wp_default_packages_scripts( $scripts ) { $suffix = defined( 'WP_RUN_CORE_TESTS' ) ? '.min' : wp_scripts_get_suffix(); $assets = include ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php"; foreach ( $assets as $file_name => $package_data ) { $basename = str_replace( $suffix . '.js', '', basename( $file_name ) ); $handle = 'wp-' . $basename; $path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; if ( ! empty( $package_data['dependencies'] ) ) { $dependencies = $package_data['dependencies']; } else { $dependencies = array(); } switch ( $handle ) { case 'wp-block-library': array_push( $dependencies, 'editor' ); break; case 'wp-edit-post': array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' ); break; case 'wp-preferences': array_push( $dependencies, 'wp-preferences-persistence' ); break; } $scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 ); if ( in_array( 'wp-i18n', $dependencies, true ) ) { $scripts->set_translations( $handle ); } if ( 'wp-i18n' === $handle ) { $ltr = _x( 'ltr', 'text direction' ); $script = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] } );", $ltr ); $scripts->add_inline_script( $handle, $script, 'after' ); } } } function wp_default_packages_inline_scripts( $scripts ) { global $wp_locale, $wpdb; if ( isset( $scripts->registered['wp-api-fetch'] ) ) { $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks'; } $scripts->add_inline_script( 'wp-api-fetch', sprintf( 'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );', sanitize_url( get_rest_url() ) ), 'after' ); $scripts->add_inline_script( 'wp-api-fetch', implode( "\n", array( sprintf( 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', wp_installing() ? '' : wp_create_nonce( 'wp_rest' ) ), 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );', 'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );', sprintf( 'wp.apiFetch.nonceEndpoint = "%s";', admin_url( 'admin-ajax.php?action=rest-nonce' ) ), ) ), 'after' ); $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences'; $user_id = get_current_user_id(); $preload_data = get_user_meta( $user_id, $meta_key, true ); $scripts->add_inline_script( 'wp-preferences', sprintf( '( function() { var serverData = %s; var userId = "%d"; var persistenceLayer = wp.preferencesPersistence.__unstableCreatePersistenceLayer( serverData, userId ); @@ -31749,7 +34436,7 @@ All at ###SITENAME### suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ', settings: ' . $init_obj . ', } - }'; $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' ); } function wp_default_packages( $scripts ) { wp_default_packages_vendor( $scripts ); wp_register_development_scripts( $scripts ); wp_register_tinymce_scripts( $scripts ); wp_default_packages_scripts( $scripts ); if ( did_action( 'init' ) ) { wp_default_packages_inline_scripts( $scripts ); } } function wp_scripts_get_suffix( $type = '' ) { static $suffixes; if ( null === $suffixes ) { require ABSPATH . WPINC . '/version.php'; $develop_src = false !== strpos( $wp_version, '-src' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', $develop_src ); } $suffix = SCRIPT_DEBUG ? '' : '.min'; $dev_suffix = $develop_src ? '' : '.min'; $suffixes = array( 'suffix' => $suffix, 'dev_suffix' => $dev_suffix, ); } if ( 'dev' === $type ) { return $suffixes['dev_suffix']; } return $suffixes['suffix']; } function wp_default_scripts( $scripts ) { $suffix = wp_scripts_get_suffix(); $dev_suffix = wp_scripts_get_suffix( 'dev' ); $guessurl = site_url(); if ( ! $guessurl ) { $guessed_url = true; $guessurl = wp_guess_url(); } $scripts->base_url = $guessurl; $scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; $scripts->default_version = get_bloginfo( 'version' ); $scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array( 'url' => (string) SITECOOKIEPATH, 'uid' => (string) get_current_user_id(), 'time' => (string) time(), 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ), ) ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 ); $scripts->set_translations( 'common' ); $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 ); $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array( 'closeAllOpenTags' => __( 'Close all open tags' ), 'closeTags' => __( 'close tags' ), 'enterURL' => __( 'Enter the URL' ), 'enterImageURL' => __( 'Enter the URL of the image' ), 'enterImageDescription' => __( 'Enter a description of the image' ), 'textdirection' => __( 'text direction' ), 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ), 'dfw' => __( 'Distraction-free writing mode' ), 'strong' => __( 'Bold' ), 'strongClose' => __( 'Close bold tag' ), 'em' => __( 'Italic' ), 'emClose' => __( 'Close italic tag' ), 'link' => __( 'Insert link' ), 'blockquote' => __( 'Blockquote' ), 'blockquoteClose' => __( 'Close blockquote tag' ), 'del' => __( 'Deleted text (strikethrough)' ), 'delClose' => __( 'Close deleted text tag' ), 'ins' => __( 'Inserted text' ), 'insClose' => __( 'Close inserted text tag' ), 'image' => __( 'Insert image' ), 'ul' => __( 'Bulleted list' ), 'ulClose' => __( 'Close bulleted list tag' ), 'ol' => __( 'Numbered list' ), 'olClose' => __( 'Close numbered list tag' ), 'li' => __( 'List item' ), 'liClose' => __( 'Close list item tag' ), 'code' => __( 'Code' ), 'codeClose' => __( 'Close code tag' ), 'more' => __( 'Insert Read More tag' ), ) ); $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' ); $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), '2.0.11', 1 ); $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 'noPerm' => __( 'Sorry, you are not allowed to do that.' ), 'broken' => __( 'Something went wrong.' ), ) ); $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-api-request', 'wpApiSettings', array( 'root' => sanitize_url( get_rest_url() ), 'nonce' => wp_installing() ? '' : wp_create_nonce( 'wp_rest' ), 'versionString' => 'wp/v2/', ) ); $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-core' ), false, 1 ); $scripts->set_translations( 'wp-pointer' ); $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 ); $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings', apply_filters( 'heartbeat_settings', array() ) ); $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 ); $scripts->set_translations( 'wp-auth-check' ); $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' ); $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' ); $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' ); $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' ); $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) ); $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) ); $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '3.6.3' ); $scripts->add( 'jquery-core', "/wp-includes/js/jquery/jquery$suffix.js", array(), '3.6.3' ); $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '3.3.2' ); $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$suffix.js", array( 'jquery' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$suffix.js", array( 'jquery' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$suffix.js", array( 'jquery-ui-core', 'jquery-ui-controlgroup', 'jquery-ui-checkboxradio' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$suffix.js", array( 'jquery-ui-menu' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$suffix.js", array( 'jquery-ui-button' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-checkboxradio', "/wp-includes/js/jquery/ui/checkboxradio$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-controlgroup', "/wp-includes/js/jquery/ui/controlgroup$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$suffix.js", array( 'jquery-ui-draggable' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-position', false, array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-widget', false, array( 'jquery-ui-core' ), '1.13.2', 1 ); did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( 'noResults' => __( 'No results found.' ), 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), 'itemSelected' => __( 'Item selected.' ), ) ); $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.3.0', 1 ); $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.2.0', 1 ); $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 ); $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.2.3', 1 ); $scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2-wp', 1 ); $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 ); $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 ); $scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-core', 'jquery-ui-mouse' ), '0.2.2', 1 ); $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 ); $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 ); $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 ); $scripts->add( 'jquery-masonry', '/wp-includes/js/jquery/jquery.masonry.min.js', array( 'jquery', 'masonry' ), '3.1.2b', 1 ); $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 ); did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( 'next' => __( 'Next >' ), 'prev' => __( '< Prev' ), 'image' => __( 'Image' ), 'of' => __( 'of' ), 'close' => __( 'Close' ), 'noiframes' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ), 'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ), ) ); $scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.15' ); $scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' ); $uploader_l10n = array( 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.' ), 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.' ), 'zero_byte_file' => __( 'This file is empty. Please try another.' ), 'invalid_filetype' => __( 'Sorry, you are not allowed to upload this file type.' ), 'not_an_image' => __( 'This file is not an image. Please try another.' ), 'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.' ), 'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ), 'default_error' => __( 'An error occurred in the upload. Please try again later.' ), 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ), 'upload_limit_exceeded' => __( 'You may only upload 1 file.' ), 'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ), 'http_error_image' => __( 'The server cannot process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.' ), 'upload_failed' => __( 'Upload failed.' ), 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ), 'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ), 'io_error' => __( 'IO error.' ), 'security_error' => __( 'Security error.' ), 'file_cancelled' => __( 'File canceled.' ), 'upload_stopped' => __( 'Upload stopped.' ), 'dismiss' => __( 'Dismiss' ), 'crunching' => __( 'Crunching…' ), 'deleted' => __( 'moved to the Trash.' ), 'error_uploading' => __( '“%s” has failed to upload.' ), 'unsupported_image' => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ), 'noneditable_image' => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.' ), 'file_url_copied' => __( 'The file URL has been copied to your clipboard' ), ); $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' ); $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' ); foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' ); } $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) ); did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' ); $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' ); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' ); did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n ); $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.4', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.1', 1 ); $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( 'ajax' => array( 'url' => admin_url( 'admin-ajax.php', 'relative' ), ), ) ); $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 ); $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 ); $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.17', 1 ); $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.17', 1 ); $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array( 'language' => strtolower( strtok( determine_locale(), '_-' ) ), 'strings' => array( 'mejs.download-file' => __( 'Download File' ), 'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ), 'mejs.fullscreen' => __( 'Fullscreen' ), 'mejs.play' => __( 'Play' ), 'mejs.pause' => __( 'Pause' ), 'mejs.time-slider' => __( 'Time Slider' ), 'mejs.time-help-text' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ), 'mejs.live-broadcast' => __( 'Live Broadcast' ), 'mejs.volume-help-text' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ), 'mejs.unmute' => __( 'Unmute' ), 'mejs.mute' => __( 'Mute' ), 'mejs.volume-slider' => __( 'Volume Slider' ), 'mejs.video-player' => __( 'Video Player' ), 'mejs.audio-player' => __( 'Audio Player' ), 'mejs.captions-subtitles' => __( 'Captions/Subtitles' ), 'mejs.captions-chapters' => __( 'Chapters' ), 'mejs.none' => __( 'None' ), 'mejs.afrikaans' => __( 'Afrikaans' ), 'mejs.albanian' => __( 'Albanian' ), 'mejs.arabic' => __( 'Arabic' ), 'mejs.belarusian' => __( 'Belarusian' ), 'mejs.bulgarian' => __( 'Bulgarian' ), 'mejs.catalan' => __( 'Catalan' ), 'mejs.chinese' => __( 'Chinese' ), 'mejs.chinese-simplified' => __( 'Chinese (Simplified)' ), 'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ), 'mejs.croatian' => __( 'Croatian' ), 'mejs.czech' => __( 'Czech' ), 'mejs.danish' => __( 'Danish' ), 'mejs.dutch' => __( 'Dutch' ), 'mejs.english' => __( 'English' ), 'mejs.estonian' => __( 'Estonian' ), 'mejs.filipino' => __( 'Filipino' ), 'mejs.finnish' => __( 'Finnish' ), 'mejs.french' => __( 'French' ), 'mejs.galician' => __( 'Galician' ), 'mejs.german' => __( 'German' ), 'mejs.greek' => __( 'Greek' ), 'mejs.haitian-creole' => __( 'Haitian Creole' ), 'mejs.hebrew' => __( 'Hebrew' ), 'mejs.hindi' => __( 'Hindi' ), 'mejs.hungarian' => __( 'Hungarian' ), 'mejs.icelandic' => __( 'Icelandic' ), 'mejs.indonesian' => __( 'Indonesian' ), 'mejs.irish' => __( 'Irish' ), 'mejs.italian' => __( 'Italian' ), 'mejs.japanese' => __( 'Japanese' ), 'mejs.korean' => __( 'Korean' ), 'mejs.latvian' => __( 'Latvian' ), 'mejs.lithuanian' => __( 'Lithuanian' ), 'mejs.macedonian' => __( 'Macedonian' ), 'mejs.malay' => __( 'Malay' ), 'mejs.maltese' => __( 'Maltese' ), 'mejs.norwegian' => __( 'Norwegian' ), 'mejs.persian' => __( 'Persian' ), 'mejs.polish' => __( 'Polish' ), 'mejs.portuguese' => __( 'Portuguese' ), 'mejs.romanian' => __( 'Romanian' ), 'mejs.russian' => __( 'Russian' ), 'mejs.serbian' => __( 'Serbian' ), 'mejs.slovak' => __( 'Slovak' ), 'mejs.slovenian' => __( 'Slovenian' ), 'mejs.spanish' => __( 'Spanish' ), 'mejs.swahili' => __( 'Swahili' ), 'mejs.swedish' => __( 'Swedish' ), 'mejs.tagalog' => __( 'Tagalog' ), 'mejs.thai' => __( 'Thai' ), 'mejs.turkish' => __( 'Turkish' ), 'mejs.ukrainian' => __( 'Ukrainian' ), 'mejs.vietnamese' => __( 'Vietnamese' ), 'mejs.welsh' => __( 'Welsh' ), 'mejs.yiddish' => __( 'Yiddish' ), ), ) ) ), 'before' ); $scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.17', 1 ); $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 ); $mejs_settings = array( 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), 'classPrefix' => 'mejs-', 'stretching' => 'responsive', ); did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', apply_filters( 'mejs_settings', $mejs_settings ) ); $scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' ); $scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' ); $scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' ); $scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' ); $scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' ); $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' ); $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) ); $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) ); $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'common', 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) ); $scripts->set_translations( 'wp-theme-plugin-editor' ); $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' ); did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array( 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js', ) ); $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 'unknown' => _x( 'Password strength unknown', 'password strength' ), 'short' => _x( 'Very weak', 'password strength' ), 'bad' => _x( 'Weak', 'password strength' ), 'good' => _x( 'Medium', 'password strength' ), 'strong' => _x( 'Strong', 'password strength' ), 'mismatch' => _x( 'Mismatch', 'password mismatch' ), ) ); $scripts->set_translations( 'password-strength-meter' ); $scripts->add( 'application-passwords', "/wp-admin/js/application-passwords$suffix.js", array( 'jquery', 'wp-util', 'wp-api-request', 'wp-date', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'application-passwords' ); $scripts->add( 'auth-app', "/wp-admin/js/auth-app$suffix.js", array( 'jquery', 'wp-api-request', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'auth-app' ); $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); $scripts->set_translations( 'user-profile' ); $user_id = isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : 0; did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array( 'user_id' => $user_id, 'nonce' => wp_installing() ? '' : wp_create_nonce( 'reset-password-for-' . $user_id ), ) ); $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 ); $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 'title' => __( 'Insert/edit link' ), 'update' => __( 'Update' ), 'save' => __( 'Add Link' ), 'noTitle' => __( '(no title)' ), 'noMatchesFound' => __( 'No results found.' ), 'linkSelected' => __( 'Link selected.' ), 'linkInserted' => __( 'Link inserted.' ), 'minInputLength' => (int) _x( '3', 'minimum input length for searching post links' ), ) ); $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 ); $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.10.2', 1 ); $scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 ); $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 ); $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 ); $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 ); $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( 'activate' => __( 'Activate & Publish' ), 'save' => __( 'Save & Publish' ), 'publish' => __( 'Publish' ), 'published' => __( 'Published' ), 'saveDraft' => __( 'Save Draft' ), 'draftSaved' => __( 'Draft Saved' ), 'updating' => __( 'Updating' ), 'schedule' => _x( 'Schedule', 'customizer changeset action/button label' ), 'scheduled' => _x( 'Scheduled', 'customizer changeset status' ), 'invalid' => __( 'Invalid' ), 'saveBeforeShare' => __( 'Please save your changes in order to share the preview.' ), 'futureDateError' => __( 'You must supply a future date to schedule.' ), 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), 'saved' => __( 'Saved' ), 'cancel' => __( 'Cancel' ), 'close' => __( 'Close' ), 'action' => __( 'Action' ), 'discardChanges' => __( 'Discard changes' ), 'cheatin' => __( 'Something went wrong.' ), 'notAllowedHeading' => __( 'You need a higher level of permission.' ), 'notAllowed' => __( 'Sorry, you are not allowed to customize this site.' ), 'previewIframeTitle' => __( 'Site Preview' ), 'loginIframeTitle' => __( 'Session expired' ), 'collapseSidebar' => _x( 'Hide Controls', 'label for hide controls button without length constraints' ), 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ), 'untitledBlogName' => __( '(Untitled)' ), 'unknownRequestFail' => __( 'Looks like something’s gone wrong. Wait a couple seconds, and then try again.' ), 'themeDownloading' => __( 'Downloading your new theme…' ), 'themePreviewWait' => __( 'Setting up your live preview. This may take a bit.' ), 'revertingChanges' => __( 'Reverting unpublished changes…' ), 'trashConfirm' => __( 'Are you sure you want to discard your unpublished changes?' ), 'takenOverMessage' => __( '%s has taken over and is currently customizing.' ), 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), 'videoHeaderNotice' => __( 'This theme does not support video headers on this page. Navigate to the front page or another page that supports video headers.' ), 'allowedFiles' => __( 'Allowed Files' ), 'customCssError' => array( 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), 'saveBlockedError' => array( 'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ), 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), ), 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), 'themePreviewUnavailable' => __( 'Sorry, you cannot preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), 'themeInstallUnavailable' => sprintf( __( 'You will not be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ), esc_url( admin_url( 'theme-install.php' ) ) ), 'publishSettings' => __( 'Publish Settings' ), 'invalidDate' => __( 'Invalid date.' ), 'invalidValue' => __( 'Invalid value.' ), 'blockThemeNotification' => sprintf( __( 'Hurray! Your theme supports site editing with blocks. <a href="%1$s">Tell me more</a>. %2$s' ), __( 'https://wordpress.org/support/article/site-editor/' ), sprintf( '<button type="button" data-action="%1$s" class="button switch-to-editor">%2$s</button>', esc_url( admin_url( 'site-editor.php' ) ), __( 'Use Site Editor' ) ) ), ) ); $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 ); $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); $scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 ); $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array( 'settings' => array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 'post' => array( 'id' => 0 ), ), ) ); $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js", array(), false, 1 ); $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'clipboard' ), false, 1 ); $scripts->set_translations( 'media-views' ); $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); $scripts->set_translations( 'media-editor' ); $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 ); $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 ); if ( is_admin() ) { $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); $scripts->set_translations( 'admin-tags' ); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 ); $scripts->set_translations( 'admin-comments' ); did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsSettings', array( 'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ), 'hotkeys_highlight_last' => isset( $_GET['hotkeys_highlight_last'] ), ) ); $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'postbox' ); $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 ); $scripts->set_translations( 'tags-box' ); $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'tags-suggest' ); $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard' ), false, 1 ); $scripts->set_translations( 'post' ); $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 ); $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ), false, 1 ); $scripts->set_translations( 'comment' ); $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) ); $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'admin-widgets' ); $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) ); $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' ); $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) ); $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) ); $scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) ); $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) ); $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) ); $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) ); $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 ); $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'inline-edit-post' ); $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'inline-edit-tax' ); $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 ); $scripts->set_translations( 'plugin-install' ); $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-api-request', 'wp-url', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'site-health' ); $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'privacy-tools' ); $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize', 'wp-i18n' ), false, 1 ); $scripts->set_translations( 'updates' ); did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 'ajax_nonce' => wp_installing() ? '' : wp_create_nonce( 'updates' ), ) ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' ); $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.1.1', 1 ); $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); $scripts->set_translations( 'wp-color-picker' ); $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y', 'wp-date' ), false, 1 ); $scripts->set_translations( 'dashboard' ); $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'media' ); $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'image-edit' ); $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); $scripts->set_translations( 'set-post-thumbnail' ); $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) ); $scripts->set_translations( 'nav-menu' ); $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 ); $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 ); } } function wp_default_styles( $styles ) { global $editor_styles; require ABSPATH . WPINC . '/version.php'; if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); } $guessurl = site_url(); if ( ! $guessurl ) { $guessurl = wp_guess_url(); } $styles->base_url = $guessurl; $styles->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; $styles->default_version = get_bloginfo( 'version' ); $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; $styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); $open_sans_font_url = ''; if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { $subsets = 'latin,latin-ext'; $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); if ( 'cyrillic' === $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; } elseif ( 'greek' === $subset ) { $subsets .= ',greek,greek-ext'; } elseif ( 'vietnamese' === $subset ) { $subsets .= ',vietnamese'; } $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback"; } $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) ); $suffix = SCRIPT_DEBUG ? '' : '.min'; $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); $styles->add( 'media', "/wp-admin/css/media$suffix.css" ); $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); $styles->add( 'about', "/wp-admin/css/about$suffix.css" ); $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) ); $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) ); $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" ); $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) ); $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'imgareaselect' ) ); $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) ); $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.17' ); $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' ); $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.15' ); $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); $styles->add( 'open-sans', $open_sans_font_url ); $fonts_url = ''; $font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' ); if ( 'off' !== $font_family ) { $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family ); } $styles->add( 'wp-editor-font', $fonts_url ); $block_library_theme_path = WPINC . "/css/dist/block-library/theme$suffix.css"; $styles->add( 'wp-block-library-theme', "/$block_library_theme_path" ); $styles->add_data( 'wp-block-library-theme', 'path', ABSPATH . $block_library_theme_path ); $styles->add( 'wp-reset-editor-styles', "/wp-includes/css/dist/block-library/reset$suffix.css", array( 'common', 'forms' ) ); $styles->add( 'wp-editor-classic-layout-styles', "/wp-includes/css/dist/edit-post/classic$suffix.css", array() ); $wp_edit_blocks_dependencies = array( 'wp-components', 'wp-editor', 'wp-reset-editor-styles', 'wp-block-library', 'wp-reusable-blocks', ); if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { $wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles'; } if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) { $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } $styles->add( 'wp-edit-blocks', "/wp-includes/css/dist/block-library/editor$suffix.css", $wp_edit_blocks_dependencies ); $package_styles = array( 'block-editor' => array( 'wp-components' ), 'block-library' => array(), 'block-directory' => array(), 'components' => array(), 'edit-post' => array( 'wp-components', 'wp-block-editor', 'wp-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-nux', ), 'editor' => array( 'wp-components', 'wp-block-editor', 'wp-nux', 'wp-reusable-blocks', ), 'format-library' => array(), 'list-reusable-blocks' => array( 'wp-components' ), 'reusable-blocks' => array( 'wp-components' ), 'nux' => array( 'wp-components' ), 'widgets' => array( 'wp-components', ), 'edit-widgets' => array( 'wp-widgets', 'wp-block-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-reusable-blocks', ), 'customize-widgets' => array( 'wp-widgets', 'wp-block-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-reusable-blocks', ), 'edit-site' => array( 'wp-components', 'wp-block-editor', 'wp-edit-blocks', ), ); foreach ( $package_styles as $package => $dependencies ) { $handle = 'wp-' . $package; $path = "/wp-includes/css/dist/$package/style$suffix.css"; if ( 'block-library' === $package && wp_should_load_separate_core_block_assets() ) { $path = "/wp-includes/css/dist/$package/common$suffix.css"; } $styles->add( $handle, $path, $dependencies ); $styles->add_data( $handle, 'path', ABSPATH . $path ); } $rtl_styles = array( 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview', 'login', 'site-health', 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer', 'wp-jquery-ui-dialog', 'wp-reset-editor-styles', 'wp-editor-classic-layout-styles', 'wp-block-library-theme', 'wp-edit-blocks', 'wp-block-editor', 'wp-block-library', 'wp-block-directory', 'wp-components', 'wp-customize-widgets', 'wp-edit-post', 'wp-edit-site', 'wp-edit-widgets', 'wp-editor', 'wp-format-library', 'wp-list-reusable-blocks', 'wp-reusable-blocks', 'wp-nux', 'wp-widgets', 'deprecated-media', 'farbtastic', ); foreach ( $rtl_styles as $rtl_style ) { $styles->add_data( $rtl_style, 'rtl', 'replace' ); if ( $suffix ) { $styles->add_data( $rtl_style, 'suffix', $suffix ); } } } function wp_prototype_before_jquery( $js_array ) { $prototype = array_search( 'prototype', $js_array, true ); if ( false === $prototype ) { return $js_array; } $jquery = array_search( 'jquery', $js_array, true ); if ( false === $jquery ) { return $js_array; } if ( $prototype < $jquery ) { return $js_array; } unset( $js_array[ $prototype ] ); array_splice( $js_array, $jquery, 0, 'prototype' ); return $js_array; } function wp_just_in_time_script_localization() { wp_localize_script( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => AUTOSAVE_INTERVAL, 'blog_id' => get_current_blog_id(), ) ); wp_localize_script( 'mce-view', 'mceViewL10n', array( 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), ) ); wp_localize_script( 'word-count', 'wordCountL10n', array( 'type' => _x( 'words', 'Word count type. Do not translate!' ), 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), ) ); } function wp_localize_jquery_ui_datepicker() { global $wp_locale; if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { return; } $datepicker_date_format = str_replace( array( 'd', 'j', 'l', 'z', 'F', 'M', 'n', 'm', 'Y', 'y', ), array( 'dd', 'd', 'DD', 'o', 'MM', 'M', 'm', 'mm', 'yy', 'y', ), get_option( 'date_format' ) ); $datepicker_defaults = wp_json_encode( array( 'closeText' => __( 'Close' ), 'currentText' => __( 'Today' ), 'monthNames' => array_values( $wp_locale->month ), 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), 'nextText' => __( 'Next' ), 'prevText' => __( 'Previous' ), 'dayNames' => array_values( $wp_locale->weekday ), 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), 'dateFormat' => $datepicker_date_format, 'firstDay' => absint( get_option( 'start_of_week' ) ), 'isRTL' => $wp_locale->is_rtl(), ) ); wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" ); } function wp_localize_community_events() { if ( ! wp_script_is( 'dashboard' ) ) { return; } require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; $user_id = get_current_user_id(); $saved_location = get_user_option( 'community-events-location', $user_id ); $saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false; $current_ip_address = WP_Community_Events::get_unsafe_client_ip(); if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) { $saved_location['ip'] = $current_ip_address; update_user_meta( $user_id, 'community-events-location', $saved_location ); } $events_client = new WP_Community_Events( $user_id, $saved_location ); wp_localize_script( 'dashboard', 'communityEventsData', array( 'nonce' => wp_create_nonce( 'community_events' ), 'cache' => $events_client->get_cached_events(), 'time_format' => get_option( 'time_format' ), ) ); } function wp_style_loader_src( $src, $handle ) { global $_wp_admin_css_colors; if ( wp_installing() ) { return preg_replace( '#^wp-admin/#', './', $src ); } if ( 'colors' === $handle ) { $color = get_user_option( 'admin_color' ); if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) { $color = 'fresh'; } $color = $_wp_admin_css_colors[ $color ]; $url = $color->url; if ( ! $url ) { return false; } $parsed = parse_url( $src ); if ( isset( $parsed['query'] ) && $parsed['query'] ) { wp_parse_str( $parsed['query'], $qv ); $url = add_query_arg( $qv, $url ); } return $url; } return $src; } function print_head_scripts() { global $concatenate_scripts; if ( ! did_action( 'wp_print_scripts' ) ) { do_action( 'wp_print_scripts' ); } $wp_scripts = wp_scripts(); script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_head_items(); if ( apply_filters( 'print_head_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } function print_footer_scripts() { global $wp_scripts, $concatenate_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { return array(); } script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_footer_items(); if ( apply_filters( 'print_footer_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } function _print_scripts() { global $wp_scripts, $compress_scripts; $zip = $compress_scripts ? 1 : 0; if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { $zip = 'gzip'; } $concat = trim( $wp_scripts->concat, ', ' ); $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'"; if ( $concat ) { if ( ! empty( $wp_scripts->print_code ) ) { echo "\n<script{$type_attr}>\n"; echo "/* <![CDATA[ */\n"; echo $wp_scripts->print_code; echo "/* ]]> */\n"; echo "</script>\n"; } $concat = str_split( $concat, 128 ); $concatenated = ''; foreach ( $concat as $key => $chunk ) { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version; echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n"; } if ( ! empty( $wp_scripts->print_html ) ) { echo $wp_scripts->print_html; } } function wp_print_head_scripts() { global $wp_scripts; if ( ! did_action( 'wp_print_scripts' ) ) { do_action( 'wp_print_scripts' ); } if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { return array(); } return print_head_scripts(); } function _wp_footer_scripts() { print_late_styles(); print_footer_scripts(); } function wp_print_footer_scripts() { do_action( 'wp_print_footer_scripts' ); } function wp_enqueue_scripts() { do_action( 'wp_enqueue_scripts' ); } function print_admin_styles() { global $concatenate_scripts; $wp_styles = wp_styles(); script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_items( false ); if ( apply_filters( 'print_admin_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } function print_late_styles() { global $wp_styles, $concatenate_scripts; if ( ! ( $wp_styles instanceof WP_Styles ) ) { return; } script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_footer_items(); if ( apply_filters( 'print_late_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } function _print_styles() { global $compress_css; $wp_styles = wp_styles(); $zip = $compress_css ? 1 : 0; if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { $zip = 'gzip'; } $concat = trim( $wp_styles->concat, ', ' ); $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; if ( $concat ) { $dir = $wp_styles->text_direction; $ver = $wp_styles->default_version; $concat = str_split( $concat, 128 ); $concatenated = ''; foreach ( $concat as $key => $chunk ) { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver; echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n"; if ( ! empty( $wp_styles->print_code ) ) { echo "<style{$type_attr}>\n"; echo $wp_styles->print_code; echo "\n</style>\n"; } } if ( ! empty( $wp_styles->print_html ) ) { echo $wp_styles->print_html; } } function script_concat_settings() { global $concatenate_scripts, $compress_scripts, $compress_css; $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ); $can_compress_scripts = ! wp_installing() && get_site_option( 'can_compress_scripts' ); if ( ! isset( $concatenate_scripts ) ) { $concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true; if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) { $concatenate_scripts = false; } } if ( ! isset( $compress_scripts ) ) { $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true; if ( $compress_scripts && ( ! $can_compress_scripts || $compressed_output ) ) { $compress_scripts = false; } } if ( ! isset( $compress_css ) ) { $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true; if ( $compress_css && ( ! $can_compress_scripts || $compressed_output ) ) { $compress_css = false; } } } function wp_common_block_scripts_and_styles() { if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) { return; } wp_enqueue_style( 'wp-block-library' ); if ( current_theme_supports( 'wp-block-styles' ) ) { if ( wp_should_load_separate_core_block_assets() ) { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'css' : 'min.css'; $files = glob( __DIR__ . "/blocks/**/theme.$suffix" ); foreach ( $files as $path ) { $block_name = basename( dirname( $path ) ); if ( is_rtl() && file_exists( __DIR__ . "/blocks/$block_name/theme-rtl.$suffix" ) ) { $path = __DIR__ . "/blocks/$block_name/theme-rtl.$suffix"; } wp_add_inline_style( "wp-block-{$block_name}", file_get_contents( $path ) ); } } else { wp_enqueue_style( 'wp-block-library-theme' ); } } do_action( 'enqueue_block_assets' ); } function wp_filter_out_block_nodes( $nodes ) { return array_filter( $nodes, function( $node ) { return ! in_array( 'blocks', $node['path'], true ); }, ARRAY_FILTER_USE_BOTH ); } function wp_enqueue_global_styles() { $separate_assets = wp_should_load_separate_core_block_assets(); $is_block_theme = wp_is_block_theme(); $is_classic_theme = ! $is_block_theme; if ( ( $is_block_theme && doing_action( 'wp_footer' ) ) || ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) || ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets ) ) { return; } add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); $stylesheet = wp_get_global_stylesheet(); if ( empty( $stylesheet ) ) { return; } wp_register_style( 'global-styles', false, array(), true, true ); wp_add_inline_style( 'global-styles', $stylesheet ); wp_enqueue_style( 'global-styles' ); wp_add_global_styles_for_blocks(); } function wp_global_styles_render_svg_filters() { if ( is_admin() && ! get_current_screen()->is_block_editor() ) { return; } $filters = wp_get_global_styles_svg_filters(); if ( ! empty( $filters ) ) { echo $filters; } } function wp_should_load_block_editor_scripts_and_styles() { global $current_screen; $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor(); return apply_filters( 'should_load_block_editor_scripts_and_styles', $is_block_editor_screen ); } function wp_should_load_separate_core_block_assets() { if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { return false; } return apply_filters( 'should_load_separate_core_block_assets', false ); } function wp_enqueue_registered_block_scripts_and_styles() { global $current_screen; if ( wp_should_load_separate_core_block_assets() ) { return; } $load_editor_scripts_and_styles = is_admin() && wp_should_load_block_editor_scripts_and_styles(); $block_registry = WP_Block_Type_Registry::get_instance(); foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { foreach ( $block_type->style_handles as $style_handle ) { wp_enqueue_style( $style_handle ); } foreach ( $block_type->script_handles as $script_handle ) { wp_enqueue_script( $script_handle ); } if ( $load_editor_scripts_and_styles ) { foreach ( $block_type->editor_style_handles as $editor_style_handle ) { wp_enqueue_style( $editor_style_handle ); } foreach ( $block_type->editor_script_handles as $editor_script_handle ) { wp_enqueue_script( $editor_script_handle ); } } } } function enqueue_block_styles_assets() { global $wp_styles; $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { if ( isset( $style_properties['style_handle'] ) ) { if ( wp_should_load_separate_core_block_assets() ) { add_filter( 'render_block', function( $html, $block ) use ( $block_name, $style_properties ) { if ( $block['blockName'] === $block_name ) { wp_enqueue_style( $style_properties['style_handle'] ); } return $html; }, 10, 2 ); } else { wp_enqueue_style( $style_properties['style_handle'] ); } } if ( isset( $style_properties['inline_style'] ) ) { $handle = 'wp-block-library'; if ( wp_should_load_separate_core_block_assets() ) { $block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' ); if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) { $handle = $block_stylesheet_handle; } } wp_add_inline_style( $handle, $style_properties['inline_style'] ); } } } } function enqueue_editor_block_styles_assets() { $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); $register_script_lines = array( '( function() {' ); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { $block_style = array( 'name' => $style_properties['name'], 'label' => $style_properties['label'], ); if ( isset( $style_properties['is_default'] ) ) { $block_style['isDefault'] = $style_properties['is_default']; } $register_script_lines[] = sprintf( ' wp.blocks.registerBlockStyle( \'%s\', %s );', $block_name, wp_json_encode( $block_style ) ); } } $register_script_lines[] = '} )();'; $inline_script = implode( "\n", $register_script_lines ); wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true ); wp_add_inline_script( 'wp-block-styles', $inline_script ); wp_enqueue_script( 'wp-block-styles' ); } function wp_enqueue_editor_block_directory_assets() { wp_enqueue_script( 'wp-block-directory' ); wp_enqueue_style( 'wp-block-directory' ); } function wp_enqueue_editor_format_library_assets() { wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-format-library' ); } function wp_sanitize_script_attributes( $attributes ) { $html5_script_support = ! is_admin() && ! current_theme_supports( 'html5', 'script' ); $attributes_string = ''; foreach ( $attributes as $attribute_name => $attribute_value ) { if ( is_bool( $attribute_value ) ) { if ( $attribute_value ) { $attributes_string .= $html5_script_support ? sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) ) : ' ' . esc_attr( $attribute_name ); } } else { $attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); } } return $attributes_string; } function wp_get_script_tag( $attributes ) { if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) { $attributes['type'] = 'text/javascript'; } $attributes = apply_filters( 'wp_script_attributes', $attributes ); return sprintf( "<script%s></script>\n", wp_sanitize_script_attributes( $attributes ) ); } function wp_print_script_tag( $attributes ) { echo wp_get_script_tag( $attributes ); } function wp_get_inline_script_tag( $javascript, $attributes = array() ) { if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) { $attributes['type'] = 'text/javascript'; } $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript ); $javascript = "\n" . trim( $javascript, "\n\r " ) . "\n"; return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $javascript ); } function wp_print_inline_script_tag( $javascript, $attributes = array() ) { echo wp_get_inline_script_tag( $javascript, $attributes ); } function wp_maybe_inline_styles() { global $wp_styles; $total_inline_limit = 20000; $total_inline_limit = apply_filters( 'styles_inline_size_limit', $total_inline_limit ); $styles = array(); foreach ( $wp_styles->queue as $handle ) { if ( wp_styles()->get_data( $handle, 'path' ) && file_exists( $wp_styles->registered[ $handle ]->extra['path'] ) ) { $styles[] = array( 'handle' => $handle, 'src' => $wp_styles->registered[ $handle ]->src, 'path' => $wp_styles->registered[ $handle ]->extra['path'], 'size' => filesize( $wp_styles->registered[ $handle ]->extra['path'] ), ); } } if ( ! empty( $styles ) ) { usort( $styles, static function( $a, $b ) { return ( $a['size'] <= $b['size'] ) ? -1 : 1; } ); $total_inline_size = 0; foreach ( $styles as $style ) { if ( $total_inline_size + $style['size'] > $total_inline_limit ) { break; } $style['css'] = file_get_contents( $style['path'] ); $style['css'] = _wp_normalize_relative_css_links( $style['css'], $style['src'] ); $wp_styles->registered[ $style['handle'] ]->src = false; if ( empty( $wp_styles->registered[ $style['handle'] ]->extra['after'] ) ) { $wp_styles->registered[ $style['handle'] ]->extra['after'] = array(); } array_unshift( $wp_styles->registered[ $style['handle'] ]->extra['after'], $style['css'] ); $total_inline_size += (int) $style['size']; } } } function _wp_normalize_relative_css_links( $css, $stylesheet_url ) { $has_src_results = preg_match_all( '#url\s*\(\s*[\'"]?\s*([^\'"\)]+)#', $css, $src_results ); if ( $has_src_results ) { foreach ( $src_results[1] as $src_index => $src_result ) { if ( 0 === strpos( $src_result, 'http' ) || 0 === strpos( $src_result, '//' ) ) { continue; } if ( str_starts_with( $src_result, '#' ) ) { continue; } if ( str_starts_with( $src_result, 'data:' ) ) { continue; } $absolute_url = dirname( $stylesheet_url ) . '/' . $src_result; $absolute_url = str_replace( '/./', '/', $absolute_url ); $relative_url = wp_make_link_relative( $absolute_url ); $css = str_replace( $src_results[0][ $src_index ], str_replace( $src_result, $relative_url, $src_results[0][ $src_index ] ), $css ); } } return $css; } function wp_enqueue_global_styles_css_custom_properties() { wp_register_style( 'global-styles-css-custom-properties', false, array(), true, true ); wp_add_inline_style( 'global-styles-css-custom-properties', wp_get_global_stylesheet( array( 'variables' ) ) ); wp_enqueue_style( 'global-styles-css-custom-properties' ); } function wp_enqueue_block_support_styles( $style, $priority = 10 ) { $action_hook_name = 'wp_footer'; if ( wp_is_block_theme() ) { $action_hook_name = 'wp_head'; } add_action( $action_hook_name, static function () use ( $style ) { echo "<style>$style</style>\n"; }, $priority ); } function wp_enqueue_stored_styles( $options = array() ) { $is_block_theme = wp_is_block_theme(); $is_classic_theme = ! $is_block_theme; if ( ( $is_block_theme && doing_action( 'wp_footer' ) ) || ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) ) ) { return; } $core_styles_keys = array( 'block-supports' ); $compiled_core_stylesheet = ''; $style_tag_id = 'core'; $should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; foreach ( $core_styles_keys as $style_key ) { if ( $should_prettify ) { $compiled_core_stylesheet .= "/**\n * Core styles: $style_key\n */\n"; } $style_tag_id .= '-' . $style_key; $compiled_core_stylesheet .= wp_style_engine_get_stylesheet_from_context( $style_key, $options ); } if ( ! empty( $compiled_core_stylesheet ) ) { wp_register_style( $style_tag_id, false, array(), true, true ); wp_add_inline_style( $style_tag_id, $compiled_core_stylesheet ); wp_enqueue_style( $style_tag_id ); } $additional_stores = WP_Style_Engine_CSS_Rules_Store::get_stores(); foreach ( array_keys( $additional_stores ) as $store_name ) { if ( in_array( $store_name, $core_styles_keys, true ) ) { continue; } $styles = wp_style_engine_get_stylesheet_from_context( $store_name, $options ); if ( ! empty( $styles ) ) { $key = "wp-style-engine-$store_name"; wp_register_style( $key, false, array(), true, true ); wp_add_inline_style( $key, $styles ); wp_enqueue_style( $key ); } } } function wp_enqueue_block_style( $block_name, $args ) { $args = wp_parse_args( $args, array( 'handle' => '', 'src' => '', 'deps' => array(), 'ver' => false, 'media' => 'all', ) ); $callback = static function( $content ) use ( $args ) { if ( ! empty( $args['src'] ) ) { wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] ); } if ( isset( $args['path'] ) ) { wp_style_add_data( $args['handle'], 'path', $args['path'] ); $rtl_file_path = str_replace( '.css', '-rtl.css', $args['path'] ); if ( file_exists( $rtl_file_path ) ) { wp_style_add_data( $args['handle'], 'rtl', 'replace' ); if ( is_rtl() ) { wp_style_add_data( $args['handle'], 'path', $rtl_file_path ); } } } wp_enqueue_style( $args['handle'] ); return $content; }; $hook = did_action( 'wp_enqueue_scripts' ) ? 'wp_footer' : 'wp_enqueue_scripts'; if ( wp_should_load_separate_core_block_assets() ) { $callback_separate = static function( $content, $block ) use ( $block_name, $callback ) { if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) { return $callback( $content ); } return $content; }; add_filter( 'render_block', $callback_separate, 10, 2 ); return; } add_filter( $hook, $callback ); add_action( 'enqueue_block_assets', $callback ); } function _wp_theme_json_webfonts_handler() { if ( wp_installing() ) { return; } $registered_webfonts = array(); $fn_get_webfonts_from_theme_json = static function() { $settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings(); if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { $variations = WP_Theme_JSON_Resolver::get_style_variations(); foreach ( $variations as $variation ) { if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) { continue; } if ( empty( $settings['typography'] ) ) { $settings['typography'] = array(); } if ( empty( $settings['typography']['fontFamilies'] ) ) { $settings['typography']['fontFamilies'] = array(); } if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) { $settings['typography']['fontFamilies']['theme'] = array(); } $settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] ); $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); } } if ( empty( $settings['typography']['fontFamilies'] ) ) { return array(); } $webfonts = array(); foreach ( $settings['typography']['fontFamilies'] as $font_families ) { foreach ( $font_families as $font_family ) { if ( empty( $font_family['fontFace'] ) ) { continue; } if ( ! is_array( $font_family['fontFace'] ) ) { continue; } $webfonts = array_merge( $webfonts, $font_family['fontFace'] ); } } return $webfonts; }; $fn_transform_src_into_uri = static function( array $src ) { foreach ( $src as $key => $url ) { if ( ! str_starts_with( $url, 'file:./' ) ) { continue; } $src[ $key ] = get_theme_file_uri( str_replace( 'file:./', '', $url ) ); } return $src; }; $fn_convert_keys_to_kebab_case = static function( array $font_face ) { foreach ( $font_face as $property => $value ) { $kebab_case = _wp_to_kebab_case( $property ); $font_face[ $kebab_case ] = $value; if ( $kebab_case !== $property ) { unset( $font_face[ $property ] ); } } return $font_face; }; $fn_validate_webfont = static function( $webfont ) { $webfont = wp_parse_args( $webfont, array( 'font-family' => '', 'font-style' => 'normal', 'font-weight' => '400', 'font-display' => 'fallback', 'src' => array(), ) ); if ( empty( $webfont['font-family'] ) || ! is_string( $webfont['font-family'] ) ) { trigger_error( __( 'Webfont font family must be a non-empty string.' ) ); return false; } if ( empty( $webfont['src'] ) || ( ! is_string( $webfont['src'] ) && ! is_array( $webfont['src'] ) ) ) { trigger_error( __( 'Webfont src must be a non-empty string or an array of strings.' ) ); return false; } foreach ( (array) $webfont['src'] as $src ) { if ( ! is_string( $src ) || '' === trim( $src ) ) { trigger_error( __( 'Each webfont src must be a non-empty string.' ) ); return false; } } if ( ! is_string( $webfont['font-weight'] ) && ! is_int( $webfont['font-weight'] ) ) { trigger_error( __( 'Webfont font weight must be a properly formatted string or integer.' ) ); return false; } if ( ! in_array( $webfont['font-display'], array( 'auto', 'block', 'fallback', 'swap' ), true ) ) { $webfont['font-display'] = 'fallback'; } $valid_props = array( 'ascend-override', 'descend-override', 'font-display', 'font-family', 'font-stretch', 'font-style', 'font-weight', 'font-variant', 'font-feature-settings', 'font-variation-settings', 'line-gap-override', 'size-adjust', 'src', 'unicode-range', ); foreach ( $webfont as $prop => $value ) { if ( ! in_array( $prop, $valid_props, true ) ) { unset( $webfont[ $prop ] ); } } return $webfont; }; $fn_register_webfonts = static function() use ( &$registered_webfonts, $fn_get_webfonts_from_theme_json, $fn_convert_keys_to_kebab_case, $fn_validate_webfont, $fn_transform_src_into_uri ) { $registered_webfonts = array(); foreach ( $fn_get_webfonts_from_theme_json() as $webfont ) { if ( ! is_array( $webfont ) ) { continue; } $webfont = $fn_convert_keys_to_kebab_case( $webfont ); $webfont = $fn_validate_webfont( $webfont ); $webfont['src'] = $fn_transform_src_into_uri( (array) $webfont['src'] ); if ( empty( $webfont ) ) { continue; } $registered_webfonts[] = $webfont; } }; $fn_order_src = static function( array $webfont ) { $src = array(); $src_ordered = array(); foreach ( $webfont['src'] as $url ) { if ( str_starts_with( trim( $url ), 'data:' ) ) { $src_ordered[] = array( 'url' => $url, 'format' => 'data', ); continue; } $format = pathinfo( $url, PATHINFO_EXTENSION ); $src[ $format ] = $url; } if ( ! empty( $src['woff2'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['woff2'] ), 'format' => 'woff2', ); } if ( ! empty( $src['woff'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['woff'] ), 'format' => 'woff', ); } if ( ! empty( $src['ttf'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['ttf'] ), 'format' => 'truetype', ); } if ( ! empty( $src['eot'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['eot'] ), 'format' => 'embedded-opentype', ); } if ( ! empty( $src['otf'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['otf'] ), 'format' => 'opentype', ); } $webfont['src'] = $src_ordered; return $webfont; }; $fn_compile_src = static function( $font_family, array $value ) { $src = "local($font_family)"; foreach ( $value as $item ) { if ( str_starts_with( $item['url'], site_url() ) || str_starts_with( $item['url'], home_url() ) ) { $item['url'] = wp_make_link_relative( $item['url'] ); } $src .= ( 'data' === $item['format'] ) ? ", url({$item['url']})" : ", url('{$item['url']}') format('{$item['format']}')"; } return $src; }; $fn_compile_variations = static function( array $font_variation_settings ) { $variations = ''; foreach ( $font_variation_settings as $key => $value ) { $variations .= "$key $value"; } return $variations; }; $fn_build_font_face_css = static function( array $webfont ) use ( $fn_compile_src, $fn_compile_variations ) { $css = ''; if ( str_contains( $webfont['font-family'], ' ' ) && ! str_contains( $webfont['font-family'], '"' ) && ! str_contains( $webfont['font-family'], "'" ) ) { $webfont['font-family'] = '"' . $webfont['font-family'] . '"'; } foreach ( $webfont as $key => $value ) { if ( 'provider' === $key ) { continue; } if ( 'src' === $key ) { $value = $fn_compile_src( $webfont['font-family'], $value ); } if ( 'font-variation-settings' === $key && is_array( $value ) ) { $value = $fn_compile_variations( $value ); } if ( ! empty( $value ) ) { $css .= "$key:$value;"; } } return $css; }; $fn_get_css = static function() use ( &$registered_webfonts, $fn_order_src, $fn_build_font_face_css ) { $css = ''; foreach ( $registered_webfonts as $webfont ) { $webfont = $fn_order_src( $webfont ); $css .= '@font-face{' . $fn_build_font_face_css( $webfont ) . '}'; } return $css; }; $fn_generate_and_enqueue_styles = static function() use ( $fn_get_css ) { $styles = $fn_get_css(); if ( '' === $styles ) { return; } wp_register_style( 'wp-webfonts', '' ); wp_enqueue_style( 'wp-webfonts' ); wp_add_inline_style( 'wp-webfonts', $styles ); }; $fn_generate_and_enqueue_editor_styles = static function() use ( $fn_get_css ) { $styles = $fn_get_css(); if ( '' === $styles ) { return; } wp_add_inline_style( 'wp-block-library', $styles ); }; add_action( 'wp_loaded', $fn_register_webfonts ); add_action( 'wp_enqueue_scripts', $fn_generate_and_enqueue_styles ); add_action( 'admin_init', $fn_generate_and_enqueue_editor_styles ); } function wp_enqueue_classic_theme_styles() { if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { $suffix = wp_scripts_get_suffix(); wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css", array(), true ); wp_enqueue_style( 'classic-theme-styles' ); } } function wp_add_editor_classic_theme_styles( $editor_settings ) { if ( WP_Theme_JSON_Resolver::theme_has_support() ) { return $editor_settings; } $suffix = wp_scripts_get_suffix(); $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; $classic_theme_styles_settings = array( 'css' => file_get_contents( $classic_theme_styles ), '__unstableType' => 'core', 'isGlobalStyles' => false, ); array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); return $editor_settings; } <?php + }'; $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' ); } function wp_default_packages( $scripts ) { wp_default_packages_vendor( $scripts ); wp_register_development_scripts( $scripts ); wp_register_tinymce_scripts( $scripts ); wp_default_packages_scripts( $scripts ); if ( did_action( 'init' ) ) { wp_default_packages_inline_scripts( $scripts ); } } function wp_scripts_get_suffix( $type = '' ) { static $suffixes; if ( null === $suffixes ) { require ABSPATH . WPINC . '/version.php'; $develop_src = false !== strpos( $wp_version, '-src' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', $develop_src ); } $suffix = SCRIPT_DEBUG ? '' : '.min'; $dev_suffix = $develop_src ? '' : '.min'; $suffixes = array( 'suffix' => $suffix, 'dev_suffix' => $dev_suffix, ); } if ( 'dev' === $type ) { return $suffixes['dev_suffix']; } return $suffixes['suffix']; } function wp_default_scripts( $scripts ) { $suffix = wp_scripts_get_suffix(); $dev_suffix = wp_scripts_get_suffix( 'dev' ); $guessurl = site_url(); if ( ! $guessurl ) { $guessed_url = true; $guessurl = wp_guess_url(); } $scripts->base_url = $guessurl; $scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; $scripts->default_version = get_bloginfo( 'version' ); $scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array( 'url' => (string) SITECOOKIEPATH, 'uid' => (string) get_current_user_id(), 'time' => (string) time(), 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ), ) ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 ); $scripts->set_translations( 'common' ); $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 ); $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array( 'closeAllOpenTags' => __( 'Close all open tags' ), 'closeTags' => __( 'close tags' ), 'enterURL' => __( 'Enter the URL' ), 'enterImageURL' => __( 'Enter the URL of the image' ), 'enterImageDescription' => __( 'Enter a description of the image' ), 'textdirection' => __( 'text direction' ), 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ), 'dfw' => __( 'Distraction-free writing mode' ), 'strong' => __( 'Bold' ), 'strongClose' => __( 'Close bold tag' ), 'em' => __( 'Italic' ), 'emClose' => __( 'Close italic tag' ), 'link' => __( 'Insert link' ), 'blockquote' => __( 'Blockquote' ), 'blockquoteClose' => __( 'Close blockquote tag' ), 'del' => __( 'Deleted text (strikethrough)' ), 'delClose' => __( 'Close deleted text tag' ), 'ins' => __( 'Inserted text' ), 'insClose' => __( 'Close inserted text tag' ), 'image' => __( 'Insert image' ), 'ul' => __( 'Bulleted list' ), 'ulClose' => __( 'Close bulleted list tag' ), 'ol' => __( 'Numbered list' ), 'olClose' => __( 'Close numbered list tag' ), 'li' => __( 'List item' ), 'liClose' => __( 'Close list item tag' ), 'code' => __( 'Code' ), 'codeClose' => __( 'Close code tag' ), 'more' => __( 'Insert Read More tag' ), ) ); $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' ); $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), '2.0.11', 1 ); $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 'noPerm' => __( 'Sorry, you are not allowed to do that.' ), 'broken' => __( 'Something went wrong.' ), ) ); $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-api-request', 'wpApiSettings', array( 'root' => sanitize_url( get_rest_url() ), 'nonce' => wp_installing() ? '' : wp_create_nonce( 'wp_rest' ), 'versionString' => 'wp/v2/', ) ); $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-core' ), false, 1 ); $scripts->set_translations( 'wp-pointer' ); $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 ); $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings', apply_filters( 'heartbeat_settings', array() ) ); $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 ); $scripts->set_translations( 'wp-auth-check' ); $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' ); $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' ); $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' ); $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' ); $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) ); $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) ); $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '3.6.3' ); $scripts->add( 'jquery-core', "/wp-includes/js/jquery/jquery$suffix.js", array(), '3.6.3' ); $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '3.3.2' ); $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$suffix.js", array( 'jquery' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$suffix.js", array( 'jquery' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$suffix.js", array( 'jquery-effects-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$suffix.js", array( 'jquery-ui-core', 'jquery-ui-controlgroup', 'jquery-ui-checkboxradio' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$suffix.js", array( 'jquery-ui-menu' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$suffix.js", array( 'jquery-ui-button' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-checkboxradio', "/wp-includes/js/jquery/ui/checkboxradio$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-controlgroup', "/wp-includes/js/jquery/ui/controlgroup$suffix.js", array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$suffix.js", array( 'jquery-ui-draggable' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$suffix.js", array( 'jquery-ui-mouse' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-position', false, array( 'jquery-ui-core' ), '1.13.2', 1 ); $scripts->add( 'jquery-ui-widget', false, array( 'jquery-ui-core' ), '1.13.2', 1 ); did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( 'noResults' => __( 'No results found.' ), 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), 'itemSelected' => __( 'Item selected.' ), ) ); $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.3.0', 1 ); $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.2.0', 1 ); $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 ); $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.2.3', 1 ); $scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2-wp', 1 ); $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 ); $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 ); $scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-core', 'jquery-ui-mouse' ), '0.2.2', 1 ); $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 ); $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '4.1.4', 1 ); $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '4.2.2', 1 ); $scripts->add( 'jquery-masonry', '/wp-includes/js/jquery/jquery.masonry.min.js', array( 'jquery', 'masonry' ), '3.1.2b', 1 ); $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 ); did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( 'next' => __( 'Next >' ), 'prev' => __( '< Prev' ), 'image' => __( 'Image' ), 'of' => __( 'of' ), 'close' => __( 'Close' ), 'noiframes' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ), 'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ), ) ); $scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.15' ); $scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' ); $uploader_l10n = array( 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.' ), 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.' ), 'zero_byte_file' => __( 'This file is empty. Please try another.' ), 'invalid_filetype' => __( 'Sorry, you are not allowed to upload this file type.' ), 'not_an_image' => __( 'This file is not an image. Please try another.' ), 'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.' ), 'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ), 'default_error' => __( 'An error occurred in the upload. Please try again later.' ), 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ), 'upload_limit_exceeded' => __( 'You may only upload 1 file.' ), 'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ), 'http_error_image' => __( 'The server cannot process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.' ), 'upload_failed' => __( 'Upload failed.' ), 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ), 'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ), 'io_error' => __( 'IO error.' ), 'security_error' => __( 'Security error.' ), 'file_cancelled' => __( 'File canceled.' ), 'upload_stopped' => __( 'Upload stopped.' ), 'dismiss' => __( 'Dismiss' ), 'crunching' => __( 'Crunching…' ), 'deleted' => __( 'moved to the Trash.' ), 'error_uploading' => __( '“%s” has failed to upload.' ), 'unsupported_image' => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ), 'noneditable_image' => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.' ), 'file_url_copied' => __( 'The file URL has been copied to your clipboard' ), ); $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' ); $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' ); foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' ); } $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) ); did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' ); $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' ); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' ); did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n ); $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.4', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.1', 1 ); $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( 'ajax' => array( 'url' => admin_url( 'admin-ajax.php', 'relative' ), ), ) ); $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 ); $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 ); $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.17', 1 ); $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.17', 1 ); $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array( 'language' => strtolower( strtok( determine_locale(), '_-' ) ), 'strings' => array( 'mejs.download-file' => __( 'Download File' ), 'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ), 'mejs.fullscreen' => __( 'Fullscreen' ), 'mejs.play' => __( 'Play' ), 'mejs.pause' => __( 'Pause' ), 'mejs.time-slider' => __( 'Time Slider' ), 'mejs.time-help-text' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ), 'mejs.live-broadcast' => __( 'Live Broadcast' ), 'mejs.volume-help-text' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ), 'mejs.unmute' => __( 'Unmute' ), 'mejs.mute' => __( 'Mute' ), 'mejs.volume-slider' => __( 'Volume Slider' ), 'mejs.video-player' => __( 'Video Player' ), 'mejs.audio-player' => __( 'Audio Player' ), 'mejs.captions-subtitles' => __( 'Captions/Subtitles' ), 'mejs.captions-chapters' => __( 'Chapters' ), 'mejs.none' => __( 'None' ), 'mejs.afrikaans' => __( 'Afrikaans' ), 'mejs.albanian' => __( 'Albanian' ), 'mejs.arabic' => __( 'Arabic' ), 'mejs.belarusian' => __( 'Belarusian' ), 'mejs.bulgarian' => __( 'Bulgarian' ), 'mejs.catalan' => __( 'Catalan' ), 'mejs.chinese' => __( 'Chinese' ), 'mejs.chinese-simplified' => __( 'Chinese (Simplified)' ), 'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ), 'mejs.croatian' => __( 'Croatian' ), 'mejs.czech' => __( 'Czech' ), 'mejs.danish' => __( 'Danish' ), 'mejs.dutch' => __( 'Dutch' ), 'mejs.english' => __( 'English' ), 'mejs.estonian' => __( 'Estonian' ), 'mejs.filipino' => __( 'Filipino' ), 'mejs.finnish' => __( 'Finnish' ), 'mejs.french' => __( 'French' ), 'mejs.galician' => __( 'Galician' ), 'mejs.german' => __( 'German' ), 'mejs.greek' => __( 'Greek' ), 'mejs.haitian-creole' => __( 'Haitian Creole' ), 'mejs.hebrew' => __( 'Hebrew' ), 'mejs.hindi' => __( 'Hindi' ), 'mejs.hungarian' => __( 'Hungarian' ), 'mejs.icelandic' => __( 'Icelandic' ), 'mejs.indonesian' => __( 'Indonesian' ), 'mejs.irish' => __( 'Irish' ), 'mejs.italian' => __( 'Italian' ), 'mejs.japanese' => __( 'Japanese' ), 'mejs.korean' => __( 'Korean' ), 'mejs.latvian' => __( 'Latvian' ), 'mejs.lithuanian' => __( 'Lithuanian' ), 'mejs.macedonian' => __( 'Macedonian' ), 'mejs.malay' => __( 'Malay' ), 'mejs.maltese' => __( 'Maltese' ), 'mejs.norwegian' => __( 'Norwegian' ), 'mejs.persian' => __( 'Persian' ), 'mejs.polish' => __( 'Polish' ), 'mejs.portuguese' => __( 'Portuguese' ), 'mejs.romanian' => __( 'Romanian' ), 'mejs.russian' => __( 'Russian' ), 'mejs.serbian' => __( 'Serbian' ), 'mejs.slovak' => __( 'Slovak' ), 'mejs.slovenian' => __( 'Slovenian' ), 'mejs.spanish' => __( 'Spanish' ), 'mejs.swahili' => __( 'Swahili' ), 'mejs.swedish' => __( 'Swedish' ), 'mejs.tagalog' => __( 'Tagalog' ), 'mejs.thai' => __( 'Thai' ), 'mejs.turkish' => __( 'Turkish' ), 'mejs.ukrainian' => __( 'Ukrainian' ), 'mejs.vietnamese' => __( 'Vietnamese' ), 'mejs.welsh' => __( 'Welsh' ), 'mejs.yiddish' => __( 'Yiddish' ), ), ) ) ), 'before' ); $scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.17', 1 ); $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 ); $mejs_settings = array( 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), 'classPrefix' => 'mejs-', 'stretching' => 'responsive', ); did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', apply_filters( 'mejs_settings', $mejs_settings ) ); $scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' ); $scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' ); $scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' ); $scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' ); $scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' ); $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' ); $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) ); $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) ); $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'common', 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) ); $scripts->set_translations( 'wp-theme-plugin-editor' ); $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' ); did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array( 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js', ) ); $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 'unknown' => _x( 'Password strength unknown', 'password strength' ), 'short' => _x( 'Very weak', 'password strength' ), 'bad' => _x( 'Weak', 'password strength' ), 'good' => _x( 'Medium', 'password strength' ), 'strong' => _x( 'Strong', 'password strength' ), 'mismatch' => _x( 'Mismatch', 'password mismatch' ), ) ); $scripts->set_translations( 'password-strength-meter' ); $scripts->add( 'application-passwords', "/wp-admin/js/application-passwords$suffix.js", array( 'jquery', 'wp-util', 'wp-api-request', 'wp-date', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'application-passwords' ); $scripts->add( 'auth-app', "/wp-admin/js/auth-app$suffix.js", array( 'jquery', 'wp-api-request', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'auth-app' ); $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); $scripts->set_translations( 'user-profile' ); $user_id = isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : 0; did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array( 'user_id' => $user_id, 'nonce' => wp_installing() ? '' : wp_create_nonce( 'reset-password-for-' . $user_id ), ) ); $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 ); $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 'title' => __( 'Insert/edit link' ), 'update' => __( 'Update' ), 'save' => __( 'Add Link' ), 'noTitle' => __( '(no title)' ), 'noMatchesFound' => __( 'No results found.' ), 'linkSelected' => __( 'Link selected.' ), 'linkInserted' => __( 'Link inserted.' ), 'minInputLength' => (int) _x( '3', 'minimum input length for searching post links' ), ) ); $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 ); $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 ); $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.10.2', 1 ); $scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 ); $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 ); $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 ); $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 ); $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( 'activate' => __( 'Activate & Publish' ), 'save' => __( 'Save & Publish' ), 'publish' => __( 'Publish' ), 'published' => __( 'Published' ), 'saveDraft' => __( 'Save Draft' ), 'draftSaved' => __( 'Draft Saved' ), 'updating' => __( 'Updating' ), 'schedule' => _x( 'Schedule', 'customizer changeset action/button label' ), 'scheduled' => _x( 'Scheduled', 'customizer changeset status' ), 'invalid' => __( 'Invalid' ), 'saveBeforeShare' => __( 'Please save your changes in order to share the preview.' ), 'futureDateError' => __( 'You must supply a future date to schedule.' ), 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), 'saved' => __( 'Saved' ), 'cancel' => __( 'Cancel' ), 'close' => __( 'Close' ), 'action' => __( 'Action' ), 'discardChanges' => __( 'Discard changes' ), 'cheatin' => __( 'Something went wrong.' ), 'notAllowedHeading' => __( 'You need a higher level of permission.' ), 'notAllowed' => __( 'Sorry, you are not allowed to customize this site.' ), 'previewIframeTitle' => __( 'Site Preview' ), 'loginIframeTitle' => __( 'Session expired' ), 'collapseSidebar' => _x( 'Hide Controls', 'label for hide controls button without length constraints' ), 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ), 'untitledBlogName' => __( '(Untitled)' ), 'unknownRequestFail' => __( 'Looks like something’s gone wrong. Wait a couple seconds, and then try again.' ), 'themeDownloading' => __( 'Downloading your new theme…' ), 'themePreviewWait' => __( 'Setting up your live preview. This may take a bit.' ), 'revertingChanges' => __( 'Reverting unpublished changes…' ), 'trashConfirm' => __( 'Are you sure you want to discard your unpublished changes?' ), 'takenOverMessage' => __( '%s has taken over and is currently customizing.' ), 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), 'videoHeaderNotice' => __( 'This theme does not support video headers on this page. Navigate to the front page or another page that supports video headers.' ), 'allowedFiles' => __( 'Allowed Files' ), 'customCssError' => array( 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), 'saveBlockedError' => array( 'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ), 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), ), 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), 'themePreviewUnavailable' => __( 'Sorry, you cannot preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), 'themeInstallUnavailable' => sprintf( __( 'You will not be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ), esc_url( admin_url( 'theme-install.php' ) ) ), 'publishSettings' => __( 'Publish Settings' ), 'invalidDate' => __( 'Invalid date.' ), 'invalidValue' => __( 'Invalid value.' ), 'blockThemeNotification' => sprintf( __( 'Hurray! Your theme supports site editing with blocks. <a href="%1$s">Tell me more</a>. %2$s' ), __( 'https://wordpress.org/support/article/site-editor/' ), sprintf( '<button type="button" data-action="%1$s" class="button switch-to-editor">%2$s</button>', esc_url( admin_url( 'site-editor.php' ) ), __( 'Use Site Editor' ) ) ), ) ); $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 ); $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); $scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 ); $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array( 'settings' => array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 'post' => array( 'id' => 0 ), ), ) ); $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js", array(), false, 1 ); $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'clipboard' ), false, 1 ); $scripts->set_translations( 'media-views' ); $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); $scripts->set_translations( 'media-editor' ); $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 ); $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 ); if ( is_admin() ) { $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); $scripts->set_translations( 'admin-tags' ); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 ); $scripts->set_translations( 'admin-comments' ); did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsSettings', array( 'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ), 'hotkeys_highlight_last' => isset( $_GET['hotkeys_highlight_last'] ), ) ); $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'postbox' ); $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 ); $scripts->set_translations( 'tags-box' ); $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'tags-suggest' ); $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard' ), false, 1 ); $scripts->set_translations( 'post' ); $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 ); $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 ); $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ), false, 1 ); $scripts->set_translations( 'comment' ); $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) ); $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'admin-widgets' ); $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) ); $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' ); $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) ); $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) ); $scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) ); $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) ); $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) ); $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) ); $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 ); $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'inline-edit-post' ); $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'inline-edit-tax' ); $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 ); $scripts->set_translations( 'plugin-install' ); $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-api-request', 'wp-url', 'wp-i18n', 'wp-hooks' ), false, 1 ); $scripts->set_translations( 'site-health' ); $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'privacy-tools' ); $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'common', 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize', 'wp-i18n' ), false, 1 ); $scripts->set_translations( 'updates' ); did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 'ajax_nonce' => wp_installing() ? '' : wp_create_nonce( 'updates' ), ) ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' ); $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.1.1', 1 ); $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); $scripts->set_translations( 'wp-color-picker' ); $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y', 'wp-date' ), false, 1 ); $scripts->set_translations( 'dashboard' ); $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'media' ); $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'image-edit' ); $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); $scripts->set_translations( 'set-post-thumbnail' ); $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) ); $scripts->set_translations( 'nav-menu' ); $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 ); $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 ); $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 ); } } function wp_default_styles( $styles ) { global $editor_styles; require ABSPATH . WPINC . '/version.php'; if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); } $guessurl = site_url(); if ( ! $guessurl ) { $guessurl = wp_guess_url(); } $styles->base_url = $guessurl; $styles->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : ''; $styles->default_version = get_bloginfo( 'version' ); $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr'; $styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); $open_sans_font_url = ''; if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) { $subsets = 'latin,latin-ext'; $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' ); if ( 'cyrillic' === $subset ) { $subsets .= ',cyrillic,cyrillic-ext'; } elseif ( 'greek' === $subset ) { $subsets .= ',greek,greek-ext'; } elseif ( 'vietnamese' === $subset ) { $subsets .= ',vietnamese'; } $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback"; } $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) ); $suffix = SCRIPT_DEBUG ? '' : '.min'; $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); $styles->add( 'media', "/wp-admin/css/media$suffix.css" ); $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); $styles->add( 'about', "/wp-admin/css/about$suffix.css" ); $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) ); $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) ); $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" ); $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) ); $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) ); $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'imgareaselect' ) ); $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) ); $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) ); $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.17' ); $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' ); $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.15' ); $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); $styles->add( 'open-sans', $open_sans_font_url ); $fonts_url = ''; $font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' ); if ( 'off' !== $font_family ) { $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family ); } $styles->add( 'wp-editor-font', $fonts_url ); $block_library_theme_path = WPINC . "/css/dist/block-library/theme$suffix.css"; $styles->add( 'wp-block-library-theme', "/$block_library_theme_path" ); $styles->add_data( 'wp-block-library-theme', 'path', ABSPATH . $block_library_theme_path ); $styles->add( 'wp-reset-editor-styles', "/wp-includes/css/dist/block-library/reset$suffix.css", array( 'common', 'forms' ) ); $styles->add( 'wp-editor-classic-layout-styles', "/wp-includes/css/dist/edit-post/classic$suffix.css", array() ); $wp_edit_blocks_dependencies = array( 'wp-components', 'wp-editor', 'wp-reset-editor-styles', 'wp-block-library', 'wp-reusable-blocks', ); if ( ! wp_theme_has_theme_json() ) { $wp_edit_blocks_dependencies[] = 'wp-editor-classic-layout-styles'; } if ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 ) { $wp_edit_blocks_dependencies[] = 'wp-block-library-theme'; } $styles->add( 'wp-edit-blocks', "/wp-includes/css/dist/block-library/editor$suffix.css", $wp_edit_blocks_dependencies ); $package_styles = array( 'block-editor' => array( 'wp-components' ), 'block-library' => array(), 'block-directory' => array(), 'components' => array(), 'edit-post' => array( 'wp-components', 'wp-block-editor', 'wp-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-nux', ), 'editor' => array( 'wp-components', 'wp-block-editor', 'wp-nux', 'wp-reusable-blocks', ), 'format-library' => array(), 'list-reusable-blocks' => array( 'wp-components' ), 'reusable-blocks' => array( 'wp-components' ), 'nux' => array( 'wp-components' ), 'widgets' => array( 'wp-components', ), 'edit-widgets' => array( 'wp-widgets', 'wp-block-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-reusable-blocks', ), 'customize-widgets' => array( 'wp-widgets', 'wp-block-editor', 'wp-edit-blocks', 'wp-block-library', 'wp-reusable-blocks', ), 'edit-site' => array( 'wp-components', 'wp-block-editor', 'wp-edit-blocks', ), ); foreach ( $package_styles as $package => $dependencies ) { $handle = 'wp-' . $package; $path = "/wp-includes/css/dist/$package/style$suffix.css"; if ( 'block-library' === $package && wp_should_load_separate_core_block_assets() ) { $path = "/wp-includes/css/dist/$package/common$suffix.css"; } $styles->add( $handle, $path, $dependencies ); $styles->add_data( $handle, 'path', ABSPATH . $path ); } $rtl_styles = array( 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview', 'login', 'site-health', 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer', 'wp-jquery-ui-dialog', 'wp-reset-editor-styles', 'wp-editor-classic-layout-styles', 'wp-block-library-theme', 'wp-edit-blocks', 'wp-block-editor', 'wp-block-library', 'wp-block-directory', 'wp-components', 'wp-customize-widgets', 'wp-edit-post', 'wp-edit-site', 'wp-edit-widgets', 'wp-editor', 'wp-format-library', 'wp-list-reusable-blocks', 'wp-reusable-blocks', 'wp-nux', 'wp-widgets', 'deprecated-media', 'farbtastic', ); foreach ( $rtl_styles as $rtl_style ) { $styles->add_data( $rtl_style, 'rtl', 'replace' ); if ( $suffix ) { $styles->add_data( $rtl_style, 'suffix', $suffix ); } } } function wp_prototype_before_jquery( $js_array ) { $prototype = array_search( 'prototype', $js_array, true ); if ( false === $prototype ) { return $js_array; } $jquery = array_search( 'jquery', $js_array, true ); if ( false === $jquery ) { return $js_array; } if ( $prototype < $jquery ) { return $js_array; } unset( $js_array[ $prototype ] ); array_splice( $js_array, $jquery, 0, 'prototype' ); return $js_array; } function wp_just_in_time_script_localization() { wp_localize_script( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => AUTOSAVE_INTERVAL, 'blog_id' => get_current_blog_id(), ) ); wp_localize_script( 'mce-view', 'mceViewL10n', array( 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), ) ); wp_localize_script( 'word-count', 'wordCountL10n', array( 'type' => _x( 'words', 'Word count type. Do not translate!' ), 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(), ) ); } function wp_localize_jquery_ui_datepicker() { global $wp_locale; if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { return; } $datepicker_date_format = str_replace( array( 'd', 'j', 'l', 'z', 'F', 'M', 'n', 'm', 'Y', 'y', ), array( 'dd', 'd', 'DD', 'o', 'MM', 'M', 'm', 'mm', 'yy', 'y', ), get_option( 'date_format' ) ); $datepicker_defaults = wp_json_encode( array( 'closeText' => __( 'Close' ), 'currentText' => __( 'Today' ), 'monthNames' => array_values( $wp_locale->month ), 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), 'nextText' => __( 'Next' ), 'prevText' => __( 'Previous' ), 'dayNames' => array_values( $wp_locale->weekday ), 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), 'dateFormat' => $datepicker_date_format, 'firstDay' => absint( get_option( 'start_of_week' ) ), 'isRTL' => $wp_locale->is_rtl(), ) ); wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" ); } function wp_localize_community_events() { if ( ! wp_script_is( 'dashboard' ) ) { return; } require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php'; $user_id = get_current_user_id(); $saved_location = get_user_option( 'community-events-location', $user_id ); $saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false; $current_ip_address = WP_Community_Events::get_unsafe_client_ip(); if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) { $saved_location['ip'] = $current_ip_address; update_user_meta( $user_id, 'community-events-location', $saved_location ); } $events_client = new WP_Community_Events( $user_id, $saved_location ); wp_localize_script( 'dashboard', 'communityEventsData', array( 'nonce' => wp_create_nonce( 'community_events' ), 'cache' => $events_client->get_cached_events(), 'time_format' => get_option( 'time_format' ), ) ); } function wp_style_loader_src( $src, $handle ) { global $_wp_admin_css_colors; if ( wp_installing() ) { return preg_replace( '#^wp-admin/#', './', $src ); } if ( 'colors' === $handle ) { $color = get_user_option( 'admin_color' ); if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) { $color = 'fresh'; } $color = $_wp_admin_css_colors[ $color ]; $url = $color->url; if ( ! $url ) { return false; } $parsed = parse_url( $src ); if ( isset( $parsed['query'] ) && $parsed['query'] ) { wp_parse_str( $parsed['query'], $qv ); $url = add_query_arg( $qv, $url ); } return $url; } return $src; } function print_head_scripts() { global $concatenate_scripts; if ( ! did_action( 'wp_print_scripts' ) ) { do_action( 'wp_print_scripts' ); } $wp_scripts = wp_scripts(); script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_head_items(); if ( apply_filters( 'print_head_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } function print_footer_scripts() { global $wp_scripts, $concatenate_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { return array(); } script_concat_settings(); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_footer_items(); if ( apply_filters( 'print_footer_scripts', true ) ) { _print_scripts(); } $wp_scripts->reset(); return $wp_scripts->done; } function _print_scripts() { global $wp_scripts, $compress_scripts; $zip = $compress_scripts ? 1 : 0; if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { $zip = 'gzip'; } $concat = trim( $wp_scripts->concat, ', ' ); $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'"; if ( $concat ) { if ( ! empty( $wp_scripts->print_code ) ) { echo "\n<script{$type_attr}>\n"; echo "/* <![CDATA[ */\n"; echo $wp_scripts->print_code; echo "/* ]]> */\n"; echo "</script>\n"; } $concat = str_split( $concat, 128 ); $concatenated = ''; foreach ( $concat as $key => $chunk ) { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version; echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n"; } if ( ! empty( $wp_scripts->print_html ) ) { echo $wp_scripts->print_html; } } function wp_print_head_scripts() { global $wp_scripts; if ( ! did_action( 'wp_print_scripts' ) ) { do_action( 'wp_print_scripts' ); } if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { return array(); } return print_head_scripts(); } function _wp_footer_scripts() { print_late_styles(); print_footer_scripts(); } function wp_print_footer_scripts() { do_action( 'wp_print_footer_scripts' ); } function wp_enqueue_scripts() { do_action( 'wp_enqueue_scripts' ); } function print_admin_styles() { global $concatenate_scripts; $wp_styles = wp_styles(); script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_items( false ); if ( apply_filters( 'print_admin_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } function print_late_styles() { global $wp_styles, $concatenate_scripts; if ( ! ( $wp_styles instanceof WP_Styles ) ) { return; } script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_footer_items(); if ( apply_filters( 'print_late_styles', true ) ) { _print_styles(); } $wp_styles->reset(); return $wp_styles->done; } function _print_styles() { global $compress_css; $wp_styles = wp_styles(); $zip = $compress_css ? 1 : 0; if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) { $zip = 'gzip'; } $concat = trim( $wp_styles->concat, ', ' ); $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; if ( $concat ) { $dir = $wp_styles->text_direction; $ver = $wp_styles->default_version; $concat = str_split( $concat, 128 ); $concatenated = ''; foreach ( $concat as $key => $chunk ) { $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}"; } $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver; echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n"; if ( ! empty( $wp_styles->print_code ) ) { echo "<style{$type_attr}>\n"; echo $wp_styles->print_code; echo "\n</style>\n"; } } if ( ! empty( $wp_styles->print_html ) ) { echo $wp_styles->print_html; } } function script_concat_settings() { global $concatenate_scripts, $compress_scripts, $compress_css; $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ); $can_compress_scripts = ! wp_installing() && get_site_option( 'can_compress_scripts' ); if ( ! isset( $concatenate_scripts ) ) { $concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true; if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) { $concatenate_scripts = false; } } if ( ! isset( $compress_scripts ) ) { $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true; if ( $compress_scripts && ( ! $can_compress_scripts || $compressed_output ) ) { $compress_scripts = false; } } if ( ! isset( $compress_css ) ) { $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true; if ( $compress_css && ( ! $can_compress_scripts || $compressed_output ) ) { $compress_css = false; } } } function wp_common_block_scripts_and_styles() { if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) { return; } wp_enqueue_style( 'wp-block-library' ); if ( current_theme_supports( 'wp-block-styles' ) ) { if ( wp_should_load_separate_core_block_assets() ) { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'css' : 'min.css'; $files = glob( __DIR__ . "/blocks/**/theme.$suffix" ); foreach ( $files as $path ) { $block_name = basename( dirname( $path ) ); if ( is_rtl() && file_exists( __DIR__ . "/blocks/$block_name/theme-rtl.$suffix" ) ) { $path = __DIR__ . "/blocks/$block_name/theme-rtl.$suffix"; } wp_add_inline_style( "wp-block-{$block_name}", file_get_contents( $path ) ); } } else { wp_enqueue_style( 'wp-block-library-theme' ); } } do_action( 'enqueue_block_assets' ); } function wp_filter_out_block_nodes( $nodes ) { return array_filter( $nodes, function( $node ) { return ! in_array( 'blocks', $node['path'], true ); }, ARRAY_FILTER_USE_BOTH ); } function wp_enqueue_global_styles() { $separate_assets = wp_should_load_separate_core_block_assets(); $is_block_theme = wp_is_block_theme(); $is_classic_theme = ! $is_block_theme; if ( ( $is_block_theme && doing_action( 'wp_footer' ) ) || ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) || ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets ) ) { return; } add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); $stylesheet = wp_get_global_stylesheet(); if ( empty( $stylesheet ) ) { return; } wp_register_style( 'global-styles', false, array(), true, true ); wp_add_inline_style( 'global-styles', $stylesheet ); wp_enqueue_style( 'global-styles' ); wp_add_global_styles_for_blocks(); } function wp_global_styles_render_svg_filters() { if ( is_admin() && ! get_current_screen()->is_block_editor() ) { return; } $filters = wp_get_global_styles_svg_filters(); if ( ! empty( $filters ) ) { echo $filters; } } function wp_should_load_block_editor_scripts_and_styles() { global $current_screen; $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor(); return apply_filters( 'should_load_block_editor_scripts_and_styles', $is_block_editor_screen ); } function wp_should_load_separate_core_block_assets() { if ( is_admin() || is_feed() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { return false; } return apply_filters( 'should_load_separate_core_block_assets', false ); } function wp_enqueue_registered_block_scripts_and_styles() { global $current_screen; if ( wp_should_load_separate_core_block_assets() ) { return; } $load_editor_scripts_and_styles = is_admin() && wp_should_load_block_editor_scripts_and_styles(); $block_registry = WP_Block_Type_Registry::get_instance(); foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { foreach ( $block_type->style_handles as $style_handle ) { wp_enqueue_style( $style_handle ); } foreach ( $block_type->script_handles as $script_handle ) { wp_enqueue_script( $script_handle ); } if ( $load_editor_scripts_and_styles ) { foreach ( $block_type->editor_style_handles as $editor_style_handle ) { wp_enqueue_style( $editor_style_handle ); } foreach ( $block_type->editor_script_handles as $editor_script_handle ) { wp_enqueue_script( $editor_script_handle ); } } } } function enqueue_block_styles_assets() { global $wp_styles; $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { if ( isset( $style_properties['style_handle'] ) ) { if ( wp_should_load_separate_core_block_assets() ) { add_filter( 'render_block', function( $html, $block ) use ( $block_name, $style_properties ) { if ( $block['blockName'] === $block_name ) { wp_enqueue_style( $style_properties['style_handle'] ); } return $html; }, 10, 2 ); } else { wp_enqueue_style( $style_properties['style_handle'] ); } } if ( isset( $style_properties['inline_style'] ) ) { $handle = 'wp-block-library'; if ( wp_should_load_separate_core_block_assets() ) { $block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' ); if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) { $handle = $block_stylesheet_handle; } } wp_add_inline_style( $handle, $style_properties['inline_style'] ); } } } } function enqueue_editor_block_styles_assets() { $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered(); $register_script_lines = array( '( function() {' ); foreach ( $block_styles as $block_name => $styles ) { foreach ( $styles as $style_properties ) { $block_style = array( 'name' => $style_properties['name'], 'label' => $style_properties['label'], ); if ( isset( $style_properties['is_default'] ) ) { $block_style['isDefault'] = $style_properties['is_default']; } $register_script_lines[] = sprintf( ' wp.blocks.registerBlockStyle( \'%s\', %s );', $block_name, wp_json_encode( $block_style ) ); } } $register_script_lines[] = '} )();'; $inline_script = implode( "\n", $register_script_lines ); wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true ); wp_add_inline_script( 'wp-block-styles', $inline_script ); wp_enqueue_script( 'wp-block-styles' ); } function wp_enqueue_editor_block_directory_assets() { wp_enqueue_script( 'wp-block-directory' ); wp_enqueue_style( 'wp-block-directory' ); } function wp_enqueue_editor_format_library_assets() { wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-format-library' ); } function wp_sanitize_script_attributes( $attributes ) { $html5_script_support = ! is_admin() && ! current_theme_supports( 'html5', 'script' ); $attributes_string = ''; foreach ( $attributes as $attribute_name => $attribute_value ) { if ( is_bool( $attribute_value ) ) { if ( $attribute_value ) { $attributes_string .= $html5_script_support ? sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) ) : ' ' . esc_attr( $attribute_name ); } } else { $attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); } } return $attributes_string; } function wp_get_script_tag( $attributes ) { if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) { $attributes['type'] = 'text/javascript'; } $attributes = apply_filters( 'wp_script_attributes', $attributes ); return sprintf( "<script%s></script>\n", wp_sanitize_script_attributes( $attributes ) ); } function wp_print_script_tag( $attributes ) { echo wp_get_script_tag( $attributes ); } function wp_get_inline_script_tag( $javascript, $attributes = array() ) { if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) { $attributes['type'] = 'text/javascript'; } $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript ); $javascript = "\n" . trim( $javascript, "\n\r " ) . "\n"; return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $javascript ); } function wp_print_inline_script_tag( $javascript, $attributes = array() ) { echo wp_get_inline_script_tag( $javascript, $attributes ); } function wp_maybe_inline_styles() { global $wp_styles; $total_inline_limit = 20000; $total_inline_limit = apply_filters( 'styles_inline_size_limit', $total_inline_limit ); $styles = array(); foreach ( $wp_styles->queue as $handle ) { if ( wp_styles()->get_data( $handle, 'path' ) && file_exists( $wp_styles->registered[ $handle ]->extra['path'] ) ) { $styles[] = array( 'handle' => $handle, 'src' => $wp_styles->registered[ $handle ]->src, 'path' => $wp_styles->registered[ $handle ]->extra['path'], 'size' => filesize( $wp_styles->registered[ $handle ]->extra['path'] ), ); } } if ( ! empty( $styles ) ) { usort( $styles, static function( $a, $b ) { return ( $a['size'] <= $b['size'] ) ? -1 : 1; } ); $total_inline_size = 0; foreach ( $styles as $style ) { if ( $total_inline_size + $style['size'] > $total_inline_limit ) { break; } $style['css'] = file_get_contents( $style['path'] ); $style['css'] = _wp_normalize_relative_css_links( $style['css'], $style['src'] ); $wp_styles->registered[ $style['handle'] ]->src = false; if ( empty( $wp_styles->registered[ $style['handle'] ]->extra['after'] ) ) { $wp_styles->registered[ $style['handle'] ]->extra['after'] = array(); } array_unshift( $wp_styles->registered[ $style['handle'] ]->extra['after'], $style['css'] ); $total_inline_size += (int) $style['size']; } } } function _wp_normalize_relative_css_links( $css, $stylesheet_url ) { $has_src_results = preg_match_all( '#url\s*\(\s*[\'"]?\s*([^\'"\)]+)#', $css, $src_results ); if ( $has_src_results ) { foreach ( $src_results[1] as $src_index => $src_result ) { if ( 0 === strpos( $src_result, 'http' ) || 0 === strpos( $src_result, '//' ) ) { continue; } if ( str_starts_with( $src_result, '#' ) ) { continue; } if ( str_starts_with( $src_result, 'data:' ) ) { continue; } $absolute_url = dirname( $stylesheet_url ) . '/' . $src_result; $absolute_url = str_replace( '/./', '/', $absolute_url ); $relative_url = wp_make_link_relative( $absolute_url ); $css = str_replace( $src_results[0][ $src_index ], str_replace( $src_result, $relative_url, $src_results[0][ $src_index ] ), $css ); } } return $css; } function wp_enqueue_global_styles_css_custom_properties() { wp_register_style( 'global-styles-css-custom-properties', false, array(), true, true ); wp_add_inline_style( 'global-styles-css-custom-properties', wp_get_global_stylesheet( array( 'variables' ) ) ); wp_enqueue_style( 'global-styles-css-custom-properties' ); } function wp_enqueue_block_support_styles( $style, $priority = 10 ) { $action_hook_name = 'wp_footer'; if ( wp_is_block_theme() ) { $action_hook_name = 'wp_head'; } add_action( $action_hook_name, static function () use ( $style ) { echo "<style>$style</style>\n"; }, $priority ); } function wp_enqueue_stored_styles( $options = array() ) { $is_block_theme = wp_is_block_theme(); $is_classic_theme = ! $is_block_theme; if ( ( $is_block_theme && doing_action( 'wp_footer' ) ) || ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) ) ) { return; } $core_styles_keys = array( 'block-supports' ); $compiled_core_stylesheet = ''; $style_tag_id = 'core'; $should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; foreach ( $core_styles_keys as $style_key ) { if ( $should_prettify ) { $compiled_core_stylesheet .= "/**\n * Core styles: $style_key\n */\n"; } $style_tag_id .= '-' . $style_key; $compiled_core_stylesheet .= wp_style_engine_get_stylesheet_from_context( $style_key, $options ); } if ( ! empty( $compiled_core_stylesheet ) ) { wp_register_style( $style_tag_id, false, array(), true, true ); wp_add_inline_style( $style_tag_id, $compiled_core_stylesheet ); wp_enqueue_style( $style_tag_id ); } $additional_stores = WP_Style_Engine_CSS_Rules_Store::get_stores(); foreach ( array_keys( $additional_stores ) as $store_name ) { if ( in_array( $store_name, $core_styles_keys, true ) ) { continue; } $styles = wp_style_engine_get_stylesheet_from_context( $store_name, $options ); if ( ! empty( $styles ) ) { $key = "wp-style-engine-$store_name"; wp_register_style( $key, false, array(), true, true ); wp_add_inline_style( $key, $styles ); wp_enqueue_style( $key ); } } } function wp_enqueue_block_style( $block_name, $args ) { $args = wp_parse_args( $args, array( 'handle' => '', 'src' => '', 'deps' => array(), 'ver' => false, 'media' => 'all', ) ); $callback = static function( $content ) use ( $args ) { if ( ! empty( $args['src'] ) ) { wp_register_style( $args['handle'], $args['src'], $args['deps'], $args['ver'], $args['media'] ); } if ( isset( $args['path'] ) ) { wp_style_add_data( $args['handle'], 'path', $args['path'] ); $rtl_file_path = str_replace( '.css', '-rtl.css', $args['path'] ); if ( file_exists( $rtl_file_path ) ) { wp_style_add_data( $args['handle'], 'rtl', 'replace' ); if ( is_rtl() ) { wp_style_add_data( $args['handle'], 'path', $rtl_file_path ); } } } wp_enqueue_style( $args['handle'] ); return $content; }; $hook = did_action( 'wp_enqueue_scripts' ) ? 'wp_footer' : 'wp_enqueue_scripts'; if ( wp_should_load_separate_core_block_assets() ) { $callback_separate = static function( $content, $block ) use ( $block_name, $callback ) { if ( ! empty( $block['blockName'] ) && $block_name === $block['blockName'] ) { return $callback( $content ); } return $content; }; add_filter( 'render_block', $callback_separate, 10, 2 ); return; } add_filter( $hook, $callback ); add_action( 'enqueue_block_assets', $callback ); } function _wp_theme_json_webfonts_handler() { if ( wp_installing() ) { return; } $registered_webfonts = array(); $fn_get_webfonts_from_theme_json = static function() { $settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings(); if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { $variations = WP_Theme_JSON_Resolver::get_style_variations(); foreach ( $variations as $variation ) { if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) { continue; } if ( empty( $settings['typography'] ) ) { $settings['typography'] = array(); } if ( empty( $settings['typography']['fontFamilies'] ) ) { $settings['typography']['fontFamilies'] = array(); } if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) { $settings['typography']['fontFamilies']['theme'] = array(); } $settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] ); $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); } } if ( empty( $settings['typography']['fontFamilies'] ) ) { return array(); } $webfonts = array(); foreach ( $settings['typography']['fontFamilies'] as $font_families ) { foreach ( $font_families as $font_family ) { if ( empty( $font_family['fontFace'] ) ) { continue; } if ( ! is_array( $font_family['fontFace'] ) ) { continue; } $webfonts = array_merge( $webfonts, $font_family['fontFace'] ); } } return $webfonts; }; $fn_transform_src_into_uri = static function( array $src ) { foreach ( $src as $key => $url ) { if ( ! str_starts_with( $url, 'file:./' ) ) { continue; } $src[ $key ] = get_theme_file_uri( str_replace( 'file:./', '', $url ) ); } return $src; }; $fn_convert_keys_to_kebab_case = static function( array $font_face ) { foreach ( $font_face as $property => $value ) { $kebab_case = _wp_to_kebab_case( $property ); $font_face[ $kebab_case ] = $value; if ( $kebab_case !== $property ) { unset( $font_face[ $property ] ); } } return $font_face; }; $fn_validate_webfont = static function( $webfont ) { $webfont = wp_parse_args( $webfont, array( 'font-family' => '', 'font-style' => 'normal', 'font-weight' => '400', 'font-display' => 'fallback', 'src' => array(), ) ); if ( empty( $webfont['font-family'] ) || ! is_string( $webfont['font-family'] ) ) { trigger_error( __( 'Webfont font family must be a non-empty string.' ) ); return false; } if ( empty( $webfont['src'] ) || ( ! is_string( $webfont['src'] ) && ! is_array( $webfont['src'] ) ) ) { trigger_error( __( 'Webfont src must be a non-empty string or an array of strings.' ) ); return false; } foreach ( (array) $webfont['src'] as $src ) { if ( ! is_string( $src ) || '' === trim( $src ) ) { trigger_error( __( 'Each webfont src must be a non-empty string.' ) ); return false; } } if ( ! is_string( $webfont['font-weight'] ) && ! is_int( $webfont['font-weight'] ) ) { trigger_error( __( 'Webfont font weight must be a properly formatted string or integer.' ) ); return false; } if ( ! in_array( $webfont['font-display'], array( 'auto', 'block', 'fallback', 'swap' ), true ) ) { $webfont['font-display'] = 'fallback'; } $valid_props = array( 'ascend-override', 'descend-override', 'font-display', 'font-family', 'font-stretch', 'font-style', 'font-weight', 'font-variant', 'font-feature-settings', 'font-variation-settings', 'line-gap-override', 'size-adjust', 'src', 'unicode-range', ); foreach ( $webfont as $prop => $value ) { if ( ! in_array( $prop, $valid_props, true ) ) { unset( $webfont[ $prop ] ); } } return $webfont; }; $fn_register_webfonts = static function() use ( &$registered_webfonts, $fn_get_webfonts_from_theme_json, $fn_convert_keys_to_kebab_case, $fn_validate_webfont, $fn_transform_src_into_uri ) { $registered_webfonts = array(); foreach ( $fn_get_webfonts_from_theme_json() as $webfont ) { if ( ! is_array( $webfont ) ) { continue; } $webfont = $fn_convert_keys_to_kebab_case( $webfont ); $webfont = $fn_validate_webfont( $webfont ); $webfont['src'] = $fn_transform_src_into_uri( (array) $webfont['src'] ); if ( empty( $webfont ) ) { continue; } $registered_webfonts[] = $webfont; } }; $fn_order_src = static function( array $webfont ) { $src = array(); $src_ordered = array(); foreach ( $webfont['src'] as $url ) { if ( str_starts_with( trim( $url ), 'data:' ) ) { $src_ordered[] = array( 'url' => $url, 'format' => 'data', ); continue; } $format = pathinfo( $url, PATHINFO_EXTENSION ); $src[ $format ] = $url; } if ( ! empty( $src['woff2'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['woff2'] ), 'format' => 'woff2', ); } if ( ! empty( $src['woff'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['woff'] ), 'format' => 'woff', ); } if ( ! empty( $src['ttf'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['ttf'] ), 'format' => 'truetype', ); } if ( ! empty( $src['eot'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['eot'] ), 'format' => 'embedded-opentype', ); } if ( ! empty( $src['otf'] ) ) { $src_ordered[] = array( 'url' => sanitize_url( $src['otf'] ), 'format' => 'opentype', ); } $webfont['src'] = $src_ordered; return $webfont; }; $fn_compile_src = static function( $font_family, array $value ) { $src = "local($font_family)"; foreach ( $value as $item ) { if ( str_starts_with( $item['url'], site_url() ) || str_starts_with( $item['url'], home_url() ) ) { $item['url'] = wp_make_link_relative( $item['url'] ); } $src .= ( 'data' === $item['format'] ) ? ", url({$item['url']})" : ", url('{$item['url']}') format('{$item['format']}')"; } return $src; }; $fn_compile_variations = static function( array $font_variation_settings ) { $variations = ''; foreach ( $font_variation_settings as $key => $value ) { $variations .= "$key $value"; } return $variations; }; $fn_build_font_face_css = static function( array $webfont ) use ( $fn_compile_src, $fn_compile_variations ) { $css = ''; if ( str_contains( $webfont['font-family'], ' ' ) && ! str_contains( $webfont['font-family'], '"' ) && ! str_contains( $webfont['font-family'], "'" ) ) { $webfont['font-family'] = '"' . $webfont['font-family'] . '"'; } foreach ( $webfont as $key => $value ) { if ( 'provider' === $key ) { continue; } if ( 'src' === $key ) { $value = $fn_compile_src( $webfont['font-family'], $value ); } if ( 'font-variation-settings' === $key && is_array( $value ) ) { $value = $fn_compile_variations( $value ); } if ( ! empty( $value ) ) { $css .= "$key:$value;"; } } return $css; }; $fn_get_css = static function() use ( &$registered_webfonts, $fn_order_src, $fn_build_font_face_css ) { $css = ''; foreach ( $registered_webfonts as $webfont ) { $webfont = $fn_order_src( $webfont ); $css .= '@font-face{' . $fn_build_font_face_css( $webfont ) . '}'; } return $css; }; $fn_generate_and_enqueue_styles = static function() use ( $fn_get_css ) { $styles = $fn_get_css(); if ( '' === $styles ) { return; } wp_register_style( 'wp-webfonts', '' ); wp_enqueue_style( 'wp-webfonts' ); wp_add_inline_style( 'wp-webfonts', $styles ); }; $fn_generate_and_enqueue_editor_styles = static function() use ( $fn_get_css ) { $styles = $fn_get_css(); if ( '' === $styles ) { return; } wp_add_inline_style( 'wp-block-library', $styles ); }; add_action( 'wp_loaded', $fn_register_webfonts ); add_action( 'wp_enqueue_scripts', $fn_generate_and_enqueue_styles ); add_action( 'admin_init', $fn_generate_and_enqueue_editor_styles ); } function wp_enqueue_classic_theme_styles() { if ( ! wp_theme_has_theme_json() ) { $suffix = wp_scripts_get_suffix(); wp_register_style( 'classic-theme-styles', '/' . WPINC . "/css/classic-themes$suffix.css", array(), true ); wp_enqueue_style( 'classic-theme-styles' ); } } function wp_add_editor_classic_theme_styles( $editor_settings ) { if ( wp_theme_has_theme_json() ) { return $editor_settings; } $suffix = wp_scripts_get_suffix(); $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; $classic_theme_styles_settings = array( 'css' => file_get_contents( $classic_theme_styles ), '__unstableType' => 'core', 'isGlobalStyles' => false, ); array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); return $editor_settings; } <?php _deprecated_file( basename( __FILE__ ), '4.7.0' ); require_once ABSPATH . WPINC . '/class-wp-session-tokens.php'; require_once ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php'; <?php $shortcode_tags = array(); function add_shortcode( $tag, $callback ) { global $shortcode_tags; if ( '' === trim( $tag ) ) { _doing_it_wrong( __FUNCTION__, __( 'Invalid shortcode name: Empty name given.' ), '4.4.0' ); return; } if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ), $tag, '& / < > [ ] =' ), '4.4.0' ); return; } $shortcode_tags[ $tag ] = $callback; } function remove_shortcode( $tag ) { global $shortcode_tags; unset( $shortcode_tags[ $tag ] ); } function remove_all_shortcodes() { global $shortcode_tags; $shortcode_tags = array(); } function shortcode_exists( $tag ) { global $shortcode_tags; return array_key_exists( $tag, $shortcode_tags ); } function has_shortcode( $content, $tag ) { if ( false === strpos( $content, '[' ) ) { return false; } if ( shortcode_exists( $tag ) ) { preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) ) { return false; } foreach ( $matches as $shortcode ) { if ( $tag === $shortcode[2] ) { return true; } elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) { return true; } } } return false; } function apply_shortcodes( $content, $ignore_html = false ) { return do_shortcode( $content, $ignore_html ); } function do_shortcode( $content, $ignore_html = false ) { global $shortcode_tags; if ( false === strpos( $content, '[' ) ) { return $content; } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return $content; } preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); if ( empty( $tagnames ) ) { return $content; } $content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content ); $content = unescape_invalid_shortcodes( $content ); return $content; } function get_shortcode_regex( $tagnames = null ) { global $shortcode_tags; if ( empty( $tagnames ) ) { $tagnames = array_keys( $shortcode_tags ); } $tagregexp = implode( '|', array_map( 'preg_quote', $tagnames ) ); return '\\[' . '(\\[?)' . "($tagregexp)" . '(?![\\w-])' . '(' . '[^\\]\\/]*' . '(?:' . '\\/(?!\\])' . '[^\\]\\/]*' . ')*?' . ')' . '(?:' . '(\\/)' . '\\]' . '|' . '\\]' . '(?:' . '(' . '[^\\[]*+' . '(?:' . '\\[(?!\\/\\2\\])' . '[^\\[]*+' . ')*+' . ')' . '\\[\\/\\2\\]' . ')?' . ')' . '(\\]?)'; } function do_shortcode_tag( $m ) { global $shortcode_tags; if ( '[' === $m[1] && ']' === $m[6] ) { return substr( $m[0], 1, -1 ); } $tag = $m[2]; $attr = shortcode_parse_atts( $m[3] ); if ( ! is_callable( $shortcode_tags[ $tag ] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ), '4.3.0' ); return $m[0]; } $return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m ); if ( false !== $return ) { return $return; } $content = isset( $m[5] ) ? $m[5] : null; $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m ); } function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { $trans = array( '[' => '[', ']' => ']', ); $content = strtr( $content, $trans ); $trans = array( '[' => '[', ']' => ']', ); $pattern = get_shortcode_regex( $tagnames ); $textarr = wp_html_split( $content ); foreach ( $textarr as &$element ) { if ( '' === $element || '<' !== $element[0] ) { continue; } $noopen = false === strpos( $element, '[' ); $noclose = false === strpos( $element, ']' ); if ( $noopen || $noclose ) { if ( $noopen xor $noclose ) { $element = strtr( $element, $trans ); } continue; } if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) { $element = strtr( $element, $trans ); continue; } $attributes = wp_kses_attr_parse( $element ); if ( false === $attributes ) { if ( 1 === preg_match( '%^<\s*\[\[?[^\[\]]+\]%', $element ) ) { $element = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $element ); } $element = strtr( $element, $trans ); continue; } $front = array_shift( $attributes ); $back = array_pop( $attributes ); $matches = array(); preg_match( '%[a-zA-Z0-9]+%', $front, $matches ); $elname = $matches[0]; foreach ( $attributes as &$attr ) { $open = strpos( $attr, '[' ); $close = strpos( $attr, ']' ); if ( false === $open || false === $close ) { continue; } $double = strpos( $attr, '"' ); $single = strpos( $attr, "'" ); if ( ( false === $single || $open < $single ) && ( false === $double || $open < $double ) ) { $attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr ); } else { $count = 0; $new_attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr, -1, $count ); if ( $count > 0 ) { $new_attr = wp_kses_one_attr( $new_attr, $elname ); if ( '' !== trim( $new_attr ) ) { $attr = $new_attr; } } } } $element = $front . implode( '', $attributes ) . $back; $element = strtr( $element, $trans ); } $content = implode( '', $textarr ); return $content; } function unescape_invalid_shortcodes( $content ) { $trans = array( '[' => '[', ']' => ']', ); $content = strtr( $content, $trans ); return $content; } function get_shortcode_atts_regex() { return '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|\'([^\']*)\'(?:\s|$)|(\S+)(?:\s|$)/'; } function shortcode_parse_atts( $text ) { $atts = array(); $pattern = get_shortcode_atts_regex(); $text = preg_replace( "/[\x{00a0}\x{200b}]+/u", ' ', $text ); if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) { foreach ( $match as $m ) { if ( ! empty( $m[1] ) ) { $atts[ strtolower( $m[1] ) ] = stripcslashes( $m[2] ); } elseif ( ! empty( $m[3] ) ) { $atts[ strtolower( $m[3] ) ] = stripcslashes( $m[4] ); } elseif ( ! empty( $m[5] ) ) { $atts[ strtolower( $m[5] ) ] = stripcslashes( $m[6] ); } elseif ( isset( $m[7] ) && strlen( $m[7] ) ) { $atts[] = stripcslashes( $m[7] ); } elseif ( isset( $m[8] ) && strlen( $m[8] ) ) { $atts[] = stripcslashes( $m[8] ); } elseif ( isset( $m[9] ) ) { $atts[] = stripcslashes( $m[9] ); } } foreach ( $atts as &$value ) { if ( false !== strpos( $value, '<' ) ) { if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) { $value = ''; } } } } else { $atts = ltrim( $text ); } return $atts; } function shortcode_atts( $pairs, $atts, $shortcode = '' ) { $atts = (array) $atts; $out = array(); foreach ( $pairs as $name => $default ) { if ( array_key_exists( $name, $atts ) ) { $out[ $name ] = $atts[ $name ]; } else { $out[ $name ] = $default; } } if ( $shortcode ) { $out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode ); } return $out; } function strip_shortcodes( $content ) { global $shortcode_tags; if ( false === strpos( $content, '[' ) ) { return $content; } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return $content; } preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tags_to_remove = array_keys( $shortcode_tags ); $tags_to_remove = apply_filters( 'strip_shortcodes_tagnames', $tags_to_remove, $content ); $tagnames = array_intersect( $tags_to_remove, $matches[1] ); if ( empty( $tagnames ) ) { return $content; } $content = do_shortcodes_in_html_tags( $content, true, $tagnames ); $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'strip_shortcode_tag', $content ); $content = unescape_invalid_shortcodes( $content ); return $content; } function strip_shortcode_tag( $m ) { if ( '[' === $m[1] && ']' === $m[6] ) { return substr( $m[0], 1, -1 ); } return $m[1] . $m[6]; } <?php function wp_sitemaps_get_server() { global $wp_sitemaps; if ( empty( $wp_sitemaps ) ) { $wp_sitemaps = new WP_Sitemaps(); $wp_sitemaps->init(); do_action( 'wp_sitemaps_init', $wp_sitemaps ); } return $wp_sitemaps; } function wp_get_sitemap_providers() { $sitemaps = wp_sitemaps_get_server(); return $sitemaps->registry->get_providers(); } function wp_register_sitemap_provider( $name, WP_Sitemaps_Provider $provider ) { $sitemaps = wp_sitemaps_get_server(); return $sitemaps->registry->add_provider( $name, $provider ); } function wp_sitemaps_get_max_urls( $object_type ) { return apply_filters( 'wp_sitemaps_max_urls', 2000, $object_type ); } function get_sitemap_url( $name, $subtype_name = '', $page = 1 ) { $sitemaps = wp_sitemaps_get_server(); if ( ! $sitemaps ) { return false; } if ( 'index' === $name ) { return $sitemaps->index->get_index_url(); } $provider = $sitemaps->registry->get_provider( $name ); if ( ! $provider ) { return false; } if ( $subtype_name && ! in_array( $subtype_name, array_keys( $provider->get_object_subtypes() ), true ) ) { return false; } $page = absint( $page ); if ( 0 >= $page ) { $page = 1; } return $provider->get_sitemap_url( $subtype_name, $page ); } <?php @@ -32590,7 +35277,7 @@ if ( is_singular() ) { wp_enqueue_script( 'comment-reply' ); } ?> }() ); </script> <?php -} function wp_enable_block_templates() { if ( wp_is_block_theme() || WP_Theme_JSON_Resolver::theme_has_support() ) { add_theme_support( 'block-templates' ); } } { +} function wp_enable_block_templates() { if ( wp_is_block_theme() || wp_theme_has_theme_json() ) { add_theme_support( 'block-templates' ); } } { "version": 2, "settings": { "appearanceTools": false, @@ -33154,7 +35841,7 @@ Regards, All at ###SITENAME### ###SITEURL###' ); $content = apply_filters( 'user_request_action_email_content', $content, $email_data ); $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content ); $content = str_replace( '###CONFIRM_URL###', sanitize_url( $email_data['confirm_url'] ), $content ); $content = str_replace( '###EMAIL###', $email_data['email'], $content ); $content = str_replace( '###SITENAME###', $email_data['sitename'], $content ); $content = str_replace( '###SITEURL###', sanitize_url( $email_data['siteurl'] ), $content ); $headers = ''; $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data ); $email_sent = wp_mail( $email_data['email'], $subject, $content, $headers ); if ( $switched_locale ) { restore_previous_locale(); } if ( ! $email_sent ) { return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export confirmation email.' ) ); } return true; } function wp_generate_user_request_key( $request_id ) { global $wp_hasher; $key = wp_generate_password( 20, false ); if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } wp_update_post( array( 'ID' => $request_id, 'post_status' => 'request-pending', 'post_password' => $wp_hasher->HashPassword( $key ), ) ); return $key; } function wp_validate_user_request_key( $request_id, $key ) { global $wp_hasher; $request_id = absint( $request_id ); $request = wp_get_user_request( $request_id ); $saved_key = $request->confirm_key; $key_request_time = $request->modified_timestamp; if ( ! $request || ! $saved_key || ! $key_request_time ) { return new WP_Error( 'invalid_request', __( 'Invalid personal data request.' ) ); } if ( ! in_array( $request->status, array( 'request-pending', 'request-failed' ), true ) ) { return new WP_Error( 'expired_request', __( 'This personal data request has expired.' ) ); } if ( empty( $key ) ) { return new WP_Error( 'missing_key', __( 'The confirmation key is missing from this personal data request.' ) ); } if ( empty( $wp_hasher ) ) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash( 8, true ); } $expiration_duration = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS ); $expiration_time = $key_request_time + $expiration_duration; if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) { return new WP_Error( 'invalid_key', __( 'The confirmation key is invalid for this personal data request.' ) ); } if ( ! $expiration_time || time() > $expiration_time ) { return new WP_Error( 'expired_key', __( 'The confirmation key has expired for this personal data request.' ) ); } return true; } function wp_get_user_request( $request_id ) { $request_id = absint( $request_id ); $post = get_post( $request_id ); if ( ! $post || 'user_request' !== $post->post_type ) { return false; } return new WP_User_Request( $post ); } function wp_is_application_passwords_supported() { return is_ssl() || 'local' === wp_get_environment_type(); } function wp_is_application_passwords_available() { return apply_filters( 'wp_is_application_passwords_available', wp_is_application_passwords_supported() ); } function wp_is_application_passwords_available_for_user( $user ) { if ( ! wp_is_application_passwords_available() ) { return false; } if ( ! is_object( $user ) ) { $user = get_userdata( $user ); } if ( ! $user || ! $user->exists() ) { return false; } return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user ); } function wp_register_persisted_preferences_meta() { global $wpdb; $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences'; register_meta( 'user', $meta_key, array( 'type' => 'object', 'single' => true, 'show_in_rest' => array( 'name' => 'persisted_preferences', 'type' => 'object', 'schema' => array( 'type' => 'object', 'context' => array( 'edit' ), 'properties' => array( '_modified' => array( 'description' => __( 'The date and time the preferences were updated.' ), 'type' => 'string', 'format' => 'date-time', 'readonly' => false, ), ), 'additionalProperties' => true, ), ), ) ); } <?php global $pagenow, $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE, $is_edge, $is_apache, $is_IIS, $is_iis7, $is_nginx; if ( is_admin() ) { if ( is_network_admin() ) { preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } elseif ( is_user_admin() ) { preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } else { preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } $pagenow = ! empty( $self_matches[1] ) ? $self_matches[1] : ''; $pagenow = trim( $pagenow, '/' ); $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { $pagenow = 'index.php'; } else { preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); $pagenow = strtolower( $self_matches[1] ); if ( '.php' !== substr( $pagenow, -4, 4 ) ) { $pagenow .= '.php'; } } } else { if ( preg_match( '#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches ) ) { $pagenow = strtolower( $self_matches[1] ); } else { $pagenow = 'index.php'; } } unset( $self_matches ); $is_lynx = false; $is_gecko = false; $is_winIE = false; $is_macIE = false; $is_opera = false; $is_NS4 = false; $is_safari = false; $is_chrome = false; $is_iphone = false; $is_edge = false; if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) { $is_lynx = true; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Edg' ) !== false ) { $is_edge = true; } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) { if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { $is_admin = is_admin(); $is_chrome = apply_filters( 'use_google_chrome_frame', $is_admin ); if ( $is_chrome ) { header( 'X-UA-Compatible: chrome=1' ); } $is_winIE = ! $is_chrome; } else { $is_chrome = true; } } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'safari' ) !== false ) { $is_safari = true; } elseif ( ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) !== false ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Win' ) !== false ) { $is_winIE = true; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mac' ) !== false ) { $is_macIE = true; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Gecko' ) !== false ) { $is_gecko = true; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) !== false ) { $is_opera = true; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Nav' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.' ) !== false ) { $is_NS4 = true; } } if ( $is_safari && stripos( $_SERVER['HTTP_USER_AGENT'], 'mobile' ) !== false ) { $is_iphone = true; } $is_IE = ( $is_macIE || $is_winIE ); $is_apache = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false ); $is_nginx = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) !== false ); $is_IIS = ! $is_apache && ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) !== false ); $is_iis7 = $is_IIS && (int) substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/' ) + 14 ) >= 7; function wp_is_mobile() { if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { $is_mobile = false; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Android' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' ) !== false ) { $is_mobile = true; } else { $is_mobile = false; } return apply_filters( 'wp_is_mobile', $is_mobile ); } <?php - $wp_version = '6.2-alpha-55026'; $wp_db_version = 53496; $tinymce_version = '49110-20201110'; $required_php_version = '5.6.20'; $required_mysql_version = '5.0'; <?php + $wp_version = '6.2-alpha-55160'; $wp_db_version = 53496; $tinymce_version = '49110-20201110'; $required_php_version = '5.6.20'; $required_mysql_version = '5.0'; <?php global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; $wp_registered_sidebars = array(); $wp_registered_widgets = array(); $wp_registered_widget_controls = array(); $wp_registered_widget_updates = array(); $_wp_sidebars_widgets = array(); $GLOBALS['_wp_deprecated_widgets_callbacks'] = array( 'wp_widget_pages', 'wp_widget_pages_control', 'wp_widget_calendar', 'wp_widget_calendar_control', 'wp_widget_archives', 'wp_widget_archives_control', 'wp_widget_links', 'wp_widget_meta', 'wp_widget_meta_control', 'wp_widget_search', 'wp_widget_recent_entries', 'wp_widget_recent_entries_control', 'wp_widget_tag_cloud', 'wp_widget_tag_cloud_control', 'wp_widget_categories', 'wp_widget_categories_control', 'wp_widget_text', 'wp_widget_text_control', 'wp_widget_rss', 'wp_widget_rss_control', 'wp_widget_recent_comments', 'wp_widget_recent_comments_control', ); function register_widget( $widget ) { global $wp_widget_factory; $wp_widget_factory->register( $widget ); } function unregister_widget( $widget ) { global $wp_widget_factory; $wp_widget_factory->unregister( $widget ); } function register_sidebars( $number = 1, $args = array() ) { global $wp_registered_sidebars; $number = (int) $number; if ( is_string( $args ) ) { parse_str( $args, $args ); } for ( $i = 1; $i <= $number; $i++ ) { $_args = $args; if ( $number > 1 ) { if ( isset( $args['name'] ) ) { $_args['name'] = sprintf( $args['name'], $i ); } else { $_args['name'] = sprintf( __( 'Sidebar %d' ), $i ); } } else { $_args['name'] = isset( $args['name'] ) ? $args['name'] : __( 'Sidebar' ); } if ( isset( $args['id'] ) ) { $_args['id'] = $args['id']; $n = 2; while ( is_registered_sidebar( $_args['id'] ) ) { $_args['id'] = $args['id'] . '-' . $n++; } } else { $n = count( $wp_registered_sidebars ); do { $_args['id'] = 'sidebar-' . ++$n; } while ( is_registered_sidebar( $_args['id'] ) ); } register_sidebar( $_args ); } } function register_sidebar( $args = array() ) { global $wp_registered_sidebars; $i = count( $wp_registered_sidebars ) + 1; $id_is_empty = empty( $args['id'] ); $defaults = array( 'name' => sprintf( __( 'Sidebar %d' ), $i ), 'id' => "sidebar-$i", 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h2 class="widgettitle">', 'after_title' => "</h2>\n", 'before_sidebar' => '', 'after_sidebar' => '', 'show_in_rest' => false, ); $sidebar = wp_parse_args( $args, apply_filters( 'register_sidebar_defaults', $defaults ) ); if ( $id_is_empty ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ), '<code>id</code>', $sidebar['name'], $sidebar['id'] ), '4.2.0' ); } $wp_registered_sidebars[ $sidebar['id'] ] = $sidebar; add_theme_support( 'widgets' ); do_action( 'register_sidebar', $sidebar ); return $sidebar['id']; } function unregister_sidebar( $sidebar_id ) { global $wp_registered_sidebars; unset( $wp_registered_sidebars[ $sidebar_id ] ); } function is_registered_sidebar( $sidebar_id ) { global $wp_registered_sidebars; return isset( $wp_registered_sidebars[ $sidebar_id ] ); } function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array(), ...$params ) { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks; $id = strtolower( $id ); if ( empty( $output_callback ) ) { unset( $wp_registered_widgets[ $id ] ); return; } $id_base = _get_widget_id_base( $id ); if ( in_array( $output_callback, $_wp_deprecated_widgets_callbacks, true ) && ! is_callable( $output_callback ) ) { unset( $wp_registered_widget_controls[ $id ] ); unset( $wp_registered_widget_updates[ $id_base ] ); return; } $defaults = array( 'classname' => $output_callback ); $options = wp_parse_args( $options, $defaults ); $widget = array( 'name' => $name, 'id' => $id, 'callback' => $output_callback, 'params' => $params, ); $widget = array_merge( $widget, $options ); if ( is_callable( $output_callback ) && ( ! isset( $wp_registered_widgets[ $id ] ) || did_action( 'widgets_init' ) ) ) { do_action( 'wp_register_sidebar_widget', $widget ); $wp_registered_widgets[ $id ] = $widget; } } function wp_widget_description( $id ) { if ( ! is_scalar( $id ) ) { return; } global $wp_registered_widgets; if ( isset( $wp_registered_widgets[ $id ]['description'] ) ) { return esc_html( $wp_registered_widgets[ $id ]['description'] ); } } function wp_sidebar_description( $id ) { if ( ! is_scalar( $id ) ) { return; } global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars[ $id ]['description'] ) ) { return wp_kses( $wp_registered_sidebars[ $id ]['description'], 'sidebar_description' ); } } function wp_unregister_sidebar_widget( $id ) { do_action( 'wp_unregister_sidebar_widget', $id ); wp_register_sidebar_widget( $id, '', '' ); wp_unregister_widget_control( $id ); } function wp_register_widget_control( $id, $name, $control_callback, $options = array(), ...$params ) { global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks; $id = strtolower( $id ); $id_base = _get_widget_id_base( $id ); if ( empty( $control_callback ) ) { unset( $wp_registered_widget_controls[ $id ] ); unset( $wp_registered_widget_updates[ $id_base ] ); return; } if ( in_array( $control_callback, $_wp_deprecated_widgets_callbacks, true ) && ! is_callable( $control_callback ) ) { unset( $wp_registered_widgets[ $id ] ); return; } if ( isset( $wp_registered_widget_controls[ $id ] ) && ! did_action( 'widgets_init' ) ) { return; } $defaults = array( 'width' => 250, 'height' => 200, ); $options = wp_parse_args( $options, $defaults ); $options['width'] = (int) $options['width']; $options['height'] = (int) $options['height']; $widget = array( 'name' => $name, 'id' => $id, 'callback' => $control_callback, 'params' => $params, ); $widget = array_merge( $widget, $options ); $wp_registered_widget_controls[ $id ] = $widget; if ( isset( $wp_registered_widget_updates[ $id_base ] ) ) { return; } if ( isset( $widget['params'][0]['number'] ) ) { $widget['params'][0]['number'] = -1; } unset( $widget['width'], $widget['height'], $widget['name'], $widget['id'] ); $wp_registered_widget_updates[ $id_base ] = $widget; } function _register_widget_update_callback( $id_base, $update_callback, $options = array(), ...$params ) { global $wp_registered_widget_updates; if ( isset( $wp_registered_widget_updates[ $id_base ] ) ) { if ( empty( $update_callback ) ) { unset( $wp_registered_widget_updates[ $id_base ] ); } return; } $widget = array( 'callback' => $update_callback, 'params' => $params, ); $widget = array_merge( $widget, $options ); $wp_registered_widget_updates[ $id_base ] = $widget; } function _register_widget_form_callback( $id, $name, $form_callback, $options = array(), ...$params ) { global $wp_registered_widget_controls; $id = strtolower( $id ); if ( empty( $form_callback ) ) { unset( $wp_registered_widget_controls[ $id ] ); return; } if ( isset( $wp_registered_widget_controls[ $id ] ) && ! did_action( 'widgets_init' ) ) { return; } $defaults = array( 'width' => 250, 'height' => 200, ); $options = wp_parse_args( $options, $defaults ); $options['width'] = (int) $options['width']; $options['height'] = (int) $options['height']; $widget = array( 'name' => $name, 'id' => $id, 'callback' => $form_callback, 'params' => $params, ); $widget = array_merge( $widget, $options ); $wp_registered_widget_controls[ $id ] = $widget; } function wp_unregister_widget_control( $id ) { wp_register_widget_control( $id, '', '' ); } function dynamic_sidebar( $index = 1 ) { global $wp_registered_sidebars, $wp_registered_widgets; if ( is_int( $index ) ) { $index = "sidebar-$index"; } else { $index = sanitize_title( $index ); foreach ( (array) $wp_registered_sidebars as $key => $value ) { if ( sanitize_title( $value['name'] ) === $index ) { $index = $key; break; } } } $sidebars_widgets = wp_get_sidebars_widgets(); if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) { do_action( 'dynamic_sidebar_before', $index, false ); do_action( 'dynamic_sidebar_after', $index, false ); return apply_filters( 'dynamic_sidebar_has_widgets', false, $index ); } $sidebar = $wp_registered_sidebars[ $index ]; $sidebar['before_sidebar'] = sprintf( $sidebar['before_sidebar'], $sidebar['id'], $sidebar['class'] ); do_action( 'dynamic_sidebar_before', $index, true ); if ( ! is_admin() && ! empty( $sidebar['before_sidebar'] ) ) { echo $sidebar['before_sidebar']; } $did_one = false; foreach ( (array) $sidebars_widgets[ $index ] as $id ) { if ( ! isset( $wp_registered_widgets[ $id ] ) ) { continue; } $params = array_merge( array( array_merge( $sidebar, array( 'widget_id' => $id, 'widget_name' => $wp_registered_widgets[ $id ]['name'], ) ), ), (array) $wp_registered_widgets[ $id ]['params'] ); $classname_ = ''; foreach ( (array) $wp_registered_widgets[ $id ]['classname'] as $cn ) { if ( is_string( $cn ) ) { $classname_ .= '_' . $cn; } elseif ( is_object( $cn ) ) { $classname_ .= '_' . get_class( $cn ); } } $classname_ = ltrim( $classname_, '_' ); $params[0]['before_widget'] = sprintf( $params[0]['before_widget'], str_replace( '\\', '_', $id ), $classname_ ); $params = apply_filters( 'dynamic_sidebar_params', $params ); $callback = $wp_registered_widgets[ $id ]['callback']; do_action( 'dynamic_sidebar', $wp_registered_widgets[ $id ] ); if ( is_callable( $callback ) ) { call_user_func_array( $callback, $params ); $did_one = true; } } if ( ! is_admin() && ! empty( $sidebar['after_sidebar'] ) ) { echo $sidebar['after_sidebar']; } do_action( 'dynamic_sidebar_after', $index, true ); return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index ); } function is_active_widget( $callback = false, $widget_id = false, $id_base = false, $skip_inactive = true ) { global $wp_registered_widgets; $sidebars_widgets = wp_get_sidebars_widgets(); if ( is_array( $sidebars_widgets ) ) { foreach ( $sidebars_widgets as $sidebar => $widgets ) { if ( $skip_inactive && ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) ) { continue; } if ( is_array( $widgets ) ) { foreach ( $widgets as $widget ) { if ( ( $callback && isset( $wp_registered_widgets[ $widget ]['callback'] ) && $wp_registered_widgets[ $widget ]['callback'] === $callback ) || ( $id_base && _get_widget_id_base( $widget ) === $id_base ) ) { if ( ! $widget_id || $widget_id === $wp_registered_widgets[ $widget ]['id'] ) { return $sidebar; } } } } } } return false; } function is_dynamic_sidebar() { global $wp_registered_widgets, $wp_registered_sidebars; $sidebars_widgets = get_option( 'sidebars_widgets' ); foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) { if ( ! empty( $sidebars_widgets[ $index ] ) ) { foreach ( (array) $sidebars_widgets[ $index ] as $widget ) { if ( array_key_exists( $widget, $wp_registered_widgets ) ) { return true; } } } } return false; } function is_active_sidebar( $index ) { $index = ( is_int( $index ) ) ? "sidebar-$index" : sanitize_title( $index ); $sidebars_widgets = wp_get_sidebars_widgets(); $is_active_sidebar = ! empty( $sidebars_widgets[ $index ] ); return apply_filters( 'is_active_sidebar', $is_active_sidebar, $index ); } function wp_get_sidebars_widgets( $deprecated = true ) { if ( true !== $deprecated ) { _deprecated_argument( __FUNCTION__, '2.8.1' ); } global $_wp_sidebars_widgets, $sidebars_widgets; if ( ! is_admin() ) { if ( empty( $_wp_sidebars_widgets ) ) { $_wp_sidebars_widgets = get_option( 'sidebars_widgets', array() ); } $sidebars_widgets = $_wp_sidebars_widgets; } else { $sidebars_widgets = get_option( 'sidebars_widgets', array() ); } if ( is_array( $sidebars_widgets ) && isset( $sidebars_widgets['array_version'] ) ) { unset( $sidebars_widgets['array_version'] ); } return apply_filters( 'sidebars_widgets', $sidebars_widgets ); } function wp_get_sidebar( $id ) { global $wp_registered_sidebars; foreach ( (array) $wp_registered_sidebars as $sidebar ) { if ( $sidebar['id'] === $id ) { return $sidebar; } } if ( 'wp_inactive_widgets' === $id ) { return array( 'id' => 'wp_inactive_widgets', 'name' => __( 'Inactive widgets' ), ); } return null; } function wp_set_sidebars_widgets( $sidebars_widgets ) { global $_wp_sidebars_widgets; $_wp_sidebars_widgets = null; if ( ! isset( $sidebars_widgets['array_version'] ) ) { $sidebars_widgets['array_version'] = 3; } update_option( 'sidebars_widgets', $sidebars_widgets ); } function wp_get_widget_defaults() { global $wp_registered_sidebars; $defaults = array(); foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) { $defaults[ $index ] = array(); } return $defaults; } function wp_convert_widget_settings( $base_name, $option_name, $settings ) { $single = false; $changed = false; if ( empty( $settings ) ) { $single = true; } else { foreach ( array_keys( $settings ) as $number ) { if ( 'number' === $number ) { continue; } if ( ! is_numeric( $number ) ) { $single = true; break; } } } if ( $single ) { $settings = array( 2 => $settings ); if ( is_admin() ) { $sidebars_widgets = get_option( 'sidebars_widgets' ); } else { if ( empty( $GLOBALS['_wp_sidebars_widgets'] ) ) { $GLOBALS['_wp_sidebars_widgets'] = get_option( 'sidebars_widgets', array() ); } $sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets']; } foreach ( (array) $sidebars_widgets as $index => $sidebar ) { if ( is_array( $sidebar ) ) { foreach ( $sidebar as $i => $name ) { if ( $base_name === $name ) { $sidebars_widgets[ $index ][ $i ] = "$name-2"; $changed = true; break 2; } } } } if ( is_admin() && $changed ) { update_option( 'sidebars_widgets', $sidebars_widgets ); } } $settings['_multiwidget'] = 1; if ( is_admin() ) { update_option( $option_name, $settings ); } return $settings; } function the_widget( $widget, $instance = array(), $args = array() ) { global $wp_widget_factory; if ( ! isset( $wp_widget_factory->widgets[ $widget ] ) ) { _doing_it_wrong( __FUNCTION__, sprintf( __( 'Widgets need to be registered using %s, before they can be displayed.' ), '<code>register_widget()</code>' ), '4.9.0' ); return; } $widget_obj = $wp_widget_factory->widgets[ $widget ]; if ( ! ( $widget_obj instanceof WP_Widget ) ) { return; } $default_args = array( 'before_widget' => '<div class="widget %s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', ); $args = wp_parse_args( $args, $default_args ); $args['before_widget'] = sprintf( $args['before_widget'], $widget_obj->widget_options['classname'] ); $instance = wp_parse_args( $instance ); $instance = apply_filters( 'widget_display_callback', $instance, $widget_obj, $args ); if ( false === $instance ) { return; } do_action( 'the_widget', $widget, $instance, $args ); $widget_obj->_set( -1 ); $widget_obj->widget( $args, $instance ); } function _get_widget_id_base( $id ) { return preg_replace( '/-[0-9]+$/', '', $id ); } function _wp_sidebars_changed() { global $sidebars_widgets; if ( ! is_array( $sidebars_widgets ) ) { $sidebars_widgets = wp_get_sidebars_widgets(); } retrieve_widgets( true ); } function retrieve_widgets( $theme_changed = false ) { global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; $registered_sidebars_keys = array_keys( $wp_registered_sidebars ); $registered_widgets_ids = array_keys( $wp_registered_widgets ); if ( ! is_array( get_theme_mod( 'sidebars_widgets' ) ) ) { if ( empty( $sidebars_widgets ) ) { return array(); } unset( $sidebars_widgets['array_version'] ); $sidebars_widgets_keys = array_keys( $sidebars_widgets ); sort( $sidebars_widgets_keys ); sort( $registered_sidebars_keys ); if ( $sidebars_widgets_keys === $registered_sidebars_keys ) { $sidebars_widgets = _wp_remove_unregistered_widgets( $sidebars_widgets, $registered_widgets_ids ); return $sidebars_widgets; } } $sidebars_widgets = _wp_remove_unregistered_widgets( $sidebars_widgets, $registered_widgets_ids ); $sidebars_widgets = wp_map_sidebars_widgets( $sidebars_widgets ); $shown_widgets = array_merge( ...array_values( $sidebars_widgets ) ); $lost_widgets = array_diff( $registered_widgets_ids, $shown_widgets ); foreach ( $lost_widgets as $key => $widget_id ) { $number = preg_replace( '/.+?-([0-9]+)$/', '$1', $widget_id ); if ( is_numeric( $number ) && (int) $number < 2 ) { unset( $lost_widgets[ $key ] ); } } $sidebars_widgets['wp_inactive_widgets'] = array_merge( $lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets'] ); if ( 'customize' !== $theme_changed ) { wp_set_sidebars_widgets( $sidebars_widgets ); } return $sidebars_widgets; } function wp_map_sidebars_widgets( $existing_sidebars_widgets ) { global $wp_registered_sidebars; $new_sidebars_widgets = array( 'wp_inactive_widgets' => array(), ); if ( ! is_array( $existing_sidebars_widgets ) || empty( $existing_sidebars_widgets ) ) { return $new_sidebars_widgets; } foreach ( $existing_sidebars_widgets as $sidebar => $widgets ) { if ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) { $new_sidebars_widgets['wp_inactive_widgets'] = array_merge( $new_sidebars_widgets['wp_inactive_widgets'], (array) $widgets ); unset( $existing_sidebars_widgets[ $sidebar ] ); } } if ( 1 === count( $existing_sidebars_widgets ) && 1 === count( $wp_registered_sidebars ) ) { $new_sidebars_widgets[ key( $wp_registered_sidebars ) ] = array_pop( $existing_sidebars_widgets ); return $new_sidebars_widgets; } $existing_sidebars = array_keys( $existing_sidebars_widgets ); foreach ( $wp_registered_sidebars as $sidebar => $name ) { if ( in_array( $sidebar, $existing_sidebars, true ) ) { $new_sidebars_widgets[ $sidebar ] = $existing_sidebars_widgets[ $sidebar ]; unset( $existing_sidebars_widgets[ $sidebar ] ); } elseif ( ! array_key_exists( $sidebar, $new_sidebars_widgets ) ) { $new_sidebars_widgets[ $sidebar ] = array(); } } if ( ! empty( $existing_sidebars_widgets ) ) { $common_slug_groups = array( array( 'sidebar', 'primary', 'main', 'right' ), array( 'second', 'left' ), array( 'sidebar-2', 'footer', 'bottom' ), array( 'header', 'top' ), ); foreach ( $common_slug_groups as $slug_group ) { foreach ( $slug_group as $slug ) { foreach ( $wp_registered_sidebars as $new_sidebar => $args ) { if ( false === stripos( $new_sidebar, $slug ) && false === stripos( $slug, $new_sidebar ) ) { continue; } foreach ( $existing_sidebars_widgets as $sidebar => $widgets ) { foreach ( $slug_group as $slug ) { if ( false === stripos( $sidebar, $slug ) && false === stripos( $slug, $sidebar ) ) { continue; } if ( ! empty( $existing_sidebars_widgets[ $sidebar ] ) ) { $new_sidebars_widgets[ $new_sidebar ] = array_merge( $new_sidebars_widgets[ $new_sidebar ], $existing_sidebars_widgets[ $sidebar ] ); unset( $existing_sidebars_widgets[ $sidebar ] ); continue 3; } } } } } } } foreach ( $existing_sidebars_widgets as $widgets ) { if ( is_array( $widgets ) && ! empty( $widgets ) ) { $new_sidebars_widgets['wp_inactive_widgets'] = array_merge( $new_sidebars_widgets['wp_inactive_widgets'], $widgets ); } } $old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' ); $old_sidebars_widgets = isset( $old_sidebars_widgets['data'] ) ? $old_sidebars_widgets['data'] : false; if ( is_array( $old_sidebars_widgets ) ) { $old_sidebars_widgets = array_filter( $old_sidebars_widgets ); foreach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ) { if ( array_key_exists( $new_sidebar, $old_sidebars_widgets ) && ! empty( $new_widgets ) ) { unset( $old_sidebars_widgets[ $new_sidebar ] ); } } foreach ( $old_sidebars_widgets as $sidebar => $widgets ) { if ( 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) { unset( $old_sidebars_widgets[ $sidebar ] ); } } $old_sidebars_widgets = _wp_remove_unregistered_widgets( $old_sidebars_widgets ); if ( ! empty( $old_sidebars_widgets ) ) { foreach ( $old_sidebars_widgets as $old_sidebar => $old_widgets ) { foreach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ) { foreach ( $old_widgets as $key => $widget_id ) { $active_key = array_search( $widget_id, $new_widgets, true ); if ( false !== $active_key ) { if ( 'wp_inactive_widgets' === $new_sidebar ) { unset( $new_sidebars_widgets['wp_inactive_widgets'][ $active_key ] ); } else { unset( $old_sidebars_widgets[ $old_sidebar ][ $key ] ); } } } } } } $new_sidebars_widgets = array_merge( $new_sidebars_widgets, $old_sidebars_widgets ); } return $new_sidebars_widgets; } function _wp_remove_unregistered_widgets( $sidebars_widgets, $allowed_widget_ids = array() ) { if ( empty( $allowed_widget_ids ) ) { $allowed_widget_ids = array_keys( $GLOBALS['wp_registered_widgets'] ); } foreach ( $sidebars_widgets as $sidebar => $widgets ) { if ( is_array( $widgets ) ) { $sidebars_widgets[ $sidebar ] = array_intersect( $widgets, $allowed_widget_ids ); } } return $sidebars_widgets; } function wp_widget_rss_output( $rss, $args = array() ) { if ( is_string( $rss ) ) { $rss = fetch_feed( $rss ); } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) { $args = $rss; $rss = fetch_feed( $rss['url'] ); } elseif ( ! is_object( $rss ) ) { return; } if ( is_wp_error( $rss ) ) { if ( is_admin() || current_user_can( 'manage_options' ) ) { echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</p>'; } return; } $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0, ); $args = wp_parse_args( $args, $default_args ); $items = (int) $args['items']; if ( $items < 1 || 20 < $items ) { $items = 10; } $show_summary = (int) $args['show_summary']; $show_author = (int) $args['show_author']; $show_date = (int) $args['show_date']; if ( ! $rss->get_item_quantity() ) { echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; $rss->__destruct(); unset( $rss ); return; } echo '<ul>'; foreach ( $rss->get_items( 0, $items ) as $item ) { $link = $item->get_link(); while ( ! empty( $link ) && stristr( $link, 'http' ) !== $link ) { $link = substr( $link, 1 ); } $link = esc_url( strip_tags( $link ) ); $title = esc_html( trim( strip_tags( $item->get_title() ) ) ); if ( empty( $title ) ) { $title = __( 'Untitled' ); } $desc = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ); $desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) ); $summary = ''; if ( $show_summary ) { $summary = $desc; if ( '[...]' === substr( $summary, -5 ) ) { $summary = substr( $summary, 0, -5 ) . '[…]'; } $summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>'; } $date = ''; if ( $show_date ) { $date = $item->get_date( 'U' ); if ( $date ) { $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>'; } } $author = ''; if ( $show_author ) { $author = $item->get_author(); if ( is_object( $author ) ) { $author = $author->get_name(); $author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>'; } } if ( '' === $link ) { echo "<li>$title{$date}{$summary}{$author}</li>"; } elseif ( $show_summary ) { echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>"; } else { echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$author}</li>"; } } echo '</ul>'; $rss->__destruct(); unset( $rss ); } function wp_widget_rss_form( $args, $inputs = null ) { $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true, ); $inputs = wp_parse_args( $inputs, $default_inputs ); $args['title'] = isset( $args['title'] ) ? $args['title'] : ''; $args['url'] = isset( $args['url'] ) ? $args['url'] : ''; $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0; if ( $args['items'] < 1 || 20 < $args['items'] ) { $args['items'] = 10; } $args['show_summary'] = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary']; $args['show_author'] = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author']; $args['show_date'] = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date']; if ( ! empty( $args['error'] ) ) { echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $args['error'] ) . '</p>'; } $esc_number = esc_attr( $args['number'] ); if ( $inputs['url'] ) : ?> <p><label for="rss-url-<?php echo $esc_number; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label> <input class="widefat" id="rss-url-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][url]" type="text" value="<?php echo esc_url( $args['url'] ); ?>" /></p> @@ -34030,7 +36717,7 @@ endforeach; ?> </p> <div class="wp-pwd"> - <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="new-password" aria-describedby="pass-strength-result" /> + <input type="password" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" aria-describedby="pass-strength-result" /> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> <span class="dashicons dashicons-hidden" aria-hidden="true"></span> @@ -34045,7 +36732,7 @@ endforeach; ?> <p class="user-pass2-wrap"> <label for="pass2"><?php _e( 'Confirm new password' ); ?></label> - <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="new-password" /> + <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="new-password" spellcheck="false" /> </p> <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> @@ -34114,7 +36801,7 @@ endforeach; ?> <div class="user-pass-wrap"> <label for="user_pass"><?php _e( 'Password' ); ?></label> <div class="wp-pwd"> - <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby; ?> class="input password-input" value="" size="20" autocomplete="current-password" /> + <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby; ?> class="input password-input" value="" size="20" autocomplete="current-password" spellcheck="false" /> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Show password' ); ?>"> <span class="dashicons dashicons-visibility" aria-hidden="true"></span> </button> @@ -34169,7 +36856,7 @@ endforeach; ?> <?php } login_footer(); break; } <?php require __DIR__ . '/wp-load.php'; if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) { wp_die( __( 'This action has been disabled by the administrator.' ), 403 ); } $mailserver_url = get_option( 'mailserver_url' ); if ( 'mail.example.com' === $mailserver_url || empty( $mailserver_url ) ) { wp_die( __( 'This action has been disabled by the administrator.' ), 403 ); } do_action( 'wp-mail.php' ); require_once ABSPATH . WPINC . '/class-pop3.php'; if ( ! defined( 'WP_MAIL_INTERVAL' ) ) { define( 'WP_MAIL_INTERVAL', 5 * MINUTE_IN_SECONDS ); } $last_checked = get_transient( 'mailserver_last_checked' ); if ( $last_checked ) { wp_die( __( 'Slow down cowboy, no need to check for new mails so often!' ) ); } set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL ); $time_difference = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; $phone_delim = '::'; $pop3 = new POP3(); if ( ! $pop3->connect( get_option( 'mailserver_url' ), get_option( 'mailserver_port' ) ) || ! $pop3->user( get_option( 'mailserver_login' ) ) ) { wp_die( esc_html( $pop3->ERROR ) ); } $count = $pop3->pass( get_option( 'mailserver_pass' ) ); if ( false === $count ) { wp_die( esc_html( $pop3->ERROR ) ); } if ( 0 === $count ) { $pop3->quit(); wp_die( __( 'There does not seem to be any new mail.' ) ); } wp_set_current_user( 0 ); for ( $i = 1; $i <= $count; $i++ ) { $message = $pop3->get( $i ); $bodysignal = false; $boundary = ''; $charset = ''; $content = ''; $content_type = ''; $content_transfer_encoding = ''; $post_author = 1; $author_found = false; $post_date = null; $post_date_gmt = null; foreach ( $message as $line ) { if ( strlen( $line ) < 3 ) { $bodysignal = true; } if ( $bodysignal ) { $content .= $line; } else { if ( preg_match( '/Content-Type: /i', $line ) ) { $content_type = trim( $line ); $content_type = substr( $content_type, 14, strlen( $content_type ) - 14 ); $content_type = explode( ';', $content_type ); if ( ! empty( $content_type[1] ) ) { $charset = explode( '=', $content_type[1] ); $charset = ( ! empty( $charset[1] ) ) ? trim( $charset[1] ) : ''; } $content_type = $content_type[0]; } if ( preg_match( '/Content-Transfer-Encoding: /i', $line ) ) { $content_transfer_encoding = trim( $line ); $content_transfer_encoding = substr( $content_transfer_encoding, 27, strlen( $content_transfer_encoding ) - 27 ); $content_transfer_encoding = explode( ';', $content_transfer_encoding ); $content_transfer_encoding = $content_transfer_encoding[0]; } if ( ( 'multipart/alternative' === $content_type ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' === $boundary ) ) { $boundary = trim( $line ); $boundary = explode( '"', $boundary ); $boundary = $boundary[1]; } if ( preg_match( '/Subject: /i', $line ) ) { $subject = trim( $line ); $subject = substr( $subject, 9, strlen( $subject ) - 9 ); if ( function_exists( 'iconv_mime_decode' ) ) { $subject = iconv_mime_decode( $subject, 2, get_option( 'blog_charset' ) ); } else { $subject = wp_iso_descrambler( $subject ); } $subject = explode( $phone_delim, $subject ); $subject = $subject[0]; } if ( ! $author_found && preg_match( '/^(From|Reply-To): /', $line ) ) { if ( preg_match( '|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches ) ) { $author = $matches[0]; } else { $author = trim( $line ); } $author = sanitize_email( $author ); if ( is_email( $author ) ) { $userdata = get_user_by( 'email', $author ); if ( ! empty( $userdata ) ) { $post_author = $userdata->ID; $author_found = true; } } } if ( preg_match( '/Date: /i', $line ) ) { $ddate = str_replace( 'Date: ', '', trim( $line ) ); $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); $ddate_timestamp = strtotime( $ddate ); $post_date = gmdate( 'Y-m-d H:i:s', $ddate_timestamp + $time_difference ); $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_timestamp ); } } } if ( $author_found ) { $user = new WP_User( $post_author ); $post_status = ( $user->has_cap( 'publish_posts' ) ) ? 'publish' : 'pending'; } else { $post_status = 'pending'; } $subject = trim( $subject ); if ( 'multipart/alternative' === $content_type ) { $content = explode( '--' . $boundary, $content ); $content = $content[2]; if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim ) ) { $content = explode( $delim[0], $content ); $content = $content[1]; } $content = strip_tags( $content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>' ); } $content = trim( $content ); $content = apply_filters( 'wp_mail_original_content', $content ); if ( false !== stripos( $content_transfer_encoding, 'quoted-printable' ) ) { $content = quoted_printable_decode( $content ); } if ( function_exists( 'iconv' ) && ! empty( $charset ) ) { $content = iconv( $charset, get_option( 'blog_charset' ), $content ); } $content = explode( $phone_delim, $content ); $content = empty( $content[1] ) ? $content[0] : $content[1]; $content = trim( $content ); $post_content = apply_filters( 'phone_content', $content ); $post_title = xmlrpc_getposttitle( $content ); if ( '' === trim( $post_title ) ) { $post_title = $subject; } $post_category = array( get_option( 'default_email_category' ) ); $post_data = compact( 'post_content', 'post_title', 'post_date', 'post_date_gmt', 'post_author', 'post_category', 'post_status' ); $post_data = wp_slash( $post_data ); $post_ID = wp_insert_post( $post_data ); if ( is_wp_error( $post_ID ) ) { echo "\n" . $post_ID->get_error_message(); } if ( empty( $post_ID ) ) { continue; } do_action( 'publish_phone', $post_ID ); echo "\n<p><strong>" . __( 'Author:' ) . '</strong> ' . esc_html( $post_author ) . '</p>'; echo "\n<p><strong>" . __( 'Posted title:' ) . '</strong> ' . esc_html( $post_title ) . '</p>'; if ( ! $pop3->delete( $i ) ) { echo '<p>' . sprintf( __( 'Oops: %s' ), esc_html( $pop3->ERROR ) ) . '</p>'; $pop3->reset(); exit; } else { echo '<p>' . sprintf( __( 'Mission complete. Message %s deleted.' ), '<strong>' . $i . '</strong>' ) . '</p>'; } } $pop3->quit(); <?php - define( 'WPINC', 'wp-includes' ); global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package; require ABSPATH . WPINC . '/version.php'; require ABSPATH . WPINC . '/load.php'; wp_check_php_mysql_versions(); require ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php'; require ABSPATH . WPINC . '/class-wp-fatal-error-handler.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-cookie-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-key-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-link-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-email-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode.php'; require ABSPATH . WPINC . '/error-protection.php'; require ABSPATH . WPINC . '/default-constants.php'; require_once ABSPATH . WPINC . '/plugin.php'; global $blog_id; wp_initial_constants(); wp_register_fatal_error_handler(); date_default_timezone_set( 'UTC' ); wp_fix_server_vars(); wp_maintenance(); timer_start(); wp_debug_mode(); if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) { include WP_CONTENT_DIR . '/advanced-cache.php'; if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } } wp_set_lang_dir(); require ABSPATH . WPINC . '/compat.php'; require ABSPATH . WPINC . '/class-wp-list-util.php'; require ABSPATH . WPINC . '/formatting.php'; require ABSPATH . WPINC . '/meta.php'; require ABSPATH . WPINC . '/functions.php'; require ABSPATH . WPINC . '/class-wp-meta-query.php'; require ABSPATH . WPINC . '/class-wp-matchesmapregex.php'; require ABSPATH . WPINC . '/class-wp.php'; require ABSPATH . WPINC . '/class-wp-error.php'; require ABSPATH . WPINC . '/pomo/mo.php'; global $wpdb; require_wp_db(); $GLOBALS['table_prefix'] = $table_prefix; wp_set_wpdb_vars(); wp_start_object_cache(); require ABSPATH . WPINC . '/default-filters.php'; if ( is_multisite() ) { require ABSPATH . WPINC . '/class-wp-site-query.php'; require ABSPATH . WPINC . '/class-wp-network-query.php'; require ABSPATH . WPINC . '/ms-blogs.php'; require ABSPATH . WPINC . '/ms-settings.php'; } elseif ( ! defined( 'MULTISITE' ) ) { define( 'MULTISITE', false ); } register_shutdown_function( 'shutdown_action_hook' ); if ( SHORTINIT ) { return false; } require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; wp_not_installed(); require ABSPATH . WPINC . '/class-wp-walker.php'; require ABSPATH . WPINC . '/class-wp-ajax-response.php'; require ABSPATH . WPINC . '/capabilities.php'; require ABSPATH . WPINC . '/class-wp-roles.php'; require ABSPATH . WPINC . '/class-wp-role.php'; require ABSPATH . WPINC . '/class-wp-user.php'; require ABSPATH . WPINC . '/class-wp-query.php'; require ABSPATH . WPINC . '/query.php'; require ABSPATH . WPINC . '/class-wp-date-query.php'; require ABSPATH . WPINC . '/theme.php'; require ABSPATH . WPINC . '/class-wp-theme.php'; require ABSPATH . WPINC . '/class-wp-theme-json-schema.php'; require ABSPATH . WPINC . '/class-wp-theme-json-data.php'; require ABSPATH . WPINC . '/class-wp-theme-json.php'; require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php'; require ABSPATH . WPINC . '/global-styles-and-settings.php'; require ABSPATH . WPINC . '/class-wp-block-template.php'; require ABSPATH . WPINC . '/block-template-utils.php'; require ABSPATH . WPINC . '/block-template.php'; require ABSPATH . WPINC . '/theme-templates.php'; require ABSPATH . WPINC . '/template.php'; require ABSPATH . WPINC . '/https-detection.php'; require ABSPATH . WPINC . '/https-migration.php'; require ABSPATH . WPINC . '/class-wp-user-request.php'; require ABSPATH . WPINC . '/user.php'; require ABSPATH . WPINC . '/class-wp-user-query.php'; require ABSPATH . WPINC . '/class-wp-session-tokens.php'; require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php'; require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php'; require ABSPATH . WPINC . '/general-template.php'; require ABSPATH . WPINC . '/link-template.php'; require ABSPATH . WPINC . '/author-template.php'; require ABSPATH . WPINC . '/robots-template.php'; require ABSPATH . WPINC . '/post.php'; require ABSPATH . WPINC . '/class-walker-page.php'; require ABSPATH . WPINC . '/class-walker-page-dropdown.php'; require ABSPATH . WPINC . '/class-wp-post-type.php'; require ABSPATH . WPINC . '/class-wp-post.php'; require ABSPATH . WPINC . '/post-template.php'; require ABSPATH . WPINC . '/revision.php'; require ABSPATH . WPINC . '/post-formats.php'; require ABSPATH . WPINC . '/post-thumbnail-template.php'; require ABSPATH . WPINC . '/category.php'; require ABSPATH . WPINC . '/class-walker-category.php'; require ABSPATH . WPINC . '/class-walker-category-dropdown.php'; require ABSPATH . WPINC . '/category-template.php'; require ABSPATH . WPINC . '/comment.php'; require ABSPATH . WPINC . '/class-wp-comment.php'; require ABSPATH . WPINC . '/class-wp-comment-query.php'; require ABSPATH . WPINC . '/class-walker-comment.php'; require ABSPATH . WPINC . '/comment-template.php'; require ABSPATH . WPINC . '/rewrite.php'; require ABSPATH . WPINC . '/class-wp-rewrite.php'; require ABSPATH . WPINC . '/feed.php'; require ABSPATH . WPINC . '/bookmark.php'; require ABSPATH . WPINC . '/bookmark-template.php'; require ABSPATH . WPINC . '/kses.php'; require ABSPATH . WPINC . '/cron.php'; require ABSPATH . WPINC . '/deprecated.php'; require ABSPATH . WPINC . '/script-loader.php'; require ABSPATH . WPINC . '/taxonomy.php'; require ABSPATH . WPINC . '/class-wp-taxonomy.php'; require ABSPATH . WPINC . '/class-wp-term.php'; require ABSPATH . WPINC . '/class-wp-term-query.php'; require ABSPATH . WPINC . '/class-wp-tax-query.php'; require ABSPATH . WPINC . '/update.php'; require ABSPATH . WPINC . '/canonical.php'; require ABSPATH . WPINC . '/shortcodes.php'; require ABSPATH . WPINC . '/embed.php'; require ABSPATH . WPINC . '/class-wp-embed.php'; require ABSPATH . WPINC . '/class-wp-oembed.php'; require ABSPATH . WPINC . '/class-wp-oembed-controller.php'; require ABSPATH . WPINC . '/media.php'; require ABSPATH . WPINC . '/http.php'; require ABSPATH . WPINC . '/class-wp-http.php'; require ABSPATH . WPINC . '/class-wp-http-streams.php'; require ABSPATH . WPINC . '/class-wp-http-curl.php'; require ABSPATH . WPINC . '/class-wp-http-proxy.php'; require ABSPATH . WPINC . '/class-wp-http-cookie.php'; require ABSPATH . WPINC . '/class-wp-http-encoding.php'; require ABSPATH . WPINC . '/class-wp-http-response.php'; require ABSPATH . WPINC . '/class-wp-http-requests-response.php'; require ABSPATH . WPINC . '/class-wp-http-requests-hooks.php'; require ABSPATH . WPINC . '/widgets.php'; require ABSPATH . WPINC . '/class-wp-widget.php'; require ABSPATH . WPINC . '/class-wp-widget-factory.php'; require ABSPATH . WPINC . '/nav-menu-template.php'; require ABSPATH . WPINC . '/nav-menu.php'; require ABSPATH . WPINC . '/admin-bar.php'; require ABSPATH . WPINC . '/class-wp-application-passwords.php'; require ABSPATH . WPINC . '/rest-api.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menu-items-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menus-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menu-locations-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-search-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-blocks-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-renderer-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-plugins-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-directory-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-patterns-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-application-passwords-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-site-health-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-sidebars-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widget-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widgets-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-templates-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-url-details-controller.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-term-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-format-search-handler.php'; require ABSPATH . WPINC . '/sitemaps.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-index.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-provider.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-registry.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-renderer.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-stylesheet.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-posts.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-taxonomies.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php'; require ABSPATH . WPINC . '/class-wp-block-editor-context.php'; require ABSPATH . WPINC . '/class-wp-block-type.php'; require ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php'; require ABSPATH . WPINC . '/class-wp-block-patterns-registry.php'; require ABSPATH . WPINC . '/class-wp-block-styles-registry.php'; require ABSPATH . WPINC . '/class-wp-block-type-registry.php'; require ABSPATH . WPINC . '/class-wp-block.php'; require ABSPATH . WPINC . '/class-wp-block-list.php'; require ABSPATH . WPINC . '/class-wp-block-parser.php'; require ABSPATH . WPINC . '/blocks.php'; require ABSPATH . WPINC . '/blocks/index.php'; require ABSPATH . WPINC . '/block-editor.php'; require ABSPATH . WPINC . '/block-patterns.php'; require ABSPATH . WPINC . '/class-wp-block-supports.php'; require ABSPATH . WPINC . '/block-supports/utils.php'; require ABSPATH . WPINC . '/block-supports/align.php'; require ABSPATH . WPINC . '/block-supports/border.php'; require ABSPATH . WPINC . '/block-supports/colors.php'; require ABSPATH . WPINC . '/block-supports/custom-classname.php'; require ABSPATH . WPINC . '/block-supports/dimensions.php'; require ABSPATH . WPINC . '/block-supports/duotone.php'; require ABSPATH . WPINC . '/block-supports/elements.php'; require ABSPATH . WPINC . '/block-supports/generated-classname.php'; require ABSPATH . WPINC . '/block-supports/layout.php'; require ABSPATH . WPINC . '/block-supports/spacing.php'; require ABSPATH . WPINC . '/block-supports/typography.php'; require ABSPATH . WPINC . '/style-engine.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-declarations.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-rule.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-rules-store.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-processor.php'; $GLOBALS['wp_embed'] = new WP_Embed(); $GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry(); if ( is_multisite() ) { require ABSPATH . WPINC . '/ms-functions.php'; require ABSPATH . WPINC . '/ms-default-filters.php'; require ABSPATH . WPINC . '/ms-deprecated.php'; } wp_plugin_directory_constants(); $GLOBALS['wp_plugin_paths'] = array(); foreach ( wp_get_mu_plugins() as $mu_plugin ) { $_wp_plugin_file = $mu_plugin; include_once $mu_plugin; $mu_plugin = $_wp_plugin_file; do_action( 'mu_plugin_loaded', $mu_plugin ); } unset( $mu_plugin, $_wp_plugin_file ); if ( is_multisite() ) { foreach ( wp_get_active_network_plugins() as $network_plugin ) { wp_register_plugin_realpath( $network_plugin ); $_wp_plugin_file = $network_plugin; include_once $network_plugin; $network_plugin = $_wp_plugin_file; do_action( 'network_plugin_loaded', $network_plugin ); } unset( $network_plugin, $_wp_plugin_file ); } do_action( 'muplugins_loaded' ); if ( is_multisite() ) { ms_cookie_constants(); } wp_cookie_constants(); wp_ssl_constants(); require ABSPATH . WPINC . '/vars.php'; create_initial_taxonomies(); create_initial_post_types(); wp_start_scraping_edited_file_errors(); register_theme_directory( get_theme_root() ); if ( ! is_multisite() ) { wp_recovery_mode()->initialize(); } foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); $_wp_plugin_file = $plugin; include_once $plugin; $plugin = $_wp_plugin_file; do_action( 'plugin_loaded', $plugin ); } unset( $plugin, $_wp_plugin_file ); require ABSPATH . WPINC . '/pluggable.php'; require ABSPATH . WPINC . '/pluggable-deprecated.php'; wp_set_internal_encoding(); if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) { wp_cache_postload(); } do_action( 'plugins_loaded' ); wp_functionality_constants(); wp_magic_quotes(); do_action( 'sanitize_comment_cookies' ); $GLOBALS['wp_the_query'] = new WP_Query(); $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; $GLOBALS['wp_rewrite'] = new WP_Rewrite(); $GLOBALS['wp'] = new WP(); $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory(); $GLOBALS['wp_roles'] = new WP_Roles(); do_action( 'setup_theme' ); wp_templating_constants(); load_default_textdomain(); $locale = get_locale(); $locale_file = WP_LANG_DIR . "/$locale.php"; if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) { require $locale_file; } unset( $locale_file ); $GLOBALS['wp_locale'] = new WP_Locale(); $GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher(); $GLOBALS['wp_locale_switcher']->init(); foreach ( wp_get_active_and_valid_themes() as $theme ) { if ( file_exists( $theme . '/functions.php' ) ) { include $theme . '/functions.php'; } } unset( $theme ); do_action( 'after_setup_theme' ); if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } WP_Site_Health::get_instance(); $GLOBALS['wp']->init(); do_action( 'init' ); if ( is_multisite() ) { $file = ms_site_check(); if ( true !== $file ) { require $file; die(); } unset( $file ); } do_action( 'wp_loaded' ); <?php + define( 'WPINC', 'wp-includes' ); global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package; require ABSPATH . WPINC . '/version.php'; require ABSPATH . WPINC . '/load.php'; wp_check_php_mysql_versions(); require ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php'; require ABSPATH . WPINC . '/class-wp-fatal-error-handler.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-cookie-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-key-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-link-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode-email-service.php'; require ABSPATH . WPINC . '/class-wp-recovery-mode.php'; require ABSPATH . WPINC . '/error-protection.php'; require ABSPATH . WPINC . '/default-constants.php'; require_once ABSPATH . WPINC . '/plugin.php'; global $blog_id; wp_initial_constants(); wp_register_fatal_error_handler(); date_default_timezone_set( 'UTC' ); wp_fix_server_vars(); wp_maintenance(); timer_start(); wp_debug_mode(); if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) { include WP_CONTENT_DIR . '/advanced-cache.php'; if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } } wp_set_lang_dir(); require ABSPATH . WPINC . '/compat.php'; require ABSPATH . WPINC . '/class-wp-list-util.php'; require ABSPATH . WPINC . '/formatting.php'; require ABSPATH . WPINC . '/meta.php'; require ABSPATH . WPINC . '/functions.php'; require ABSPATH . WPINC . '/class-wp-meta-query.php'; require ABSPATH . WPINC . '/class-wp-matchesmapregex.php'; require ABSPATH . WPINC . '/class-wp.php'; require ABSPATH . WPINC . '/class-wp-error.php'; require ABSPATH . WPINC . '/pomo/mo.php'; global $wpdb; require_wp_db(); $GLOBALS['table_prefix'] = $table_prefix; wp_set_wpdb_vars(); wp_start_object_cache(); require ABSPATH . WPINC . '/default-filters.php'; if ( is_multisite() ) { require ABSPATH . WPINC . '/class-wp-site-query.php'; require ABSPATH . WPINC . '/class-wp-network-query.php'; require ABSPATH . WPINC . '/ms-blogs.php'; require ABSPATH . WPINC . '/ms-settings.php'; } elseif ( ! defined( 'MULTISITE' ) ) { define( 'MULTISITE', false ); } register_shutdown_function( 'shutdown_action_hook' ); if ( SHORTINIT ) { return false; } require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; wp_not_installed(); require ABSPATH . WPINC . '/class-wp-walker.php'; require ABSPATH . WPINC . '/class-wp-ajax-response.php'; require ABSPATH . WPINC . '/capabilities.php'; require ABSPATH . WPINC . '/class-wp-roles.php'; require ABSPATH . WPINC . '/class-wp-role.php'; require ABSPATH . WPINC . '/class-wp-user.php'; require ABSPATH . WPINC . '/class-wp-query.php'; require ABSPATH . WPINC . '/query.php'; require ABSPATH . WPINC . '/class-wp-date-query.php'; require ABSPATH . WPINC . '/theme.php'; require ABSPATH . WPINC . '/class-wp-theme.php'; require ABSPATH . WPINC . '/class-wp-theme-json-schema.php'; require ABSPATH . WPINC . '/class-wp-theme-json-data.php'; require ABSPATH . WPINC . '/class-wp-theme-json.php'; require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php'; require ABSPATH . WPINC . '/global-styles-and-settings.php'; require ABSPATH . WPINC . '/class-wp-block-template.php'; require ABSPATH . WPINC . '/block-template-utils.php'; require ABSPATH . WPINC . '/block-template.php'; require ABSPATH . WPINC . '/theme-templates.php'; require ABSPATH . WPINC . '/template.php'; require ABSPATH . WPINC . '/https-detection.php'; require ABSPATH . WPINC . '/https-migration.php'; require ABSPATH . WPINC . '/class-wp-user-request.php'; require ABSPATH . WPINC . '/user.php'; require ABSPATH . WPINC . '/class-wp-user-query.php'; require ABSPATH . WPINC . '/class-wp-session-tokens.php'; require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php'; require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php'; require ABSPATH . WPINC . '/general-template.php'; require ABSPATH . WPINC . '/link-template.php'; require ABSPATH . WPINC . '/author-template.php'; require ABSPATH . WPINC . '/robots-template.php'; require ABSPATH . WPINC . '/post.php'; require ABSPATH . WPINC . '/class-walker-page.php'; require ABSPATH . WPINC . '/class-walker-page-dropdown.php'; require ABSPATH . WPINC . '/class-wp-post-type.php'; require ABSPATH . WPINC . '/class-wp-post.php'; require ABSPATH . WPINC . '/post-template.php'; require ABSPATH . WPINC . '/revision.php'; require ABSPATH . WPINC . '/post-formats.php'; require ABSPATH . WPINC . '/post-thumbnail-template.php'; require ABSPATH . WPINC . '/category.php'; require ABSPATH . WPINC . '/class-walker-category.php'; require ABSPATH . WPINC . '/class-walker-category-dropdown.php'; require ABSPATH . WPINC . '/category-template.php'; require ABSPATH . WPINC . '/comment.php'; require ABSPATH . WPINC . '/class-wp-comment.php'; require ABSPATH . WPINC . '/class-wp-comment-query.php'; require ABSPATH . WPINC . '/class-walker-comment.php'; require ABSPATH . WPINC . '/comment-template.php'; require ABSPATH . WPINC . '/rewrite.php'; require ABSPATH . WPINC . '/class-wp-rewrite.php'; require ABSPATH . WPINC . '/feed.php'; require ABSPATH . WPINC . '/bookmark.php'; require ABSPATH . WPINC . '/bookmark-template.php'; require ABSPATH . WPINC . '/kses.php'; require ABSPATH . WPINC . '/cron.php'; require ABSPATH . WPINC . '/deprecated.php'; require ABSPATH . WPINC . '/script-loader.php'; require ABSPATH . WPINC . '/taxonomy.php'; require ABSPATH . WPINC . '/class-wp-taxonomy.php'; require ABSPATH . WPINC . '/class-wp-term.php'; require ABSPATH . WPINC . '/class-wp-term-query.php'; require ABSPATH . WPINC . '/class-wp-tax-query.php'; require ABSPATH . WPINC . '/update.php'; require ABSPATH . WPINC . '/canonical.php'; require ABSPATH . WPINC . '/shortcodes.php'; require ABSPATH . WPINC . '/embed.php'; require ABSPATH . WPINC . '/class-wp-embed.php'; require ABSPATH . WPINC . '/class-wp-oembed.php'; require ABSPATH . WPINC . '/class-wp-oembed-controller.php'; require ABSPATH . WPINC . '/media.php'; require ABSPATH . WPINC . '/http.php'; require ABSPATH . WPINC . '/class-wp-http.php'; require ABSPATH . WPINC . '/class-wp-http-streams.php'; require ABSPATH . WPINC . '/class-wp-http-curl.php'; require ABSPATH . WPINC . '/class-wp-http-proxy.php'; require ABSPATH . WPINC . '/class-wp-http-cookie.php'; require ABSPATH . WPINC . '/class-wp-http-encoding.php'; require ABSPATH . WPINC . '/class-wp-http-response.php'; require ABSPATH . WPINC . '/class-wp-http-requests-response.php'; require ABSPATH . WPINC . '/class-wp-http-requests-hooks.php'; require ABSPATH . WPINC . '/widgets.php'; require ABSPATH . WPINC . '/class-wp-widget.php'; require ABSPATH . WPINC . '/class-wp-widget-factory.php'; require ABSPATH . WPINC . '/nav-menu-template.php'; require ABSPATH . WPINC . '/nav-menu.php'; require ABSPATH . WPINC . '/admin-bar.php'; require ABSPATH . WPINC . '/class-wp-application-passwords.php'; require ABSPATH . WPINC . '/rest-api.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php'; require ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menu-items-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menus-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-menu-locations-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-search-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-blocks-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-renderer-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-plugins-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-directory-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-patterns-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-application-passwords-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-site-health-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-sidebars-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widget-types-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widgets-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-templates-controller.php'; require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-url-details-controller.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-term-search-handler.php'; require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-format-search-handler.php'; require ABSPATH . WPINC . '/sitemaps.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-index.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-provider.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-registry.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-renderer.php'; require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-stylesheet.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-posts.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-taxonomies.php'; require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php'; require ABSPATH . WPINC . '/class-wp-block-editor-context.php'; require ABSPATH . WPINC . '/class-wp-block-type.php'; require ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php'; require ABSPATH . WPINC . '/class-wp-block-patterns-registry.php'; require ABSPATH . WPINC . '/class-wp-block-styles-registry.php'; require ABSPATH . WPINC . '/class-wp-block-type-registry.php'; require ABSPATH . WPINC . '/class-wp-block.php'; require ABSPATH . WPINC . '/class-wp-block-list.php'; require ABSPATH . WPINC . '/class-wp-block-parser.php'; require ABSPATH . WPINC . '/blocks.php'; require ABSPATH . WPINC . '/blocks/index.php'; require ABSPATH . WPINC . '/block-editor.php'; require ABSPATH . WPINC . '/block-patterns.php'; require ABSPATH . WPINC . '/class-wp-block-supports.php'; require ABSPATH . WPINC . '/block-supports/utils.php'; require ABSPATH . WPINC . '/block-supports/align.php'; require ABSPATH . WPINC . '/block-supports/border.php'; require ABSPATH . WPINC . '/block-supports/colors.php'; require ABSPATH . WPINC . '/block-supports/custom-classname.php'; require ABSPATH . WPINC . '/block-supports/dimensions.php'; require ABSPATH . WPINC . '/block-supports/duotone.php'; require ABSPATH . WPINC . '/block-supports/elements.php'; require ABSPATH . WPINC . '/block-supports/generated-classname.php'; require ABSPATH . WPINC . '/block-supports/layout.php'; require ABSPATH . WPINC . '/block-supports/spacing.php'; require ABSPATH . WPINC . '/block-supports/typography.php'; require ABSPATH . WPINC . '/style-engine.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-declarations.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-rule.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-rules-store.php'; require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-processor.php'; $GLOBALS['wp_embed'] = new WP_Embed(); $GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry(); if ( is_multisite() ) { require ABSPATH . WPINC . '/ms-functions.php'; require ABSPATH . WPINC . '/ms-default-filters.php'; require ABSPATH . WPINC . '/ms-deprecated.php'; } wp_plugin_directory_constants(); $GLOBALS['wp_plugin_paths'] = array(); foreach ( wp_get_mu_plugins() as $mu_plugin ) { $_wp_plugin_file = $mu_plugin; include_once $mu_plugin; $mu_plugin = $_wp_plugin_file; do_action( 'mu_plugin_loaded', $mu_plugin ); } unset( $mu_plugin, $_wp_plugin_file ); if ( is_multisite() ) { foreach ( wp_get_active_network_plugins() as $network_plugin ) { wp_register_plugin_realpath( $network_plugin ); $_wp_plugin_file = $network_plugin; include_once $network_plugin; $network_plugin = $_wp_plugin_file; do_action( 'network_plugin_loaded', $network_plugin ); } unset( $network_plugin, $_wp_plugin_file ); } do_action( 'muplugins_loaded' ); if ( is_multisite() ) { ms_cookie_constants(); } wp_cookie_constants(); wp_ssl_constants(); require ABSPATH . WPINC . '/vars.php'; create_initial_taxonomies(); create_initial_post_types(); wp_start_scraping_edited_file_errors(); register_theme_directory( get_theme_root() ); if ( ! is_multisite() && wp_is_fatal_error_handler_enabled() ) { wp_recovery_mode()->initialize(); } foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); $_wp_plugin_file = $plugin; include_once $plugin; $plugin = $_wp_plugin_file; do_action( 'plugin_loaded', $plugin ); } unset( $plugin, $_wp_plugin_file ); require ABSPATH . WPINC . '/pluggable.php'; require ABSPATH . WPINC . '/pluggable-deprecated.php'; wp_set_internal_encoding(); if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) { wp_cache_postload(); } do_action( 'plugins_loaded' ); wp_functionality_constants(); wp_magic_quotes(); do_action( 'sanitize_comment_cookies' ); $GLOBALS['wp_the_query'] = new WP_Query(); $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; $GLOBALS['wp_rewrite'] = new WP_Rewrite(); $GLOBALS['wp'] = new WP(); $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory(); $GLOBALS['wp_roles'] = new WP_Roles(); do_action( 'setup_theme' ); wp_templating_constants(); load_default_textdomain(); $locale = get_locale(); $locale_file = WP_LANG_DIR . "/$locale.php"; if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) { require $locale_file; } unset( $locale_file ); $GLOBALS['wp_locale'] = new WP_Locale(); $GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher(); $GLOBALS['wp_locale_switcher']->init(); foreach ( wp_get_active_and_valid_themes() as $theme ) { if ( file_exists( $theme . '/functions.php' ) ) { include $theme . '/functions.php'; } } unset( $theme ); do_action( 'after_setup_theme' ); if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } WP_Site_Health::get_instance(); $GLOBALS['wp']->init(); do_action( 'init' ); if ( is_multisite() ) { $file = ms_site_check(); if ( true !== $file ) { require $file; die(); } unset( $file ); } do_action( 'wp_loaded' ); <?php require __DIR__ . '/wp-load.php'; add_filter( 'wp_robots', 'wp_robots_no_robots' ); require __DIR__ . '/wp-blog-header.php'; nocache_headers(); if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ), true ) ) { wp_redirect( network_home_url() ); die(); } function do_signup_header() { do_action( 'signup_header' ); } add_action( 'wp_head', 'do_signup_header' ); if ( ! is_multisite() ) { wp_redirect( wp_registration_url() ); die(); } if ( ! is_main_site() ) { wp_redirect( network_site_url( 'wp-signup.php' ) ); die(); } $wp_query->is_404 = false; do_action( 'before_signup_header' ); function wpmu_signup_stylesheet() { ?> <style type="text/css"> .mu_register { width: 90%; margin: 0 auto; } diff --git a/build/wp-nightly.js b/build/wp-nightly.js old mode 100755 new mode 100644 index 8ac3927438..f2d6ed1045 --- a/build/wp-nightly.js +++ b/build/wp-nightly.js @@ -1,6 +1,6 @@ // The number of bytes to download, which is just the size of the `wp.data` file. // Populated by the Dockerfile. -export const dependenciesTotalSize = 10389954; +export const dependenciesTotalSize = 10490215; // The final wp.data filename – populated by the Dockerfile. export const dependencyFilename = 'wp-nightly.data'; @@ -33,8 +33,8 @@ export default function(PHPModule) { // web worker PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/'); } - var PACKAGE_NAME = '/root/output//wp-nightly.data?'; - var REMOTE_PACKAGE_BASE = '/wp-nightly.data?'; + var PACKAGE_NAME = '/root/output//wp-nightly.data?1a7b24eefde2e9df778eb22ef0c6f71c'; + var REMOTE_PACKAGE_BASE = '/wp-nightly.data?1a7b24eefde2e9df778eb22ef0c6f71c'; if (typeof Module['locateFilePackage'] === 'function' && !Module['locateFile']) { Module['locateFile'] = Module['locateFilePackage']; err('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); @@ -123,6 +123,8 @@ Module['FS_createPath']("/wordpress/wp-content", "database", true, true); Module['FS_createPath']("/wordpress/wp-content", "plugins", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins", "akismet", true, true); Module['FS_createPath']("/wordpress/wp-content/plugins/akismet", "views", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins", "wordpress-importer", true, true); +Module['FS_createPath']("/wordpress/wp-content/plugins/wordpress-importer", "parsers", true, true); Module['FS_createPath']("/wordpress/wp-content", "themes", true, true); Module['FS_createPath']("/wordpress/wp-content/themes", "twentytwentythree", true, true); Module['FS_createPath']("/wordpress/wp-content/themes/twentytwentythree", "parts", true, true); @@ -335,10 +337,10 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); var files = metadata['files']; for (var i = 0; i < files.length; ++i) { DataRequest.prototype.requests[files[i].filename].onload(); - } Module['removeRunDependency']('datafile_/root/output//wp-nightly.data?'); + } Module['removeRunDependency']('datafile_/root/output//wp-nightly.data?1a7b24eefde2e9df778eb22ef0c6f71c'); }; - Module['addRunDependency']('datafile_/root/output//wp-nightly.data?'); + Module['addRunDependency']('datafile_/root/output//wp-nightly.data?1a7b24eefde2e9df778eb22ef0c6f71c'); if (!Module.preloadResults) Module.preloadResults = {}; @@ -359,7 +361,7 @@ Module['FS_createPath']("/wordpress/wp-includes", "widgets", true, true); } } - loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4180}, {"filename": "/wordpress/index.php", "start": 4180, "end": 4261}, {"filename": "/wordpress/readme.html", "start": 4261, "end": 11651}, {"filename": "/wordpress/wp-activate.php", "start": 11651, "end": 17673}, {"filename": "/wordpress/wp-admin/about.php", "start": 17673, "end": 47553}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 47553, "end": 51265}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 51265, "end": 52445}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 52445, "end": 52588}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 52588, "end": 57991}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 57991, "end": 58838}, {"filename": "/wordpress/wp-admin/admin.php", "start": 58838, "end": 64792}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 64792, "end": 68458}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 68458, "end": 75990}, {"filename": "/wordpress/wp-admin/comment.php", "start": 75990, "end": 85749}, {"filename": "/wordpress/wp-admin/credits.php", "start": 85749, "end": 89084}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 89084, "end": 89263}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 89263, "end": 89446}, {"filename": "/wordpress/wp-admin/customize.php", "start": 89446, "end": 98318}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 98318, "end": 110868}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 110868, "end": 134759}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 134759, "end": 142601}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 142601, "end": 149774}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 149774, "end": 155288}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 155288, "end": 161271}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 161271, "end": 177702}, {"filename": "/wordpress/wp-admin/edit.php", "start": 177702, "end": 193759}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 193759, "end": 200643}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 200643, "end": 207931}, {"filename": "/wordpress/wp-admin/export.php", "start": 207931, "end": 217749}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 217749, "end": 221692}, {"filename": "/wordpress/wp-admin/import.php", "start": 221692, "end": 227560}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 227560, "end": 234472}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 234472, "end": 236614}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 236614, "end": 347739}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 347739, "end": 354495}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 354495, "end": 355770}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 355770, "end": 356910}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 356910, "end": 358098}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 358098, "end": 362165}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 362165, "end": 370940}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 370940, "end": 388625}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 388625, "end": 426125}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 426125, "end": 427895}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 427895, "end": 432010}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 432010, "end": 439011}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 439011, "end": 462066}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 462066, "end": 463532}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 463532, "end": 472498}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 472498, "end": 561557}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 561557, "end": 570086}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 570086, "end": 571931}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 571931, "end": 583585}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 583585, "end": 592747}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 592747, "end": 595412}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 595412, "end": 610054}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 610054, "end": 612308}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 612308, "end": 615962}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 615962, "end": 626099}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 626099, "end": 627890}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 627890, "end": 631575}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 631575, "end": 660181}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 660181, "end": 681949}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 681949, "end": 689321}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 689321, "end": 732826}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 732826, "end": 740398}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 740398, "end": 747078}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 747078, "end": 757183}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 757183, "end": 764331}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 764331, "end": 774069}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 774069, "end": 778731}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 778731, "end": 781133}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 781133, "end": 785929}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 785929, "end": 786657}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 786657, "end": 812950}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 812950, "end": 830388}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 830388, "end": 843273}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 843273, "end": 860888}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 860888, "end": 869882}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 869882, "end": 886783}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 886783, "end": 915338}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 915338, "end": 916296}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 916296, "end": 957381}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 957381, "end": 961588}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 961588, "end": 965805}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 965805, "end": 989210}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 989210, "end": 997325}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 997325, "end": 1017313}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 1017313, "end": 1025814}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1025814, "end": 1099122}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1099122, "end": 1101745}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1101745, "end": 1113922}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1113922, "end": 1124064}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1124064, "end": 1131819}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1131819, "end": 1134914}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1134914, "end": 1135836}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1135836, "end": 1151712}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1151712, "end": 1163060}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1163060, "end": 1166896}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1166896, "end": 1187202}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1187202, "end": 1190988}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1190988, "end": 1238910}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1238910, "end": 1259127}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1259127, "end": 1260229}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1260229, "end": 1275741}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1275741, "end": 1324409}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1324409, "end": 1353229}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1353229, "end": 1372170}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1372170, "end": 1376424}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1376424, "end": 1378279}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1378279, "end": 1462323}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1462323, "end": 1467668}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1467668, "end": 1515307}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1515307, "end": 1542666}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1542666, "end": 1543686}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1543686, "end": 1545315}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1545315, "end": 1568241}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1568241, "end": 1603553}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1603553, "end": 1625304}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1625304, "end": 1625902}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1625902, "end": 1629602}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1629602, "end": 1651155}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1651155, "end": 1691508}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1691508, "end": 1743016}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1743016, "end": 1762568}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1762568, "end": 1772467}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1772467, "end": 1803353}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1803353, "end": 1806364}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1806364, "end": 1810177}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1810177, "end": 1864964}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1864964, "end": 1870351}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1870351, "end": 1896494}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1896494, "end": 1902390}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1902390, "end": 1955922}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1955922, "end": 1977863}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1977863, "end": 2048636}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 2048636, "end": 2061626}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2061626, "end": 2070326}, {"filename": "/wordpress/wp-admin/index.php", "start": 2070326, "end": 2076899}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2076899, "end": 2078827}, {"filename": "/wordpress/wp-admin/install.php", "start": 2078827, "end": 2092931}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2092931, "end": 2093482}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2093482, "end": 2097139}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2097139, "end": 2098561}, {"filename": "/wordpress/wp-admin/link.php", "start": 2098561, "end": 2100531}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2100531, "end": 2102061}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2102061, "end": 2104318}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2104318, "end": 2110369}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2110369, "end": 2113206}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2113206, "end": 2114726}, {"filename": "/wordpress/wp-admin/media.php", "start": 2114726, "end": 2119806}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2119806, "end": 2126985}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2126985, "end": 2141237}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2141237, "end": 2141374}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2141374, "end": 2141460}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2141460, "end": 2145031}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2145031, "end": 2145117}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2145117, "end": 2145213}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2145213, "end": 2145312}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2145312, "end": 2145412}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2145412, "end": 2145513}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2145513, "end": 2145612}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2145612, "end": 2149113}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2149113, "end": 2188473}, {"filename": "/wordpress/wp-admin/network.php", "start": 2188473, "end": 2193301}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2193301, "end": 2193385}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2193385, "end": 2193970}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2193970, "end": 2194056}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2194056, "end": 2194350}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2194350, "end": 2194437}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2194437, "end": 2197051}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2197051, "end": 2201271}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2201271, "end": 2201363}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2201363, "end": 2201568}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2201568, "end": 2201654}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2201654, "end": 2201740}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2201740, "end": 2201826}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2201826, "end": 2220892}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2220892, "end": 2220978}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2220978, "end": 2227119}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2227119, "end": 2234907}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2234907, "end": 2239541}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2239541, "end": 2244831}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2244831, "end": 2254633}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2254633, "end": 2265275}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2265275, "end": 2265366}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2265366, "end": 2265569}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2265569, "end": 2279787}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2279787, "end": 2279877}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2279877, "end": 2280142}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2280142, "end": 2283925}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2283925, "end": 2284013}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2284013, "end": 2288539}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2288539, "end": 2296266}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2296266, "end": 2309761}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2309761, "end": 2323127}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2323127, "end": 2323341}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2323341, "end": 2329186}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2329186, "end": 2347494}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2347494, "end": 2355955}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2355955, "end": 2364523}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2364523, "end": 2372162}, {"filename": "/wordpress/wp-admin/options.php", "start": 2372162, "end": 2381879}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2381879, "end": 2394163}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2394163, "end": 2398933}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2398933, "end": 2423542}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2423542, "end": 2425614}, {"filename": "/wordpress/wp-admin/post.php", "start": 2425614, "end": 2433884}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2433884, "end": 2435800}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2435800, "end": 2439131}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2439131, "end": 2441272}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2441272, "end": 2441355}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2441355, "end": 2445491}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2445491, "end": 2459275}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2459275, "end": 2463841}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2463841, "end": 2467478}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2467478, "end": 2475867}, {"filename": "/wordpress/wp-admin/term.php", "start": 2475867, "end": 2477801}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2477801, "end": 2491782}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2491782, "end": 2511053}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2511053, "end": 2550339}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2550339, "end": 2553088}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2553088, "end": 2589832}, {"filename": "/wordpress/wp-admin/update.php", "start": 2589832, "end": 2600355}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2600355, "end": 2600502}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2600502, "end": 2604846}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2604846, "end": 2617884}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2617884, "end": 2649168}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2649168, "end": 2669688}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2669688, "end": 2669772}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2669772, "end": 2670314}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2670314, "end": 2670400}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2670400, "end": 2670487}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2670487, "end": 2670571}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2670571, "end": 2671157}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2671157, "end": 2671243}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2671243, "end": 2671329}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2671329, "end": 2671417}, {"filename": "/wordpress/wp-admin/users.php", "start": 2671417, "end": 2690005}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2690005, "end": 2691779}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2691779, "end": 2708833}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2708833, "end": 2709710}, {"filename": "/wordpress/wp-blog-header.php", "start": 2709710, "end": 2709877}, {"filename": "/wordpress/wp-comments-post.php", "start": 2709877, "end": 2711288}, {"filename": "/wordpress/wp-config-sample.php", "start": 2711288, "end": 2712131}, {"filename": "/wordpress/wp-config.php", "start": 2712131, "end": 2713014}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2713014, "end": 2917814}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2917814, "end": 2917827}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2917827, "end": 2917855}, {"filename": "/wordpress/wp-content/db.php", "start": 2917855, "end": 3001245}, {"filename": "/wordpress/wp-content/index.php", "start": 3001245, "end": 3001251}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 3001251, "end": 3002386}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 3002386, "end": 3042759}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 3042759, "end": 3045792}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 3045792, "end": 3053959}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 3053959, "end": 3056790}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 3056790, "end": 3100678}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3100678, "end": 3100684}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3100684, "end": 3100861}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3100861, "end": 3112558}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3112558, "end": 3117056}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3117056, "end": 3117870}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3117870, "end": 3118625}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3118625, "end": 3131507}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3131507, "end": 3131770}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3131770, "end": 3132094}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3132094, "end": 3132901}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3132901, "end": 3133679}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3133679, "end": 3133804}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3133804, "end": 3140103}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3140103, "end": 3141838}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3141838, "end": 3141844}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/comments.html", "start": 3141844, "end": 3141910}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/footer.html", "start": 3141910, "end": 3141975}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/header.html", "start": 3141975, "end": 3142511}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/post-meta.html", "start": 3142511, "end": 3142571}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/call-to-action.php", "start": 3142571, "end": 3143675}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/footer-default.php", "start": 3143675, "end": 3144409}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-404.php", "start": 3144409, "end": 3145741}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-comments.php", "start": 3145741, "end": 3147789}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-no-results.php", "start": 3147789, "end": 3148388}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/post-meta.php", "start": 3148388, "end": 3150899}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/style.css", "start": 3150899, "end": 3151995}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/aubergine.json", "start": 3151995, "end": 3158029}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/block-out.json", "start": 3158029, "end": 3162394}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/canary.json", "start": 3162394, "end": 3166986}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/electric.json", "start": 3166986, "end": 3168858}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/grapes.json", "start": 3168858, "end": 3170609}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/marigold.json", "start": 3170609, "end": 3176823}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pilgrimage.json", "start": 3176823, "end": 3183352}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pitch.json", "start": 3183352, "end": 3188109}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/sherbet.json", "start": 3188109, "end": 3193394}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/whisper.json", "start": 3193394, "end": 3204763}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/404.html", "start": 3204763, "end": 3205081}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/archive.html", "start": 3205081, "end": 3206757}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blank.html", "start": 3206757, "end": 3206817}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blog-alternative.html", "start": 3206817, "end": 3208319}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/home.html", "start": 3208319, "end": 3210385}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/index.html", "start": 3210385, "end": 3211755}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/page.html", "start": 3211755, "end": 3212645}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/search.html", "start": 3212645, "end": 3214463}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/single.html", "start": 3214463, "end": 3215402}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/theme.json", "start": 3215402, "end": 3230239}, {"filename": "/wordpress/wp-cron.php", "start": 3230239, "end": 3232954}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3232954, "end": 3269833}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3269833, "end": 3317094}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3317094, "end": 3402431}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3402431, "end": 3419146}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3419146, "end": 3478097}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3478097, "end": 3590328}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 3590328, "end": 3678677}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 3678677, "end": 3704613}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 3704613, "end": 3712063}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 3712063, "end": 3726125}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 3726125, "end": 3800836}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 3800836, "end": 3834947}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 3834947, "end": 3849671}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 3849671, "end": 3859810}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 3859810, "end": 3949915}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 3949915, "end": 3958698}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 3958698, "end": 3958940}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 3958940, "end": 3961868}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 3961868, "end": 3962494}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 3962494, "end": 3963717}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 3963717, "end": 3964380}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 3964380, "end": 3967498}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 3967498, "end": 3972093}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 3972093, "end": 3972730}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 3972730, "end": 3977030}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 3977030, "end": 3979175}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 3979175, "end": 3979394}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 3979394, "end": 4055204}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4055204, "end": 4072246}, {"filename": "/wordpress/wp-includes/Requests/library/Requests.php", "start": 4072246, "end": 4072307}, {"filename": "/wordpress/wp-includes/Requests/src/Auth.php", "start": 4072307, "end": 4072425}, {"filename": "/wordpress/wp-includes/Requests/src/Auth/Basic.php", "start": 4072425, "end": 4073566}, {"filename": "/wordpress/wp-includes/Requests/src/Autoload.php", "start": 4073566, "end": 4078934}, {"filename": "/wordpress/wp-includes/Requests/src/Capability.php", "start": 4078934, "end": 4079039}, {"filename": "/wordpress/wp-includes/Requests/src/Cookie.php", "start": 4079039, "end": 4085808}, {"filename": "/wordpress/wp-includes/Requests/src/Cookie/Jar.php", "start": 4085808, "end": 4088012}, {"filename": "/wordpress/wp-includes/Requests/src/Exception.php", "start": 4088012, "end": 4088405}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/ArgumentCount.php", "start": 4088405, "end": 4088782}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http.php", "start": 4088782, "end": 4089511}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status304.php", "start": 4089511, "end": 4089692}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status305.php", "start": 4089692, "end": 4089870}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status306.php", "start": 4089870, "end": 4090051}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status400.php", "start": 4090051, "end": 4090231}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status401.php", "start": 4090231, "end": 4090412}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status402.php", "start": 4090412, "end": 4090597}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status403.php", "start": 4090597, "end": 4090775}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status404.php", "start": 4090775, "end": 4090953}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status405.php", "start": 4090953, "end": 4091140}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status406.php", "start": 4091140, "end": 4091323}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status407.php", "start": 4091323, "end": 4091521}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status408.php", "start": 4091521, "end": 4091705}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status409.php", "start": 4091705, "end": 4091882}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status410.php", "start": 4091882, "end": 4092055}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status411.php", "start": 4092055, "end": 4092239}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status412.php", "start": 4092239, "end": 4092427}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status413.php", "start": 4092427, "end": 4092620}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status414.php", "start": 4092620, "end": 4092810}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status415.php", "start": 4092810, "end": 4093001}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status416.php", "start": 4093001, "end": 4093201}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status417.php", "start": 4093201, "end": 4093388}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status418.php", "start": 4093388, "end": 4093569}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status428.php", "start": 4093569, "end": 4093759}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status429.php", "start": 4093759, "end": 4093945}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status431.php", "start": 4093945, "end": 4094145}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status500.php", "start": 4094145, "end": 4094335}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status501.php", "start": 4094335, "end": 4094519}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status502.php", "start": 4094519, "end": 4094699}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status503.php", "start": 4094699, "end": 4094887}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status504.php", "start": 4094887, "end": 4095071}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status505.php", "start": 4095071, "end": 4095266}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status511.php", "start": 4095266, "end": 4095466}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/StatusUnknown.php", "start": 4095466, "end": 4095847}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/InvalidArgument.php", "start": 4095847, "end": 4096290}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Transport.php", "start": 4096290, "end": 4096400}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Transport/Curl.php", "start": 4096400, "end": 4097091}, {"filename": "/wordpress/wp-includes/Requests/src/HookManager.php", "start": 4097091, "end": 4097260}, {"filename": "/wordpress/wp-includes/Requests/src/Hooks.php", "start": 4097260, "end": 4098686}, {"filename": "/wordpress/wp-includes/Requests/src/IdnaEncoder.php", "start": 4098686, "end": 4104162}, {"filename": "/wordpress/wp-includes/Requests/src/Ipv6.php", "start": 4104162, "end": 4106712}, {"filename": "/wordpress/wp-includes/Requests/src/Iri.php", "start": 4106712, "end": 4122731}, {"filename": "/wordpress/wp-includes/Requests/src/Port.php", "start": 4122731, "end": 4123275}, {"filename": "/wordpress/wp-includes/Requests/src/Proxy.php", "start": 4123275, "end": 4123394}, {"filename": "/wordpress/wp-includes/Requests/src/Proxy/Http.php", "start": 4123394, "end": 4125314}, {"filename": "/wordpress/wp-includes/Requests/src/Requests.php", "start": 4125314, "end": 4140930}, {"filename": "/wordpress/wp-includes/Requests/src/Response.php", "start": 4140930, "end": 4142249}, {"filename": "/wordpress/wp-includes/Requests/src/Response/Headers.php", "start": 4142249, "end": 4143597}, {"filename": "/wordpress/wp-includes/Requests/src/Session.php", "start": 4143597, "end": 4147439}, {"filename": "/wordpress/wp-includes/Requests/src/Ssl.php", "start": 4147439, "end": 4149652}, {"filename": "/wordpress/wp-includes/Requests/src/Transport.php", "start": 4149652, "end": 4149886}, {"filename": "/wordpress/wp-includes/Requests/src/Transport/Curl.php", "start": 4149886, "end": 4161435}, {"filename": "/wordpress/wp-includes/Requests/src/Transport/Fsockopen.php", "start": 4161435, "end": 4171095}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/CaseInsensitiveDictionary.php", "start": 4171095, "end": 4172279}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/FilteredIterator.php", "start": 4172279, "end": 4173086}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/InputValidator.php", "start": 4173086, "end": 4174054}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4174054, "end": 4174610}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4174610, "end": 4175736}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4175736, "end": 4176012}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4176012, "end": 4178078}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4178078, "end": 4179116}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4179116, "end": 4180484}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4180484, "end": 4181887}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4181887, "end": 4190244}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4190244, "end": 4191895}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4191895, "end": 4192785}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4192785, "end": 4193414}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4193414, "end": 4197858}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4197858, "end": 4198276}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4198276, "end": 4198325}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4198325, "end": 4198888}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4198888, "end": 4210808}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4210808, "end": 4224404}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4224404, "end": 4224458}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4224458, "end": 4230859}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4230859, "end": 4237202}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4237202, "end": 4253333}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4253333, "end": 4326330}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4326330, "end": 4336085}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4336085, "end": 4377402}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4377402, "end": 4379768}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4379768, "end": 4392902}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4392902, "end": 4415296}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4415296, "end": 4415726}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4415726, "end": 4417981}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4417981, "end": 4418598}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4418598, "end": 4430743}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4430743, "end": 4447344}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4447344, "end": 4450772}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4450772, "end": 4453840}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4453840, "end": 4459388}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4459388, "end": 4465961}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4465961, "end": 4468252}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4468252, "end": 4472251}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4472251, "end": 4472983}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4472983, "end": 4476055}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4476055, "end": 4478769}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4478769, "end": 4502008}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.min.php", "start": 4502008, "end": 4513143}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4513143, "end": 4524062}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.min.php", "start": 4524062, "end": 4524172}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.php", "start": 4524172, "end": 4524282}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.min.php", "start": 4524282, "end": 4524366}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.php", "start": 4524366, "end": 4524450}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4524450, "end": 4531991}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4531991, "end": 4539172}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4539172, "end": 4554136}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4554136, "end": 4554452}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4554452, "end": 4561603}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4561603, "end": 4562514}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4562514, "end": 4564433}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4564433, "end": 4565416}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4565416, "end": 4567357}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4567357, "end": 4568455}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4568455, "end": 4569198}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4569198, "end": 4569935}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4569935, "end": 4570946}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4570946, "end": 4574987}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4574987, "end": 4579143}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4579143, "end": 4580187}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4580187, "end": 4581061}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4581061, "end": 4590747}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 4590747, "end": 4592948}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 4592948, "end": 4593733}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 4593733, "end": 4607117}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 4607117, "end": 4608879}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 4608879, "end": 4623220}, {"filename": "/wordpress/wp-includes/block-supports/utils.php", "start": 4623220, "end": 4623669}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 4623669, "end": 4649972}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 4649972, "end": 4655591}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 4655591, "end": 4681813}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 4681813, "end": 4684086}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 4684086, "end": 4685119}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 4685119, "end": 4685159}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 4685159, "end": 4685207}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 4685207, "end": 4686371}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 4686371, "end": 4686584}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 4686584, "end": 4686732}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 4686732, "end": 4686902}, {"filename": "/wordpress/wp-includes/blocks/avatar.php", "start": 4686902, "end": 4690923}, {"filename": "/wordpress/wp-includes/blocks/avatar/block.json", "start": 4690923, "end": 4691929}, {"filename": "/wordpress/wp-includes/blocks/avatar/editor.min.css", "start": 4691929, "end": 4692048}, {"filename": "/wordpress/wp-includes/blocks/avatar/style.min.css", "start": 4692048, "end": 4692134}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 4692134, "end": 4693203}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 4693203, "end": 4693690}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 4693690, "end": 4694052}, {"filename": "/wordpress/wp-includes/blocks/blocks-json.php", "start": 4694052, "end": 4801636}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 4801636, "end": 4803899}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 4803899, "end": 4805080}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 4805080, "end": 4807212}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 4807212, "end": 4808315}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 4808315, "end": 4809424}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 4809424, "end": 4810727}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 4810727, "end": 4813334}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 4813334, "end": 4814083}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 4814083, "end": 4814492}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 4814492, "end": 4816532}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 4816532, "end": 4817683}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 4817683, "end": 4817768}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 4817768, "end": 4817907}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 4817907, "end": 4819099}, {"filename": "/wordpress/wp-includes/blocks/code/editor.min.css", "start": 4819099, "end": 4819135}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 4819135, "end": 4819272}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 4819272, "end": 4819388}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 4819388, "end": 4820831}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 4820831, "end": 4822538}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 4822538, "end": 4822677}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 4822677, "end": 4824151}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name.php", "start": 4824151, "end": 4825573}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name/block.json", "start": 4825573, "end": 4826711}, {"filename": "/wordpress/wp-includes/blocks/comment-content.php", "start": 4826711, "end": 4828382}, {"filename": "/wordpress/wp-includes/blocks/comment-content/block.json", "start": 4828382, "end": 4829425}, {"filename": "/wordpress/wp-includes/blocks/comment-content/style.min.css", "start": 4829425, "end": 4829501}, {"filename": "/wordpress/wp-includes/blocks/comment-date.php", "start": 4829501, "end": 4830513}, {"filename": "/wordpress/wp-includes/blocks/comment-date/block.json", "start": 4830513, "end": 4831571}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link.php", "start": 4831571, "end": 4832621}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link/block.json", "start": 4832621, "end": 4833780}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link.php", "start": 4833780, "end": 4835033}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link/block.json", "start": 4835033, "end": 4836034}, {"filename": "/wordpress/wp-includes/blocks/comment-template.php", "start": 4836034, "end": 4838193}, {"filename": "/wordpress/wp-includes/blocks/comment-template/block.json", "start": 4838193, "end": 4839039}, {"filename": "/wordpress/wp-includes/blocks/comment-template/style.min.css", "start": 4839039, "end": 4839472}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next.php", "start": 4839472, "end": 4840697}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next/block.json", "start": 4840697, "end": 4841654}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers.php", "start": 4841654, "end": 4842609}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/block.json", "start": 4842609, "end": 4843380}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/editor.min.css", "start": 4843380, "end": 4843593}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous.php", "start": 4843593, "end": 4844676}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous/block.json", "start": 4844676, "end": 4845645}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination.php", "start": 4845645, "end": 4846167}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/block.json", "start": 4846167, "end": 4847480}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/editor.min.css", "start": 4847480, "end": 4848200}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/style.min.css", "start": 4848200, "end": 4849207}, {"filename": "/wordpress/wp-includes/blocks/comments-title.php", "start": 4849207, "end": 4851184}, {"filename": "/wordpress/wp-includes/blocks/comments-title/block.json", "start": 4851184, "end": 4852596}, {"filename": "/wordpress/wp-includes/blocks/comments-title/editor.min.css", "start": 4852596, "end": 4852652}, {"filename": "/wordpress/wp-includes/blocks/comments.php", "start": 4852652, "end": 4856314}, {"filename": "/wordpress/wp-includes/blocks/comments/block.json", "start": 4856314, "end": 4857414}, {"filename": "/wordpress/wp-includes/blocks/comments/editor.min.css", "start": 4857414, "end": 4861688}, {"filename": "/wordpress/wp-includes/blocks/comments/style.min.css", "start": 4861688, "end": 4863968}, {"filename": "/wordpress/wp-includes/blocks/cover.php", "start": 4863968, "end": 4865699}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 4865699, "end": 4867922}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 4867922, "end": 4869569}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 4869569, "end": 4886228}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 4886228, "end": 4887032}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 4887032, "end": 4887654}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 4887654, "end": 4889242}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 4889242, "end": 4889412}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 4889412, "end": 4890371}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 4890371, "end": 4891660}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 4891660, "end": 4892294}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 4892294, "end": 4892870}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 4892870, "end": 4892954}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 4892954, "end": 4893038}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 4893038, "end": 4893582}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 4893582, "end": 4894019}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 4894019, "end": 4903073}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 4903073, "end": 4905676}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 4905676, "end": 4908344}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 4908344, "end": 4911689}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 4911689, "end": 4925802}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 4925802, "end": 4925935}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 4925935, "end": 4927593}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 4927593, "end": 4928742}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 4928742, "end": 4928780}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 4928780, "end": 4928842}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 4928842, "end": 4930407}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 4930407, "end": 4930538}, {"filename": "/wordpress/wp-includes/blocks/home-link.php", "start": 4930538, "end": 4933642}, {"filename": "/wordpress/wp-includes/blocks/home-link/block.json", "start": 4933642, "end": 4934718}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 4934718, "end": 4935191}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 4935191, "end": 4935926}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 4935926, "end": 4936477}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 4936477, "end": 4938853}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 4938853, "end": 4941713}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 4941713, "end": 4944197}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 4944197, "end": 4944367}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 4944367, "end": 4944854}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 4944854, "end": 4948099}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 4948099, "end": 4948848}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 4948848, "end": 4949767}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 4949767, "end": 4955321}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 4955321, "end": 4957382}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 4957382, "end": 4957811}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 4957811, "end": 4959426}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 4959426, "end": 4962516}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 4962516, "end": 4963017}, {"filename": "/wordpress/wp-includes/blocks/list-item/block.json", "start": 4963017, "end": 4963531}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 4963531, "end": 4965105}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 4965105, "end": 4965192}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 4965192, "end": 4966089}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 4966089, "end": 4966599}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 4966599, "end": 4969160}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 4969160, "end": 4969718}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 4969718, "end": 4971969}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 4971969, "end": 4972533}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 4972533, "end": 4973097}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 4973097, "end": 4973828}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 4973828, "end": 4981940}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 4981940, "end": 4983517}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 4983517, "end": 4985671}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 4985671, "end": 4985841}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 4985841, "end": 4993091}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 4993091, "end": 4994277}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 4994277, "end": 4995381}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 4995381, "end": 5013417}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 5013417, "end": 5016481}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 5016481, "end": 5027197}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 5027197, "end": 5042539}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.asset.php", "start": 5042539, "end": 5042623}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.asset.php", "start": 5042623, "end": 5042707}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.js", "start": 5042707, "end": 5050486}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5050486, "end": 5050570}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5050570, "end": 5050654}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5050654, "end": 5051798}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5051798, "end": 5052253}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5052253, "end": 5052845}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5052845, "end": 5062565}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5062565, "end": 5063288}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5063288, "end": 5064347}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5064347, "end": 5064709}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5064709, "end": 5066116}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5066116, "end": 5066482}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5066482, "end": 5066918}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5066918, "end": 5067476}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5067476, "end": 5067800}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography.php", "start": 5067800, "end": 5068740}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography/block.json", "start": 5068740, "end": 5069662}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5069662, "end": 5071325}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5071325, "end": 5072643}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5072643, "end": 5072979}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form.php", "start": 5072979, "end": 5074422}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/block.json", "start": 5074422, "end": 5075374}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/editor.min.css", "start": 5075374, "end": 5075498}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/style.min.css", "start": 5075498, "end": 5077371}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5077371, "end": 5078539}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5078539, "end": 5079340}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5079340, "end": 5080692}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5080692, "end": 5081807}, {"filename": "/wordpress/wp-includes/blocks/post-date/style.min.css", "start": 5081807, "end": 5081849}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5081849, "end": 5083370}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5083370, "end": 5084519}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5084519, "end": 5084605}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5084605, "end": 5084660}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5084660, "end": 5089799}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5089799, "end": 5091542}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5091542, "end": 5095688}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5095688, "end": 5097434}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5097434, "end": 5099524}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5099524, "end": 5100556}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5100556, "end": 5102933}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5102933, "end": 5103981}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5103981, "end": 5104075}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5104075, "end": 5104928}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5104928, "end": 5107144}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5107144, "end": 5108257}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5108257, "end": 5108310}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5108310, "end": 5109499}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5109499, "end": 5110864}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5110864, "end": 5110973}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5110973, "end": 5111997}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5111997, "end": 5112102}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5112102, "end": 5113711}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5113711, "end": 5113953}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5113953, "end": 5114879}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5114879, "end": 5115146}, {"filename": "/wordpress/wp-includes/blocks/query-no-results.php", "start": 5115146, "end": 5116183}, {"filename": "/wordpress/wp-includes/blocks/query-no-results/block.json", "start": 5116183, "end": 5117028}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5117028, "end": 5118958}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5118958, "end": 5119897}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5119897, "end": 5121768}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5121768, "end": 5122699}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5122699, "end": 5122903}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5122903, "end": 5124401}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5124401, "end": 5125352}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5125352, "end": 5125904}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5125904, "end": 5127224}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5127224, "end": 5127899}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5127899, "end": 5129114}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5129114, "end": 5130658}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5130658, "end": 5131865}, {"filename": "/wordpress/wp-includes/blocks/query-title/style.min.css", "start": 5131865, "end": 5131909}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5131909, "end": 5132065}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5132065, "end": 5133321}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5133321, "end": 5134656}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5134656, "end": 5136136}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5136136, "end": 5136736}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5136736, "end": 5137204}, {"filename": "/wordpress/wp-includes/blocks/read-more.php", "start": 5137204, "end": 5138088}, {"filename": "/wordpress/wp-includes/blocks/read-more/block.json", "start": 5138088, "end": 5139298}, {"filename": "/wordpress/wp-includes/blocks/read-more/style.min.css", "start": 5139298, "end": 5139557}, {"filename": "/wordpress/wp-includes/blocks/require-dynamic-blocks.php", "start": 5139557, "end": 5143095}, {"filename": "/wordpress/wp-includes/blocks/require-static-blocks.php", "start": 5143095, "end": 5143426}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5143426, "end": 5146780}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5146780, "end": 5147685}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5147685, "end": 5148121}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5148121, "end": 5148820}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5148820, "end": 5163673}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5163673, "end": 5165598}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5165598, "end": 5165855}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5165855, "end": 5167076}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5167076, "end": 5167202}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5167202, "end": 5168206}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5168206, "end": 5168434}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5168434, "end": 5168786}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5168786, "end": 5169223}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5169223, "end": 5169547}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5169547, "end": 5170012}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5170012, "end": 5171036}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5171036, "end": 5174785}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5174785, "end": 5176126}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5176126, "end": 5177638}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5177638, "end": 5178063}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5178063, "end": 5178719}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5178719, "end": 5179843}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5179843, "end": 5179911}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5179911, "end": 5181169}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5181169, "end": 5182611}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5182611, "end": 5182677}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5182677, "end": 5241192}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5241192, "end": 5241828}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5241828, "end": 5242201}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5242201, "end": 5244125}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5244125, "end": 5246112}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5246112, "end": 5255901}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5255901, "end": 5256524}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5256524, "end": 5257348}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5257348, "end": 5257376}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5257376, "end": 5260920}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5260920, "end": 5262900}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5262900, "end": 5266686}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5266686, "end": 5267005}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5267005, "end": 5268170}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5268170, "end": 5269071}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5269071, "end": 5269569}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5269569, "end": 5275272}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5275272, "end": 5275869}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5275869, "end": 5276401}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5276401, "end": 5276492}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5276492, "end": 5277259}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5277259, "end": 5278276}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5278276, "end": 5279006}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5279006, "end": 5279092}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5279092, "end": 5279544}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5279544, "end": 5280763}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5280763, "end": 5280837}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5280837, "end": 5282652}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5282652, "end": 5284915}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5284915, "end": 5285164}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5285164, "end": 5285334}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5285334, "end": 5286710}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5286710, "end": 5287029}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5287029, "end": 5292515}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5292515, "end": 5300915}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5300915, "end": 5302787}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5302787, "end": 5305648}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5305648, "end": 5329159}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5329159, "end": 5349175}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5349175, "end": 5369972}, {"filename": "/wordpress/wp-includes/category.php", "start": 5369972, "end": 5374443}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5374443, "end": 5607674}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5607674, "end": 5608300}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5608300, "end": 5608740}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5608740, "end": 5608881}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5608881, "end": 5622893}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5622893, "end": 5623038}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5623038, "end": 5626784}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5626784, "end": 5627300}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5627300, "end": 5637877}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5637877, "end": 5638745}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5638745, "end": 5694945}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5694945, "end": 5695265}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5695265, "end": 5716704}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5716704, "end": 5717660}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5717660, "end": 5721284}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5721284, "end": 5729096}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5729096, "end": 5732409}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5732409, "end": 5733275}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5733275, "end": 5736662}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5736662, "end": 5747677}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5747677, "end": 5750004}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5750004, "end": 5755871}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5755871, "end": 5756175}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5756175, "end": 5757529}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5757529, "end": 5763735}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5763735, "end": 5765792}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5765792, "end": 5768116}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5768116, "end": 5770263}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5770263, "end": 5773537}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5773537, "end": 5773868}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5773868, "end": 5775870}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5775870, "end": 5779765}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5779765, "end": 5783782}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5783782, "end": 5805491}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5805491, "end": 5808489}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5808489, "end": 5821582}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5821582, "end": 5945956}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 5945956, "end": 5984904}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 5984904, "end": 5988879}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 5988879, "end": 5993163}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 5993163, "end": 6005747}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 6005747, "end": 6046865}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6046865, "end": 6062018}, {"filename": "/wordpress/wp-includes/class-wp-dependencies.php", "start": 6062018, "end": 6067417}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6067417, "end": 6068120}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6068120, "end": 6110448}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6110448, "end": 6118032}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6118032, "end": 6120831}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6120831, "end": 6123924}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6123924, "end": 6124849}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6124849, "end": 6125234}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6125234, "end": 6131341}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6131341, "end": 6134179}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6134179, "end": 6141784}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6141784, "end": 6144402}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6144402, "end": 6146808}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6146808, "end": 6148745}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6148745, "end": 6149314}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6149314, "end": 6151387}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6151387, "end": 6152267}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6152267, "end": 6163090}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6163090, "end": 6179853}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6179853, "end": 6189058}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6189058, "end": 6203671}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6203671, "end": 6210107}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6210107, "end": 6213131}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6213131, "end": 6215070}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6215070, "end": 6220594}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6220594, "end": 6221332}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6221332, "end": 6234581}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6234581, "end": 6236447}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6236447, "end": 6245426}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6245426, "end": 6250334}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6250334, "end": 6257052}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6257052, "end": 6260764}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6260764, "end": 6274615}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6274615, "end": 6277145}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6277145, "end": 6288890}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6288890, "end": 6291874}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6291874, "end": 6370665}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6370665, "end": 6374304}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6374304, "end": 6380084}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6380084, "end": 6382143}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6382143, "end": 6383718}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6383718, "end": 6389819}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6389819, "end": 6414600}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6414600, "end": 6415258}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6415258, "end": 6418782}, {"filename": "/wordpress/wp-includes/class-wp-scripts.php", "start": 6418782, "end": 6427900}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6427900, "end": 6430408}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6430408, "end": 6431720}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6431720, "end": 6432575}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6432575, "end": 6446680}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6446680, "end": 6449367}, {"filename": "/wordpress/wp-includes/class-wp-styles.php", "start": 6449367, "end": 6454510}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6454510, "end": 6463785}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6463785, "end": 6472945}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6472945, "end": 6491152}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6491152, "end": 6493356}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6493356, "end": 6493693}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6493693, "end": 6501719}, {"filename": "/wordpress/wp-includes/class-wp-textdomain-registry.php", "start": 6501719, "end": 6504094}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-data.php", "start": 6504094, "end": 6504545}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6504545, "end": 6515730}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6515730, "end": 6517559}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6517559, "end": 6576923}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6576923, "end": 6604493}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6604493, "end": 6605955}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6605955, "end": 6624438}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6624438, "end": 6625444}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6625444, "end": 6634661}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6634661, "end": 6640281}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6640281, "end": 6641680}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6641680, "end": 6649121}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6649121, "end": 6776136}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6776136, "end": 6790576}, {"filename": "/wordpress/wp-includes/class-wpdb.php", "start": 6790576, "end": 6840714}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6840714, "end": 6840871}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6840871, "end": 6841018}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6841018, "end": 6841163}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6841163, "end": 6878771}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6878771, "end": 6939158}, {"filename": "/wordpress/wp-includes/compat.php", "start": 6939158, "end": 6944835}, {"filename": "/wordpress/wp-includes/cron.php", "start": 6944835, "end": 6958308}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 6958308, "end": 6958946}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 6958946, "end": 6959158}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 6959158, "end": 6961397}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 6961397, "end": 6962638}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 6962638, "end": 6964365}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 6964365, "end": 6964934}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 6964934, "end": 6967111}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 6967111, "end": 6973593}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 6973593, "end": 6973703}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 6973703, "end": 6980320}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 6980320, "end": 6981253}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 6981253, "end": 6981717}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 6981717, "end": 6988437}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 6988437, "end": 6989048}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 6989048, "end": 6990431}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 6990431, "end": 6995682}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 6995682, "end": 7012078}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 7012078, "end": 7013623}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 7013623, "end": 7015598}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 7015598, "end": 7016226}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 7016226, "end": 7016490}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 7016490, "end": 7026080}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 7026080, "end": 7027928}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7027928, "end": 7028512}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7028512, "end": 7029248}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7029248, "end": 7031934}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7031934, "end": 7037415}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7037415, "end": 7037753}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7037753, "end": 7040061}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7040061, "end": 7048877}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7048877, "end": 7051081}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7051081, "end": 7055730}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7055730, "end": 7056208}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7056208, "end": 7056362}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7056362, "end": 7057462}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7057462, "end": 7058710}, {"filename": "/wordpress/wp-includes/date.php", "start": 7058710, "end": 7058863}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7058863, "end": 7064669}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7064669, "end": 7092356}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7092356, "end": 7093807}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7093807, "end": 7153885}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7153885, "end": 7154031}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7154031, "end": 7172595}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7172595, "end": 7174481}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7174481, "end": 7178407}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7178407, "end": 7180925}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7180925, "end": 7183053}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7183053, "end": 7183984}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7183984, "end": 7186807}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7186807, "end": 7189532}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7189532, "end": 7199118}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7199118, "end": 7409215}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7409215, "end": 7524205}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7524205, "end": 7528757}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7528757, "end": 7530800}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7530800, "end": 7605726}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7605726, "end": 7609906}, {"filename": "/wordpress/wp-includes/http.php", "start": 7609906, "end": 7618226}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7618226, "end": 7621288}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7621288, "end": 7622965}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7622965, "end": 7623710}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7623710, "end": 7625561}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7625561, "end": 7658959}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7658959, "end": 7680721}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7680721, "end": 7741379}, {"filename": "/wordpress/wp-includes/load.php", "start": 7741379, "end": 7764890}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7764890, "end": 7764948}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7764948, "end": 7821030}, {"filename": "/wordpress/wp-includes/media.php", "start": 7821030, "end": 7908781}, {"filename": "/wordpress/wp-includes/meta.php", "start": 7908781, "end": 7931230}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 7931230, "end": 7944601}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 7944601, "end": 7947613}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 7947613, "end": 7953301}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 7953301, "end": 7964717}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 7964717, "end": 7966876}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 7966876, "end": 8008685}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 8008685, "end": 8017442}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 8017442, "end": 8018938}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 8018938, "end": 8020907}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 8020907, "end": 8038726}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8038726, "end": 8052870}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8052870, "end": 8077662}, {"filename": "/wordpress/wp-includes/option.php", "start": 8077662, "end": 8111544}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8111544, "end": 8111749}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8111749, "end": 8114231}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8114231, "end": 8162227}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8162227, "end": 8171118}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8171118, "end": 8172637}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8172637, "end": 8178871}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8178871, "end": 8183099}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8183099, "end": 8192885}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8192885, "end": 8197359}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8197359, "end": 8203075}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8203075, "end": 8207022}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8207022, "end": 8237096}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8237096, "end": 8240099}, {"filename": "/wordpress/wp-includes/post.php", "start": 8240099, "end": 8360421}, {"filename": "/wordpress/wp-includes/query.php", "start": 8360421, "end": 8374211}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8374211, "end": 8376274}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8376274, "end": 8376735}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8376735, "end": 8376985}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8376985, "end": 8379851}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8379851, "end": 8380556}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8380556, "end": 8381886}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8381886, "end": 8382561}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8382561, "end": 8383249}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8383249, "end": 8383752}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8383752, "end": 8384886}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8384886, "end": 8384999}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8384999, "end": 8385112}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8385112, "end": 8440483}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8440483, "end": 8451558}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8451558, "end": 8454021}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8454021, "end": 8479328}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8479328, "end": 8494398}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8494398, "end": 8523254}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8523254, "end": 8531333}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8531333, "end": 8537657}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php", "start": 8537657, "end": 8540148}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php", "start": 8540148, "end": 8544569}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8544569, "end": 8548096}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8548096, "end": 8564507}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8564507, "end": 8565379}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8565379, "end": 8604316}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8604316, "end": 8613271}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8613271, "end": 8614478}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8614478, "end": 8626468}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8626468, "end": 8649328}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8649328, "end": 8654528}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8654528, "end": 8665451}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8665451, "end": 8672000}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8672000, "end": 8691197}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8691197, "end": 8697760}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8697760, "end": 8706632}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8706632, "end": 8771087}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8771087, "end": 8787466}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8787466, "end": 8794820}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8794820, "end": 8799358}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8799358, "end": 8809102}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8809102, "end": 8815436}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8815436, "end": 8824494}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8824494, "end": 8844939}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8844939, "end": 8865963}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8865963, "end": 8878719}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8878719, "end": 8886976}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8886976, "end": 8918380}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 8918380, "end": 8929798}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 8929798, "end": 8945984}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 8945984, "end": 8946234}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 8946234, "end": 8956683}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 8956683, "end": 8957040}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 8957040, "end": 8957432}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 8957432, "end": 8957670}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 8957670, "end": 8959610}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 8959610, "end": 8962585}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 8962585, "end": 8963033}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 8963033, "end": 8965422}, {"filename": "/wordpress/wp-includes/revision.php", "start": 8965422, "end": 8977566}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 8977566, "end": 8985591}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 8985591, "end": 8986907}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 8986907, "end": 8987070}, {"filename": "/wordpress/wp-includes/rss.php", "start": 8987070, "end": 9001512}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 9001512, "end": 9092680}, {"filename": "/wordpress/wp-includes/session.php", "start": 9092680, "end": 9092874}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9092874, "end": 9100774}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9100774, "end": 9101974}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9101974, "end": 9102751}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9102751, "end": 9104413}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9104413, "end": 9105033}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9105033, "end": 9108589}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9108589, "end": 9115534}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9115534, "end": 9118783}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9118783, "end": 9121274}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9121274, "end": 9123491}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9123491, "end": 9124980}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9124980, "end": 9125840}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9125840, "end": 9126259}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9126259, "end": 9127960}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9127960, "end": 9129568}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9129568, "end": 9133726}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9133726, "end": 9134277}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9134277, "end": 9156714}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9156714, "end": 9161310}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9161310, "end": 9165473}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9165473, "end": 9176691}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9176691, "end": 9177558}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9177558, "end": 9177642}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9177642, "end": 9177738}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9177738, "end": 9177836}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9177836, "end": 9177942}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9177942, "end": 9178056}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9178056, "end": 9178158}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9178158, "end": 9178266}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9178266, "end": 9178388}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9178388, "end": 9178506}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9178506, "end": 9178620}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9178620, "end": 9178734}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9178734, "end": 9178858}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9178858, "end": 9178964}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9178964, "end": 9179060}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9179060, "end": 9179160}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9179160, "end": 9179258}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9179258, "end": 9179356}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9179356, "end": 9179466}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9179466, "end": 9179562}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9179562, "end": 9179658}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9179658, "end": 9179748}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9179748, "end": 9179842}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9179842, "end": 9179942}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9179942, "end": 9180040}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9180040, "end": 9180124}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9180124, "end": 9180204}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9180204, "end": 9262655}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9262655, "end": 9273626}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9273626, "end": 9276586}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9276586, "end": 9280021}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9280021, "end": 9283456}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9283456, "end": 9288656}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9288656, "end": 9290692}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9290692, "end": 9291398}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9291398, "end": 9370615}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9370615, "end": 9371898}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9371898, "end": 9372721}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9372721, "end": 9373462}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9373462, "end": 9374057}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9374057, "end": 9374794}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9374794, "end": 9375483}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9375483, "end": 9464523}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9464523, "end": 9473305}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9473305, "end": 9475871}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9475871, "end": 9478335}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9478335, "end": 9479110}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9479110, "end": 9485956}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9485956, "end": 9498484}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9498484, "end": 9503358}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9503358, "end": 9505463}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9505463, "end": 9508774}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9508774, "end": 9521150}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9521150, "end": 9525865}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9525865, "end": 9527462}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9527462, "end": 9527944}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9527944, "end": 9537325}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9537325, "end": 9542829}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9542829, "end": 9545594}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9545594, "end": 9546448}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9546448, "end": 9629550}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9629550, "end": 9632240}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9632240, "end": 9633083}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9633083, "end": 9633840}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9633840, "end": 9634451}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9634451, "end": 9635208}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9635208, "end": 9635910}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9635910, "end": 9724261}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9724261, "end": 9732032}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9732032, "end": 9735108}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9735108, "end": 9739116}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9739116, "end": 9752557}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9752557, "end": 9770147}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9770147, "end": 9770932}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9770932, "end": 9779546}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9779546, "end": 9786139}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9786139, "end": 9788272}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9788272, "end": 9791041}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9791041, "end": 9791200}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9791200, "end": 9797198}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9797198, "end": 9798339}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9798339, "end": 9798827}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9798827, "end": 9823374}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9823374, "end": 9848230}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9848230, "end": 9877638}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9877638, "end": 9879294}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9879294, "end": 9879394}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9879394, "end": 9879504}, {"filename": "/wordpress/wp-includes/style-engine.php", "start": 9879504, "end": 9881396}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-declarations.php", "start": 9881396, "end": 9883359}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rule.php", "start": 9883359, "end": 9884959}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php", "start": 9884959, "end": 9886072}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-processor.php", "start": 9886072, "end": 9888140}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine.php", "start": 9888140, "end": 9898492}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9898492, "end": 9968193}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 9968193, "end": 9968519}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 9968519, "end": 9970244}, {"filename": "/wordpress/wp-includes/template.php", "start": 9970244, "end": 9977225}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 9977225, "end": 9978853}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 9978853, "end": 9979370}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 9979370, "end": 9981360}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 9981360, "end": 9981574}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 9981574, "end": 9981629}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 9981629, "end": 9982305}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 9982305, "end": 9982635}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 9982635, "end": 9984195}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 9984195, "end": 9987320}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 9987320, "end": 9988471}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 9988471, "end": 9992144}, {"filename": "/wordpress/wp-includes/theme.json", "start": 9992144, "end": 10001552}, {"filename": "/wordpress/wp-includes/theme.php", "start": 10001552, "end": 10071493}, {"filename": "/wordpress/wp-includes/update.php", "start": 10071493, "end": 10092192}, {"filename": "/wordpress/wp-includes/user.php", "start": 10092192, "end": 10165617}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10165617, "end": 10169612}, {"filename": "/wordpress/wp-includes/version.php", "start": 10169612, "end": 10169780}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10169780, "end": 10202525}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10202525, "end": 10206387}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10206387, "end": 10210627}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10210627, "end": 10213832}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10213832, "end": 10215318}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10215318, "end": 10219849}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10219849, "end": 10226991}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10226991, "end": 10232430}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10232430, "end": 10236644}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10236644, "end": 10241784}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10241784, "end": 10250618}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10250618, "end": 10256695}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10256695, "end": 10264822}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10264822, "end": 10267020}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10267020, "end": 10270597}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10270597, "end": 10274707}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10274707, "end": 10278591}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10278591, "end": 10281769}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10281769, "end": 10283161}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10283161, "end": 10287410}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10287410, "end": 10299807}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10299807, "end": 10300852}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10300852, "end": 10301031}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10301031, "end": 10301380}, {"filename": "/wordpress/wp-links-opml.php", "start": 10301380, "end": 10302991}, {"filename": "/wordpress/wp-load.php", "start": 10302991, "end": 10304786}, {"filename": "/wordpress/wp-login.php", "start": 10304786, "end": 10338919}, {"filename": "/wordpress/wp-mail.php", "start": 10338919, "end": 10344870}, {"filename": "/wordpress/wp-settings.php", "start": 10344870, "end": 10361792}, {"filename": "/wordpress/wp-signup.php", "start": 10361792, "end": 10384704}, {"filename": "/wordpress/wp-trackback.php", "start": 10384704, "end": 10388131}, {"filename": "/wordpress/xmlrpc.php", "start": 10388131, "end": 10389954}], "remote_package_size": 10389954}); + loadPackage({"files": [{"filename": "/wordpress/debug.txt", "start": 0, "end": 4337}, {"filename": "/wordpress/index.php", "start": 4337, "end": 4418}, {"filename": "/wordpress/readme.html", "start": 4418, "end": 11808}, {"filename": "/wordpress/wp-activate.php", "start": 11808, "end": 17830}, {"filename": "/wordpress/wp-admin/about.php", "start": 17830, "end": 47710}, {"filename": "/wordpress/wp-admin/admin-ajax.php", "start": 47710, "end": 51422}, {"filename": "/wordpress/wp-admin/admin-footer.php", "start": 51422, "end": 52602}, {"filename": "/wordpress/wp-admin/admin-functions.php", "start": 52602, "end": 52745}, {"filename": "/wordpress/wp-admin/admin-header.php", "start": 52745, "end": 58148}, {"filename": "/wordpress/wp-admin/admin-post.php", "start": 58148, "end": 58995}, {"filename": "/wordpress/wp-admin/admin.php", "start": 58995, "end": 64949}, {"filename": "/wordpress/wp-admin/async-upload.php", "start": 64949, "end": 68615}, {"filename": "/wordpress/wp-admin/authorize-application.php", "start": 68615, "end": 76147}, {"filename": "/wordpress/wp-admin/comment.php", "start": 76147, "end": 85906}, {"filename": "/wordpress/wp-admin/credits.php", "start": 85906, "end": 89241}, {"filename": "/wordpress/wp-admin/custom-background.php", "start": 89241, "end": 89420}, {"filename": "/wordpress/wp-admin/custom-header.php", "start": 89420, "end": 89603}, {"filename": "/wordpress/wp-admin/customize.php", "start": 89603, "end": 98475}, {"filename": "/wordpress/wp-admin/edit-comments.php", "start": 98475, "end": 111057}, {"filename": "/wordpress/wp-admin/edit-form-advanced.php", "start": 111057, "end": 134948}, {"filename": "/wordpress/wp-admin/edit-form-blocks.php", "start": 134948, "end": 142772}, {"filename": "/wordpress/wp-admin/edit-form-comment.php", "start": 142772, "end": 149945}, {"filename": "/wordpress/wp-admin/edit-link-form.php", "start": 149945, "end": 155459}, {"filename": "/wordpress/wp-admin/edit-tag-form.php", "start": 155459, "end": 161442}, {"filename": "/wordpress/wp-admin/edit-tags.php", "start": 161442, "end": 177873}, {"filename": "/wordpress/wp-admin/edit.php", "start": 177873, "end": 193930}, {"filename": "/wordpress/wp-admin/erase-personal-data.php", "start": 193930, "end": 200814}, {"filename": "/wordpress/wp-admin/export-personal-data.php", "start": 200814, "end": 208102}, {"filename": "/wordpress/wp-admin/export.php", "start": 208102, "end": 217920}, {"filename": "/wordpress/wp-admin/freedoms.php", "start": 217920, "end": 221863}, {"filename": "/wordpress/wp-admin/import.php", "start": 221863, "end": 227731}, {"filename": "/wordpress/wp-admin/includes/admin-filters.php", "start": 227731, "end": 234643}, {"filename": "/wordpress/wp-admin/includes/admin.php", "start": 234643, "end": 236785}, {"filename": "/wordpress/wp-admin/includes/ajax-actions.php", "start": 236785, "end": 347967}, {"filename": "/wordpress/wp-admin/includes/bookmark.php", "start": 347967, "end": 354723}, {"filename": "/wordpress/wp-admin/includes/class-automatic-upgrader-skin.php", "start": 354723, "end": 355998}, {"filename": "/wordpress/wp-admin/includes/class-bulk-plugin-upgrader-skin.php", "start": 355998, "end": 357138}, {"filename": "/wordpress/wp-admin/includes/class-bulk-theme-upgrader-skin.php", "start": 357138, "end": 358326}, {"filename": "/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php", "start": 358326, "end": 362393}, {"filename": "/wordpress/wp-admin/includes/class-core-upgrader.php", "start": 362393, "end": 371168}, {"filename": "/wordpress/wp-admin/includes/class-custom-background.php", "start": 371168, "end": 388853}, {"filename": "/wordpress/wp-admin/includes/class-custom-image-header.php", "start": 388853, "end": 426353}, {"filename": "/wordpress/wp-admin/includes/class-file-upload-upgrader.php", "start": 426353, "end": 428123}, {"filename": "/wordpress/wp-admin/includes/class-ftp-pure.php", "start": 428123, "end": 432238}, {"filename": "/wordpress/wp-admin/includes/class-ftp-sockets.php", "start": 432238, "end": 439239}, {"filename": "/wordpress/wp-admin/includes/class-ftp.php", "start": 439239, "end": 462294}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader-skin.php", "start": 462294, "end": 463760}, {"filename": "/wordpress/wp-admin/includes/class-language-pack-upgrader.php", "start": 463760, "end": 472726}, {"filename": "/wordpress/wp-admin/includes/class-pclzip.php", "start": 472726, "end": 561785}, {"filename": "/wordpress/wp-admin/includes/class-plugin-installer-skin.php", "start": 561785, "end": 570314}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader-skin.php", "start": 570314, "end": 572159}, {"filename": "/wordpress/wp-admin/includes/class-plugin-upgrader.php", "start": 572159, "end": 583813}, {"filename": "/wordpress/wp-admin/includes/class-theme-installer-skin.php", "start": 583813, "end": 592975}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader-skin.php", "start": 592975, "end": 595640}, {"filename": "/wordpress/wp-admin/includes/class-theme-upgrader.php", "start": 595640, "end": 610282}, {"filename": "/wordpress/wp-admin/includes/class-walker-category-checklist.php", "start": 610282, "end": 612536}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-checklist.php", "start": 612536, "end": 616190}, {"filename": "/wordpress/wp-admin/includes/class-walker-nav-menu-edit.php", "start": 616190, "end": 626338}, {"filename": "/wordpress/wp-admin/includes/class-wp-ajax-upgrader-skin.php", "start": 626338, "end": 628129}, {"filename": "/wordpress/wp-admin/includes/class-wp-application-passwords-list-table.php", "start": 628129, "end": 631814}, {"filename": "/wordpress/wp-admin/includes/class-wp-automatic-updater.php", "start": 631814, "end": 660420}, {"filename": "/wordpress/wp-admin/includes/class-wp-comments-list-table.php", "start": 660420, "end": 682188}, {"filename": "/wordpress/wp-admin/includes/class-wp-community-events.php", "start": 682188, "end": 689560}, {"filename": "/wordpress/wp-admin/includes/class-wp-debug-data.php", "start": 689560, "end": 733065}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-base.php", "start": 733065, "end": 740637}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-direct.php", "start": 740637, "end": 747317}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php", "start": 747317, "end": 757422}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php", "start": 757422, "end": 764570}, {"filename": "/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php", "start": 764570, "end": 774308}, {"filename": "/wordpress/wp-admin/includes/class-wp-importer.php", "start": 774308, "end": 778970}, {"filename": "/wordpress/wp-admin/includes/class-wp-internal-pointers.php", "start": 778970, "end": 781372}, {"filename": "/wordpress/wp-admin/includes/class-wp-links-list-table.php", "start": 781372, "end": 786168}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table-compat.php", "start": 786168, "end": 786896}, {"filename": "/wordpress/wp-admin/includes/class-wp-list-table.php", "start": 786896, "end": 813189}, {"filename": "/wordpress/wp-admin/includes/class-wp-media-list-table.php", "start": 813189, "end": 830625}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-sites-list-table.php", "start": 830625, "end": 843510}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php", "start": 843510, "end": 861125}, {"filename": "/wordpress/wp-admin/includes/class-wp-ms-users-list-table.php", "start": 861125, "end": 870119}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugin-install-list-table.php", "start": 870119, "end": 887020}, {"filename": "/wordpress/wp-admin/includes/class-wp-plugins-list-table.php", "start": 887020, "end": 915575}, {"filename": "/wordpress/wp-admin/includes/class-wp-post-comments-list-table.php", "start": 915575, "end": 916533}, {"filename": "/wordpress/wp-admin/includes/class-wp-posts-list-table.php", "start": 916533, "end": 957618}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php", "start": 957618, "end": 961825}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php", "start": 961825, "end": 966042}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-policy-content.php", "start": 966042, "end": 989447}, {"filename": "/wordpress/wp-admin/includes/class-wp-privacy-requests-table.php", "start": 989447, "end": 997562}, {"filename": "/wordpress/wp-admin/includes/class-wp-screen.php", "start": 997562, "end": 1017550}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health-auto-updates.php", "start": 1017550, "end": 1026051}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-health.php", "start": 1026051, "end": 1099359}, {"filename": "/wordpress/wp-admin/includes/class-wp-site-icon.php", "start": 1099359, "end": 1101982}, {"filename": "/wordpress/wp-admin/includes/class-wp-terms-list-table.php", "start": 1101982, "end": 1114159}, {"filename": "/wordpress/wp-admin/includes/class-wp-theme-install-list-table.php", "start": 1114159, "end": 1124301}, {"filename": "/wordpress/wp-admin/includes/class-wp-themes-list-table.php", "start": 1124301, "end": 1132056}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skin.php", "start": 1132056, "end": 1135151}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader-skins.php", "start": 1135151, "end": 1136073}, {"filename": "/wordpress/wp-admin/includes/class-wp-upgrader.php", "start": 1136073, "end": 1151658}, {"filename": "/wordpress/wp-admin/includes/class-wp-users-list-table.php", "start": 1151658, "end": 1163006}, {"filename": "/wordpress/wp-admin/includes/comment.php", "start": 1163006, "end": 1166842}, {"filename": "/wordpress/wp-admin/includes/continents-cities.php", "start": 1166842, "end": 1187148}, {"filename": "/wordpress/wp-admin/includes/credits.php", "start": 1187148, "end": 1190934}, {"filename": "/wordpress/wp-admin/includes/dashboard.php", "start": 1190934, "end": 1238856}, {"filename": "/wordpress/wp-admin/includes/deprecated.php", "start": 1238856, "end": 1259073}, {"filename": "/wordpress/wp-admin/includes/edit-tag-messages.php", "start": 1259073, "end": 1260175}, {"filename": "/wordpress/wp-admin/includes/export.php", "start": 1260175, "end": 1275687}, {"filename": "/wordpress/wp-admin/includes/file.php", "start": 1275687, "end": 1324374}, {"filename": "/wordpress/wp-admin/includes/image-edit.php", "start": 1324374, "end": 1353194}, {"filename": "/wordpress/wp-admin/includes/image.php", "start": 1353194, "end": 1372135}, {"filename": "/wordpress/wp-admin/includes/import.php", "start": 1372135, "end": 1376389}, {"filename": "/wordpress/wp-admin/includes/list-table.php", "start": 1376389, "end": 1378244}, {"filename": "/wordpress/wp-admin/includes/media.php", "start": 1378244, "end": 1462439}, {"filename": "/wordpress/wp-admin/includes/menu.php", "start": 1462439, "end": 1467784}, {"filename": "/wordpress/wp-admin/includes/meta-boxes.php", "start": 1467784, "end": 1515419}, {"filename": "/wordpress/wp-admin/includes/misc.php", "start": 1515419, "end": 1542778}, {"filename": "/wordpress/wp-admin/includes/ms-admin-filters.php", "start": 1542778, "end": 1543798}, {"filename": "/wordpress/wp-admin/includes/ms-deprecated.php", "start": 1543798, "end": 1545427}, {"filename": "/wordpress/wp-admin/includes/ms.php", "start": 1545427, "end": 1568353}, {"filename": "/wordpress/wp-admin/includes/nav-menu.php", "start": 1568353, "end": 1603665}, {"filename": "/wordpress/wp-admin/includes/network.php", "start": 1603665, "end": 1625416}, {"filename": "/wordpress/wp-admin/includes/noop.php", "start": 1625416, "end": 1626014}, {"filename": "/wordpress/wp-admin/includes/options.php", "start": 1626014, "end": 1629714}, {"filename": "/wordpress/wp-admin/includes/plugin-install.php", "start": 1629714, "end": 1651267}, {"filename": "/wordpress/wp-admin/includes/plugin.php", "start": 1651267, "end": 1691620}, {"filename": "/wordpress/wp-admin/includes/post.php", "start": 1691620, "end": 1743172}, {"filename": "/wordpress/wp-admin/includes/privacy-tools.php", "start": 1743172, "end": 1762724}, {"filename": "/wordpress/wp-admin/includes/revision.php", "start": 1762724, "end": 1772623}, {"filename": "/wordpress/wp-admin/includes/schema.php", "start": 1772623, "end": 1803509}, {"filename": "/wordpress/wp-admin/includes/screen.php", "start": 1803509, "end": 1806520}, {"filename": "/wordpress/wp-admin/includes/taxonomy.php", "start": 1806520, "end": 1810333}, {"filename": "/wordpress/wp-admin/includes/template.php", "start": 1810333, "end": 1865120}, {"filename": "/wordpress/wp-admin/includes/theme-install.php", "start": 1865120, "end": 1870507}, {"filename": "/wordpress/wp-admin/includes/theme.php", "start": 1870507, "end": 1896698}, {"filename": "/wordpress/wp-admin/includes/translation-install.php", "start": 1896698, "end": 1902594}, {"filename": "/wordpress/wp-admin/includes/update-core.php", "start": 1902594, "end": 1956126}, {"filename": "/wordpress/wp-admin/includes/update.php", "start": 1956126, "end": 1978067}, {"filename": "/wordpress/wp-admin/includes/upgrade.php", "start": 1978067, "end": 2048840}, {"filename": "/wordpress/wp-admin/includes/user.php", "start": 2048840, "end": 2061988}, {"filename": "/wordpress/wp-admin/includes/widgets.php", "start": 2061988, "end": 2070688}, {"filename": "/wordpress/wp-admin/index.php", "start": 2070688, "end": 2077261}, {"filename": "/wordpress/wp-admin/install-helper.php", "start": 2077261, "end": 2079189}, {"filename": "/wordpress/wp-admin/install.php", "start": 2079189, "end": 2093331}, {"filename": "/wordpress/wp-admin/link-add.php", "start": 2093331, "end": 2093882}, {"filename": "/wordpress/wp-admin/link-manager.php", "start": 2093882, "end": 2097539}, {"filename": "/wordpress/wp-admin/link-parse-opml.php", "start": 2097539, "end": 2098961}, {"filename": "/wordpress/wp-admin/link.php", "start": 2098961, "end": 2100931}, {"filename": "/wordpress/wp-admin/load-scripts.php", "start": 2100931, "end": 2102461}, {"filename": "/wordpress/wp-admin/load-styles.php", "start": 2102461, "end": 2104718}, {"filename": "/wordpress/wp-admin/maint/repair.php", "start": 2104718, "end": 2110769}, {"filename": "/wordpress/wp-admin/media-new.php", "start": 2110769, "end": 2113606}, {"filename": "/wordpress/wp-admin/media-upload.php", "start": 2113606, "end": 2115126}, {"filename": "/wordpress/wp-admin/media.php", "start": 2115126, "end": 2120206}, {"filename": "/wordpress/wp-admin/menu-header.php", "start": 2120206, "end": 2127385}, {"filename": "/wordpress/wp-admin/menu.php", "start": 2127385, "end": 2141637}, {"filename": "/wordpress/wp-admin/moderation.php", "start": 2141637, "end": 2141774}, {"filename": "/wordpress/wp-admin/ms-admin.php", "start": 2141774, "end": 2141860}, {"filename": "/wordpress/wp-admin/ms-delete-site.php", "start": 2141860, "end": 2145431}, {"filename": "/wordpress/wp-admin/ms-edit.php", "start": 2145431, "end": 2145517}, {"filename": "/wordpress/wp-admin/ms-options.php", "start": 2145517, "end": 2145613}, {"filename": "/wordpress/wp-admin/ms-sites.php", "start": 2145613, "end": 2145712}, {"filename": "/wordpress/wp-admin/ms-themes.php", "start": 2145712, "end": 2145812}, {"filename": "/wordpress/wp-admin/ms-upgrade-network.php", "start": 2145812, "end": 2145913}, {"filename": "/wordpress/wp-admin/ms-users.php", "start": 2145913, "end": 2146012}, {"filename": "/wordpress/wp-admin/my-sites.php", "start": 2146012, "end": 2149513}, {"filename": "/wordpress/wp-admin/nav-menus.php", "start": 2149513, "end": 2188873}, {"filename": "/wordpress/wp-admin/network.php", "start": 2188873, "end": 2193701}, {"filename": "/wordpress/wp-admin/network/about.php", "start": 2193701, "end": 2193785}, {"filename": "/wordpress/wp-admin/network/admin.php", "start": 2193785, "end": 2194370}, {"filename": "/wordpress/wp-admin/network/credits.php", "start": 2194370, "end": 2194456}, {"filename": "/wordpress/wp-admin/network/edit.php", "start": 2194456, "end": 2194750}, {"filename": "/wordpress/wp-admin/network/freedoms.php", "start": 2194750, "end": 2194837}, {"filename": "/wordpress/wp-admin/network/index.php", "start": 2194837, "end": 2197451}, {"filename": "/wordpress/wp-admin/network/menu.php", "start": 2197451, "end": 2201671}, {"filename": "/wordpress/wp-admin/network/plugin-editor.php", "start": 2201671, "end": 2201763}, {"filename": "/wordpress/wp-admin/network/plugin-install.php", "start": 2201763, "end": 2201968}, {"filename": "/wordpress/wp-admin/network/plugins.php", "start": 2201968, "end": 2202054}, {"filename": "/wordpress/wp-admin/network/privacy.php", "start": 2202054, "end": 2202140}, {"filename": "/wordpress/wp-admin/network/profile.php", "start": 2202140, "end": 2202226}, {"filename": "/wordpress/wp-admin/network/settings.php", "start": 2202226, "end": 2221292}, {"filename": "/wordpress/wp-admin/network/setup.php", "start": 2221292, "end": 2221378}, {"filename": "/wordpress/wp-admin/network/site-info.php", "start": 2221378, "end": 2227519}, {"filename": "/wordpress/wp-admin/network/site-new.php", "start": 2227519, "end": 2235307}, {"filename": "/wordpress/wp-admin/network/site-settings.php", "start": 2235307, "end": 2239941}, {"filename": "/wordpress/wp-admin/network/site-themes.php", "start": 2239941, "end": 2245231}, {"filename": "/wordpress/wp-admin/network/site-users.php", "start": 2245231, "end": 2255033}, {"filename": "/wordpress/wp-admin/network/sites.php", "start": 2255033, "end": 2265675}, {"filename": "/wordpress/wp-admin/network/theme-editor.php", "start": 2265675, "end": 2265766}, {"filename": "/wordpress/wp-admin/network/theme-install.php", "start": 2265766, "end": 2265969}, {"filename": "/wordpress/wp-admin/network/themes.php", "start": 2265969, "end": 2280187}, {"filename": "/wordpress/wp-admin/network/update-core.php", "start": 2280187, "end": 2280277}, {"filename": "/wordpress/wp-admin/network/update.php", "start": 2280277, "end": 2280542}, {"filename": "/wordpress/wp-admin/network/upgrade.php", "start": 2280542, "end": 2284325}, {"filename": "/wordpress/wp-admin/network/user-edit.php", "start": 2284325, "end": 2284413}, {"filename": "/wordpress/wp-admin/network/user-new.php", "start": 2284413, "end": 2288939}, {"filename": "/wordpress/wp-admin/network/users.php", "start": 2288939, "end": 2296666}, {"filename": "/wordpress/wp-admin/options-discussion.php", "start": 2296666, "end": 2310161}, {"filename": "/wordpress/wp-admin/options-general.php", "start": 2310161, "end": 2323527}, {"filename": "/wordpress/wp-admin/options-head.php", "start": 2323527, "end": 2323741}, {"filename": "/wordpress/wp-admin/options-media.php", "start": 2323741, "end": 2329586}, {"filename": "/wordpress/wp-admin/options-permalink.php", "start": 2329586, "end": 2347894}, {"filename": "/wordpress/wp-admin/options-privacy.php", "start": 2347894, "end": 2356355}, {"filename": "/wordpress/wp-admin/options-reading.php", "start": 2356355, "end": 2364923}, {"filename": "/wordpress/wp-admin/options-writing.php", "start": 2364923, "end": 2372562}, {"filename": "/wordpress/wp-admin/options.php", "start": 2372562, "end": 2382279}, {"filename": "/wordpress/wp-admin/plugin-editor.php", "start": 2382279, "end": 2394563}, {"filename": "/wordpress/wp-admin/plugin-install.php", "start": 2394563, "end": 2399333}, {"filename": "/wordpress/wp-admin/plugins.php", "start": 2399333, "end": 2423942}, {"filename": "/wordpress/wp-admin/post-new.php", "start": 2423942, "end": 2426014}, {"filename": "/wordpress/wp-admin/post.php", "start": 2426014, "end": 2434284}, {"filename": "/wordpress/wp-admin/press-this.php", "start": 2434284, "end": 2436200}, {"filename": "/wordpress/wp-admin/privacy-policy-guide.php", "start": 2436200, "end": 2439531}, {"filename": "/wordpress/wp-admin/privacy.php", "start": 2439531, "end": 2441672}, {"filename": "/wordpress/wp-admin/profile.php", "start": 2441672, "end": 2441755}, {"filename": "/wordpress/wp-admin/revision.php", "start": 2441755, "end": 2445891}, {"filename": "/wordpress/wp-admin/setup-config.php", "start": 2445891, "end": 2459694}, {"filename": "/wordpress/wp-admin/site-editor.php", "start": 2459694, "end": 2464242}, {"filename": "/wordpress/wp-admin/site-health-info.php", "start": 2464242, "end": 2467879}, {"filename": "/wordpress/wp-admin/site-health.php", "start": 2467879, "end": 2476268}, {"filename": "/wordpress/wp-admin/term.php", "start": 2476268, "end": 2478202}, {"filename": "/wordpress/wp-admin/theme-editor.php", "start": 2478202, "end": 2492183}, {"filename": "/wordpress/wp-admin/theme-install.php", "start": 2492183, "end": 2511454}, {"filename": "/wordpress/wp-admin/themes.php", "start": 2511454, "end": 2550740}, {"filename": "/wordpress/wp-admin/tools.php", "start": 2550740, "end": 2553489}, {"filename": "/wordpress/wp-admin/update-core.php", "start": 2553489, "end": 2590233}, {"filename": "/wordpress/wp-admin/update.php", "start": 2590233, "end": 2600756}, {"filename": "/wordpress/wp-admin/upgrade-functions.php", "start": 2600756, "end": 2600903}, {"filename": "/wordpress/wp-admin/upgrade.php", "start": 2600903, "end": 2605247}, {"filename": "/wordpress/wp-admin/upload.php", "start": 2605247, "end": 2618285}, {"filename": "/wordpress/wp-admin/user-edit.php", "start": 2618285, "end": 2650322}, {"filename": "/wordpress/wp-admin/user-new.php", "start": 2650322, "end": 2670880}, {"filename": "/wordpress/wp-admin/user/about.php", "start": 2670880, "end": 2670964}, {"filename": "/wordpress/wp-admin/user/admin.php", "start": 2670964, "end": 2671506}, {"filename": "/wordpress/wp-admin/user/credits.php", "start": 2671506, "end": 2671592}, {"filename": "/wordpress/wp-admin/user/freedoms.php", "start": 2671592, "end": 2671679}, {"filename": "/wordpress/wp-admin/user/index.php", "start": 2671679, "end": 2671763}, {"filename": "/wordpress/wp-admin/user/menu.php", "start": 2671763, "end": 2672349}, {"filename": "/wordpress/wp-admin/user/privacy.php", "start": 2672349, "end": 2672435}, {"filename": "/wordpress/wp-admin/user/profile.php", "start": 2672435, "end": 2672521}, {"filename": "/wordpress/wp-admin/user/user-edit.php", "start": 2672521, "end": 2672609}, {"filename": "/wordpress/wp-admin/users.php", "start": 2672609, "end": 2691197}, {"filename": "/wordpress/wp-admin/widgets-form-blocks.php", "start": 2691197, "end": 2692971}, {"filename": "/wordpress/wp-admin/widgets-form.php", "start": 2692971, "end": 2710025}, {"filename": "/wordpress/wp-admin/widgets.php", "start": 2710025, "end": 2710902}, {"filename": "/wordpress/wp-blog-header.php", "start": 2710902, "end": 2711069}, {"filename": "/wordpress/wp-comments-post.php", "start": 2711069, "end": 2712480}, {"filename": "/wordpress/wp-config-sample.php", "start": 2712480, "end": 2713323}, {"filename": "/wordpress/wp-config.php", "start": 2713323, "end": 2714206}, {"filename": "/wordpress/wp-content/database/.ht.sqlite", "start": 2714206, "end": 2919006}, {"filename": "/wordpress/wp-content/database/.htaccess", "start": 2919006, "end": 2919019}, {"filename": "/wordpress/wp-content/database/index.php", "start": 2919019, "end": 2919027}, {"filename": "/wordpress/wp-content/db.php", "start": 2919027, "end": 3002417}, {"filename": "/wordpress/wp-content/index.php", "start": 3002417, "end": 3002423}, {"filename": "/wordpress/wp-content/plugins/akismet/akismet.php", "start": 3002423, "end": 3003558}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-admin.php", "start": 3003558, "end": 3043931}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-cli.php", "start": 3043931, "end": 3046964}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-rest-api.php", "start": 3046964, "end": 3055131}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet-widget.php", "start": 3055131, "end": 3057962}, {"filename": "/wordpress/wp-content/plugins/akismet/class.akismet.php", "start": 3057962, "end": 3101850}, {"filename": "/wordpress/wp-content/plugins/akismet/index.php", "start": 3101850, "end": 3101856}, {"filename": "/wordpress/wp-content/plugins/akismet/views/activate.php", "start": 3101856, "end": 3102033}, {"filename": "/wordpress/wp-content/plugins/akismet/views/config.php", "start": 3102033, "end": 3113730}, {"filename": "/wordpress/wp-content/plugins/akismet/views/connect-jp.php", "start": 3113730, "end": 3118228}, {"filename": "/wordpress/wp-content/plugins/akismet/views/enter.php", "start": 3118228, "end": 3119042}, {"filename": "/wordpress/wp-content/plugins/akismet/views/get.php", "start": 3119042, "end": 3119797}, {"filename": "/wordpress/wp-content/plugins/akismet/views/notice.php", "start": 3119797, "end": 3132679}, {"filename": "/wordpress/wp-content/plugins/akismet/views/predefined.php", "start": 3132679, "end": 3132942}, {"filename": "/wordpress/wp-content/plugins/akismet/views/setup.php", "start": 3132942, "end": 3133266}, {"filename": "/wordpress/wp-content/plugins/akismet/views/start.php", "start": 3133266, "end": 3134073}, {"filename": "/wordpress/wp-content/plugins/akismet/views/stats.php", "start": 3134073, "end": 3134851}, {"filename": "/wordpress/wp-content/plugins/akismet/views/title.php", "start": 3134851, "end": 3134976}, {"filename": "/wordpress/wp-content/plugins/akismet/wrapper.php", "start": 3134976, "end": 3141275}, {"filename": "/wordpress/wp-content/plugins/hello.php", "start": 3141275, "end": 3143010}, {"filename": "/wordpress/wp-content/plugins/index.php", "start": 3143010, "end": 3143016}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php", "start": 3143016, "end": 3194445}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/compat.php", "start": 3194445, "end": 3195309}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers.php", "start": 3195309, "end": 3195890}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php", "start": 3195890, "end": 3207192}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php", "start": 3207192, "end": 3215371}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-xml.php", "start": 3215371, "end": 3222258}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser.php", "start": 3222258, "end": 3224162}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/readme.txt", "start": 3224162, "end": 3229983}, {"filename": "/wordpress/wp-content/plugins/wordpress-importer/wordpress-importer.php", "start": 3229983, "end": 3232191}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/comments.html", "start": 3232191, "end": 3232257}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/footer.html", "start": 3232257, "end": 3232322}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/header.html", "start": 3232322, "end": 3232858}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/parts/post-meta.html", "start": 3232858, "end": 3232918}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/call-to-action.php", "start": 3232918, "end": 3234022}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/footer-default.php", "start": 3234022, "end": 3234756}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-404.php", "start": 3234756, "end": 3236088}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-comments.php", "start": 3236088, "end": 3238136}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/hidden-no-results.php", "start": 3238136, "end": 3238735}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/patterns/post-meta.php", "start": 3238735, "end": 3241246}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/style.css", "start": 3241246, "end": 3242342}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/aubergine.json", "start": 3242342, "end": 3248374}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/block-out.json", "start": 3248374, "end": 3252739}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/canary.json", "start": 3252739, "end": 3257331}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/electric.json", "start": 3257331, "end": 3259203}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/grapes.json", "start": 3259203, "end": 3260954}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/marigold.json", "start": 3260954, "end": 3267168}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pilgrimage.json", "start": 3267168, "end": 3273697}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/pitch.json", "start": 3273697, "end": 3278454}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/sherbet.json", "start": 3278454, "end": 3283739}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/styles/whisper.json", "start": 3283739, "end": 3295108}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/404.html", "start": 3295108, "end": 3295426}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/archive.html", "start": 3295426, "end": 3297102}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blank.html", "start": 3297102, "end": 3297162}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/blog-alternative.html", "start": 3297162, "end": 3298664}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/home.html", "start": 3298664, "end": 3300730}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/index.html", "start": 3300730, "end": 3302100}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/page.html", "start": 3302100, "end": 3302990}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/search.html", "start": 3302990, "end": 3304808}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/templates/single.html", "start": 3304808, "end": 3305747}, {"filename": "/wordpress/wp-content/themes/twentytwentythree/theme.json", "start": 3305747, "end": 3320584}, {"filename": "/wordpress/wp-cron.php", "start": 3320584, "end": 3323299}, {"filename": "/wordpress/wp-includes/ID3/getid3.lib.php", "start": 3323299, "end": 3360178}, {"filename": "/wordpress/wp-includes/ID3/getid3.php", "start": 3360178, "end": 3407439}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.asf.php", "start": 3407439, "end": 3492776}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.flv.php", "start": 3492776, "end": 3509491}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.matroska.php", "start": 3509491, "end": 3568442}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.quicktime.php", "start": 3568442, "end": 3680673}, {"filename": "/wordpress/wp-includes/ID3/module.audio-video.riff.php", "start": 3680673, "end": 3769022}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ac3.php", "start": 3769022, "end": 3794958}, {"filename": "/wordpress/wp-includes/ID3/module.audio.dts.php", "start": 3794958, "end": 3802408}, {"filename": "/wordpress/wp-includes/ID3/module.audio.flac.php", "start": 3802408, "end": 3816470}, {"filename": "/wordpress/wp-includes/ID3/module.audio.mp3.php", "start": 3816470, "end": 3891181}, {"filename": "/wordpress/wp-includes/ID3/module.audio.ogg.php", "start": 3891181, "end": 3925292}, {"filename": "/wordpress/wp-includes/ID3/module.tag.apetag.php", "start": 3925292, "end": 3940016}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v1.php", "start": 3940016, "end": 3950155}, {"filename": "/wordpress/wp-includes/ID3/module.tag.id3v2.php", "start": 3950155, "end": 4040260}, {"filename": "/wordpress/wp-includes/ID3/module.tag.lyrics3.php", "start": 4040260, "end": 4049043}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-base64.php", "start": 4049043, "end": 4049285}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-client.php", "start": 4049285, "end": 4052213}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-clientmulticall.php", "start": 4052213, "end": 4052839}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-date.php", "start": 4052839, "end": 4054062}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-error.php", "start": 4054062, "end": 4054725}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-introspectionserver.php", "start": 4054725, "end": 4057843}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-message.php", "start": 4057843, "end": 4062439}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-request.php", "start": 4062439, "end": 4063076}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-server.php", "start": 4063076, "end": 4067376}, {"filename": "/wordpress/wp-includes/IXR/class-IXR-value.php", "start": 4067376, "end": 4069521}, {"filename": "/wordpress/wp-includes/PHPMailer/Exception.php", "start": 4069521, "end": 4069740}, {"filename": "/wordpress/wp-includes/PHPMailer/PHPMailer.php", "start": 4069740, "end": 4145550}, {"filename": "/wordpress/wp-includes/PHPMailer/SMTP.php", "start": 4145550, "end": 4162592}, {"filename": "/wordpress/wp-includes/Requests/library/Requests.php", "start": 4162592, "end": 4162653}, {"filename": "/wordpress/wp-includes/Requests/src/Auth.php", "start": 4162653, "end": 4162771}, {"filename": "/wordpress/wp-includes/Requests/src/Auth/Basic.php", "start": 4162771, "end": 4163912}, {"filename": "/wordpress/wp-includes/Requests/src/Autoload.php", "start": 4163912, "end": 4169280}, {"filename": "/wordpress/wp-includes/Requests/src/Capability.php", "start": 4169280, "end": 4169385}, {"filename": "/wordpress/wp-includes/Requests/src/Cookie.php", "start": 4169385, "end": 4176154}, {"filename": "/wordpress/wp-includes/Requests/src/Cookie/Jar.php", "start": 4176154, "end": 4178358}, {"filename": "/wordpress/wp-includes/Requests/src/Exception.php", "start": 4178358, "end": 4178751}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/ArgumentCount.php", "start": 4178751, "end": 4179128}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http.php", "start": 4179128, "end": 4179857}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status304.php", "start": 4179857, "end": 4180038}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status305.php", "start": 4180038, "end": 4180216}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status306.php", "start": 4180216, "end": 4180397}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status400.php", "start": 4180397, "end": 4180577}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status401.php", "start": 4180577, "end": 4180758}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status402.php", "start": 4180758, "end": 4180943}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status403.php", "start": 4180943, "end": 4181121}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status404.php", "start": 4181121, "end": 4181299}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status405.php", "start": 4181299, "end": 4181486}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status406.php", "start": 4181486, "end": 4181669}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status407.php", "start": 4181669, "end": 4181867}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status408.php", "start": 4181867, "end": 4182051}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status409.php", "start": 4182051, "end": 4182228}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status410.php", "start": 4182228, "end": 4182401}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status411.php", "start": 4182401, "end": 4182585}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status412.php", "start": 4182585, "end": 4182773}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status413.php", "start": 4182773, "end": 4182966}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status414.php", "start": 4182966, "end": 4183156}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status415.php", "start": 4183156, "end": 4183347}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status416.php", "start": 4183347, "end": 4183547}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status417.php", "start": 4183547, "end": 4183734}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status418.php", "start": 4183734, "end": 4183915}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status428.php", "start": 4183915, "end": 4184105}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status429.php", "start": 4184105, "end": 4184291}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status431.php", "start": 4184291, "end": 4184491}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status500.php", "start": 4184491, "end": 4184681}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status501.php", "start": 4184681, "end": 4184865}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status502.php", "start": 4184865, "end": 4185045}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status503.php", "start": 4185045, "end": 4185233}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status504.php", "start": 4185233, "end": 4185417}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status505.php", "start": 4185417, "end": 4185612}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/Status511.php", "start": 4185612, "end": 4185812}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Http/StatusUnknown.php", "start": 4185812, "end": 4186193}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/InvalidArgument.php", "start": 4186193, "end": 4186636}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Transport.php", "start": 4186636, "end": 4186746}, {"filename": "/wordpress/wp-includes/Requests/src/Exception/Transport/Curl.php", "start": 4186746, "end": 4187437}, {"filename": "/wordpress/wp-includes/Requests/src/HookManager.php", "start": 4187437, "end": 4187606}, {"filename": "/wordpress/wp-includes/Requests/src/Hooks.php", "start": 4187606, "end": 4189032}, {"filename": "/wordpress/wp-includes/Requests/src/IdnaEncoder.php", "start": 4189032, "end": 4194508}, {"filename": "/wordpress/wp-includes/Requests/src/Ipv6.php", "start": 4194508, "end": 4197058}, {"filename": "/wordpress/wp-includes/Requests/src/Iri.php", "start": 4197058, "end": 4213077}, {"filename": "/wordpress/wp-includes/Requests/src/Port.php", "start": 4213077, "end": 4213621}, {"filename": "/wordpress/wp-includes/Requests/src/Proxy.php", "start": 4213621, "end": 4213740}, {"filename": "/wordpress/wp-includes/Requests/src/Proxy/Http.php", "start": 4213740, "end": 4215660}, {"filename": "/wordpress/wp-includes/Requests/src/Requests.php", "start": 4215660, "end": 4231276}, {"filename": "/wordpress/wp-includes/Requests/src/Response.php", "start": 4231276, "end": 4232595}, {"filename": "/wordpress/wp-includes/Requests/src/Response/Headers.php", "start": 4232595, "end": 4233943}, {"filename": "/wordpress/wp-includes/Requests/src/Session.php", "start": 4233943, "end": 4237785}, {"filename": "/wordpress/wp-includes/Requests/src/Ssl.php", "start": 4237785, "end": 4239998}, {"filename": "/wordpress/wp-includes/Requests/src/Transport.php", "start": 4239998, "end": 4240232}, {"filename": "/wordpress/wp-includes/Requests/src/Transport/Curl.php", "start": 4240232, "end": 4251781}, {"filename": "/wordpress/wp-includes/Requests/src/Transport/Fsockopen.php", "start": 4251781, "end": 4261441}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/CaseInsensitiveDictionary.php", "start": 4261441, "end": 4262625}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/FilteredIterator.php", "start": 4262625, "end": 4263432}, {"filename": "/wordpress/wp-includes/Requests/src/Utility/InputValidator.php", "start": 4263432, "end": 4264400}, {"filename": "/wordpress/wp-includes/SimplePie/Author.php", "start": 4264400, "end": 4264956}, {"filename": "/wordpress/wp-includes/SimplePie/Cache.php", "start": 4264956, "end": 4266082}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Base.php", "start": 4266082, "end": 4266358}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/DB.php", "start": 4266358, "end": 4268424}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/File.php", "start": 4268424, "end": 4269462}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcache.php", "start": 4269462, "end": 4270830}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Memcached.php", "start": 4270830, "end": 4272233}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/MySQL.php", "start": 4272233, "end": 4280590}, {"filename": "/wordpress/wp-includes/SimplePie/Cache/Redis.php", "start": 4280590, "end": 4282241}, {"filename": "/wordpress/wp-includes/SimplePie/Caption.php", "start": 4282241, "end": 4283131}, {"filename": "/wordpress/wp-includes/SimplePie/Category.php", "start": 4283131, "end": 4283760}, {"filename": "/wordpress/wp-includes/SimplePie/Content/Type/Sniffer.php", "start": 4283760, "end": 4288204}, {"filename": "/wordpress/wp-includes/SimplePie/Copyright.php", "start": 4288204, "end": 4288622}, {"filename": "/wordpress/wp-includes/SimplePie/Core.php", "start": 4288622, "end": 4288671}, {"filename": "/wordpress/wp-includes/SimplePie/Credit.php", "start": 4288671, "end": 4289234}, {"filename": "/wordpress/wp-includes/SimplePie/Decode/HTML/Entities.php", "start": 4289234, "end": 4301154}, {"filename": "/wordpress/wp-includes/SimplePie/Enclosure.php", "start": 4301154, "end": 4314750}, {"filename": "/wordpress/wp-includes/SimplePie/Exception.php", "start": 4314750, "end": 4314804}, {"filename": "/wordpress/wp-includes/SimplePie/File.php", "start": 4314804, "end": 4321205}, {"filename": "/wordpress/wp-includes/SimplePie/HTTP/Parser.php", "start": 4321205, "end": 4327548}, {"filename": "/wordpress/wp-includes/SimplePie/IRI.php", "start": 4327548, "end": 4343679}, {"filename": "/wordpress/wp-includes/SimplePie/Item.php", "start": 4343679, "end": 4416676}, {"filename": "/wordpress/wp-includes/SimplePie/Locator.php", "start": 4416676, "end": 4426431}, {"filename": "/wordpress/wp-includes/SimplePie/Misc.php", "start": 4426431, "end": 4467748}, {"filename": "/wordpress/wp-includes/SimplePie/Net/IPv6.php", "start": 4467748, "end": 4470114}, {"filename": "/wordpress/wp-includes/SimplePie/Parse/Date.php", "start": 4470114, "end": 4483248}, {"filename": "/wordpress/wp-includes/SimplePie/Parser.php", "start": 4483248, "end": 4505642}, {"filename": "/wordpress/wp-includes/SimplePie/Rating.php", "start": 4505642, "end": 4506072}, {"filename": "/wordpress/wp-includes/SimplePie/Registry.php", "start": 4506072, "end": 4508327}, {"filename": "/wordpress/wp-includes/SimplePie/Restriction.php", "start": 4508327, "end": 4508944}, {"filename": "/wordpress/wp-includes/SimplePie/Sanitize.php", "start": 4508944, "end": 4521089}, {"filename": "/wordpress/wp-includes/SimplePie/Source.php", "start": 4521089, "end": 4537690}, {"filename": "/wordpress/wp-includes/SimplePie/XML/Declaration/Parser.php", "start": 4537690, "end": 4541118}, {"filename": "/wordpress/wp-includes/SimplePie/gzdecode.php", "start": 4541118, "end": 4544186}, {"filename": "/wordpress/wp-includes/Text/Diff.php", "start": 4544186, "end": 4549734}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/native.php", "start": 4549734, "end": 4556307}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/shell.php", "start": 4556307, "end": 4558598}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/string.php", "start": 4558598, "end": 4562597}, {"filename": "/wordpress/wp-includes/Text/Diff/Engine/xdiff.php", "start": 4562597, "end": 4563329}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer.php", "start": 4563329, "end": 4566401}, {"filename": "/wordpress/wp-includes/Text/Diff/Renderer/inline.php", "start": 4566401, "end": 4569115}, {"filename": "/wordpress/wp-includes/admin-bar.php", "start": 4569115, "end": 4592354}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.min.php", "start": 4592354, "end": 4603489}, {"filename": "/wordpress/wp-includes/assets/script-loader-packages.php", "start": 4603489, "end": 4614408}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.min.php", "start": 4614408, "end": 4614518}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-entry.php", "start": 4614518, "end": 4614628}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.min.php", "start": 4614628, "end": 4614712}, {"filename": "/wordpress/wp-includes/assets/script-loader-react-refresh-runtime.php", "start": 4614712, "end": 4614796}, {"filename": "/wordpress/wp-includes/atomlib.php", "start": 4614796, "end": 4622337}, {"filename": "/wordpress/wp-includes/author-template.php", "start": 4622337, "end": 4629518}, {"filename": "/wordpress/wp-includes/block-editor.php", "start": 4629518, "end": 4644803}, {"filename": "/wordpress/wp-includes/block-i18n.json", "start": 4644803, "end": 4645119}, {"filename": "/wordpress/wp-includes/block-patterns.php", "start": 4645119, "end": 4654639}, {"filename": "/wordpress/wp-includes/block-patterns/query-grid-posts.php", "start": 4654639, "end": 4655550}, {"filename": "/wordpress/wp-includes/block-patterns/query-large-title-posts.php", "start": 4655550, "end": 4657469}, {"filename": "/wordpress/wp-includes/block-patterns/query-medium-posts.php", "start": 4657469, "end": 4658452}, {"filename": "/wordpress/wp-includes/block-patterns/query-offset-posts.php", "start": 4658452, "end": 4660393}, {"filename": "/wordpress/wp-includes/block-patterns/query-small-posts.php", "start": 4660393, "end": 4661491}, {"filename": "/wordpress/wp-includes/block-patterns/query-standard-posts.php", "start": 4661491, "end": 4662234}, {"filename": "/wordpress/wp-includes/block-patterns/social-links-shared-background-color.php", "start": 4662234, "end": 4662971}, {"filename": "/wordpress/wp-includes/block-supports/align.php", "start": 4662971, "end": 4663982}, {"filename": "/wordpress/wp-includes/block-supports/border.php", "start": 4663982, "end": 4668023}, {"filename": "/wordpress/wp-includes/block-supports/colors.php", "start": 4668023, "end": 4672179}, {"filename": "/wordpress/wp-includes/block-supports/custom-classname.php", "start": 4672179, "end": 4673223}, {"filename": "/wordpress/wp-includes/block-supports/dimensions.php", "start": 4673223, "end": 4674097}, {"filename": "/wordpress/wp-includes/block-supports/duotone.php", "start": 4674097, "end": 4683717}, {"filename": "/wordpress/wp-includes/block-supports/elements.php", "start": 4683717, "end": 4685918}, {"filename": "/wordpress/wp-includes/block-supports/generated-classname.php", "start": 4685918, "end": 4686703}, {"filename": "/wordpress/wp-includes/block-supports/layout.php", "start": 4686703, "end": 4700051}, {"filename": "/wordpress/wp-includes/block-supports/spacing.php", "start": 4700051, "end": 4701813}, {"filename": "/wordpress/wp-includes/block-supports/typography.php", "start": 4701813, "end": 4716523}, {"filename": "/wordpress/wp-includes/block-supports/utils.php", "start": 4716523, "end": 4716972}, {"filename": "/wordpress/wp-includes/block-template-utils.php", "start": 4716972, "end": 4743239}, {"filename": "/wordpress/wp-includes/block-template.php", "start": 4743239, "end": 4748858}, {"filename": "/wordpress/wp-includes/blocks.php", "start": 4748858, "end": 4775098}, {"filename": "/wordpress/wp-includes/blocks/archives.php", "start": 4775098, "end": 4777371}, {"filename": "/wordpress/wp-includes/blocks/archives/block.json", "start": 4777371, "end": 4778404}, {"filename": "/wordpress/wp-includes/blocks/archives/editor.min.css", "start": 4778404, "end": 4778444}, {"filename": "/wordpress/wp-includes/blocks/archives/style.min.css", "start": 4778444, "end": 4778492}, {"filename": "/wordpress/wp-includes/blocks/audio/block.json", "start": 4778492, "end": 4779656}, {"filename": "/wordpress/wp-includes/blocks/audio/editor.min.css", "start": 4779656, "end": 4779869}, {"filename": "/wordpress/wp-includes/blocks/audio/style.min.css", "start": 4779869, "end": 4780017}, {"filename": "/wordpress/wp-includes/blocks/audio/theme.min.css", "start": 4780017, "end": 4780187}, {"filename": "/wordpress/wp-includes/blocks/avatar.php", "start": 4780187, "end": 4784208}, {"filename": "/wordpress/wp-includes/blocks/avatar/block.json", "start": 4784208, "end": 4785214}, {"filename": "/wordpress/wp-includes/blocks/avatar/editor.min.css", "start": 4785214, "end": 4785333}, {"filename": "/wordpress/wp-includes/blocks/avatar/style.min.css", "start": 4785333, "end": 4785419}, {"filename": "/wordpress/wp-includes/blocks/block.php", "start": 4785419, "end": 4786488}, {"filename": "/wordpress/wp-includes/blocks/block/block.json", "start": 4786488, "end": 4786975}, {"filename": "/wordpress/wp-includes/blocks/block/editor.min.css", "start": 4786975, "end": 4787337}, {"filename": "/wordpress/wp-includes/blocks/blocks-json.php", "start": 4787337, "end": 4894921}, {"filename": "/wordpress/wp-includes/blocks/button/block.json", "start": 4894921, "end": 4897184}, {"filename": "/wordpress/wp-includes/blocks/button/editor.min.css", "start": 4897184, "end": 4898365}, {"filename": "/wordpress/wp-includes/blocks/button/style.min.css", "start": 4898365, "end": 4900490}, {"filename": "/wordpress/wp-includes/blocks/buttons/block.json", "start": 4900490, "end": 4901593}, {"filename": "/wordpress/wp-includes/blocks/buttons/editor.min.css", "start": 4901593, "end": 4902702}, {"filename": "/wordpress/wp-includes/blocks/buttons/style.min.css", "start": 4902702, "end": 4904005}, {"filename": "/wordpress/wp-includes/blocks/calendar.php", "start": 4904005, "end": 4906612}, {"filename": "/wordpress/wp-includes/blocks/calendar/block.json", "start": 4906612, "end": 4907361}, {"filename": "/wordpress/wp-includes/blocks/calendar/style.min.css", "start": 4907361, "end": 4907770}, {"filename": "/wordpress/wp-includes/blocks/categories.php", "start": 4907770, "end": 4909810}, {"filename": "/wordpress/wp-includes/blocks/categories/block.json", "start": 4909810, "end": 4910961}, {"filename": "/wordpress/wp-includes/blocks/categories/editor.min.css", "start": 4910961, "end": 4911046}, {"filename": "/wordpress/wp-includes/blocks/categories/style.min.css", "start": 4911046, "end": 4911185}, {"filename": "/wordpress/wp-includes/blocks/code/block.json", "start": 4911185, "end": 4912377}, {"filename": "/wordpress/wp-includes/blocks/code/editor.min.css", "start": 4912377, "end": 4912413}, {"filename": "/wordpress/wp-includes/blocks/code/style.min.css", "start": 4912413, "end": 4912550}, {"filename": "/wordpress/wp-includes/blocks/code/theme.min.css", "start": 4912550, "end": 4912666}, {"filename": "/wordpress/wp-includes/blocks/column/block.json", "start": 4912666, "end": 4914109}, {"filename": "/wordpress/wp-includes/blocks/columns/block.json", "start": 4914109, "end": 4915816}, {"filename": "/wordpress/wp-includes/blocks/columns/editor.min.css", "start": 4915816, "end": 4915955}, {"filename": "/wordpress/wp-includes/blocks/columns/style.min.css", "start": 4915955, "end": 4917429}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name.php", "start": 4917429, "end": 4918851}, {"filename": "/wordpress/wp-includes/blocks/comment-author-name/block.json", "start": 4918851, "end": 4919989}, {"filename": "/wordpress/wp-includes/blocks/comment-content.php", "start": 4919989, "end": 4921660}, {"filename": "/wordpress/wp-includes/blocks/comment-content/block.json", "start": 4921660, "end": 4922703}, {"filename": "/wordpress/wp-includes/blocks/comment-content/style.min.css", "start": 4922703, "end": 4922779}, {"filename": "/wordpress/wp-includes/blocks/comment-date.php", "start": 4922779, "end": 4923791}, {"filename": "/wordpress/wp-includes/blocks/comment-date/block.json", "start": 4923791, "end": 4924849}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link.php", "start": 4924849, "end": 4925899}, {"filename": "/wordpress/wp-includes/blocks/comment-edit-link/block.json", "start": 4925899, "end": 4927058}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link.php", "start": 4927058, "end": 4928311}, {"filename": "/wordpress/wp-includes/blocks/comment-reply-link/block.json", "start": 4928311, "end": 4929312}, {"filename": "/wordpress/wp-includes/blocks/comment-template.php", "start": 4929312, "end": 4931471}, {"filename": "/wordpress/wp-includes/blocks/comment-template/block.json", "start": 4931471, "end": 4932317}, {"filename": "/wordpress/wp-includes/blocks/comment-template/style.min.css", "start": 4932317, "end": 4932750}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next.php", "start": 4932750, "end": 4933975}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-next/block.json", "start": 4933975, "end": 4934932}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers.php", "start": 4934932, "end": 4935887}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/block.json", "start": 4935887, "end": 4936658}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-numbers/editor.min.css", "start": 4936658, "end": 4936871}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous.php", "start": 4936871, "end": 4937954}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination-previous/block.json", "start": 4937954, "end": 4938923}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination.php", "start": 4938923, "end": 4939445}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/block.json", "start": 4939445, "end": 4940758}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/editor.min.css", "start": 4940758, "end": 4941478}, {"filename": "/wordpress/wp-includes/blocks/comments-pagination/style.min.css", "start": 4941478, "end": 4942485}, {"filename": "/wordpress/wp-includes/blocks/comments-title.php", "start": 4942485, "end": 4944462}, {"filename": "/wordpress/wp-includes/blocks/comments-title/block.json", "start": 4944462, "end": 4945874}, {"filename": "/wordpress/wp-includes/blocks/comments-title/editor.min.css", "start": 4945874, "end": 4945930}, {"filename": "/wordpress/wp-includes/blocks/comments.php", "start": 4945930, "end": 4949592}, {"filename": "/wordpress/wp-includes/blocks/comments/block.json", "start": 4949592, "end": 4950692}, {"filename": "/wordpress/wp-includes/blocks/comments/editor.min.css", "start": 4950692, "end": 4954966}, {"filename": "/wordpress/wp-includes/blocks/comments/style.min.css", "start": 4954966, "end": 4957246}, {"filename": "/wordpress/wp-includes/blocks/cover.php", "start": 4957246, "end": 4958977}, {"filename": "/wordpress/wp-includes/blocks/cover/block.json", "start": 4958977, "end": 4961200}, {"filename": "/wordpress/wp-includes/blocks/cover/editor.min.css", "start": 4961200, "end": 4962847}, {"filename": "/wordpress/wp-includes/blocks/cover/style.min.css", "start": 4962847, "end": 4979522}, {"filename": "/wordpress/wp-includes/blocks/embed/block.json", "start": 4979522, "end": 4980326}, {"filename": "/wordpress/wp-includes/blocks/embed/editor.min.css", "start": 4980326, "end": 4980948}, {"filename": "/wordpress/wp-includes/blocks/embed/style.min.css", "start": 4980948, "end": 4982536}, {"filename": "/wordpress/wp-includes/blocks/embed/theme.min.css", "start": 4982536, "end": 4982706}, {"filename": "/wordpress/wp-includes/blocks/file.php", "start": 4982706, "end": 4983665}, {"filename": "/wordpress/wp-includes/blocks/file/block.json", "start": 4983665, "end": 4984954}, {"filename": "/wordpress/wp-includes/blocks/file/editor.min.css", "start": 4984954, "end": 4985588}, {"filename": "/wordpress/wp-includes/blocks/file/style.min.css", "start": 4985588, "end": 4986164}, {"filename": "/wordpress/wp-includes/blocks/file/view.asset.php", "start": 4986164, "end": 4986248}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.asset.php", "start": 4986248, "end": 4986332}, {"filename": "/wordpress/wp-includes/blocks/file/view.min.js", "start": 4986332, "end": 4986876}, {"filename": "/wordpress/wp-includes/blocks/freeform/block.json", "start": 4986876, "end": 4987313}, {"filename": "/wordpress/wp-includes/blocks/freeform/editor.min.css", "start": 4987313, "end": 4996363}, {"filename": "/wordpress/wp-includes/blocks/gallery.php", "start": 4996363, "end": 4998966}, {"filename": "/wordpress/wp-includes/blocks/gallery/block.json", "start": 4998966, "end": 5001634}, {"filename": "/wordpress/wp-includes/blocks/gallery/editor.min.css", "start": 5001634, "end": 5004979}, {"filename": "/wordpress/wp-includes/blocks/gallery/style.min.css", "start": 5004979, "end": 5019124}, {"filename": "/wordpress/wp-includes/blocks/gallery/theme.min.css", "start": 5019124, "end": 5019257}, {"filename": "/wordpress/wp-includes/blocks/group/block.json", "start": 5019257, "end": 5020915}, {"filename": "/wordpress/wp-includes/blocks/group/editor.min.css", "start": 5020915, "end": 5022064}, {"filename": "/wordpress/wp-includes/blocks/group/style.min.css", "start": 5022064, "end": 5022102}, {"filename": "/wordpress/wp-includes/blocks/group/theme.min.css", "start": 5022102, "end": 5022164}, {"filename": "/wordpress/wp-includes/blocks/heading/block.json", "start": 5022164, "end": 5023729}, {"filename": "/wordpress/wp-includes/blocks/heading/style.min.css", "start": 5023729, "end": 5023860}, {"filename": "/wordpress/wp-includes/blocks/home-link.php", "start": 5023860, "end": 5026964}, {"filename": "/wordpress/wp-includes/blocks/home-link/block.json", "start": 5026964, "end": 5028040}, {"filename": "/wordpress/wp-includes/blocks/html/block.json", "start": 5028040, "end": 5028513}, {"filename": "/wordpress/wp-includes/blocks/html/editor.min.css", "start": 5028513, "end": 5029248}, {"filename": "/wordpress/wp-includes/blocks/image.php", "start": 5029248, "end": 5029799}, {"filename": "/wordpress/wp-includes/blocks/image/block.json", "start": 5029799, "end": 5032175}, {"filename": "/wordpress/wp-includes/blocks/image/editor.min.css", "start": 5032175, "end": 5035035}, {"filename": "/wordpress/wp-includes/blocks/image/style.min.css", "start": 5035035, "end": 5037517}, {"filename": "/wordpress/wp-includes/blocks/image/theme.min.css", "start": 5037517, "end": 5037687}, {"filename": "/wordpress/wp-includes/blocks/index.php", "start": 5037687, "end": 5038174}, {"filename": "/wordpress/wp-includes/blocks/latest-comments.php", "start": 5038174, "end": 5041419}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/block.json", "start": 5041419, "end": 5042168}, {"filename": "/wordpress/wp-includes/blocks/latest-comments/style.min.css", "start": 5042168, "end": 5043087}, {"filename": "/wordpress/wp-includes/blocks/latest-posts.php", "start": 5043087, "end": 5048641}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/block.json", "start": 5048641, "end": 5050702}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/editor.min.css", "start": 5050702, "end": 5051131}, {"filename": "/wordpress/wp-includes/blocks/latest-posts/style.min.css", "start": 5051131, "end": 5052746}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget.php", "start": 5052746, "end": 5055836}, {"filename": "/wordpress/wp-includes/blocks/legacy-widget/block.json", "start": 5055836, "end": 5056337}, {"filename": "/wordpress/wp-includes/blocks/list-item/block.json", "start": 5056337, "end": 5056851}, {"filename": "/wordpress/wp-includes/blocks/list/block.json", "start": 5056851, "end": 5058425}, {"filename": "/wordpress/wp-includes/blocks/list/style.min.css", "start": 5058425, "end": 5058512}, {"filename": "/wordpress/wp-includes/blocks/loginout.php", "start": 5058512, "end": 5059409}, {"filename": "/wordpress/wp-includes/blocks/loginout/block.json", "start": 5059409, "end": 5059919}, {"filename": "/wordpress/wp-includes/blocks/media-text/block.json", "start": 5059919, "end": 5062480}, {"filename": "/wordpress/wp-includes/blocks/media-text/editor.min.css", "start": 5062480, "end": 5063038}, {"filename": "/wordpress/wp-includes/blocks/media-text/style.min.css", "start": 5063038, "end": 5065289}, {"filename": "/wordpress/wp-includes/blocks/missing/block.json", "start": 5065289, "end": 5065853}, {"filename": "/wordpress/wp-includes/blocks/more/block.json", "start": 5065853, "end": 5066417}, {"filename": "/wordpress/wp-includes/blocks/more/editor.min.css", "start": 5066417, "end": 5067148}, {"filename": "/wordpress/wp-includes/blocks/navigation-link.php", "start": 5067148, "end": 5075260}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/block.json", "start": 5075260, "end": 5076837}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/editor.min.css", "start": 5076837, "end": 5078991}, {"filename": "/wordpress/wp-includes/blocks/navigation-link/style.min.css", "start": 5078991, "end": 5079161}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu.php", "start": 5079161, "end": 5086411}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/block.json", "start": 5086411, "end": 5087597}, {"filename": "/wordpress/wp-includes/blocks/navigation-submenu/editor.min.css", "start": 5087597, "end": 5088701}, {"filename": "/wordpress/wp-includes/blocks/navigation.php", "start": 5088701, "end": 5106737}, {"filename": "/wordpress/wp-includes/blocks/navigation/block.json", "start": 5106737, "end": 5109801}, {"filename": "/wordpress/wp-includes/blocks/navigation/editor.min.css", "start": 5109801, "end": 5120487}, {"filename": "/wordpress/wp-includes/blocks/navigation/style.min.css", "start": 5120487, "end": 5135863}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.asset.php", "start": 5135863, "end": 5135947}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.asset.php", "start": 5135947, "end": 5136031}, {"filename": "/wordpress/wp-includes/blocks/navigation/view-modal.min.js", "start": 5136031, "end": 5143810}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.asset.php", "start": 5143810, "end": 5143894}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.asset.php", "start": 5143894, "end": 5143978}, {"filename": "/wordpress/wp-includes/blocks/navigation/view.min.js", "start": 5143978, "end": 5145122}, {"filename": "/wordpress/wp-includes/blocks/nextpage/block.json", "start": 5145122, "end": 5145577}, {"filename": "/wordpress/wp-includes/blocks/nextpage/editor.min.css", "start": 5145577, "end": 5146169}, {"filename": "/wordpress/wp-includes/blocks/page-list.php", "start": 5146169, "end": 5155889}, {"filename": "/wordpress/wp-includes/blocks/page-list/block.json", "start": 5155889, "end": 5156612}, {"filename": "/wordpress/wp-includes/blocks/page-list/editor.min.css", "start": 5156612, "end": 5157671}, {"filename": "/wordpress/wp-includes/blocks/page-list/style.min.css", "start": 5157671, "end": 5158033}, {"filename": "/wordpress/wp-includes/blocks/paragraph/block.json", "start": 5158033, "end": 5159440}, {"filename": "/wordpress/wp-includes/blocks/paragraph/editor.min.css", "start": 5159440, "end": 5159806}, {"filename": "/wordpress/wp-includes/blocks/paragraph/style.min.css", "start": 5159806, "end": 5160242}, {"filename": "/wordpress/wp-includes/blocks/pattern.php", "start": 5160242, "end": 5160800}, {"filename": "/wordpress/wp-includes/blocks/pattern/block.json", "start": 5160800, "end": 5161124}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography.php", "start": 5161124, "end": 5162064}, {"filename": "/wordpress/wp-includes/blocks/post-author-biography/block.json", "start": 5162064, "end": 5162986}, {"filename": "/wordpress/wp-includes/blocks/post-author.php", "start": 5162986, "end": 5164649}, {"filename": "/wordpress/wp-includes/blocks/post-author/block.json", "start": 5164649, "end": 5165967}, {"filename": "/wordpress/wp-includes/blocks/post-author/style.min.css", "start": 5165967, "end": 5166303}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form.php", "start": 5166303, "end": 5167746}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/block.json", "start": 5167746, "end": 5168698}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/editor.min.css", "start": 5168698, "end": 5168822}, {"filename": "/wordpress/wp-includes/blocks/post-comments-form/style.min.css", "start": 5168822, "end": 5170695}, {"filename": "/wordpress/wp-includes/blocks/post-content.php", "start": 5170695, "end": 5171863}, {"filename": "/wordpress/wp-includes/blocks/post-content/block.json", "start": 5171863, "end": 5172664}, {"filename": "/wordpress/wp-includes/blocks/post-date.php", "start": 5172664, "end": 5174016}, {"filename": "/wordpress/wp-includes/blocks/post-date/block.json", "start": 5174016, "end": 5175131}, {"filename": "/wordpress/wp-includes/blocks/post-date/style.min.css", "start": 5175131, "end": 5175173}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt.php", "start": 5175173, "end": 5176694}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/block.json", "start": 5176694, "end": 5177843}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/editor.min.css", "start": 5177843, "end": 5177929}, {"filename": "/wordpress/wp-includes/blocks/post-excerpt/style.min.css", "start": 5177929, "end": 5177984}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image.php", "start": 5177984, "end": 5183178}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/block.json", "start": 5183178, "end": 5184921}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/editor.min.css", "start": 5184921, "end": 5189067}, {"filename": "/wordpress/wp-includes/blocks/post-featured-image/style.min.css", "start": 5189067, "end": 5190809}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link.php", "start": 5190809, "end": 5192899}, {"filename": "/wordpress/wp-includes/blocks/post-navigation-link/block.json", "start": 5192899, "end": 5193931}, {"filename": "/wordpress/wp-includes/blocks/post-template.php", "start": 5193931, "end": 5196308}, {"filename": "/wordpress/wp-includes/blocks/post-template/block.json", "start": 5196308, "end": 5197356}, {"filename": "/wordpress/wp-includes/blocks/post-template/editor.min.css", "start": 5197356, "end": 5197450}, {"filename": "/wordpress/wp-includes/blocks/post-template/style.min.css", "start": 5197450, "end": 5198303}, {"filename": "/wordpress/wp-includes/blocks/post-terms.php", "start": 5198303, "end": 5200519}, {"filename": "/wordpress/wp-includes/blocks/post-terms/block.json", "start": 5200519, "end": 5201632}, {"filename": "/wordpress/wp-includes/blocks/post-terms/style.min.css", "start": 5201632, "end": 5201685}, {"filename": "/wordpress/wp-includes/blocks/post-title.php", "start": 5201685, "end": 5202874}, {"filename": "/wordpress/wp-includes/blocks/post-title/block.json", "start": 5202874, "end": 5204239}, {"filename": "/wordpress/wp-includes/blocks/post-title/style.min.css", "start": 5204239, "end": 5204348}, {"filename": "/wordpress/wp-includes/blocks/preformatted/block.json", "start": 5204348, "end": 5205372}, {"filename": "/wordpress/wp-includes/blocks/preformatted/style.min.css", "start": 5205372, "end": 5205477}, {"filename": "/wordpress/wp-includes/blocks/pullquote/block.json", "start": 5205477, "end": 5207086}, {"filename": "/wordpress/wp-includes/blocks/pullquote/editor.min.css", "start": 5207086, "end": 5207328}, {"filename": "/wordpress/wp-includes/blocks/pullquote/style.min.css", "start": 5207328, "end": 5208254}, {"filename": "/wordpress/wp-includes/blocks/pullquote/theme.min.css", "start": 5208254, "end": 5208521}, {"filename": "/wordpress/wp-includes/blocks/query-no-results.php", "start": 5208521, "end": 5209558}, {"filename": "/wordpress/wp-includes/blocks/query-no-results/block.json", "start": 5209558, "end": 5210403}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next.php", "start": 5210403, "end": 5212333}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-next/block.json", "start": 5212333, "end": 5213272}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers.php", "start": 5213272, "end": 5215143}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/block.json", "start": 5215143, "end": 5216074}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-numbers/editor.min.css", "start": 5216074, "end": 5216278}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous.php", "start": 5216278, "end": 5217776}, {"filename": "/wordpress/wp-includes/blocks/query-pagination-previous/block.json", "start": 5217776, "end": 5218727}, {"filename": "/wordpress/wp-includes/blocks/query-pagination.php", "start": 5218727, "end": 5219279}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/block.json", "start": 5219279, "end": 5220599}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/editor.min.css", "start": 5220599, "end": 5221274}, {"filename": "/wordpress/wp-includes/blocks/query-pagination/style.min.css", "start": 5221274, "end": 5222489}, {"filename": "/wordpress/wp-includes/blocks/query-title.php", "start": 5222489, "end": 5224033}, {"filename": "/wordpress/wp-includes/blocks/query-title/block.json", "start": 5224033, "end": 5225240}, {"filename": "/wordpress/wp-includes/blocks/query-title/style.min.css", "start": 5225240, "end": 5225284}, {"filename": "/wordpress/wp-includes/blocks/query.php", "start": 5225284, "end": 5225440}, {"filename": "/wordpress/wp-includes/blocks/query/block.json", "start": 5225440, "end": 5226696}, {"filename": "/wordpress/wp-includes/blocks/query/editor.min.css", "start": 5226696, "end": 5228031}, {"filename": "/wordpress/wp-includes/blocks/quote/block.json", "start": 5228031, "end": 5229511}, {"filename": "/wordpress/wp-includes/blocks/quote/style.min.css", "start": 5229511, "end": 5230111}, {"filename": "/wordpress/wp-includes/blocks/quote/theme.min.css", "start": 5230111, "end": 5230579}, {"filename": "/wordpress/wp-includes/blocks/read-more.php", "start": 5230579, "end": 5231463}, {"filename": "/wordpress/wp-includes/blocks/read-more/block.json", "start": 5231463, "end": 5232673}, {"filename": "/wordpress/wp-includes/blocks/read-more/style.min.css", "start": 5232673, "end": 5232932}, {"filename": "/wordpress/wp-includes/blocks/require-dynamic-blocks.php", "start": 5232932, "end": 5236470}, {"filename": "/wordpress/wp-includes/blocks/require-static-blocks.php", "start": 5236470, "end": 5236801}, {"filename": "/wordpress/wp-includes/blocks/rss.php", "start": 5236801, "end": 5240155}, {"filename": "/wordpress/wp-includes/blocks/rss/block.json", "start": 5240155, "end": 5241060}, {"filename": "/wordpress/wp-includes/blocks/rss/editor.min.css", "start": 5241060, "end": 5241496}, {"filename": "/wordpress/wp-includes/blocks/rss/style.min.css", "start": 5241496, "end": 5242195}, {"filename": "/wordpress/wp-includes/blocks/search.php", "start": 5242195, "end": 5257048}, {"filename": "/wordpress/wp-includes/blocks/search/block.json", "start": 5257048, "end": 5258973}, {"filename": "/wordpress/wp-includes/blocks/search/editor.min.css", "start": 5258973, "end": 5259230}, {"filename": "/wordpress/wp-includes/blocks/search/style.min.css", "start": 5259230, "end": 5260451}, {"filename": "/wordpress/wp-includes/blocks/search/theme.min.css", "start": 5260451, "end": 5260577}, {"filename": "/wordpress/wp-includes/blocks/separator/block.json", "start": 5260577, "end": 5261581}, {"filename": "/wordpress/wp-includes/blocks/separator/editor.min.css", "start": 5261581, "end": 5261809}, {"filename": "/wordpress/wp-includes/blocks/separator/style.min.css", "start": 5261809, "end": 5262161}, {"filename": "/wordpress/wp-includes/blocks/separator/theme.min.css", "start": 5262161, "end": 5262598}, {"filename": "/wordpress/wp-includes/blocks/shortcode.php", "start": 5262598, "end": 5262922}, {"filename": "/wordpress/wp-includes/blocks/shortcode/block.json", "start": 5262922, "end": 5263387}, {"filename": "/wordpress/wp-includes/blocks/shortcode/editor.min.css", "start": 5263387, "end": 5264411}, {"filename": "/wordpress/wp-includes/blocks/site-logo.php", "start": 5264411, "end": 5268160}, {"filename": "/wordpress/wp-includes/blocks/site-logo/block.json", "start": 5268160, "end": 5269501}, {"filename": "/wordpress/wp-includes/blocks/site-logo/editor.min.css", "start": 5269501, "end": 5271013}, {"filename": "/wordpress/wp-includes/blocks/site-logo/style.min.css", "start": 5271013, "end": 5271438}, {"filename": "/wordpress/wp-includes/blocks/site-tagline.php", "start": 5271438, "end": 5272094}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/block.json", "start": 5272094, "end": 5273218}, {"filename": "/wordpress/wp-includes/blocks/site-tagline/editor.min.css", "start": 5273218, "end": 5273286}, {"filename": "/wordpress/wp-includes/blocks/site-title.php", "start": 5273286, "end": 5274544}, {"filename": "/wordpress/wp-includes/blocks/site-title/block.json", "start": 5274544, "end": 5275986}, {"filename": "/wordpress/wp-includes/blocks/site-title/editor.min.css", "start": 5275986, "end": 5276052}, {"filename": "/wordpress/wp-includes/blocks/social-link.php", "start": 5276052, "end": 5334567}, {"filename": "/wordpress/wp-includes/blocks/social-link/block.json", "start": 5334567, "end": 5335203}, {"filename": "/wordpress/wp-includes/blocks/social-link/editor.min.css", "start": 5335203, "end": 5335576}, {"filename": "/wordpress/wp-includes/blocks/social-links/block.json", "start": 5335576, "end": 5337500}, {"filename": "/wordpress/wp-includes/blocks/social-links/editor.min.css", "start": 5337500, "end": 5339487}, {"filename": "/wordpress/wp-includes/blocks/social-links/style.min.css", "start": 5339487, "end": 5349276}, {"filename": "/wordpress/wp-includes/blocks/spacer/block.json", "start": 5349276, "end": 5349899}, {"filename": "/wordpress/wp-includes/blocks/spacer/editor.min.css", "start": 5349899, "end": 5350723}, {"filename": "/wordpress/wp-includes/blocks/spacer/style.min.css", "start": 5350723, "end": 5350751}, {"filename": "/wordpress/wp-includes/blocks/table/block.json", "start": 5350751, "end": 5354295}, {"filename": "/wordpress/wp-includes/blocks/table/editor.min.css", "start": 5354295, "end": 5356275}, {"filename": "/wordpress/wp-includes/blocks/table/style.min.css", "start": 5356275, "end": 5360047}, {"filename": "/wordpress/wp-includes/blocks/table/theme.min.css", "start": 5360047, "end": 5360366}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud.php", "start": 5360366, "end": 5361531}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/block.json", "start": 5361531, "end": 5362432}, {"filename": "/wordpress/wp-includes/blocks/tag-cloud/style.min.css", "start": 5362432, "end": 5362930}, {"filename": "/wordpress/wp-includes/blocks/template-part.php", "start": 5362930, "end": 5368633}, {"filename": "/wordpress/wp-includes/blocks/template-part/block.json", "start": 5368633, "end": 5369230}, {"filename": "/wordpress/wp-includes/blocks/template-part/editor.min.css", "start": 5369230, "end": 5369762}, {"filename": "/wordpress/wp-includes/blocks/template-part/theme.min.css", "start": 5369762, "end": 5369853}, {"filename": "/wordpress/wp-includes/blocks/term-description.php", "start": 5369853, "end": 5370620}, {"filename": "/wordpress/wp-includes/blocks/term-description/block.json", "start": 5370620, "end": 5371637}, {"filename": "/wordpress/wp-includes/blocks/text-columns/block.json", "start": 5371637, "end": 5372367}, {"filename": "/wordpress/wp-includes/blocks/text-columns/editor.min.css", "start": 5372367, "end": 5372453}, {"filename": "/wordpress/wp-includes/blocks/text-columns/style.min.css", "start": 5372453, "end": 5372905}, {"filename": "/wordpress/wp-includes/blocks/verse/block.json", "start": 5372905, "end": 5374124}, {"filename": "/wordpress/wp-includes/blocks/verse/style.min.css", "start": 5374124, "end": 5374198}, {"filename": "/wordpress/wp-includes/blocks/video/block.json", "start": 5374198, "end": 5376013}, {"filename": "/wordpress/wp-includes/blocks/video/editor.min.css", "start": 5376013, "end": 5378276}, {"filename": "/wordpress/wp-includes/blocks/video/style.min.css", "start": 5378276, "end": 5378545}, {"filename": "/wordpress/wp-includes/blocks/video/theme.min.css", "start": 5378545, "end": 5378715}, {"filename": "/wordpress/wp-includes/blocks/widget-group.php", "start": 5378715, "end": 5380091}, {"filename": "/wordpress/wp-includes/blocks/widget-group/block.json", "start": 5380091, "end": 5380410}, {"filename": "/wordpress/wp-includes/bookmark-template.php", "start": 5380410, "end": 5385896}, {"filename": "/wordpress/wp-includes/bookmark.php", "start": 5385896, "end": 5394296}, {"filename": "/wordpress/wp-includes/cache-compat.php", "start": 5394296, "end": 5396168}, {"filename": "/wordpress/wp-includes/cache.php", "start": 5396168, "end": 5399029}, {"filename": "/wordpress/wp-includes/canonical.php", "start": 5399029, "end": 5422540}, {"filename": "/wordpress/wp-includes/capabilities.php", "start": 5422540, "end": 5442556}, {"filename": "/wordpress/wp-includes/category-template.php", "start": 5442556, "end": 5463353}, {"filename": "/wordpress/wp-includes/category.php", "start": 5463353, "end": 5467824}, {"filename": "/wordpress/wp-includes/certificates/ca-bundle.crt", "start": 5467824, "end": 5701055}, {"filename": "/wordpress/wp-includes/class-IXR.php", "start": 5701055, "end": 5701681}, {"filename": "/wordpress/wp-includes/class-feed.php", "start": 5701681, "end": 5702121}, {"filename": "/wordpress/wp-includes/class-http.php", "start": 5702121, "end": 5702262}, {"filename": "/wordpress/wp-includes/class-json.php", "start": 5702262, "end": 5716274}, {"filename": "/wordpress/wp-includes/class-oembed.php", "start": 5716274, "end": 5716419}, {"filename": "/wordpress/wp-includes/class-phpass.php", "start": 5716419, "end": 5720165}, {"filename": "/wordpress/wp-includes/class-phpmailer.php", "start": 5720165, "end": 5720681}, {"filename": "/wordpress/wp-includes/class-pop3.php", "start": 5720681, "end": 5731258}, {"filename": "/wordpress/wp-includes/class-requests.php", "start": 5731258, "end": 5732126}, {"filename": "/wordpress/wp-includes/class-simplepie.php", "start": 5732126, "end": 5788326}, {"filename": "/wordpress/wp-includes/class-smtp.php", "start": 5788326, "end": 5788646}, {"filename": "/wordpress/wp-includes/class-snoopy.php", "start": 5788646, "end": 5810085}, {"filename": "/wordpress/wp-includes/class-walker-category-dropdown.php", "start": 5810085, "end": 5811041}, {"filename": "/wordpress/wp-includes/class-walker-category.php", "start": 5811041, "end": 5814665}, {"filename": "/wordpress/wp-includes/class-walker-comment.php", "start": 5814665, "end": 5822477}, {"filename": "/wordpress/wp-includes/class-walker-nav-menu.php", "start": 5822477, "end": 5825790}, {"filename": "/wordpress/wp-includes/class-walker-page-dropdown.php", "start": 5825790, "end": 5826656}, {"filename": "/wordpress/wp-includes/class-walker-page.php", "start": 5826656, "end": 5830043}, {"filename": "/wordpress/wp-includes/class-wp-admin-bar.php", "start": 5830043, "end": 5841058}, {"filename": "/wordpress/wp-includes/class-wp-ajax-response.php", "start": 5841058, "end": 5843385}, {"filename": "/wordpress/wp-includes/class-wp-application-passwords.php", "start": 5843385, "end": 5849252}, {"filename": "/wordpress/wp-includes/class-wp-block-editor-context.php", "start": 5849252, "end": 5849556}, {"filename": "/wordpress/wp-includes/class-wp-block-list.php", "start": 5849556, "end": 5850910}, {"filename": "/wordpress/wp-includes/class-wp-block-parser.php", "start": 5850910, "end": 5857116}, {"filename": "/wordpress/wp-includes/class-wp-block-pattern-categories-registry.php", "start": 5857116, "end": 5859173}, {"filename": "/wordpress/wp-includes/class-wp-block-patterns-registry.php", "start": 5859173, "end": 5861497}, {"filename": "/wordpress/wp-includes/class-wp-block-styles-registry.php", "start": 5861497, "end": 5863644}, {"filename": "/wordpress/wp-includes/class-wp-block-supports.php", "start": 5863644, "end": 5866918}, {"filename": "/wordpress/wp-includes/class-wp-block-template.php", "start": 5866918, "end": 5867249}, {"filename": "/wordpress/wp-includes/class-wp-block-type-registry.php", "start": 5867249, "end": 5869251}, {"filename": "/wordpress/wp-includes/class-wp-block-type.php", "start": 5869251, "end": 5873146}, {"filename": "/wordpress/wp-includes/class-wp-block.php", "start": 5873146, "end": 5877163}, {"filename": "/wordpress/wp-includes/class-wp-comment-query.php", "start": 5877163, "end": 5898872}, {"filename": "/wordpress/wp-includes/class-wp-comment.php", "start": 5898872, "end": 5901870}, {"filename": "/wordpress/wp-includes/class-wp-customize-control.php", "start": 5901870, "end": 5914963}, {"filename": "/wordpress/wp-includes/class-wp-customize-manager.php", "start": 5914963, "end": 6039337}, {"filename": "/wordpress/wp-includes/class-wp-customize-nav-menus.php", "start": 6039337, "end": 6078285}, {"filename": "/wordpress/wp-includes/class-wp-customize-panel.php", "start": 6078285, "end": 6082260}, {"filename": "/wordpress/wp-includes/class-wp-customize-section.php", "start": 6082260, "end": 6086544}, {"filename": "/wordpress/wp-includes/class-wp-customize-setting.php", "start": 6086544, "end": 6099128}, {"filename": "/wordpress/wp-includes/class-wp-customize-widgets.php", "start": 6099128, "end": 6140246}, {"filename": "/wordpress/wp-includes/class-wp-date-query.php", "start": 6140246, "end": 6155399}, {"filename": "/wordpress/wp-includes/class-wp-dependencies.php", "start": 6155399, "end": 6160798}, {"filename": "/wordpress/wp-includes/class-wp-dependency.php", "start": 6160798, "end": 6161501}, {"filename": "/wordpress/wp-includes/class-wp-editor.php", "start": 6161501, "end": 6203829}, {"filename": "/wordpress/wp-includes/class-wp-embed.php", "start": 6203829, "end": 6211413}, {"filename": "/wordpress/wp-includes/class-wp-error.php", "start": 6211413, "end": 6214212}, {"filename": "/wordpress/wp-includes/class-wp-fatal-error-handler.php", "start": 6214212, "end": 6217305}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache-transient.php", "start": 6217305, "end": 6218230}, {"filename": "/wordpress/wp-includes/class-wp-feed-cache.php", "start": 6218230, "end": 6218615}, {"filename": "/wordpress/wp-includes/class-wp-hook.php", "start": 6218615, "end": 6224722}, {"filename": "/wordpress/wp-includes/class-wp-http-cookie.php", "start": 6224722, "end": 6227560}, {"filename": "/wordpress/wp-includes/class-wp-http-curl.php", "start": 6227560, "end": 6235165}, {"filename": "/wordpress/wp-includes/class-wp-http-encoding.php", "start": 6235165, "end": 6237783}, {"filename": "/wordpress/wp-includes/class-wp-http-ixr-client.php", "start": 6237783, "end": 6240189}, {"filename": "/wordpress/wp-includes/class-wp-http-proxy.php", "start": 6240189, "end": 6242126}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-hooks.php", "start": 6242126, "end": 6242695}, {"filename": "/wordpress/wp-includes/class-wp-http-requests-response.php", "start": 6242695, "end": 6244768}, {"filename": "/wordpress/wp-includes/class-wp-http-response.php", "start": 6244768, "end": 6245648}, {"filename": "/wordpress/wp-includes/class-wp-http-streams.php", "start": 6245648, "end": 6256471}, {"filename": "/wordpress/wp-includes/class-wp-http.php", "start": 6256471, "end": 6273234}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-gd.php", "start": 6273234, "end": 6282439}, {"filename": "/wordpress/wp-includes/class-wp-image-editor-imagick.php", "start": 6282439, "end": 6297052}, {"filename": "/wordpress/wp-includes/class-wp-image-editor.php", "start": 6297052, "end": 6303488}, {"filename": "/wordpress/wp-includes/class-wp-list-util.php", "start": 6303488, "end": 6306512}, {"filename": "/wordpress/wp-includes/class-wp-locale-switcher.php", "start": 6306512, "end": 6308451}, {"filename": "/wordpress/wp-includes/class-wp-locale.php", "start": 6308451, "end": 6314055}, {"filename": "/wordpress/wp-includes/class-wp-matchesmapregex.php", "start": 6314055, "end": 6314793}, {"filename": "/wordpress/wp-includes/class-wp-meta-query.php", "start": 6314793, "end": 6328042}, {"filename": "/wordpress/wp-includes/class-wp-metadata-lazyloader.php", "start": 6328042, "end": 6329908}, {"filename": "/wordpress/wp-includes/class-wp-network-query.php", "start": 6329908, "end": 6338887}, {"filename": "/wordpress/wp-includes/class-wp-network.php", "start": 6338887, "end": 6343795}, {"filename": "/wordpress/wp-includes/class-wp-object-cache.php", "start": 6343795, "end": 6350513}, {"filename": "/wordpress/wp-includes/class-wp-oembed-controller.php", "start": 6350513, "end": 6354225}, {"filename": "/wordpress/wp-includes/class-wp-oembed.php", "start": 6354225, "end": 6368076}, {"filename": "/wordpress/wp-includes/class-wp-paused-extensions-storage.php", "start": 6368076, "end": 6370606}, {"filename": "/wordpress/wp-includes/class-wp-post-type.php", "start": 6370606, "end": 6382351}, {"filename": "/wordpress/wp-includes/class-wp-post.php", "start": 6382351, "end": 6385335}, {"filename": "/wordpress/wp-includes/class-wp-query.php", "start": 6385335, "end": 6464092}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-cookie-service.php", "start": 6464092, "end": 6467731}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-email-service.php", "start": 6467731, "end": 6473511}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-key-service.php", "start": 6473511, "end": 6475570}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode-link-service.php", "start": 6475570, "end": 6477145}, {"filename": "/wordpress/wp-includes/class-wp-recovery-mode.php", "start": 6477145, "end": 6483246}, {"filename": "/wordpress/wp-includes/class-wp-rewrite.php", "start": 6483246, "end": 6508027}, {"filename": "/wordpress/wp-includes/class-wp-role.php", "start": 6508027, "end": 6508685}, {"filename": "/wordpress/wp-includes/class-wp-roles.php", "start": 6508685, "end": 6512209}, {"filename": "/wordpress/wp-includes/class-wp-scripts.php", "start": 6512209, "end": 6521327}, {"filename": "/wordpress/wp-includes/class-wp-session-tokens.php", "start": 6521327, "end": 6523835}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-file.php", "start": 6523835, "end": 6525147}, {"filename": "/wordpress/wp-includes/class-wp-simplepie-sanitize-kses.php", "start": 6525147, "end": 6526002}, {"filename": "/wordpress/wp-includes/class-wp-site-query.php", "start": 6526002, "end": 6540107}, {"filename": "/wordpress/wp-includes/class-wp-site.php", "start": 6540107, "end": 6542794}, {"filename": "/wordpress/wp-includes/class-wp-styles.php", "start": 6542794, "end": 6547937}, {"filename": "/wordpress/wp-includes/class-wp-tax-query.php", "start": 6547937, "end": 6557212}, {"filename": "/wordpress/wp-includes/class-wp-taxonomy.php", "start": 6557212, "end": 6566372}, {"filename": "/wordpress/wp-includes/class-wp-term-query.php", "start": 6566372, "end": 6584809}, {"filename": "/wordpress/wp-includes/class-wp-term.php", "start": 6584809, "end": 6587013}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-inline.php", "start": 6587013, "end": 6587350}, {"filename": "/wordpress/wp-includes/class-wp-text-diff-renderer-table.php", "start": 6587350, "end": 6595376}, {"filename": "/wordpress/wp-includes/class-wp-textdomain-registry.php", "start": 6595376, "end": 6597751}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-data.php", "start": 6597751, "end": 6598202}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-resolver.php", "start": 6598202, "end": 6609333}, {"filename": "/wordpress/wp-includes/class-wp-theme-json-schema.php", "start": 6609333, "end": 6611162}, {"filename": "/wordpress/wp-includes/class-wp-theme-json.php", "start": 6611162, "end": 6670586}, {"filename": "/wordpress/wp-includes/class-wp-theme.php", "start": 6670586, "end": 6698156}, {"filename": "/wordpress/wp-includes/class-wp-user-meta-session-tokens.php", "start": 6698156, "end": 6699618}, {"filename": "/wordpress/wp-includes/class-wp-user-query.php", "start": 6699618, "end": 6718101}, {"filename": "/wordpress/wp-includes/class-wp-user-request.php", "start": 6718101, "end": 6719107}, {"filename": "/wordpress/wp-includes/class-wp-user.php", "start": 6719107, "end": 6728324}, {"filename": "/wordpress/wp-includes/class-wp-walker.php", "start": 6728324, "end": 6733944}, {"filename": "/wordpress/wp-includes/class-wp-widget-factory.php", "start": 6733944, "end": 6735343}, {"filename": "/wordpress/wp-includes/class-wp-widget.php", "start": 6735343, "end": 6742784}, {"filename": "/wordpress/wp-includes/class-wp-xmlrpc-server.php", "start": 6742784, "end": 6869799}, {"filename": "/wordpress/wp-includes/class-wp.php", "start": 6869799, "end": 6884239}, {"filename": "/wordpress/wp-includes/class-wpdb.php", "start": 6884239, "end": 6937456}, {"filename": "/wordpress/wp-includes/class.wp-dependencies.php", "start": 6937456, "end": 6937613}, {"filename": "/wordpress/wp-includes/class.wp-scripts.php", "start": 6937613, "end": 6937760}, {"filename": "/wordpress/wp-includes/class.wp-styles.php", "start": 6937760, "end": 6937905}, {"filename": "/wordpress/wp-includes/comment-template.php", "start": 6937905, "end": 6975513}, {"filename": "/wordpress/wp-includes/comment.php", "start": 6975513, "end": 7035900}, {"filename": "/wordpress/wp-includes/compat.php", "start": 7035900, "end": 7041577}, {"filename": "/wordpress/wp-includes/cron.php", "start": 7041577, "end": 7055050}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-control.php", "start": 7055050, "end": 7055688}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-image-setting.php", "start": 7055688, "end": 7055900}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-background-position-control.php", "start": 7055900, "end": 7058139}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-code-editor-control.php", "start": 7058139, "end": 7059380}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-color-control.php", "start": 7059380, "end": 7061107}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-cropped-image-control.php", "start": 7061107, "end": 7061676}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php", "start": 7061676, "end": 7063853}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-date-time-control.php", "start": 7063853, "end": 7070335}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-filter-setting.php", "start": 7070335, "end": 7070445}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php", "start": 7070445, "end": 7077062}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-header-image-setting.php", "start": 7077062, "end": 7077995}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-image-control.php", "start": 7077995, "end": 7078459}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-media-control.php", "start": 7078459, "end": 7085179}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php", "start": 7085179, "end": 7085790}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-control.php", "start": 7085790, "end": 7087173}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-control.php", "start": 7087173, "end": 7092424}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php", "start": 7092424, "end": 7108820}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-location-control.php", "start": 7108820, "end": 7110365}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-locations-control.php", "start": 7110365, "end": 7112340}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-name-control.php", "start": 7112340, "end": 7112968}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-section.php", "start": 7112968, "end": 7113232}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menu-setting.php", "start": 7113232, "end": 7122822}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-nav-menus-panel.php", "start": 7122822, "end": 7124670}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-control.php", "start": 7124670, "end": 7125254}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-new-menu-section.php", "start": 7125254, "end": 7125990}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-partial.php", "start": 7125990, "end": 7128676}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-selective-refresh.php", "start": 7128676, "end": 7134157}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-sidebar-section.php", "start": 7134157, "end": 7134495}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-site-icon-control.php", "start": 7134495, "end": 7136803}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-theme-control.php", "start": 7136803, "end": 7145619}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-panel.php", "start": 7145619, "end": 7147823}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-themes-section.php", "start": 7147823, "end": 7152472}, {"filename": "/wordpress/wp-includes/customize/class-wp-customize-upload-control.php", "start": 7152472, "end": 7152950}, {"filename": "/wordpress/wp-includes/customize/class-wp-sidebar-block-editor-control.php", "start": 7152950, "end": 7153104}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-area-customize-control.php", "start": 7153104, "end": 7154204}, {"filename": "/wordpress/wp-includes/customize/class-wp-widget-form-customize-control.php", "start": 7154204, "end": 7155452}, {"filename": "/wordpress/wp-includes/date.php", "start": 7155452, "end": 7155605}, {"filename": "/wordpress/wp-includes/default-constants.php", "start": 7155605, "end": 7161411}, {"filename": "/wordpress/wp-includes/default-filters.php", "start": 7161411, "end": 7189044}, {"filename": "/wordpress/wp-includes/default-widgets.php", "start": 7189044, "end": 7190495}, {"filename": "/wordpress/wp-includes/deprecated.php", "start": 7190495, "end": 7250573}, {"filename": "/wordpress/wp-includes/embed-template.php", "start": 7250573, "end": 7250719}, {"filename": "/wordpress/wp-includes/embed.php", "start": 7250719, "end": 7269283}, {"filename": "/wordpress/wp-includes/error-protection.php", "start": 7269283, "end": 7271169}, {"filename": "/wordpress/wp-includes/feed-atom-comments.php", "start": 7271169, "end": 7275095}, {"filename": "/wordpress/wp-includes/feed-atom.php", "start": 7275095, "end": 7277613}, {"filename": "/wordpress/wp-includes/feed-rdf.php", "start": 7277613, "end": 7279741}, {"filename": "/wordpress/wp-includes/feed-rss.php", "start": 7279741, "end": 7280672}, {"filename": "/wordpress/wp-includes/feed-rss2-comments.php", "start": 7280672, "end": 7283495}, {"filename": "/wordpress/wp-includes/feed-rss2.php", "start": 7283495, "end": 7286220}, {"filename": "/wordpress/wp-includes/feed.php", "start": 7286220, "end": 7295806}, {"filename": "/wordpress/wp-includes/formatting.php", "start": 7295806, "end": 7505903}, {"filename": "/wordpress/wp-includes/functions.php", "start": 7505903, "end": 7620911}, {"filename": "/wordpress/wp-includes/functions.wp-scripts.php", "start": 7620911, "end": 7625463}, {"filename": "/wordpress/wp-includes/functions.wp-styles.php", "start": 7625463, "end": 7627506}, {"filename": "/wordpress/wp-includes/general-template.php", "start": 7627506, "end": 7702451}, {"filename": "/wordpress/wp-includes/global-styles-and-settings.php", "start": 7702451, "end": 7707569}, {"filename": "/wordpress/wp-includes/http.php", "start": 7707569, "end": 7715889}, {"filename": "/wordpress/wp-includes/https-detection.php", "start": 7715889, "end": 7718951}, {"filename": "/wordpress/wp-includes/https-migration.php", "start": 7718951, "end": 7720628}, {"filename": "/wordpress/wp-includes/js/tinymce/wp-tinymce.php", "start": 7720628, "end": 7721373}, {"filename": "/wordpress/wp-includes/js/wp-emoji-loader.min.js", "start": 7721373, "end": 7723224}, {"filename": "/wordpress/wp-includes/kses.php", "start": 7723224, "end": 7756837}, {"filename": "/wordpress/wp-includes/l10n.php", "start": 7756837, "end": 7778599}, {"filename": "/wordpress/wp-includes/link-template.php", "start": 7778599, "end": 7839443}, {"filename": "/wordpress/wp-includes/load.php", "start": 7839443, "end": 7862968}, {"filename": "/wordpress/wp-includes/locale.php", "start": 7862968, "end": 7863026}, {"filename": "/wordpress/wp-includes/media-template.php", "start": 7863026, "end": 7919285}, {"filename": "/wordpress/wp-includes/media.php", "start": 7919285, "end": 8007036}, {"filename": "/wordpress/wp-includes/meta.php", "start": 8007036, "end": 8029485}, {"filename": "/wordpress/wp-includes/ms-blogs.php", "start": 8029485, "end": 8042884}, {"filename": "/wordpress/wp-includes/ms-default-constants.php", "start": 8042884, "end": 8045896}, {"filename": "/wordpress/wp-includes/ms-default-filters.php", "start": 8045896, "end": 8051584}, {"filename": "/wordpress/wp-includes/ms-deprecated.php", "start": 8051584, "end": 8063000}, {"filename": "/wordpress/wp-includes/ms-files.php", "start": 8063000, "end": 8065159}, {"filename": "/wordpress/wp-includes/ms-functions.php", "start": 8065159, "end": 8106968}, {"filename": "/wordpress/wp-includes/ms-load.php", "start": 8106968, "end": 8115725}, {"filename": "/wordpress/wp-includes/ms-network.php", "start": 8115725, "end": 8117221}, {"filename": "/wordpress/wp-includes/ms-settings.php", "start": 8117221, "end": 8119190}, {"filename": "/wordpress/wp-includes/ms-site.php", "start": 8119190, "end": 8137009}, {"filename": "/wordpress/wp-includes/nav-menu-template.php", "start": 8137009, "end": 8151161}, {"filename": "/wordpress/wp-includes/nav-menu.php", "start": 8151161, "end": 8175953}, {"filename": "/wordpress/wp-includes/option.php", "start": 8175953, "end": 8209835}, {"filename": "/wordpress/wp-includes/php-compat/readonly.php", "start": 8209835, "end": 8210040}, {"filename": "/wordpress/wp-includes/pluggable-deprecated.php", "start": 8210040, "end": 8212522}, {"filename": "/wordpress/wp-includes/pluggable.php", "start": 8212522, "end": 8260648}, {"filename": "/wordpress/wp-includes/plugin.php", "start": 8260648, "end": 8269539}, {"filename": "/wordpress/wp-includes/pomo/entry.php", "start": 8269539, "end": 8271058}, {"filename": "/wordpress/wp-includes/pomo/mo.php", "start": 8271058, "end": 8277292}, {"filename": "/wordpress/wp-includes/pomo/plural-forms.php", "start": 8277292, "end": 8281520}, {"filename": "/wordpress/wp-includes/pomo/po.php", "start": 8281520, "end": 8291306}, {"filename": "/wordpress/wp-includes/pomo/streams.php", "start": 8291306, "end": 8295780}, {"filename": "/wordpress/wp-includes/pomo/translations.php", "start": 8295780, "end": 8301496}, {"filename": "/wordpress/wp-includes/post-formats.php", "start": 8301496, "end": 8305443}, {"filename": "/wordpress/wp-includes/post-template.php", "start": 8305443, "end": 8335536}, {"filename": "/wordpress/wp-includes/post-thumbnail-template.php", "start": 8335536, "end": 8338605}, {"filename": "/wordpress/wp-includes/post.php", "start": 8338605, "end": 8458927}, {"filename": "/wordpress/wp-includes/query.php", "start": 8458927, "end": 8472717}, {"filename": "/wordpress/wp-includes/random_compat/byte_safe_strings.php", "start": 8472717, "end": 8474780}, {"filename": "/wordpress/wp-includes/random_compat/cast_to_int.php", "start": 8474780, "end": 8475241}, {"filename": "/wordpress/wp-includes/random_compat/error_polyfill.php", "start": 8475241, "end": 8475491}, {"filename": "/wordpress/wp-includes/random_compat/random.php", "start": 8475491, "end": 8478357}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_com_dotnet.php", "start": 8478357, "end": 8479062}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_dev_urandom.php", "start": 8479062, "end": 8480392}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium.php", "start": 8480392, "end": 8481067}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_libsodium_legacy.php", "start": 8481067, "end": 8481755}, {"filename": "/wordpress/wp-includes/random_compat/random_bytes_mcrypt.php", "start": 8481755, "end": 8482258}, {"filename": "/wordpress/wp-includes/random_compat/random_int.php", "start": 8482258, "end": 8483392}, {"filename": "/wordpress/wp-includes/registration-functions.php", "start": 8483392, "end": 8483505}, {"filename": "/wordpress/wp-includes/registration.php", "start": 8483505, "end": 8483618}, {"filename": "/wordpress/wp-includes/rest-api.php", "start": 8483618, "end": 8539178}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-request.php", "start": 8539178, "end": 8550253}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-response.php", "start": 8550253, "end": 8552716}, {"filename": "/wordpress/wp-includes/rest-api/class-wp-rest-server.php", "start": 8552716, "end": 8578023}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php", "start": 8578023, "end": 8593093}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php", "start": 8593093, "end": 8621949}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php", "start": 8621949, "end": 8629982}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php", "start": 8629982, "end": 8636306}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php", "start": 8636306, "end": 8639030}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php", "start": 8639030, "end": 8644035}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php", "start": 8644035, "end": 8647562}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php", "start": 8647562, "end": 8663973}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php", "start": 8663973, "end": 8664845}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php", "start": 8664845, "end": 8703782}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-controller.php", "start": 8703782, "end": 8712775}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php", "start": 8712775, "end": 8713982}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php", "start": 8713982, "end": 8725972}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php", "start": 8725972, "end": 8748832}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php", "start": 8748832, "end": 8754032}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php", "start": 8754032, "end": 8764955}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php", "start": 8764955, "end": 8772163}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php", "start": 8772163, "end": 8791360}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php", "start": 8791360, "end": 8797923}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php", "start": 8797923, "end": 8806795}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php", "start": 8806795, "end": 8871250}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php", "start": 8871250, "end": 8887629}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php", "start": 8887629, "end": 8894983}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php", "start": 8894983, "end": 8899521}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php", "start": 8899521, "end": 8909265}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php", "start": 8909265, "end": 8915599}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php", "start": 8915599, "end": 8924657}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php", "start": 8924657, "end": 8945102}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php", "start": 8945102, "end": 8966126}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php", "start": 8966126, "end": 8978882}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php", "start": 8978882, "end": 8987139}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php", "start": 8987139, "end": 9018543}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php", "start": 9018543, "end": 9029961}, {"filename": "/wordpress/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php", "start": 9029961, "end": 9046147}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-comment-meta-fields.php", "start": 9046147, "end": 9046397}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php", "start": 9046397, "end": 9056846}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-post-meta-fields.php", "start": 9056846, "end": 9057203}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-term-meta-fields.php", "start": 9057203, "end": 9057595}, {"filename": "/wordpress/wp-includes/rest-api/fields/class-wp-rest-user-meta-fields.php", "start": 9057595, "end": 9057833}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php", "start": 9057833, "end": 9059773}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php", "start": 9059773, "end": 9062748}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-search-handler.php", "start": 9062748, "end": 9063196}, {"filename": "/wordpress/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php", "start": 9063196, "end": 9065585}, {"filename": "/wordpress/wp-includes/revision.php", "start": 9065585, "end": 9077729}, {"filename": "/wordpress/wp-includes/rewrite.php", "start": 9077729, "end": 9085754}, {"filename": "/wordpress/wp-includes/robots-template.php", "start": 9085754, "end": 9087070}, {"filename": "/wordpress/wp-includes/rss-functions.php", "start": 9087070, "end": 9087233}, {"filename": "/wordpress/wp-includes/rss.php", "start": 9087233, "end": 9101675}, {"filename": "/wordpress/wp-includes/script-loader.php", "start": 9101675, "end": 9192863}, {"filename": "/wordpress/wp-includes/session.php", "start": 9192863, "end": 9193057}, {"filename": "/wordpress/wp-includes/shortcodes.php", "start": 9193057, "end": 9200957}, {"filename": "/wordpress/wp-includes/sitemaps.php", "start": 9200957, "end": 9202157}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-index.php", "start": 9202157, "end": 9202934}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-provider.php", "start": 9202934, "end": 9204596}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-registry.php", "start": 9204596, "end": 9205216}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-renderer.php", "start": 9205216, "end": 9208772}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php", "start": 9208772, "end": 9215717}, {"filename": "/wordpress/wp-includes/sitemaps/class-wp-sitemaps.php", "start": 9215717, "end": 9218966}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php", "start": 9218966, "end": 9221457}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php", "start": 9221457, "end": 9223674}, {"filename": "/wordpress/wp-includes/sitemaps/providers/class-wp-sitemaps-users.php", "start": 9223674, "end": 9225163}, {"filename": "/wordpress/wp-includes/sodium_compat/LICENSE", "start": 9225163, "end": 9226023}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload-php7.php", "start": 9226023, "end": 9226442}, {"filename": "/wordpress/wp-includes/sodium_compat/autoload.php", "start": 9226442, "end": 9228143}, {"filename": "/wordpress/wp-includes/sodium_compat/composer.json", "start": 9228143, "end": 9229751}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/constants.php", "start": 9229751, "end": 9233909}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/namespaced.php", "start": 9233909, "end": 9234460}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat.php", "start": 9234460, "end": 9256897}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/php72compat_const.php", "start": 9256897, "end": 9261493}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/ristretto255.php", "start": 9261493, "end": 9265656}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/sodium_compat.php", "start": 9265656, "end": 9276874}, {"filename": "/wordpress/wp-includes/sodium_compat/lib/stream-xchacha20.php", "start": 9276874, "end": 9277741}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Compat.php", "start": 9277741, "end": 9277825}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/BLAKE2b.php", "start": 9277825, "end": 9277921}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20.php", "start": 9277921, "end": 9278019}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/Ctx.php", "start": 9278019, "end": 9278125}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/ChaCha20/IetfCtx.php", "start": 9278125, "end": 9278239}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519.php", "start": 9278239, "end": 9278341}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Fe.php", "start": 9278341, "end": 9278449}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Cached.php", "start": 9278449, "end": 9278571}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P1p1.php", "start": 9278571, "end": 9278689}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P2.php", "start": 9278689, "end": 9278803}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/P3.php", "start": 9278803, "end": 9278917}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/Ge/Precomp.php", "start": 9278917, "end": 9279041}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Curve25519/H.php", "start": 9279041, "end": 9279147}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Ed25519.php", "start": 9279147, "end": 9279243}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HChaCha20.php", "start": 9279243, "end": 9279343}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/HSalsa20.php", "start": 9279343, "end": 9279441}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305.php", "start": 9279441, "end": 9279539}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Poly1305/State.php", "start": 9279539, "end": 9279649}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Salsa20.php", "start": 9279649, "end": 9279745}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/SipHash.php", "start": 9279745, "end": 9279841}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Util.php", "start": 9279841, "end": 9279931}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/X25519.php", "start": 9279931, "end": 9280025}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/XChaCha20.php", "start": 9280025, "end": 9280125}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Core/Xsalsa20.php", "start": 9280125, "end": 9280223}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/Crypto.php", "start": 9280223, "end": 9280307}, {"filename": "/wordpress/wp-includes/sodium_compat/namespaced/File.php", "start": 9280307, "end": 9280387}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Compat.php", "start": 9280387, "end": 9362838}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/BLAKE2b.php", "start": 9362838, "end": 9373809}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Common.php", "start": 9373809, "end": 9376769}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/Original.php", "start": 9376769, "end": 9380204}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Base64/UrlSafe.php", "start": 9380204, "end": 9383639}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20.php", "start": 9383639, "end": 9388839}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php", "start": 9388839, "end": 9390875}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php", "start": 9390875, "end": 9391581}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519.php", "start": 9391581, "end": 9470798}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Fe.php", "start": 9470798, "end": 9472081}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Cached.php", "start": 9472081, "end": 9472904}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P1p1.php", "start": 9472904, "end": 9473645}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P2.php", "start": 9473645, "end": 9474240}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/P3.php", "start": 9474240, "end": 9474977}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/Ge/Precomp.php", "start": 9474977, "end": 9475666}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Curve25519/H.php", "start": 9475666, "end": 9564706}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ed25519.php", "start": 9564706, "end": 9573488}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HChaCha20.php", "start": 9573488, "end": 9576054}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/HSalsa20.php", "start": 9576054, "end": 9578518}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305.php", "start": 9578518, "end": 9579293}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Poly1305/State.php", "start": 9579293, "end": 9586139}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Ristretto255.php", "start": 9586139, "end": 9598667}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Salsa20.php", "start": 9598667, "end": 9603541}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SecretStream/State.php", "start": 9603541, "end": 9605646}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/SipHash.php", "start": 9605646, "end": 9608957}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/Util.php", "start": 9608957, "end": 9621333}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/X25519.php", "start": 9621333, "end": 9626048}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XChaCha20.php", "start": 9626048, "end": 9627645}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core/XSalsa20.php", "start": 9627645, "end": 9628127}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/BLAKE2b.php", "start": 9628127, "end": 9637508}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20.php", "start": 9637508, "end": 9643012}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/Ctx.php", "start": 9643012, "end": 9645777}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/ChaCha20/IetfCtx.php", "start": 9645777, "end": 9646631}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519.php", "start": 9646631, "end": 9729733}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Fe.php", "start": 9729733, "end": 9732423}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Cached.php", "start": 9732423, "end": 9733266}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P1p1.php", "start": 9733266, "end": 9734023}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P2.php", "start": 9734023, "end": 9734634}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/P3.php", "start": 9734634, "end": 9735391}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/Ge/Precomp.php", "start": 9735391, "end": 9736093}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Curve25519/H.php", "start": 9736093, "end": 9824444}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Ed25519.php", "start": 9824444, "end": 9832215}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HChaCha20.php", "start": 9832215, "end": 9835291}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/HSalsa20.php", "start": 9835291, "end": 9839299}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int32.php", "start": 9839299, "end": 9852740}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Int64.php", "start": 9852740, "end": 9870330}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305.php", "start": 9870330, "end": 9871115}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Poly1305/State.php", "start": 9871115, "end": 9879729}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Salsa20.php", "start": 9879729, "end": 9886322}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SecretStream/State.php", "start": 9886322, "end": 9888455}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/SipHash.php", "start": 9888455, "end": 9891224}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/Util.php", "start": 9891224, "end": 9891383}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/X25519.php", "start": 9891383, "end": 9897381}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XChaCha20.php", "start": 9897381, "end": 9898522}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Core32/XSalsa20.php", "start": 9898522, "end": 9899010}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto.php", "start": 9899010, "end": 9923557}, {"filename": "/wordpress/wp-includes/sodium_compat/src/Crypto32.php", "start": 9923557, "end": 9948413}, {"filename": "/wordpress/wp-includes/sodium_compat/src/File.php", "start": 9948413, "end": 9977821}, {"filename": "/wordpress/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php", "start": 9977821, "end": 9979477}, {"filename": "/wordpress/wp-includes/sodium_compat/src/SodiumException.php", "start": 9979477, "end": 9979577}, {"filename": "/wordpress/wp-includes/spl-autoload-compat.php", "start": 9979577, "end": 9979687}, {"filename": "/wordpress/wp-includes/style-engine.php", "start": 9979687, "end": 9981579}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-declarations.php", "start": 9981579, "end": 9983542}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rule.php", "start": 9983542, "end": 9985142}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php", "start": 9985142, "end": 9986255}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine-processor.php", "start": 9986255, "end": 9988323}, {"filename": "/wordpress/wp-includes/style-engine/class-wp-style-engine.php", "start": 9988323, "end": 9998675}, {"filename": "/wordpress/wp-includes/taxonomy.php", "start": 9998675, "end": 10068376}, {"filename": "/wordpress/wp-includes/template-canvas.php", "start": 10068376, "end": 10068702}, {"filename": "/wordpress/wp-includes/template-loader.php", "start": 10068702, "end": 10070427}, {"filename": "/wordpress/wp-includes/template.php", "start": 10070427, "end": 10077408}, {"filename": "/wordpress/wp-includes/theme-compat/comments.php", "start": 10077408, "end": 10079036}, {"filename": "/wordpress/wp-includes/theme-compat/embed-404.php", "start": 10079036, "end": 10079553}, {"filename": "/wordpress/wp-includes/theme-compat/embed-content.php", "start": 10079553, "end": 10081543}, {"filename": "/wordpress/wp-includes/theme-compat/embed.php", "start": 10081543, "end": 10081757}, {"filename": "/wordpress/wp-includes/theme-compat/footer-embed.php", "start": 10081757, "end": 10081812}, {"filename": "/wordpress/wp-includes/theme-compat/footer.php", "start": 10081812, "end": 10082488}, {"filename": "/wordpress/wp-includes/theme-compat/header-embed.php", "start": 10082488, "end": 10082818}, {"filename": "/wordpress/wp-includes/theme-compat/header.php", "start": 10082818, "end": 10084378}, {"filename": "/wordpress/wp-includes/theme-compat/sidebar.php", "start": 10084378, "end": 10087503}, {"filename": "/wordpress/wp-includes/theme-i18n.json", "start": 10087503, "end": 10088654}, {"filename": "/wordpress/wp-includes/theme-templates.php", "start": 10088654, "end": 10092309}, {"filename": "/wordpress/wp-includes/theme.json", "start": 10092309, "end": 10101717}, {"filename": "/wordpress/wp-includes/theme.php", "start": 10101717, "end": 10171658}, {"filename": "/wordpress/wp-includes/update.php", "start": 10171658, "end": 10192357}, {"filename": "/wordpress/wp-includes/user.php", "start": 10192357, "end": 10265782}, {"filename": "/wordpress/wp-includes/vars.php", "start": 10265782, "end": 10269777}, {"filename": "/wordpress/wp-includes/version.php", "start": 10269777, "end": 10269945}, {"filename": "/wordpress/wp-includes/widgets.php", "start": 10269945, "end": 10302690}, {"filename": "/wordpress/wp-includes/widgets/class-wp-nav-menu-widget.php", "start": 10302690, "end": 10306552}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-archives.php", "start": 10306552, "end": 10310792}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-block.php", "start": 10310792, "end": 10313997}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-calendar.php", "start": 10313997, "end": 10315483}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-categories.php", "start": 10315483, "end": 10320014}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-custom-html.php", "start": 10320014, "end": 10327156}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-links.php", "start": 10327156, "end": 10332595}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-audio.php", "start": 10332595, "end": 10336809}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-gallery.php", "start": 10336809, "end": 10341949}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-image.php", "start": 10341949, "end": 10350783}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media-video.php", "start": 10350783, "end": 10356860}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-media.php", "start": 10356860, "end": 10364987}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-meta.php", "start": 10364987, "end": 10367185}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-pages.php", "start": 10367185, "end": 10370762}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-comments.php", "start": 10370762, "end": 10374872}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-recent-posts.php", "start": 10374872, "end": 10378756}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-rss.php", "start": 10378756, "end": 10381934}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-search.php", "start": 10381934, "end": 10383326}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-tag-cloud.php", "start": 10383326, "end": 10387575}, {"filename": "/wordpress/wp-includes/widgets/class-wp-widget-text.php", "start": 10387575, "end": 10399972}, {"filename": "/wordpress/wp-includes/wlwmanifest.xml", "start": 10399972, "end": 10401017}, {"filename": "/wordpress/wp-includes/wp-db.php", "start": 10401017, "end": 10401196}, {"filename": "/wordpress/wp-includes/wp-diff.php", "start": 10401196, "end": 10401545}, {"filename": "/wordpress/wp-links-opml.php", "start": 10401545, "end": 10403156}, {"filename": "/wordpress/wp-load.php", "start": 10403156, "end": 10404951}, {"filename": "/wordpress/wp-login.php", "start": 10404951, "end": 10439141}, {"filename": "/wordpress/wp-mail.php", "start": 10439141, "end": 10445092}, {"filename": "/wordpress/wp-settings.php", "start": 10445092, "end": 10462053}, {"filename": "/wordpress/wp-signup.php", "start": 10462053, "end": 10484965}, {"filename": "/wordpress/wp-trackback.php", "start": 10484965, "end": 10488392}, {"filename": "/wordpress/xmlrpc.php", "start": 10488392, "end": 10490215}], "remote_package_size": 10490215}); })(); // See esm-prefix.js diff --git a/jest.config.js b/jest.config.js index b50545c425..0b9b71eaad 100644 --- a/jest.config.js +++ b/jest.config.js @@ -65,7 +65,9 @@ module.exports = { // globalTeardown: undefined, // A set of global variables that need to be available in all test environments - // globals: {}, + globals: { + PHP_JS_HASH: '', + }, // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. // maxWorkers: "50%", diff --git a/package.json b/package.json index dc9e41fcbb..9f828af404 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "eslint-plugin-react": "^7.31.1", "eslint-plugin-react-hooks": "^4.6.0", "estree-walker": "^3.0.1", + "file-saver": "^2.0.5", "glob": "^8.0.3", "gulp": "^4.0.2", "gulp-rename": "^2.0.0", diff --git a/src/php-wasm-browser/worker-thread/window-library.ts b/src/php-wasm-browser/worker-thread/window-library.ts index 4233169310..923234a7eb 100644 --- a/src/php-wasm-browser/worker-thread/window-library.ts +++ b/src/php-wasm-browser/worker-thread/window-library.ts @@ -173,6 +173,14 @@ export class SpawnedWorkerThread { return await this.#rpc('readFile', { path }); } + /** + * @param path + * @see {PHP.readFile} + */ + async readFileAsBuffer(path: string): Promise<string> { + return await this.#rpc('readFileAsBuffer', { path }); + } + /** * @param path * @param contents diff --git a/src/php-wasm-browser/worker-thread/worker-library.ts b/src/php-wasm-browser/worker-thread/worker-library.ts index bff12e399e..e5e5139bb4 100644 --- a/src/php-wasm-browser/worker-thread/worker-library.ts +++ b/src/php-wasm-browser/worker-thread/worker-library.ts @@ -94,6 +94,8 @@ export async function initializeWorkerThread( return scope; } else if (message.type === 'readFile') { return phpBrowser.server.php.readFileAsText(message.path); + } else if (message.type === 'readFileAsBuffer') { + return phpBrowser.server.php.readFileAsBuffer(message.path); } else if (message.type === 'listFiles') { return phpBrowser.server.php.listFiles(message.path); } else if (message.type === 'unlink') { diff --git a/src/wordpress-playground/__tests__/migration-tests.ts b/src/wordpress-playground/__tests__/migration-tests.ts new file mode 100644 index 0000000000..4795eceb22 --- /dev/null +++ b/src/wordpress-playground/__tests__/migration-tests.ts @@ -0,0 +1,312 @@ +import * as phpLoaderModule from '../../../build/php-7.4.node.js'; +import { startPHP } from '../../php-wasm/php-node'; +import { existsSync, rmdirSync, readFileSync } from 'fs'; + +const { TextDecoder } = require('util'); + +// Code to test +const migration = readFileSync(__dirname + '/../migration.php'); + +// Mock files +const testDirPath = __dirname + '/__test39024'; +const fileSystemPath = testDirPath + '/filesystem'; +const wpImporterOutputPath = fileSystemPath + '/databaseExport.xml'; +const wpImporterOutputValue = 'Mock WordPress Importer migration file'; + +const exportName = `wordpress-playground-export.zip`; +const exportPath = `${testDirPath}/${exportName}`; + +// ------------------------ +// Mock WordPress Directory +// ------------------------ + +// Root +const wpDir = fileSystemPath + '/wordpress'; +const wpDirFilePath = wpDir + '/test-wp-root.php'; +const wpDirFileValue = 'Mock WP root file'; + +// WP Admin +const wpAdminDir = wpDir + '/wp-admin'; +const wpAdminFilePath = wpAdminDir + '/test-admin.php'; +const wpAdminFileValue = 'Mock WP admin file'; + +// WP Content +const wpContentDir = wpDir + '/wp-content'; +const wpContentFilePath = wpContentDir + '/test-content.php'; +const wpContentFileValue = 'Mock WP content file'; + +// WP Content - SQL DB +const wpSqlDbDir = wpContentDir + '/database'; +const wpSqlDbFilePath = wpSqlDbDir + '/test-database.php'; +const wpSqlDbFileValue = 'Mock SQL content'; + +// WP Includes +const wpIncludesDir = wpDir + '/wp-includes'; +const wpIncludesFilePath = wpIncludesDir + '/test-includes.php'; +const wpIncludesFileValue = 'Mock WP includes'; + +function createMockStructure(phpRuntime) { + phpRuntime.mkdirTree(testDirPath); + phpRuntime.mkdirTree(fileSystemPath); + phpRuntime.mkdirTree(wpDir); + + phpRuntime.writeFile(wpImporterOutputPath, wpImporterOutputValue); + + // WP Root + phpRuntime.writeFile(wpDirFilePath, wpDirFileValue); + + // WP Admin + phpRuntime.mkdirTree(wpAdminDir); + phpRuntime.writeFile(wpAdminFilePath, wpAdminFileValue); + + // WP Content + phpRuntime.mkdirTree(wpContentDir); + phpRuntime.writeFile(wpContentFilePath, wpContentFileValue); + + // WP Content - SQL DB + phpRuntime.mkdirTree(wpSqlDbDir); + phpRuntime.writeFile(wpSqlDbFilePath, wpSqlDbFileValue); + + // WP Includes + phpRuntime.mkdirTree(wpIncludesDir); + phpRuntime.writeFile(wpIncludesFilePath, wpIncludesFileValue); + + const exportWriteRequest = phpRuntime.run({ + code: + migration + + ` generateZipFile("${exportPath}", "${wpImporterOutputPath}", "${wpDir}");`, + }); + + if (exportWriteRequest.exitCode !== 0) { + throw exportWriteRequest.errors; + } +} + +describe('generateZipFile()', () => { + let php; + + beforeEach(async () => { + php = await startPHP(phpLoaderModule, 'NODE'); + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + createMockStructure(php); + }); + + afterAll(() => { + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + }); + + it('should creata a ZIP file of specified WP Importer output file and WordPress files', () => { + const runTest = php.run({ + code: ` + <?php + $zip = new ZipArchive; + $res = $zip->open('${exportPath}'); + if ($res === TRUE) { + if( + $zip->getFromName('${wpImporterOutputPath}') && + $zip->getFromName('${wpDirFilePath}') && + $zip->getFromName('${wpContentFilePath}') + ) { + echo 'success'; + } else { + echo 'failure'; + } + } + `, + }); + + const runTestOutput = new TextDecoder().decode(runTest.body).trim(); + + expect(runTestOutput).toEqual('success'); + }); + + it('should omit wp-content/database directory', () => { + const runTest = php.run({ + code: ` + <?php + $zip = new ZipArchive; + $res = $zip->open('${exportPath}'); + if ($res === TRUE) { + if( + !$zip->getFromName('${wpSqlDbFilePath}') + ) { + echo 'success'; + } else { + echo 'failure'; + } + } + `, + }); + + const runTestOutput = new TextDecoder().decode(runTest.body).trim(); + + expect(runTestOutput).toEqual('success'); + }); + + it('should omit wp-includes directory', () => { + const runTest = php.run({ + code: ` + <?php + $zip = new ZipArchive; + $res = $zip->open('${exportPath}'); + if ($res === TRUE) { + if( + !$zip->getFromName('${wpIncludesFilePath}') + ) { + echo 'success'; + } else { + echo 'failure'; + } + } + `, + }); + + const runTestOutput = new TextDecoder().decode(runTest.body).trim(); + + expect(runTestOutput).toEqual('success'); + }); +}); + +describe('readFileFromZipArchive()', () => { + let php; + + beforeEach(async () => { + php = await startPHP(phpLoaderModule, 'NODE'); + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + createMockStructure(php); + }); + + afterAll(() => { + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + }); + + describe("given a path to a generateZipFile() output, it should return a specified file's contents", () => { + it('filesystem root file', () => { + const readFileRequest = php.run({ + code: + migration + + ` readFileFromZipArchive('${exportPath}', '${wpImporterOutputPath}');`, + }); + + if (readFileRequest.exitCode !== 0) { + throw readFileRequest.errors; + } + + const readFileOutput = new TextDecoder() + .decode(readFileRequest.body) + .trim(); + + expect(readFileOutput).toEqual(wpImporterOutputValue); + }); + it('wp root file', () => { + const readFileRequest = php.run({ + code: + migration + + ` readFileFromZipArchive('${exportPath}', '${wpDirFilePath}');`, + }); + + if (readFileRequest.exitCode !== 0) { + throw readFileRequest.errors; + } + + const readFileOutput = new TextDecoder() + .decode(readFileRequest.body) + .trim(); + + expect(readFileOutput).toEqual(wpDirFileValue); + }); + it('wp admin file', () => { + const readFileRequest = php.run({ + code: + migration + + ` readFileFromZipArchive('${exportPath}', '${wpAdminFilePath}');`, + }); + + if (readFileRequest.exitCode !== 0) { + throw readFileRequest.errors; + } + + const readFileOutput = new TextDecoder() + .decode(readFileRequest.body) + .trim(); + + expect(readFileOutput).toEqual(wpAdminFileValue); + }); + it('wp content file', () => { + const readFileRequest = php.run({ + code: + migration + + ` readFileFromZipArchive('${exportPath}', '${wpContentFilePath}');`, + }); + + if (readFileRequest.exitCode !== 0) { + throw readFileRequest.errors; + } + + const readFileOutput = new TextDecoder() + .decode(readFileRequest.body) + .trim(); + + expect(readFileOutput).toEqual(wpContentFileValue); + }); + }); +}); + +describe('importZipFile()', () => { + let php; + + beforeAll(async () => { + php = await startPHP(phpLoaderModule, 'NODE'); + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + createMockStructure(php); + }); + + beforeEach(() => { + if (existsSync(fileSystemPath)) { + rmdirSync(fileSystemPath, { recursive: true }); + } + const writeFileRequest = php.run({ + code: migration + ` importZipFile('${exportPath}');`, + }); + if (writeFileRequest.exitCode !== 0) { + throw writeFileRequest.errors; + } + }); + + afterAll(() => { + if (existsSync(testDirPath)) { + rmdirSync(testDirPath, { recursive: true }); + } + }); + + describe('given a path to a generateZipFile() output, it should write ZIP to filesystem', () => { + it('filesystem root file', () => { + expect(php.readFileAsText(wpImporterOutputPath)).toEqual( + wpImporterOutputValue + ); + }); + it('wp root file', () => { + expect(php.readFileAsText(wpDirFilePath)).toEqual(wpDirFileValue); + }); + it('wp admin file', () => { + expect(php.readFileAsText(wpAdminFilePath)).toEqual( + wpAdminFileValue + ); + }); + it('wp content file', () => { + expect(php.readFileAsText(wpContentFilePath)).toEqual( + wpContentFileValue + ); + }); + }); +}); diff --git a/src/wordpress-playground/config.ts b/src/wordpress-playground/config.ts index 2d71ed9356..63aabc35fe 100644 --- a/src/wordpress-playground/config.ts +++ b/src/wordpress-playground/config.ts @@ -1,5 +1,8 @@ /* eslint-disable no-undef */ +// Hardcoded in wp.js: +export const DOCROOT = '/wordpress'; + // Provided by esbuild – see build.js in the repo root. declare let SERVICE_WORKER_URL: any; export const serviceWorkerUrl = SERVICE_WORKER_URL; diff --git a/src/wordpress-playground/index.tsx b/src/wordpress-playground/index.tsx index 2c5df181d0..a9016c28ce 100644 --- a/src/wordpress-playground/index.tsx +++ b/src/wordpress-playground/index.tsx @@ -6,10 +6,50 @@ import { } from '../php-wasm-browser/index'; import { ProgressObserver, ProgressType } from './progress-observer'; import { PromiseQueue } from './promise-queue'; +import { saveAs } from 'file-saver'; +import { DOCROOT } from './config'; +import migration from './migration.php'; const query = new URL(document.location.href).searchParams as any; const wpFrame = document.querySelector('#wp') as HTMLIFrameElement; +const addressBar = document.querySelector('#url-bar')! as HTMLInputElement; + +let wpVersion; +let phpVersion; + +// Migration Logic +const importWindow = document.querySelector('#import-window') as HTMLElement; +const overlay = document.querySelector('#overlay') as HTMLElement; +const exportButton = document.querySelector( + '#export-playground--btn' +) as HTMLButtonElement; +const importOpenModalButton = document.querySelector( + '#import-open-modal--btn' +) as HTMLButtonElement; +const importPlaygroundForm = document.querySelector( + '#import-playground-form' +) as HTMLFormElement; +const importSelectFile = document.querySelector( + '#import-select-file' +) as HTMLInputElement; +const importSelectFileText = document.querySelector( + '#import-select-file--text' +) as HTMLElement; +const importSelectFileButton = document.querySelector( + '#import-select-file--btn' +) as HTMLButtonElement; +const importSubmitButton = document.querySelector( + '#import-submit--btn' +) as HTMLButtonElement; +const importCloseModalButton = document.querySelector( + '#import-close-modal--btn' +) as HTMLButtonElement; + +const databaseExportName = 'databaseExport.xml'; +const databaseExportPath = '/' + databaseExportName; + +let workerThread; let isBooted = false; @@ -19,26 +59,32 @@ async function main() { const queryTheme = query.get('theme') === 'twentytwentythree' ? null : query.get('theme'); const preinstallTheme = toZipName(queryTheme); - + wpVersion = query.get('wp') ? query.get('wp') : '6.1'; + phpVersion = query.get('php') ? query.get('php') : '8.0'; const installPluginProgress = Math.min(preinstallPlugins.length * 15, 45); const installThemeProgress = preinstallTheme ? 20 : 0; const bootProgress = 100 - installPluginProgress - installThemeProgress; const progress = setupProgressBar(); - const workerThread = await bootWordPress({ + workerThread = await bootWordPress({ onWasmDownloadProgress: progress.partialObserver( bootProgress, 'Preparing WordPress...' ), - phpVersion: query.get('php'), - dataModule: query.get('wp'), + phpVersion, + dataModule: wpVersion, }); const appMode = query.get('mode') === 'seamless' ? 'seamless' : 'browser'; if (appMode === 'browser') { setupAddressBar(workerThread); } - if (query.get('login') || preinstallPlugins.length || query.get('theme')) { + if ( + !query.get('disableImportExport') || + query.get('login') || + preinstallPlugins.length || + query.get('theme') + ) { await login(workerThread, 'admin', 'password'); } @@ -139,7 +185,6 @@ async function main() { } if (query.get('rpc')) { - console.log('Registering an RPC handler'); async function handleMessage(data) { if (data.type === 'rpc') { return await workerThread[data.method](...data.args); @@ -222,7 +267,6 @@ function toZipName(rawInput) { function setupAddressBar(wasmWorker) { // Manage the address bar - const addressBar = document.querySelector('#url-bar')! as HTMLInputElement; wpFrame.addEventListener('load', (e: any) => { addressBar.value = wasmWorker.internalUrlToPath( e.currentTarget!.contentWindow.location.href @@ -296,4 +340,225 @@ function zipNameToHumanName(zipName) { ); } +async function generateZip() { + const databaseExportResponse = await workerThread.HTTPRequest({ + absoluteUrl: workerThread.pathToInternalUrl( + '/wp-admin/export.php?download=true&&content=all' + ), + method: 'GET', + }); + const databaseExportContent = new TextDecoder().decode( + databaseExportResponse.body + ); + await workerThread.writeFile(databaseExportPath, databaseExportContent); + const exportName = `wordpress-playground--wp${wpVersion}--php${phpVersion}.zip`; + const exportPath = `/${exportName}`; + const exportWriteRequest = await workerThread.run({ + code: + migration + + ` generateZipFile('${exportPath}', '${databaseExportPath}', '${DOCROOT}');`, + }); + if (exportWriteRequest.exitCode !== 0) { + throw exportWriteRequest.errors; + } + + const fileBuffer = await workerThread.readFileAsBuffer(exportName); + const file = new File([fileBuffer], exportName); + saveAs(file); +} + +async function importFile() { + if ( + // eslint-disable-next-line no-alert + !confirm( + 'Are you sure you want to import this file? Previous data will be lost.' + ) + ) { + return false; + } + + // Write uploaded file to filesystem for processing with PHP + const userUploadedFileInput = importSelectFile as HTMLInputElement; + const userUploadedFile = userUploadedFileInput.files + ? userUploadedFileInput.files[0] + : null; + if (!userUploadedFile) return; + + const fileArrayBuffer = await userUploadedFile.arrayBuffer(); + const fileContent = new Uint8Array(fileArrayBuffer); + const importPath = '/import.zip'; + + await workerThread.writeFile(importPath, fileContent); + + // Import the database + const databaseFromZipFileReadRequest = await workerThread.run({ + code: + migration + + ` readFileFromZipArchive('${importPath}', '${databaseExportPath}');`, + }); + if (databaseFromZipFileReadRequest.exitCode !== 0) { + throw databaseFromZipFileReadRequest.errors; + } + + const databaseFromZipFileContent = new TextDecoder().decode( + databaseFromZipFileReadRequest.body + ); + + const databaseFile = new File( + [databaseFromZipFileContent], + databaseExportName + ); + + const importerPageOneResponse = await workerThread.HTTPRequest({ + absoluteUrl: workerThread.pathToInternalUrl( + '/wp-admin/admin.php?import=wordpress' + ), + method: 'GET', + }); + + const importerPageOneContent = new DOMParser().parseFromString( + importerPageOneResponse.text, + 'text/html' + ); + + const firstUrlAction = importerPageOneContent + .getElementById('import-upload-form') + ?.getAttribute('action'); + + const stepOneResponse = await workerThread.HTTPRequest({ + absoluteUrl: workerThread.pathToInternalUrl( + `/wp-admin/${firstUrlAction}` + ), + method: 'POST', + files: { import: databaseFile }, + }); + + const importerPageTwoContent = new DOMParser().parseFromString( + stepOneResponse.text, + 'text/html' + ); + + const importerPageTwoForm = importerPageTwoContent.querySelector( + '#wpbody-content form' + ); + const secondUrlAction = importerPageTwoForm?.getAttribute('action'); + + const nonce = ( + importerPageTwoForm?.querySelector( + "input[name='_wpnonce']" + ) as HTMLInputElement + ).value; + + const referrer = ( + importerPageTwoForm?.querySelector( + "input[name='_wp_http_referer']" + ) as HTMLInputElement + ).value; + + const importId = ( + importerPageTwoForm?.querySelector( + "input[name='import_id']" + ) as HTMLInputElement + ).value; + + await workerThread.HTTPRequest({ + absoluteUrl: secondUrlAction, + method: 'POST', + headers: { + 'content-type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ + _wpnonce: nonce, + _wp_http_referer: referrer, + import_id: importId, + }).toString(), + }); + + // Import the file system + const importFileSystemRequest = await workerThread.run({ + code: migration + ` importZipFile('${importPath}');`, + }); + if (importFileSystemRequest.exitCode !== 0) { + throw importFileSystemRequest.errors; + } + + return true; +} + +if ( + importWindow && + overlay && + exportButton && + importOpenModalButton && + importPlaygroundForm && + importSelectFileButton && + importSelectFileText && + importSelectFile && + importSubmitButton && + importCloseModalButton +) { + const resetImportWindow = () => { + overlay.style.display = 'none'; + importWindow.style.display = 'none'; + importPlaygroundForm.reset(); + importSelectFileText.innerHTML = 'No file selected'; + importSubmitButton.disabled = true; + }; + + exportButton.addEventListener('click', generateZip); + + importOpenModalButton.addEventListener('click', () => { + importWindow.style.display = 'block'; + overlay.style.display = 'block'; + importCloseModalButton.focus(); + }); + + importSelectFile.addEventListener('change', (e) => { + if (importSelectFile.files === null) return; + importSubmitButton.disabled = false; + importSelectFileText.innerHTML = importSelectFile.files[0].name; + }); + + importSelectFileButton.addEventListener('click', (e) => { + e.preventDefault(); + importPlaygroundForm.reset(); + importSelectFile.click(); + }); + + importSubmitButton.addEventListener('click', async (e) => { + e.preventDefault(); + let uploadAttempt; + try { + uploadAttempt = await importFile(); + } catch (error) { + console.error(error); + importSelectFileText.innerHTML = + '<span class="error" style="color: red;">Unable to import file. <br/> Is it a valid WordPress Playground export?</span>'; + } + + if (uploadAttempt) { + // eslint-disable-next-line no-alert + alert( + 'File imported! This Playground instance has been updated. Refreshing now.' + ); + resetImportWindow(); + wpFrame.src = workerThread.pathToInternalUrl(addressBar.value); + addressBar.focus(); + } + }); + + importCloseModalButton.addEventListener('click', (e) => { + e.preventDefault(); + resetImportWindow(); + importOpenModalButton.focus(); + }); + + overlay.addEventListener('click', (e) => { + e.preventDefault(); + resetImportWindow(); + }); +} else { + console.error('Migration user interface elements not found.'); +} + main(); diff --git a/src/wordpress-playground/migration.php b/src/wordpress-playground/migration.php new file mode 100644 index 0000000000..8afcd6e12e --- /dev/null +++ b/src/wordpress-playground/migration.php @@ -0,0 +1,68 @@ +<?php + +function generateZipFile($exportPath, $databasePath, $docRoot) { + $zip = new ZipArchive; + $res = $zip->open($exportPath, ZipArchive::CREATE); + if ($res === TRUE) { + $zip->addFile($databasePath); + $directories = array(); + $directories[] = $docRoot . '/'; + + while(sizeof($directories)) { + $dir = array_pop($directories); + + if ($handle = opendir($dir)) { + while (false !== ($entry = readdir($handle))) { + if ($entry == '.' || $entry == '..') { + continue; + } + + $entry = $dir . $entry; + + if ( + is_dir($entry) && + strpos($entry, 'wp-content/database') == false && + strpos($entry, 'wp-includes') == false + ) { + $directory_path = $entry . '/'; + array_push($directories, $directory_path); + } else if (is_file($entry)) { + $zip->addFile($entry); + } + } + closedir($handle); + } + } + $zip->close(); + chmod($exportPath, 0777); + } +} + +function readFileFromZipArchive($pathToZip, $pathToFile) { + chmod($pathToZip, 0777); + $zip = new ZipArchive; + $res = $zip->open($pathToZip); + if ($res === TRUE) { + $file = $zip->getFromName($pathToFile); + echo $file; + } +} + +function importZipFile($pathToZip) { + $zip = new ZipArchive; + $res = $zip->open($pathToZip); + if ($res === TRUE) { + $counter = 0; + while ($zip->statIndex($counter)) { + $file = $zip->statIndex($counter); + $filePath = $file['name']; + if (!file_exists(dirname($filePath))) { + mkdir(dirname($filePath), 0777, true); + } + $overwrite = fopen($filePath, 'w'); + fwrite($overwrite, $zip->getFromIndex($counter)); + $counter++; + } + $zip->close(); + } +} diff --git a/src/wordpress-playground/wordpress.html b/src/wordpress-playground/wordpress.html index 78e5bdfe20..504e3977f5 100644 --- a/src/wordpress-playground/wordpress.html +++ b/src/wordpress-playground/wordpress.html @@ -23,6 +23,40 @@ background-attachment: fixed; } + .migration-controls { + position: absolute; + right: 10px; + } + + .btn { + cursor: pointer; + background: none; + border: none; + } + + .btn:hover, + .btn:active { + opacity: 0.8; + } + + .btn-close { + position: absolute; + top: 5px; + right: 5px; + } + + #overlay { + width: 100vw; + height: 100vh; + position: absolute; + top: 0; + left: 0; + z-index: 100; + background: #1E2327; + opacity: 0.8; + display: none; + } + .full-window { width: 100vw; height: 100vh; @@ -31,6 +65,10 @@ padding: 0; } + .screenreader-text { + display: none; + } + .fake-window-wrapper { padding: 55px 60px; } @@ -94,6 +132,7 @@ height: 50px; flex-direction: row; align-items: center; + position: relative; } .dots { @@ -304,6 +343,68 @@ .is-code-mirror .cm-editor .cm-gutters { background-color: rgba(255,255,255,0.2); } + + .modal { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 400px; + background: #fff; + border-radius: 6px; + z-index: 200; + text-align: center; + color:#000; + border:#000 1px solid; + display: none; + } + + .modal-inner { + position: relative; + padding: 20px; + } + + .modal-text, + .modal-text-list { + text-align: left; + } + + .modal-text-list { + padding-left: 15px; + } + + .modal .inputs-container { + display: flex; + flex-direction: column; + margin-bottom: 20px; + } + + .modal .inputs-container { + display: flex; + flex-direction: column; + margin-bottom: 20px; + } + + .modal .inputs-container .btn { + background: #1E2327; + color: #fff; + height: 40px; + border-radius: 6px; + margin: 5px 0; + } + + .modal .inputs-container .btn[disabled] { + opacity: 0.5; + } + + .file-input-text { + margin-top: 5px; + margin-bottom: 15px; + } + + .file-input-label .btn { + width: 100%; + } </style> </head> <body class="is-loading"> @@ -314,6 +415,41 @@ <div id="test-snippets"></div> <div id="app-root" class="full-window"></div> + <div id="overlay"></div> + <div id="import-window" class="modal" aria-hidden="true" aria-describedby='import-window-description'> + <div class='screenreader-text' id='import-window-description'> + This is a dialog window which overlays the main content of the page. The modal begins with a heading 2 called "Import Playground". Pressing the Close Import Window will close the modal and bring you back to where you were on the page. + </div> + <div class="modal-inner"> + <form id="import-playground-form"> + <button id="import-close-modal--btn" class="btn btn-close" aria-label="Close import window"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="32" height="32" aria-hidden="true" focusable="false"> + <path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path> + </svg> + </button> + <h2 tabindex="0">Import Playground</h2> + <p class="modal-text"> + You may import a previously exported WordPress Playground instance here. + </p> + <p class="modal-text"> + <strong>Known Limitations</strong><br/> + <ul class="modal-text-list"> + <li>Styling changes may take up to one minute to update.</li><br/> + <li>Migrating between different WordPress versions is not supported.</li><br/> + <li>Media files, options/users, and plugin state will not be included.</li> + </ul> + </p> + <div class="inputs-container"> + <input type="file" id="import-select-file" style="display:none;" accept="application/zip"/> + <label for="import-select-file" class="file-input-label"> + <div id="import-select-file--text" class="file-input-text">No File Selected</div> + <button id="import-select-file--btn" class="btn">Choose File</button> + </label> + <button id="import-submit--btn" disabled="true" class="btn">Import</button> + </div> + </form> + </div> + </div> <script type="template" id="browser-mode"> <div class="fake-window-wrapper full-window"> <div class="fake-window"> @@ -330,6 +466,18 @@ </div> <input type="submit" tabindex="-1" /> </form> + <div class="migration-controls"> + <button id="export-playground--btn" class="btn" aria-label="Download Playground export as ZIP file"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"> + <path fill="#ffffff" d="M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"></path> + </svg> + </button> + <button id="import-open-modal--btn" class="btn" aria-label="Open Playground import window"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"> + <path fill="#ffffff" d="M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"></path> + </svg> + </button> + </div> </div> <div class="main-content"> <div class="progress-bar-overlay"> diff --git a/src/wordpress-playground/wordpress/Dockerfile b/src/wordpress-playground/wordpress/Dockerfile index 8cf530ee16..534b80a50e 100644 --- a/src/wordpress-playground/wordpress/Dockerfile +++ b/src/wordpress-playground/wordpress/Dockerfile @@ -110,25 +110,13 @@ RUN cd wordpress && \ # Remove any empty directories find . -type d -empty -delete -# Strip whitespaces from PHP files. -# PHP 7.4 is a safe choice here: `php -w` ran on 7.4 -# produces code compatible with PHP 8+, but the reverse -# isn't true. FROM php:7.4-cli AS php WORKDIR /root/ COPY --from=emscripten /root/wordpress ./wordpress -RUN cd wordpress && \ - for phpfile in $(find ./ -type f -name '*.php'); do \ - # Remove whitespace from PHP files - php -w $phpfile > $phpfile.small && \ - # remove set_time_limit function calls as they invoke the - # setitimer system call unsupported by emscripten - perl -pe 's/@?set_time_limit\([^)]+\)//g' $phpfile.small > $phpfile && \ - rm $phpfile.small; \ - done # === Run WordPress Installer === -RUN cd wordpress && \ +RUN ls -la && \ + cd wordpress && \ nohup bash -c "php -S 127.0.0.1:8000&" && \ sleep 6; \ http_response=$(curl -o ./debug.txt -s -w "%{http_code}\n" -XPOST http://127.0.0.1:8000/wp-admin/install.php\?step\=2 --data "language=en&prefix=wp_&weblog_title=My WordPress Website&user_name=admin&admin_password=password&admin_password2=password&Submit=Install WordPress&pw_weak=1&admin_email=admin@localhost.com") && \ @@ -137,6 +125,29 @@ RUN cd wordpress && \ exit 'WordPress installation failed'; \ fi +# === Install WP-CLI === +RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ + chmod +x wp-cli.phar + +# === Install WordPress Importer === +RUN cd wordpress && \ + ../wp-cli.phar --allow-root plugin install wordpress-importer && \ + ../wp-cli.phar --allow-root plugin activate wordpress-importer + +# Strip whitespaces from PHP files. +# PHP 7.4 is a safe choice here: `php -w` ran on 7.4 +# produces code compatible with PHP 8+, but the reverse +# isn't true. +RUN cd wordpress && \ + for phpfile in $(find ./ -type f -name '*.php' -not -path '*wordpress-importer*' ); do \ + # Remove whitespace from PHP files + php -w $phpfile > $phpfile.small && \ + # remove set_time_limit function calls as they invoke the + # setitimer system call unsupported by emscripten + perl -pe 's/@?set_time_limit\([^)]+\)//g' $phpfile.small > $phpfile && \ + rm $phpfile.small; \ + done + FROM emscripten as emscripten2 RUN rm -rf ./wordpress COPY --from=php /root/wordpress ./wordpress diff --git a/src/wordpress-playground/worker-thread.ts b/src/wordpress-playground/worker-thread.ts index 702e938ef6..86c1d9600f 100644 --- a/src/wordpress-playground/worker-thread.ts +++ b/src/wordpress-playground/worker-thread.ts @@ -9,13 +9,16 @@ import { currentBackend, setURLScope, } from '../php-wasm-browser/worker-thread/worker-library'; -import { phpJsCacheBuster, wpJsCacheBuster, wordPressSiteUrl } from './config'; +import { + DOCROOT, + phpJsCacheBuster, + wpJsCacheBuster, + wordPressSiteUrl, +} from './config'; import { isUploadedFilePath } from './worker-utils'; const scope = Math.random().toFixed(16); const scopedSiteUrl = setURLScope(wordPressSiteUrl, scope).toString(); -// Hardcoded in wp.js: -const DOCROOT = '/wordpress'; startWordPress().then(({ browser, wpLoaderModule, staticAssetsDirectory }) => initializeWorkerThread({