Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create A Simple Plugin To Disable "Simple" Mode When Editing Style Sheets
#1
I don't know if anyone else is interested at all, but I despise the "simple" editing mode, so I wrote a very simple plugin to disable "simple" mode in ACP.

To make this edit on your forums, you will need to add the following contents to a PHP file named smmd.php (for simple mode must die lol) and copy it into the inc/plugins folder of your forum. Then of course, you have to activate it.

<?php
/**
 * Simple Mode Must Die!
 */

/**
 * plugin info
 *
 * @return array
 */
function smmd_info()
{
    return array(
        'name' => 'Simple Mode Must Die!',
        'compatability' => '18*',
        'version' => '0.1',
        'author' => 'Wildcard',
    );
}

if (defined('IN_ADMINCP')) {
    $plugins->add_hook('admin_style_themes_begin', 'smmd_admin_themes_begin');
}

/**
 * disable simple mode style sheet editing
 *
 * @return void
 */
function smmd_admin_themes_begin()
{
    global $mybb;
    if($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "simple"))
    {
        $mybb->input['mode'] = 'advanced';
    }
}


If you already have a custom plugin for your forum, it would be much better to just copy the plugin hook conditional and the function into an existing plugin.

Note: The compatibility option in plugin info can work for 1.6 as well, just edit it as you like.
Reply
#2
@Wildcard - great, useful for many admins... anyway I recommend you to use FASTyle from @Shade Smile his new version is just a must have plugin for your board (dark color mode for night work friendly to your eyes, tabs, diffs, ajax saving changes, ability to search etc.)-
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system
Reply
#3
(10-14-2018, 05:33 PM)Eldenroot Wrote: I recommend you to use FASTyle from @Shade Smile

Totally agree. 2.0 is amazing. Can't work without it anymore.
Reply
#4
I get these errors in my admin panel when activating it. I am using 1.8.

https://i.postimg.cc/kJTxWg9j/Screenshot-1.jpg
[Image: sig2.jpg]
Reply
#5
(10-14-2018, 05:58 PM)iAndrew Wrote: I get these errors in my admin panel when activating it. I am using 1.8.

https://i.postimg.cc/kJTxWg9j/Screenshot-1.jpg

When you copy and pasted, you probably just got some trash on the end. Edit the file and delete everything after the closing PHP tag.
Reply
#6
(10-14-2018, 04:45 PM)Wildcard Wrote: I don't know if anyone else is interested at all, but I despise the "simple" editing mode, so I wrote a very simple plugin to disable "simple" mode in ACP.

Thanks for this handy lil plug. I used it awhile ago, forgot about it for a bit and started using a mildly modified variant of it recently. Simple and handy, without a doubt, thanks. Smile

The simple variant I currently use:
<?php
/**
 * Plugin Title: Simple Mode Must Die!
 *
 * Plugin Description: Disables or re-enables simple mode.
 *
 * MyBB Version: 1.8
 *
 * Plugin Version: 1.0
 *
 */
 
// No direct initialization

if( !defined('IN_MYBB') )
{
	die('Direct initialization of this file is not allowed.');
}
 
/**
 * Plugin information
 *
 * @return void
 */

function smmd_info()
{

    return array(
        'name' => 'Simple Mode Must Die!',
        'compatability' => '18*',
        'version' => '1.0',
        'author' => 'Wildcard & Vintagedaddyo',
    );
    
}

if (defined('IN_ADMINCP')) {

    $plugins->add_hook('admin_style_themes_begin', 'smmd_admin_themes_begin');

}

/**
 * Plugin activation
 */
 
function smmd_activate()
{

    global $db, $mybb;

    $smmd_settinggroup = array(
        'name'           => 'smmd_settinggroup',
        'title'          => 'Simple Mode Must Die! Plugin Settings', 
        'description'    => 'This plugin disables or re-enables simple mode theme editor',
        'disporder'      => '1',
        'isdefault'      => '0'
        );
        
    $group['gid'] = $db->insert_query('settinggroups', $smmd_settinggroup);

    $gid = $db->insert_id();
    
    $enable_smmd = array(
        'name'           => 'enable_smmd',
        'title'          => 'Enable smmd?', 
        'description'    => 'Do you want the smmd turned on?',
        'optionscode'    => 'yesno',
        'value'          => '1',
        'disporder'      => '2',
        'gid'            => intval($gid)
        );
        
    $db->insert_query('settings', $enable_smmd);

    rebuild_settings();

}

/**
 * Plugin de-activation
 */
 
