<?php /** * Customizations to wp editor for LearnDash * * All functions currently are customizations for custom certificate implementations * * @since 2.1.0 * * @package LearnDash\TinyMCE */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Adds hooks for TinyMCE customization on edit screen. * * Fires on `load-post.php` and `load-post-new.php` hook. * * @since 2.1.0 */ function learndash_mce_init() { $screen = get_current_screen(); if ( ( $screen ) && ( $screen instanceof WP_Screen ) ) { if ( ( 'post' === $screen->base ) && ( 'sfwd-certificates' === $screen->post_type ) ) { add_filter( 'tiny_mce_before_init', 'learndash_wp_tiny_mce_before_init' ); add_filter( 'mce_css', 'learndash_filter_mce_css' ); } } } /** * Changes hook in LD v2.3 to only hook into the load of post.php and post-new.php */ add_action( 'load-post.php', 'learndash_mce_init' ); add_action( 'load-post-new.php', 'learndash_mce_init' ); /** * Loads editor styles for LearnDash. * * Fires on `mce_css` hook. * We need to add the LD custom CSS to the function parameter. Not replace it * see https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_css * * @since 2.1.0 * * @param string $mce_css Optional. Comma-delimited list of stylesheets. Default empty. * * @return string Comma-delimited list of stylesheets. */ function learndash_filter_mce_css( $mce_css = '' ) { $ld_mce_css = plugins_url( 'assets/css/sfwd_editor.css', LEARNDASH_LMS_PLUGIN_DIR . 'index.php' ); if ( ! empty( $ld_mce_css ) ) { if ( ! empty( $mce_css ) ) { $mce_css .= ','; } $mce_css .= $ld_mce_css; } return $mce_css; } /** * Loads the certificate image as the background for the visual editor. * * Fires on `tiny_mce_before_init` hook. * * @todo confirm intent of function and if it's still needed * not currently functional * * @since 2.1.0 * * @param array $init_array The tinymce editor settings. * * @return array The tinymce editor settings. */ function learndash_wp_tiny_mce_before_init( $init_array ) { if ( isset( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $post_id = absint( $_GET['post'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } else { $post_id = get_the_id(); } if ( ! empty( $post_id ) ) { $img_path = learndash_get_thumb_url( $post_id ); if ( ! empty( $img_path ) ) { $init_array['setup'] = <<<JS [function(ed) { ed.onInit.add(function(ed, e) { var w = jQuery("#content_ifr").width(); var editorId = ed.getParam("fullscreen_editor_id") || ed.id; jQuery("#content_ifr").contents().find("#tinymce").css ({"background-image":"url($img_path)" }); if(editorId == 'wp_mce_fullscreen'){ jQuery("#wp_mce_fullscreen_ifr").contents().find("#tinymce").css ({"background-image":"url($img_path)" }); } }); }][0] JS; } } return $init_array; } /** * Gets the featured image URL for the post. * * @since 2.1.0 * * @param int $post_id Optional. Post ID. Default 0. * @param string $size Optional. The size of the image. Default 'full'. * * @return string The featured image url. */ function learndash_get_thumb_url( $post_id = 0, $size = 'full' ) { if ( ( ! empty( $post_id ) ) && ( has_post_thumbnail( $post_id ) ) ) { $image_src_array = wp_get_attachment_image_src( get_post_thumbnail_id(), $size ); if ( ( ! empty( $image_src_array ) ) && ( is_array( $image_src_array ) ) && ( ! empty( $image_src_array[0] ) ) ) { return $image_src_array[0]; } } return ''; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
admin | Folder | 0755 |
|
|
classes | Folder | 0755 |
|
|
coupon | Folder | 0755 |
|
|
course | Folder | 0755 |
|
|
deprecated | Folder | 0755 |
|
|
dto | Folder | 0755 |
|
|
exam | Folder | 0755 |
|
|
group | Folder | 0755 |
|
|
gutenberg | Folder | 0755 |
|
|
helpers | Folder | 0755 |
|
|
import | Folder | 0755 |
|
|
interfaces | Folder | 0755 |
|
|
lib | Folder | 0755 |
|
|
licensing | Folder | 0755 |
|
|
loggers | Folder | 0755 |
|
|
models | Folder | 0755 |
|
|
payments | Folder | 0755 |
|
|
quiz | Folder | 0755 |
|
|
reports | Folder | 0755 |
|
|
rest-api | Folder | 0755 |
|
|
settings | Folder | 0755 |
|
|
shortcodes | Folder | 0755 |
|
|
site-health | Folder | 0755 |
|
|
views | Folder | 0755 |
|
|
widgets | Folder | 0755 |
|
|
class-ld-addons-updater.php | File | 35.03 KB | 0644 |
|
class-ld-bitbucket-api.php | File | 59.32 KB | 0644 |
|
class-ld-course-wizard.php | File | 29.51 KB | 0644 |
|
class-ld-cpt-instance.php | File | 34.14 KB | 0644 |
|
class-ld-cpt-widget.php | File | 198 B | 0644 |
|
class-ld-cpt.php | File | 18.17 KB | 0644 |
|
class-ld-custom-label.php | File | 24.3 KB | 0644 |
|
class-ld-design-wizard.php | File | 37.05 KB | 0644 |
|
class-ld-gdpr.php | File | 48.61 KB | 0644 |
|
class-ld-lms.php | File | 224.76 KB | 0644 |
|
class-ld-permalinks.php | File | 29.92 KB | 0644 |
|
class-ld-search.php | File | 6.66 KB | 0644 |
|
class-ld-semper-fi-module.php | File | 61.88 KB | 0644 |
|
class-ld-setup-wizard.php | File | 23.09 KB | 0644 |
|
class-ld-translations.php | File | 28.85 KB | 0644 |
|
class-ldlms-db.php | File | 19.01 KB | 0644 |
|
class-ldlms-post-types.php | File | 8.64 KB | 0644 |
|
class-ldlms-transients.php | File | 5.04 KB | 0644 |
|
ld-assignment-uploads.php | File | 38.35 KB | 0644 |
|
ld-autoupdate.php | File | 241 B | 0644 |
|
ld-certificates.php | File | 26.74 KB | 0644 |
|
ld-convert-post-pdf.php | File | 31.07 KB | 0644 |
|
ld-core-functions.php | File | 857 B | 0644 |
|
ld-groups.php | File | 92.44 KB | 0644 |
|
ld-license.php | File | 12.93 KB | 0644 |
|
ld-misc-functions.php | File | 72.5 KB | 0644 |
|
ld-reports.php | File | 59.38 KB | 0644 |
|
ld-scripts.php | File | 6.89 KB | 0644 |
|
ld-users.php | File | 47.6 KB | 0644 |
|
ld-wp-editor.php | File | 3.46 KB | 0644 |
|