Skip to content

Commit

Permalink
= 4.2.6.4 =
Browse files Browse the repository at this point in the history
~ Compatible YoastSeo plugin.
  • Loading branch information
tungnxt89 committed Mar 7, 2024
1 parent 6c74044 commit 3e2ab32
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
29 changes: 29 additions & 0 deletions inc/ExternalPlugin/YoastSeo/LPYoastSeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Class LPYoastSeo
*
* Compatible with wordpress.org/plugins/wordpress-seo/
* @since 4.2.6.4
* @version 1.0.0
*/
namespace LearnPress\ExternalPlugin\YoastSeo;

use LearnPress\Helpers\Singleton;
use LP_Helper;
use LP_Page_Controller;

class LPYoastSeo {
use Singleton;

public function init() {
add_filter( 'wpseo_opengraph_url', [ $this, 'opengraph_url' ] );
}

public function opengraph_url( $open_graph_url ) {
if ( LP_Page_Controller::is_page_instructor() ) {
$open_graph_url = LP_Helper::getUrlCurrent();
}

return $open_graph_url;
}
}
8 changes: 8 additions & 0 deletions inc/class-lp-page-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ protected function __construct() {
add_filter( 'get_comment_link', array( $this, 'edit_lesson_comment_links' ), 10, 2 );
// Active menu
add_filter( 'wp_nav_menu_objects', [ $this, 'menu_active' ], 10, 1 );
// Canonical
add_filter( 'get_canonical_url', function ( $canonical_url ) {
if ( LP_Page_Controller::is_page_instructor() ) {
$canonical_url = LP_Helper::getUrlCurrent();
}

return $canonical_url;
} );
}
}

Expand Down
8 changes: 8 additions & 0 deletions learnpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

use LearnPress\ExternalPlugin\Elementor\LPElementor;
use LearnPress\ExternalPlugin\YoastSeo\LPYoastSeo;
use LearnPress\Shortcodes\Course\FilterCourseShortcode;
use LearnPress\Shortcodes\ListInstructorsShortcode;
use LearnPress\Shortcodes\SingleInstructorShortcode;
Expand All @@ -25,6 +26,7 @@
use LearnPress\TemplateHooks\Instructor\SingleInstructorTemplate;
use LearnPress\TemplateHooks\Profile\ProfileInstructorStatisticsTemplate;
use LearnPress\TemplateHooks\Profile\ProfileOrdersTemplate;
use LearnPress\TemplateHooks\Profile\ProfileOrderTemplate;
use LearnPress\TemplateHooks\Profile\ProfileStudentStatisticsTemplate;
use LearnPress\TemplateHooks\Course\CourseMaterialTemplate;
use LearnPress\Widgets\LPRegisterWidget;
Expand Down Expand Up @@ -288,6 +290,7 @@ private function include_files_global() {
ProfileInstructorStatisticsTemplate::instance();
ProfileStudentStatisticsTemplate::instance();
ProfileOrdersTemplate::instance();
ProfileOrderTemplate::instance();
FilterCourseTemplate::instance();

CourseMaterialTemplate::instance();
Expand Down Expand Up @@ -644,6 +647,11 @@ public function plugins_loaded() {
LPElementor::instance();
}

// For plugin Elementor
if ( defined( 'WPSEO_FILE' ) ) {
LPYoastSeo::instance();
}

$this->init();

include_once 'inc/lp-template-hooks.php';
Expand Down

0 comments on commit 3e2ab32

Please sign in to comment.