function smmd_deactivate()
{

     global $db;

     $db->delete_query('settings', "name IN ('enable_smmd')");
     $db->delete_query('settinggroups', "name = 'smmd_settinggroup'");

     rebuild_settings();

}

/**
 * Disable / re-enable simple mode style sheet editing
 *
 * @return void
 */
 
function smmd_admin_themes_begin()
{

    global $db, $mybb;
    
    if ($mybb->settings['enable_smmd'] == 1)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "simple"))
      {
      	
        $mybb->input['mode'] = 'advanced';
      
      }
      
    }

    if ($mybb->settings['enable_smmd'] == 0)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "advanced"))
      {
      	
        $mybb->input['mode'] = 'simple';
      
      }
      
    }

}

?>

* primarily I only made the variant because I wanted to be able to enable and disable in configuration settings as I spend more time there than in plugin activation/de-activation section and for my purposes being able to say enable the plugin while say for example using a respo acp style and then quickly disable when not as for me going to plugins page was not the only option I wanted and allowing for setting in configuration works for me.
MyBB Themes Team - Making more professional themes by the hour. (Retired)
My Mods | Offer me a coffee!
Reply
#7
I'm glad it is useful to you.

But, you need to install the setting in _install instead of _activate then you don't lose your settings when you uninstall.
Reply
#8
(08-19-2019, 11:00 AM)Wildcard Wrote: I'm glad it is useful to you.

But, you need to install the setting in _install instead of _activate then you don't lose your settings when you uninstall deactivate.
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#9
(08-19-2019, 11:00 AM)Wildcard Wrote: I'm glad it is useful to you.

But, you need to install the setting in _install instead of _activate then you don't lose your settings when you uninstall.


Good point, and yes I could do that, though for this simple purpose I install setting on activate, uninstall setting on deactivate in plugin page while turning on or off setting of the active plugin via configuration settings. Yes as you say using _install and _uninstall is better just didn't opt at the time to do so as this way using _activate = to _install and _deactivate = to _uninstall also works for my purpose. Obviously it also works for a ton of other plugins and plugin devs over the years because plenty opt to use activate/deactivate just like install / uninstall, lol, just saying. Perhaps if I spend more than the 5 minutes edit  on it at some point I will transition to renaming said functions, but to be perfectly honest , I do mot see the point as the simple edited variant works as intended  and while yes, one could spend more time if they desired to do say for simple example sake:

<?php
/**
 * Plugin Title: Simple Mode Must Die!
 *
 * Plugin Description: Disables or re-enables simple mode.
 *
 * MyBB Version: 1.8
 *
 * Plugin Version: 1.1
 *
 */
 
// No direct initialization

if( !defined('IN_MYBB') )
{
	die('Direct initialization of this file is not allowed.');
}
 
/**
 * Plugin information
 *
 * @return void
 */

function smmd_info()
{

    return array(
        'name' => 'Simple Mode Must Die!',
        'compatability' => '18*',
        'version' => '1.1',
        'author' => 'Wildcard & Vintagedaddyo',
    );
    
}

if (defined('IN_ADMINCP')) {

    $plugins->add_hook('admin_style_themes_begin', 'smmd_admin_themes_begin');

}

/**
 * Plugin installation
 */
 
function smmd_install()
{

    global $db, $mybb;

    $smmd_settinggroup = array(
        'name'           => 'smmd_settinggroup',
        'title'          => 'Simple Mode Must Die! Plugin Settings', 
        'description'    => 'This plugin disables or re-enables simple mode theme editor',
        'disporder'      => '1',
        'isdefault'      => '0'
        );
        
    $group['gid'] = $db->insert_query('settinggroups', $smmd_settinggroup);

    $gid = $db->insert_id();
    
    $enable_smmd = array(
        'name'           => 'enable_smmd',
        'title'          => 'Enable smmd?', 
        'description'    => 'Do you want the smmd turned on?',
        'optionscode'    => 'yesno',
        'value'          => '1',
        'disporder'      => '2',
        'gid'            => intval($gid)
        );
        
    $db->insert_query('settings', $enable_smmd);

    rebuild_settings();

}

function smmd_is_installed() { 

  global $mybb; 

  if(isset($mybb->settings['enable_smmd'])) 
   { 
   
    return true; 

   } 
   
    return false;
}

/**
 * Plugin activation
 * Activate via plugin listing page
 */
 
function smmd_activate()
{
	
    global $db, $mybb;
        	
    if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "simple"))
     {
      	
      $mybb->input['mode'] = 'advanced';
      
     }
 
}

