WordPress.org

Ready to get started?Download WordPress

Forums

Social Gallery Lite
[resolved] Disable on Mobile (9 posts)

  1. karenfya
    Member
    Posted 1 year ago #

    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.

    Thanks!

    http://wordpress.org/extend/plugins/social-gallery-lite/

  2. karenfya
    Member
    Posted 1 year ago #

    I am currently trying to use

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

    but I have to disable WPtouch Pro based on browser. Maybe with http://detectmobilebrowsers.mobi/

  3. mikemayhem3030
    Member
    Plugin Author

    Posted 1 year ago #

    Hi
    There's the add ons which make it awesome on mobile

  4. karenfya
    Member
    Posted 1 year ago #

    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. :(

  5. karenfya
    Member
    Posted 1 year ago #

    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() {
    if($detect->isMobile()){
    deactivate_plugins('social-gallery-lite/SocialGalleryLite.php');
    
    }
    }

    in functions.php

    and:

    <?php
    // These lines are mandatory.
    include('Mobile_Detect.php');
    $detect = new Mobile_Detect;
    
    if(!$_SESSION['isMobile']){
    $_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. :(

  6. mikemayhem3030
    Member
    Plugin Author

    Posted 1 year ago #

    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;
    if($x->isMobile()){
    
    //do something here for mobiles..
    
    }else{
    
    //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

  7. karenfya
    Member
    Posted 1 year ago #

    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
    with:

    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:

    <?php
    /*
    Plugin Name: Social Gallery Lite
    Plugin URI: http://www.socialgalleryplugin.com
    Description: Social Gallery is the ultimate Social Lightbox for WordPress. This is the Lite Version. Upgrade Now.
    Version: 2.0
    Author: StormGate
    Author URI: http://www.stormgate.co.uk
    License: GPL v2

    WordPress Lightbox Plugin
    Copyright (C) 20012-2013, StormGate Ltd. - http://www.stormgate.co.uk

    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
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    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 <http://www.gnu.org/licenses/>.

    */

    #} 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;
    if($detect->isMobile()){
    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
    $scriptVersion = $detect->getScriptVersion();
    }else{
    register_activation_hook(__FILE__,'sgp08b');
    register_deactivation_hook(__FILE__,'sgpeb11c');

    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'] = "http://www.socialgalleryplugin.com";
    $socialGalleryLite_urls['support'] = "http://forum.socialgalleryplugin.com";
    $socialGalleryLite_urls['forum'] = "http://forum.socialgalleryplugin.com";
    $socialGalleryLite_urls['faq'] = "http://www.socialgalleryplugin.com/frequently-asked-questions/";
    $socialGalleryLite_urls['subscribe'] = "http://www.socialgalleryplugin.com/join-social-gallery-newsletter/";
    $socialGalleryLite_urls['docs'] = "http://socialgalleryplugin.com/documentation/lite/";
    $socialGalleryLite_urls['showcase'] = 'http://www.socialgalleryplugin.com/showcase/';
    $socialGalleryLite_urls['updateCheck'] = 'http://www.socialgalleryplugin.com/updateEngine/lite/';
    $socialGalleryLite_urls['regCheck'] = 'http://www.socialgalleryplugin.com/updateEngine/lite/registration/';
    $socialGalleryLite_urls['comCheck'] = 'http://www.socialgalleryplugin.com/updateEngine/lite/compat/';
    $socialGalleryLite_urls['newsFeed'] = 'http://www.socialgalleryplugin.com/feed/';
    $socialGalleryLite_urls['gopro'] = 'http://www.socialgalleryplugin.com/get-social-gallery-pro';
    $socialGalleryLite_urls['wporg'] = 'http://wordpress.org/extend/plugins/social-gallery-lite/';

    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__);
    include("$application_path/Mobile_Detect.php);
    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;
    if($detect->isMobile())
    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
    $scriptVersion = $detect->getScriptVersion();
    } else {
    register_activation_hook(__FILE__,'sgp08b');
    register_deactivation_hook(__FILE__,'sgpeb11c');

    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? :)

  8. mikemayhem3030
    Member
    Plugin Author

    Posted 1 year ago #

    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

  9. mikemayhem3030
    Member
    Plugin Author

    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.