Changeset 10237 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/wporg-learn.php
- Timestamp:
- 09/03/2020 11:57:12 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.