/**
 * Plugin de-activation
 * Deactivate via plugin listing page
 */
 
function smmd_deactivate()
{
	    
    global $db, $mybb;
        
    if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "advanced"))
     {
      	
      $mybb->input['mode'] = 'simple';
      
     }
 
}

/**
 * Plugin uninstall
 */ 
 
function smmd_uninstall()
{

     global $db;

     $db->delete_query('settings', "name IN ('enable_smmd')");
     $db->delete_query('settinggroups', "name = 'smmd_settinggroup'");

     rebuild_settings();

}

/**
 * Disable / re-enable simple mode style sheet editing
 * Disable / re-enable via configuration listing
 * @return void
 */
 
function smmd_admin_themes_begin()
{

    global $db, $mybb;
    
    if ($mybb->settings['enable_smmd'] == 1)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "simple"))
      {
      	
        $mybb->input['mode'] = 'advanced';
      
      }
      
    }

    if ($mybb->settings['enable_smmd'] == 0)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "advanced"))
      {
      	
        $mybb->input['mode'] = 'simple';
      
      }
      
    }

}

?>


Whereas the first example I shared does simply what it was intended for with less editing, less time, etc etc,
<?php
/**
 * Plugin Title: Simple Mode Must Die!
 *
 * Plugin Description: Disables or re-enables simple mode.
 *
 * MyBB Version: 1.8
 *
 * Plugin Version: 1.0
 *
 */
 
// No direct initialization

if( !defined('IN_MYBB') )
{
	die('Direct initialization of this file is not allowed.');
}
 
/**
 * Plugin information
 *
 * @return void
 */

function smmd_info()
{

    return array(
        'name' => 'Simple Mode Must Die!',
        'compatability' => '18*',
        'version' => '1.0',
        'author' => 'Wildcard & Vintagedaddyo',
    );
    
}

if (defined('IN_ADMINCP')) {

    $plugins->add_hook('admin_style_themes_begin', 'smmd_admin_themes_begin');

}

/**
 * Plugin activation
 */
 
function smmd_activate()
{

    global $db, $mybb;

    $smmd_settinggroup = array(
        'name'           => 'smmd_settinggroup',
        'title'          => 'Simple Mode Must Die! Plugin Settings', 
        'description'    => 'This plugin disables or re-enables simple mode theme editor',
        'disporder'      => '1',
        'isdefault'      => '0'
        );
        
    $group['gid'] = $db->insert_query('settinggroups', $smmd_settinggroup);

    $gid = $db->insert_id();
    
    $enable_smmd = array(
        'name'           => 'enable_smmd',
        'title'          => 'Enable smmd?', 
        'description'    => 'Do you want the smmd turned on?',
        'optionscode'    => 'yesno',
        'value'          => '1',
        'disporder'      => '2',
        'gid'            => intval($gid)
        );
        
    $db->insert_query('settings', $enable_smmd);

    rebuild_settings();

}

/**
 * Plugin de-activation
 */
 
function smmd_deactivate()
{

     global $db;

     $db->delete_query('settings', "name IN ('enable_smmd')");
     $db->delete_query('settinggroups', "name = 'smmd_settinggroup'");

     rebuild_settings();

}

/**
 * Disable / re-enable simple mode style sheet editing
 *
 * @return void
 */
 
function smmd_admin_themes_begin()
{

    global $db, $mybb;
    
    if ($mybb->settings['enable_smmd'] == 1)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "simple"))
      {
      	
        $mybb->input['mode'] = 'advanced';
      
      }
      
    }

    if ($mybb->settings['enable_smmd'] == 0)
    {
    	
      if ($mybb->input['action'] == "edit_stylesheet" && (!isset($mybb->input['mode']) || $mybb->input['mode'] == "advanced"))
      {
      	
        $mybb->input['mode'] = 'simple';
      
      }
      
    }

}

?>



For me it makes absolutely no sense to further edit the first example I shared when in the 5 minutes of creating it, it was able to do what I needed it and intended it to do without any such extra time spent editing it regardless if suggestions are made to edit it simply because some logical minds think in terms of uninstall and install being the only way to do such when in reality other logical minds clearly understand that either install / uninstall or activate / deactivate can be used for exactly the same purposes if so desired. Just a thought. Thanks again. :)
MyBB Themes Team - Making more professional themes by the hour. (Retired)
My Mods | Offer me a coffee!
Reply
#10
(08-19-2019, 04:13 PM)vintagedaddyo Wrote: [...]For me it makes absolutely no sense to further edit the first example[...]

Totally agree, I was just being picky Toungue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)