Plugin Directory

Changeset 1278839


Ignore:
Timestamp:
11/03/2015 06:05:09 PM (10 years ago)
Author:
DarkWolf
Message:

New 2.0

Location:
my-custom-css/tags/2.0
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • my-custom-css/tags/2.0/my-custom-css.php

    r1278547 r1278839  
    77You can see in action (source code) here: http://vegamami.altervista.org/ :)
    88Author: Salvatore Noschese - DarkWolf
    9 Version: 1.9
     9Version: 2.0
    1010Author URI: https://laltroweb.it/
    1111Text Domain: my-custom-css
     
    2525}
    2626
    27 // Fix no backup folder
    28 $dirpath = plugin_dir_path(__FILE__).'_backup/';
    29 if (!is_dir($dirpath))
    30 {
    31     mkdir($dirpath, 0755, true);
    32 }
     27// Fix old backup folder or no exist
     28$dirpath = plugin_dir_path(__FILE__).'hidden/bkk/';
     29$old_dirpath = plugin_dir_path(__FILE__).'_backup/';
     30if (!is_dir($old_dirpath) && !is_dir($dirpath))
     31{
     32    wp_mkdir_p($dirpath);
     33}
     34else if (is_dir($old_dirpath))
     35{
     36    wp_mkdir_p($dirpath);
     37    rename($old_dirpath, $dirpath);
     38}
     39
    3340
    3441// Make backup when save!
     
    3744
    3845    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    39     $directory = plugin_dir_path(__FILE__) . "_backup/*.css";
     46    $directory = plugin_dir_path(__FILE__) . "hidden/bkk/*.css";
    4047    if (glob($directory) != false)
    4148    {
     
    4754    }
    4855    $oldname = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
    49     $newname = plugin_dir_path(__FILE__).'_backup/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
     56    $newname = plugin_dir_path(__FILE__).'hidden/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
    5057    rename($oldname, $newname);
    5158}
     
    5461if(isset($_POST['viewbackup']))
    5562{
    56 $directory = plugin_dir_path(__FILE__)."_backup/";
     63$directory = plugin_dir_path(__FILE__)."hidden/bkk/";
    5764$files=array();
    5865if ($dh=opendir($directory))
     
    6673krsort($files);
    6774reset($files);
    68 $href = plugin_dir_url(__FILE__)."_backup/";
     75$href = plugin_dir_url(__FILE__)."hidden/bkk/";
    6976date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
    7077
     
    119126  </head>
    120127    <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">";
    121     $glob = glob(plugin_dir_path(__FILE__)."_backup/*.css");
     128    $glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
    122129    if ($glob == false)
    123130    {
     
    134141        <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" />
    135142        <br />";
    136         foreach (glob(plugin_dir_path(__FILE__)."_backup/*.css") as $filename)
     143        foreach (glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css") as $filename)
    137144        {
    138145        echo "
     
    179186    // make my_style.css and write write css code!
    180187    $mycustomcss = mycustomcss();
    181     $makecss = file_put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n\n".mycustomcss());
     188    global $wp_filesystem;
     189    if (empty($wp_filesystem))
     190    {
     191        require_once (ABSPATH . '/wp-admin/includes/file.php');
     192        WP_Filesystem();
     193    }
     194    $makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n\n".mycustomcss(), 0644);
    182195    return $makecss;
    183196}
     
    295308$plugin_version = $plugin_data['Version'];
    296309
    297 $glob = glob(plugin_dir_path(__FILE__)."_backup/*.css");
     310$glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
    298311if ($glob == false)
    299312{
     
    334347        makecss();
    335348    }
    336             elseif (empty($mycustomcss) && file_exists(css_path()))
    337     {
    338         unlink(css_path());
    339     }
    340349}
    341350
  • my-custom-css/tags/2.0/readme.txt

    r1278547 r1278839  
    55Requires at least: 3.0
    66Tested up to: 4.3.1
    7 Stable tag: 1.9
     7Stable tag: 2.0
    88
    99Enable to add Custom CSS Code via admin panel (with syntax and tab support by CodeMirror)
     
    4747== Upgrade Notice ==
    4848
    49 = 1.9 =
     49= 2.0 =
    5050
    51 * Some fix in multisite network (disable view/erase backup except for blog_id 1)!
     51* Now use "$wp_filesystem->put_contents" and "wp_mkdir_p" instead of "file_put_contents" and "mkdir" (fix issue permission)...
    5252
    5353== Changelog ==
     54
     55= 2.0 =
     56
     57* Now use "$wp_filesystem->put_contents" and "wp_mkdir_p" instead of "file_put_contents" and "mkdir" (fix issue permission)...
     58* Move backup in "hidden directory" - with old backup migration (prevent long css list in wordpress plugin editor)...
    5459
    5560= 1.9 =
Note: See TracChangeset for help on using the changeset viewer.