Support » Plugin: Social Gallery Lite » Disable on Mobile

  • Resolved karenfya


    I use WPtouch Pro and Photoswipe for NextGEN Gallery to make for a polished mobile site. I understand it is difficult to integrate mobile functionality into your already wonderful plugin. I am hoping you might include an option to disable your plugin on mobile browsers because WPtouch Pro, although normally quite capable, is unable to disable the hook for your plugin and I very much dislike having images cut off.


Viewing 8 replies - 1 through 8 (of 8 total)
  • I am currently trying to use

    function deactivate_plugin_conditional() {
        if ( is_plugin_active('plugin-folder/plugin-name.php') ) {
    add_action( 'admin_init', 'deactivate_plugin_conditional' );

    but I have to disable WPtouch Pro based on browser. Maybe with

    Plugin Author mikemayhem3030


    There’s the add ons which make it awesome on mobile

    Thank you Mike for that link. I actually didn’t know about that! Unfortunately it won’t help though because, although I work for a company, I have zero budget available to me and getting reimbursed is questionable so I’m going to have to continue to use the Lite version of SG and work on my workaround to disable it for mobile. I realize now though that if the author has released an add-on like that he is probably not interested at all in offering an option to simply disable on mobile. 🙁

    I thought I made some progress with Mobile_Detect.php but I got really stuck. If anyone could help me I would be very grateful. I do not understand PHP but I have tried my best to come up with a solution to my problem anyway. I want to disable a WordPress plugin if a mobile browser is detected. The code I am trying is:

    function deactivate_plugin_conditional() {

    in functions.php


    // These lines are mandatory.
    $detect = new Mobile_Detect;
    $_SESSION['isMobile'] = $detect->isMobile();

    in header.php

    Did I put them in the wrong spots? I couldn’t figure it out. The only combination that actually worked just redirected the entire site to my local Mobile_Detect.php. 🙁

    Plugin Author mikemayhem3030


    I wouldn’t do it using deactive_plugins() as this will, as it says, deactivate the plugin (rather than disable it for mobile viewers).

    You want to go into the SocialGalleryLite.php and look for where it registers and enqueues the SocialGalleryPlugin.js

    Then add your statement around it

    $x = new Mobile_Detect;
    //do something here for mobiles..
    //code here that registers and enqueues the scripts.

    Without the scripts the lightbox won’t show on images.

    *note I’ve not tested the above code

    I use the mobile add on here: Epic Plugins

    Oh man, I think I’m so close I can feel it!!
    You are awesome mikemayhem3030!

    I have it going off without fatal errors but it still gives me “For security reasons, framing is not allowed.” and then redirects to /wp-admin/plugins.php?action=error_scrape&plugin=social-gallery-lite/SocialGalleryLite.php&_wpnonce=ae1ec1d8bc

    Warning: require_once(/Mobile_Detect.php) [function.require-once]: failed to open stream: No such file or directory in /home/content/38/7902638/html/wp-content/plugins/social-gallery-lite/SocialGalleryLite.php on line 45

    Fatal error: require_once() [function.require]: Failed opening required ‘/Mobile_Detect.php’ (include_path=’.:/usr/local/php5/lib/php’) in /home/content/38/7902638/html/wp-content/plugins/social-gallery-lite/SocialGalleryLite.php on line 45

    Here is the code now in social-gallery-lite/SocialGalleryLite.php:

    Plugin Name: Social Gallery Lite
    Plugin URI:
    Description: Social Gallery is the ultimate Social Lightbox for WordPress. This is the Lite Version. Upgrade Now.
    Version: 2.0
    Author: StormGate
    Author URI:
    License: GPL v2

    WordPress Lightbox Plugin
    Copyright (C) 20012-2013, StormGate Ltd. –

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <;.


    #} Check’s blog capacity to run Social Gallery
    $socialGalleryProof = true;
    #} PHP 5
    if (strtok(phpversion(),’.’) < 5){
    $socialGalleryProof = false;
    add_action(‘admin_notices’,’sgpd7967′);function sgpd7967(){echo ‘<div class=”error”>Social Gallery Cannot run without PHP5!</div>’;}

    #} TOTAL on/off switch
    if ($socialGalleryProof){

    #} Hooks
    define(‘APP_PATH’, dirname(__FILE__));
    include(APP_PATH . “/Mobile_Detect.php”);

    require_once ‘/Mobile_Detect.php’;
    $detect = new Mobile_Detect;
    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? ‘tablet’ : ‘phone’) : ‘computer’);
    $scriptVersion = $detect->getScriptVersion();

    add_action(‘init’, ‘sgpbb28d9’);
    add_action(‘admin_menu’, ‘sgpac2’);
    add_action(‘admin_head’, ‘sgp3222’);
    add_action(‘wp_head’, ‘sgpa5c’);

    global $socialGalleryLite_db_version;
    $socialGalleryLite_db_version = “2.0”;
    $socialGalleryLite_version = “2.0 Lite”;

    global $socialGalleryLite_urls;
    $socialGalleryLite_urls[‘home’] = “”;
    $socialGalleryLite_urls[‘support’] = “”;
    $socialGalleryLite_urls[‘forum’] = “”;
    $socialGalleryLite_urls[‘faq’] = “”;
    $socialGalleryLite_urls[‘subscribe’] = “”;
    $socialGalleryLite_urls[‘docs’] = “”;
    $socialGalleryLite_urls[‘showcase’] = ‘’;
    $socialGalleryLite_urls[‘updateCheck’] = ‘’;
    $socialGalleryLite_urls[‘regCheck’] = ‘’;
    $socialGalleryLite_urls[‘comCheck’] = ‘’;
    $socialGalleryLite_urls[‘newsFeed’] = ‘’;
    $socialGalleryLite_urls[‘gopro’] = ‘’;
    $socialGalleryLite_urls[‘wporg’] = ‘’;

    global $socialGalleryLite_slugs;
    $socialGalleryLite_slugs[‘home’] = “sgp-plugin-config”;
    $socialGalleryLite_slugs[‘settings’] = “sgp-plugin-settings”;

    global $socialGalleryLite_acceptableThemes;
    $socialGalleryLite_acceptableThemes = array(‘classic’);
    define( ‘SOCIALGALLERYPLUGIN_PATH’, plugin_dir_path(__FILE__) );
    define( ‘SOCIALGALLERYPLUGIN_URL’, plugin_dir_url(__FILE__) );

    function sgp08b(){

    I tried

    $application_path = dirname(__FILE__);
    define(‘APP_PATH’, dirname(__FILE__));
    include(APP_PATH . “/Mobile_Detect.php”);

    but it gave fatal errors.

    #} Hooks
    define(‘APP_PATH’, dirname(__FILE__));
    include(APP_PATH . “/Mobile_Detect.php”);

    require_once(APP_PATH . “/Mobile_Detect.php”);
    $detect = new Mobile_Detect;
    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? ‘tablet’ : ‘phone’) : ‘computer’);
    $scriptVersion = $detect->getScriptVersion();
    } else {

    gives Fatal error: Class ‘Mobile_Detect’ not found in /home/content/38/7902638/html/wp-content/plugins/social-gallery-lite/SocialGalleryLite.php on line 46

    What say you mikemayhem3030/random-friendly-stranger? Can you help me again? 🙂

    Plugin Author mikemayhem3030


    Hello sorry I’ve been away and I’ve been getting more involved with SGP.

    I’m on annual leave until 1 July, I’ll come back with more info upon my return

    Plugin Author mikemayhem3030


    I suggest just spending $10 on getting the mobile add on, not only does it solve ALL the above it looks great too.

    Other would be to hire a developer to adapt for you properly, but it’d cost more than $10

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Disable on Mobile’ is closed to new replies.