Plugin Directory

Changeset 1369562


Ignore:
Timestamp:
03/11/2016 11:20:34 PM (10 years ago)
Author:
christophherr
Message:

Adds check if Sensei is active, conditional to use the adequate remove-action depensing on Sensei version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • genesis-connect-for-woothemes-sensei/trunk/genesis-connect-for-woothemes-sensei.php

    r1272292 r1369562  
    66 * Author:      Christoph Herr
    77 * Author URI:  http://www.christophherr.com
    8  * Version:     1.0.3
     8 * Version:     1.1.0
    99 * Text Domain: genesis-connect-for-woothemes-sensei
    1010 * Domain Path: /languages
     
    1414 * @package   GenesisConnectforWoothemesSensei
    1515 * @author    Christoph Herr
    16  * @version   1.0.3
     16 * @version   1.1.0
    1717 * @license   GPL-2.0+
    1818 *
     
    3838/**
    3939 * This function runs on plugin activation. It checks to make sure the
    40  * Genesis Framework is active. If not, it deactivates the plugin.
     40 * Genesis Framework and Woothemes Sensei are active. If not, it deactivates the plugin.
    4141 *
    4242 * @since 1.0
     
    4747        deactivate_plugins( plugin_basename( __FILE__ ) );
    4848        add_action( 'admin_notices', 'gcfws_admin_notice_message' );
     49    }
     50    if ( ! class_exists( ('Sensei_Main' ) || ( 'WooThemes_Sensei' ) ) ) {
     51        // Deactivate.
     52        deactivate_plugins( plugin_basename( __FILE__ ) );
     53        add_action( 'admin_notices', 'gcfws_admin_notice_message_sensei' );
    4954    }
    5055}
     
    8590
    8691/**
     92 * Error message if you're not using Woothemes Sensei.
     93 *
     94 * @since 1.1
     95 */
     96function gcfws_admin_notice_message_sensei() {
     97    $error = sprintf( _e( 'Sorry, you can\'t use the Genesis Connect for Woothemes Sensei Plugin unless the <a href="%s">Sensei Plugin</a> is active. The plugin has been deactivated.', 'gcfws' ), 'http://senseilms.com' );
     98
     99    echo '<div class="error"><p>' . $error . '</p></div>';
     100
     101    if ( isset( $_GET['activate'] ) ) {
     102        unset( $_GET['activate'] );
     103    }
     104}
     105
     106/**
    87107 * Load plugin textdomain.
    88108 *
     
    108128
    109129/**
    110  * Remove the default Sensei wrappers
     130 * Force content-sidebar layout on Woothemes Sensei Course, Lesson and Question pages.
     131 * @since 1.1
    111132 */
    112 global $woothemes_sensei;
    113 remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
    114 remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
     133function gcfws_force_content_sidebar_layout() {
     134    if ( is_singular( array( 'course', 'lesson', 'question' ) ) ) {
     135            add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
     136    }
     137}
     138
     139add_action( 'genesis_meta', 'gcfws_force_content_sidebar_layout' );
     140
     141/**
     142 * Remove the default Woothemes Sensei wrappers.
     143 * Checks which version of Woothemes Sensei is running
     144 * and removes the wrappers accordingly.
     145 * @since 1.1
     146 */
     147function gcfws_remove_default_sensei_wrappers() {
     148
     149    if ( Sensei()->version >= '1.9.0' ) {
     150        remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
     151        remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
     152        return;
     153    }
     154    global $woothemes_sensei;
     155    remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
     156    remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
     157}
     158
     159add_action( 'genesis_meta', 'gcfws_remove_default_sensei_wrappers' );
    115160
    116161
Note: See TracChangeset for help on using the changeset viewer.