Changeset 10237
- Timestamp:
- 09/03/2020 11:57:12 PM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 71 added
- 3 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins
-
Property
svn:ignore
set to
0-sandbox.php
-
Property
svn:ignore
set to
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/locales.php
r8347 r10237 12 12 namespace WordPressdotorg\Locales { 13 13 14 use GP_Locales ;14 use GP_Locales, GP_Locale; 15 15 16 16 /** … … 29 29 } 30 30 add_filter( 'get_available_languages', __NAMESPACE__ . '\set_available_languages', 10, 0 ); 31 32 /** 33 * Retrieves all available locales. 34 * 35 * @return GP_Locale[] Array of locale objects. 36 */ 37 function get_locales() { 38 wp_cache_add_global_groups( array( 'locale-associations' ) ); 39 40 $wp_locales = wp_cache_get( 'locale-list', 'locale-associations' ); 41 if ( false === $wp_locales ) { 42 $wp_locales = (array) $GLOBALS['wpdb']->get_col( 'SELECT locale FROM wporg_locales' ); 43 wp_cache_set( 'locale-list', $wp_locales, 'locale-associations' ); 44 } 45 46 $wp_locales[] = 'en_US'; 47 $locales = array(); 48 49 foreach ( $wp_locales as $locale ) { 50 $gp_locale = GP_Locales::by_field( 'wp_locale', $locale ); 51 if ( ! $gp_locale ) { 52 continue; 53 } 54 55 $locales[ $locale ] = $gp_locale; 56 } 57 58 natsort( $locales ); 59 60 return $locales; 61 } 62 63 /** 64 * Get an array of locales with the locale code as key and the native name as value. 65 * 66 * @return array 67 */ 68 function get_locales_with_native_names() { 69 $locales = get_locales(); 70 71 return wp_list_pluck( $locales, 'native_name', 'wp_locale' ); 72 } 73 74 /** 75 * Get an array of locales with the locale code as key and the English name as value. 76 * 77 * @return array 78 */ 79 function get_locales_with_english_names() { 80 $locales = get_locales(); 81 82 return wp_list_pluck( $locales, 'english_name', 'wp_locale' ); 83 } 31 84 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/blocks.php
r10169 r10237 3 3 namespace WPOrg_Learn\Blocks; 4 4 5 use Error; 5 6 use function WPOrg_Learn\Post_Meta\get_workshop_duration; 6 7 7 8 defined( 'WPINC' ) || die(); 9 10 /** 11 * Actions and filters. 12 */ 13 add_action( 'init', __NAMESPACE__ . '\workshop_details_init' ); 14 add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_style_assets' ); 15 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_block_style_assets' ); 8 16 9 17 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/class-markdown-import.php
r10169 r10237 1 1 <?php 2 /** 3 * Markdown Import 4 * 5 * This functionality has been disabled as of 2020-08-12. All of the lesson plans have been imported 6 * to learn.wordpress.org and can be updated via the WP admin interface. Leaving this here for now 7 * in case we need to re-activate for some reason. 8 */ 2 9 3 10 namespace WPOrg_Learn; 4 11 5 use WP_Error; 6 use WP_Query; 7 12 use WP_Error, WP_Query; 13 14 // These actions/filters should not be added while markdown import is disabled. 15 //add_action( 'init', array( 'WPOrg_Learn\Markdown_Import', 'action_init' ) ); 16 //add_action( 'wporg_learn_manifest_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_manifest_import' ) ); 17 //add_action( 'wporg_learn_markdown_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_markdown_import' ) ); 18 //add_action( 'load-post.php', array( 'WPOrg_Learn\Markdown_Import', 'action_load_post_php' ) ); 19 //add_action( 'edit_form_after_title', array( 'WPOrg_Learn\Markdown_Import', 'action_edit_form_after_title' ) ); 20 //add_action( 'save_post', array( 'WPOrg_Learn\Markdown_Import', 'action_save_post' ) ); 21 //add_filter( 'cron_schedules', array( 'WPOrg_Learn\Markdown_Import', 'filter_cron_schedules' ) ); 22 23 // This filter is still necessary because the lesson plans that were originally imported from GitHub still require 24 // that image assets be loaded from the same repositories. 25 add_filter( 'the_content', array( 'WPOrg_Learn\Markdown_Import', 'replace_image_links' ) ); 26 27 /** 28 * Class Markdown_Import 29 * 30 * @package WPOrg_Learn 31 */ 8 32 class Markdown_Import { 9 33 … … 184 208 placeholder="Enter a URL representing a markdown file to import" 185 209 size="50" /> 186 </label> 210 </label> 187 211 <?php 188 212 if ( $markdown_source ) : … … 319 343 return $html; 320 344 } 345 346 /** 347 * Source images from the GitHub repo. 348 * 349 * @param string $content 350 * 351 * @return string|string[] 352 */ 353 public static function replace_image_links( $content ) { 354 $post_id = get_the_ID(); 355 $markdown_source = self::get_markdown_source( $post_id ); 356 if ( is_wp_error( $markdown_source ) ) { 357 return $content; 358 } 359 $markdown_source = str_replace( '/README.md', '', $markdown_source ); 360 $content = str_replace( '<img src="/images/', '<img src="' . $markdown_source . '/images/', $content ); 361 362 return $content; 363 } 321 364 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
r10169 r10237 7 7 8 8 defined( 'WPINC' ) || die(); 9 10 /** 11 * Actions and filters. 12 */ 13 add_action( 'init', __NAMESPACE__ . '\register' ); 14 add_action( 'add_meta_boxes', __NAMESPACE__ . '\add_workshop_metaboxes' ); 15 add_action( 'save_post_wporg_workshop', __NAMESPACE__ . '\save_workshop_metabox_fields', 10, 2 ); 9 16 10 17 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-type.php
r10202 r10237 4 4 5 5 defined( 'WPINC' ) || die(); 6 7 /** 8 * Actions and filters. 9 */ 10 add_action( 'init', __NAMESPACE__ . '\register' ); 6 11 7 12 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/taxonomy.php
r10202 r10237 4 4 5 5 defined( 'WPINC' ) || die(); 6 7 /** 8 * Actions and filters. 9 */ 10 add_action( 'init', __NAMESPACE__ . '\register' ); 6 11 7 12 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/package.json
r10169 r10237 10 10 "build": "wp-scripts build", 11 11 "format:js": "wp-scripts format-js js", 12 "lint:css": "wp-scripts lint-style ",12 "lint:css": "wp-scripts lint-style './**/*.{css,scss}' '!3rd-party'", 13 13 "lint:js": "wp-scripts lint-js js", 14 14 "packages-update": "wp-scripts packages-update" -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/wporg-learn.php
r10202 r10237 9 9 */ 10 10 11 require_once dirname( __FILE__ ) . '/inc/class-shortcodes.php';12 require_once dirname( __FILE__ ) . '/inc/class-lesson-plan.php'; 13 require_once dirname( __FILE__ ) . '/inc/blocks.php';14 require_once dirname( __FILE__ ) . '/inc/post-meta.php'; 15 require_once dirname( __FILE__ ) . '/inc/post-type.php';16 require_once dirname( __FILE__ ) . '/inc/taxonomy.php';11 namespace WPOrg_Learn; 12 13 defined( 'WPINC' ) || die(); 14 15 define( __NAMESPACE__ . '\PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 16 define( __NAMESPACE__ . '\PLUGIN_URL', plugins_url( '/', __FILE__ ) ); 17 17 18 18 /** 19 * Registry of actions and filters19 * Actions and filters. 20 20 */ 21 add_action( 'init', 'WPORG_Learn\Post_Type\register' ); 22 add_action( 'init', 'WPORG_Learn\Post_Meta\register' ); 23 add_action( 'init', 'WPORG_Learn\Taxonomy\register' ); 24 add_action( 'init', array( 'WPOrg_Learn\Shortcodes', 'action_init' ) ); 25 add_filter( 'the_title', array( 'WPOrg_Learn\Lesson_Plan', 'filter_the_title_edit_link' ), 10, 2 ); 26 add_filter( 'get_edit_post_link', array( 'WPOrg_Learn\Lesson_Plan', 'redirect_edit_link_to_github' ), 10, 3 ); 27 add_filter( 'o2_filter_post_actions', array( 'WPOrg_Learn\Lesson_Plan', 'redirect_o2_edit_link_to_github' ), 11, 2 ); 28 add_filter( 'the_content', array( 'WPORG_Learn\Lesson_Plan', 'replace_image_links' ) ); 29 30 add_action( 'init', 'WPORG_Learn\Blocks\workshop_details_init' ); 31 add_action( 'enqueue_block_editor_assets', 'WPORG_Learn\Blocks\enqueue_block_style_assets' ); 32 add_action( 'wp_enqueue_scripts', 'WPORG_Learn\Blocks\enqueue_block_style_assets' ); 33 add_action( 'add_meta_boxes', 'WPORG_Learn\Post_Meta\add_workshop_metaboxes' ); 34 add_action( 'save_post_wporg_workshop', 'WPORG_Learn\Post_Meta\save_workshop_metabox_fields', 10, 2 ); 35 add_filter( 'excerpt_length', 'theme_slug_excerpt_length', 999 ); 36 37 require_once dirname( __FILE__ ) . '/inc/class-markdown-import.php'; 38 /** 39 * Markdown Import 40 * 41 * This functionality has been disabled as of 2020-08-12. All of the lesson plans have been imported 42 * to learn.wordpress.org and can be updated via the WP admin interface. Leaving this here for now 43 * in case we need to re-activate for some reason. 44 * 45 add_action( 'init', array( 'WPOrg_Learn\Markdown_Import', 'action_init' ) ); 46 add_action( 'wporg_learn_manifest_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_manifest_import' ) ); 47 add_action( 'wporg_learn_markdown_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_markdown_import' ) ); 48 add_action( 'load-post.php', array( 'WPOrg_Learn\Markdown_Import', 'action_load_post_php' ) ); 49 add_action( 'edit_form_after_title', array( 'WPOrg_Learn\Markdown_Import', 'action_edit_form_after_title' ) ); 50 add_action( 'save_post', array( 'WPOrg_Learn\Markdown_Import', 'action_save_post' ) ); 51 add_filter( 'cron_schedules', array( 'WPOrg_Learn\Markdown_Import', 'filter_cron_schedules' ) ); 52 */ 21 add_action( 'plugins_loaded', __NAMESPACE__ . '\load_files' ); 22 add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\register_thirdparty_assets', 9 ); 23 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_thirdparty_assets', 9 ); 53 24 54 25 /** 55 * Filter the excerpt length to 50 words.26 * Shortcut to the includes directory. 56 27 * 57 * @param int $length Excerpt length. 58 * @return int (Maybe) modified excerpt length. 28 * @return string 59 29 */ 60 function theme_slug_excerpt_length( $length ) { 61 global $post; 62 63 if ( is_admin() ) { 64 return $length; 65 } 66 67 if ( 'workshop' === $post->post_type ) { 68 return 35; 69 } 70 71 return 25; 30 function get_includes_path() { 31 return plugin_dir_path( __FILE__ ) . 'inc/'; 72 32 } 73 33 74 add_action( 'wp_head', function() { 75 ?> 76 <style> 77 pre code { 78 line-height: 16px; 79 } 80 a.github-edit { 81 margin-left: .5em; 82 font-size: .5em; 83 vertical-align: top; 84 display: inline-block; 85 border: 1px solid #eeeeee; 86 border-radius: 2px; 87 background: #eeeeee; 88 padding: .5em .6em .4em; 89 color: black; 90 margin-top: 0.1em; 91 } 92 a.github-edit > * { 93 opacity: 0.6; 94 } 95 a.github-edit:hover > * { 96 opacity: 1; 97 color: black; 98 } 99 a.github-edit img { 100 height: .8em; 101 } 102 .single-handbook div.table-of-contents { 103 margin: 0; 104 float: none; 105 padding: 0; 106 border: none; 107 box-shadow: none; 108 width: auto; 109 } 110 .single-handbook div.table-of-contents:after { 111 content: " "; 112 display: block; 113 clear: both; 114 } 115 .single-handbook .table-of-contents h2 { 116 display: none; 117 } 118 .single-handbook div.table-of-contents ul { 119 padding: 0; 120 margin-top: 0.4em; 121 margin-bottom: 1.1em; 122 } 123 .single-handbook div.table-of-contents > ul li { 124 display: inline-block; 125 padding: 0; 126 font-size: 12px; 127 } 128 .single-handbook div.table-of-contents > ul li a:after { 129 content: "|"; 130 display: inline-block; 131 width: 20px; 132 text-align: center; 133 color: #eeeeee 134 } 135 .single-handbook div.table-of-contents > ul li:last-child a:after { 136 content: ""; 137 } 138 .single-handbook div.table-of-contents ul ul { 139 display: none; 140 } 141 .single-handbook #secondary { 142 max-width: 240px; 143 } 144 </style> 145 <?php 146 }); 34 /** 35 * Load the other PHP files for the plugin. 36 * 37 * @return void 38 */ 39 function load_files() { 40 require_once get_includes_path() . 'blocks.php'; 41 require_once get_includes_path() . 'class-markdown-import.php'; 42 require_once get_includes_path() . 'post-meta.php'; 43 require_once get_includes_path() . 'post-type.php'; 44 require_once get_includes_path() . 'taxonomy.php'; 45 } 46 47 /** 48 * Register scripts and styles for 3rd party libraries. 49 * 50 * @return void 51 */ 52 function register_thirdparty_assets() { 53 wp_register_script( 54 'select2', 55 plugins_url( '/3rd-party/selectWoo/js/selectWoo.min.js', __FILE__ ), 56 array( 'jquery' ), 57 '1.0.8', 58 true 59 ); 60 61 wp_register_style( 62 'select2', 63 plugins_url( '/3rd-party/selectWoo/css/selectWoo.min.css', __FILE__ ), 64 array(), 65 '1.0.8' 66 ); 67 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php
r10202 r10237 199 199 return get_post_meta( get_the_ID(), 'download_lesson_plan_slides_url', true ); 200 200 } 201 202 /** 203 * Modify the excerpt length for our custom post types. 204 * 205 * @param int $length Excerpt length. 206 * 207 * @return int (Maybe) modified excerpt length. 208 */ 209 function wporg_modify_excerpt_length( $length ) { 210 if ( is_admin() ) { 211 return $length; 212 } 213 214 if ( 'wporg_workshop' === get_post_type() ) { 215 return 35; 216 } 217 218 return 25; 219 } 220 add_filter( 'excerpt_length', 'wporg_modify_excerpt_length', 999 ); 201 221 202 222 /**
Note: See TracChangeset
for help on using the changeset viewer.