Plugin Directory

Changeset 1278942


Ignore:
Timestamp:
11/03/2015 08:32:03 PM (10 years ago)
Author:
DarkWolf
Message:

new 2.1 (big code change)!!!

Location:
my-custom-css
Files:
4 edited
1 copied

Legend:

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

    r1278839 r1278942  
    77You can see in action (source code) here: http://vegamami.altervista.org/ :)
    88Author: Salvatore Noschese - DarkWolf
    9 Version: 2.0
     9Version: 2.1
    1010Author URI: https://laltroweb.it/
    1111Text Domain: my-custom-css
     
    2626
    2727// Fix old backup folder or no exist
    28 $dirpath = plugin_dir_path(__FILE__).'hidden/bkk/';
    29 $old_dirpath = plugin_dir_path(__FILE__).'_backup/';
    30 if (!is_dir($old_dirpath) && !is_dir($dirpath))
     28$dirpath = WP_CONTENT_DIR.'/my_custom_css/bkk';
     29if (!is_dir($dirpath))
    3130{
    3231    wp_mkdir_p($dirpath);
    3332}
    34 else if (is_dir($old_dirpath))
    35 {
    36     wp_mkdir_p($dirpath);
    37     rename($old_dirpath, $dirpath);
    38 }
    39 
    4033
    4134// Make backup when save!
     
    4437
    4538    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    46     $directory = plugin_dir_path(__FILE__) . "hidden/bkk/*.css";
     39    $directory = WP_CONTENT_DIR."/my_custom_css/bkk/*.css";
    4740    if (glob($directory) != false)
    4841    {
     
    5346        $filecount = 1;
    5447    }
    55     $oldname = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
    56     $newname = plugin_dir_path(__FILE__).'hidden/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
     48    $oldname = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css";
     49    $newname = WP_CONTENT_DIR.'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
    5750    rename($oldname, $newname);
    5851}
     
    6154if(isset($_POST['viewbackup']))
    6255{
    63 $directory = plugin_dir_path(__FILE__)."hidden/bkk/";
     56$directory = WP_CONTENT_DIR."/my_custom_css/bkk/";
    6457$files=array();
    6558if ($dh=opendir($directory))
     
    7366krsort($files);
    7467reset($files);
    75 $href = plugin_dir_url(__FILE__)."hidden/bkk/";
     68$href = WP_CONTENT_URL."/my_custom_css/bkk/";
    7669date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
    7770
     
    126119  </head>
    127120    <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">";
    128     $glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
     121    $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css");
    129122    if ($glob == false)
    130123    {
     
    141134        <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" />
    142135        <br />";
    143         foreach (glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css") as $filename)
     136        foreach (glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css") as $filename)
    144137        {
    145138        echo "
     
    158151{
    159152    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    160     $css_path = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
     153    $css_path = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css";
    161154    return $css_path;
    162155}
     
    165158{
    166159    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    167     $css_url = plugin_dir_url(__FILE__)."my_style".$cssid.".css";
     160    $css_url = WP_CONTENT_URL."/my_custom_css/my_style".$cssid.".css";
    168161    return $css_url;
    169162}
     
    282275function mycustomcss_syntax()
    283276{
    284 $plugdir = plugin_dir_url(__FILE__);
    285277?>
    286278<!-- Syntax Support Start -->
    287 <link type="text/css" rel="stylesheet" href="<?php echo $plugdir; ?>syntax/codemirror.css" />
    288 <script language="javascript" src="<?php echo $plugdir; ?>syntax/codemirror.js"></script>
    289 <script language="javascript" src="<?php echo $plugdir; ?>syntax/css.js"></script>
     279<link type="text/css" rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.css" />
     280<script language="javascript" src="<?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.js"></script>
     281<script language="javascript" src="<?php echo plugin_dir_url(__FILE__); ?>syntax/css.js"></script>
    290282<!-- Syntax Support End -->
    291283<?php
     
    308300$plugin_version = $plugin_data['Version'];
    309301
    310 $glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
     302$glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css");
    311303if ($glob == false)
    312304{
  • my-custom-css/tags/2.1/readme.txt

    r1278839 r1278942  
    55Requires at least: 3.0
    66Tested up to: 4.3.1
    7 Stable tag: 2.0
     7Stable tag: 2.1
    88
    99Enable to add Custom CSS Code via admin panel (with syntax and tab support by CodeMirror)
     
    4747== Upgrade Notice ==
    4848
    49 = 2.0 =
     49= 2.1 =
    5050
    51 * Now use "$wp_filesystem->put_contents" and "wp_mkdir_p" instead of "file_put_contents" and "mkdir" (fix issue permission)...
     51* Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)!
     52* More other change in code...
    5253
    5354== Changelog ==
     55
     56= 2.1 =
     57
     58* Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)!
     59* More other change in code...
    5460
    5561= 2.0 =
  • my-custom-css/trunk/my-custom-css.php

    r1278834 r1278942  
    77You can see in action (source code) here: http://vegamami.altervista.org/ :)
    88Author: Salvatore Noschese - DarkWolf
    9 Version: 2.0
     9Version: 2.1
    1010Author URI: https://laltroweb.it/
    1111Text Domain: my-custom-css
     
    2626
    2727// Fix old backup folder or no exist
    28 $dirpath = plugin_dir_path(__FILE__).'hidden/bkk/';
    29 $old_dirpath = plugin_dir_path(__FILE__).'_backup/';
    30 if (!is_dir($old_dirpath) && !is_dir($dirpath))
     28$dirpath = WP_CONTENT_DIR.'/my_custom_css/bkk';
     29if (!is_dir($dirpath))
    3130{
    3231    wp_mkdir_p($dirpath);
    3332}
    34 else if (is_dir($old_dirpath))
    35 {
    36     wp_mkdir_p($dirpath);
    37     rename($old_dirpath, $dirpath);
    38 }
    39 
    4033
    4134// Make backup when save!
     
    4437
    4538    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    46     $directory = plugin_dir_path(__FILE__) . "hidden/bkk/*.css";
     39    $directory = WP_CONTENT_DIR."/my_custom_css/bkk/*.css";
    4740    if (glob($directory) != false)
    4841    {
     
    5346        $filecount = 1;
    5447    }
    55     $oldname = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
    56     $newname = plugin_dir_path(__FILE__).'hidden/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
     48    $oldname = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css";
     49    $newname = WP_CONTENT_DIR.'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
    5750    rename($oldname, $newname);
    5851}
     
    6154if(isset($_POST['viewbackup']))
    6255{
    63 $directory = plugin_dir_path(__FILE__)."hidden/bkk/";
     56$directory = WP_CONTENT_DIR."/my_custom_css/bkk/";
    6457$files=array();
    6558if ($dh=opendir($directory))
     
    7366krsort($files);
    7467reset($files);
    75 $href = plugin_dir_url(__FILE__)."hidden/bkk/";
     68$href = WP_CONTENT_URL."/my_custom_css/bkk/";
    7669date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
    7770
     
    126119  </head>
    127120    <body style=\"background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray\">";
    128     $glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
     121    $glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css");
    129122    if ($glob == false)
    130123    {
     
    141134        <input type=\"button\" value=\"Close now!\" onclick=\"self.close()\" style=\"margin: 0px 20px; float: right\" />
    142135        <br />";
    143         foreach (glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css") as $filename)
     136        foreach (glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css") as $filename)
    144137        {
    145138        echo "
     
    158151{
    159152    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    160     $css_path = plugin_dir_path(__FILE__)."my_style".$cssid.".css";
     153    $css_path = WP_CONTENT_DIR."/my_custom_css/my_style".$cssid.".css";
    161154    return $css_path;
    162155}
     
    165158{
    166159    $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    167     $css_url = plugin_dir_url(__FILE__)."my_style".$cssid.".css";
     160    $css_url = WP_CONTENT_URL."/my_custom_css/my_style".$cssid.".css";
    168161    return $css_url;
    169162}
     
    282275function mycustomcss_syntax()
    283276{
    284 $plugdir = plugin_dir_url(__FILE__);
    285277?>
    286278<!-- Syntax Support Start -->
    287 <link type="text/css" rel="stylesheet" href="<?php echo $plugdir; ?>syntax/codemirror.css" />
    288 <script language="javascript" src="<?php echo $plugdir; ?>syntax/codemirror.js"></script>
    289 <script language="javascript" src="<?php echo $plugdir; ?>syntax/css.js"></script>
     279<link type="text/css" rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.css" />
     280<script language="javascript" src="<?php echo plugin_dir_url(__FILE__); ?>syntax/codemirror.js"></script>
     281<script language="javascript" src="<?php echo plugin_dir_url(__FILE__); ?>syntax/css.js"></script>
    290282<!-- Syntax Support End -->
    291283<?php
     
    308300$plugin_version = $plugin_data['Version'];
    309301
    310 $glob = glob(plugin_dir_path(__FILE__)."hidden/bkk/*.css");
     302$glob = glob(WP_CONTENT_DIR."/my_custom_css/bkk/*.css");
    311303if ($glob == false)
    312304{
  • my-custom-css/trunk/readme.txt

    r1278941 r1278942  
    55Requires at least: 3.0
    66Tested up to: 4.3.1
    7 Stable tag: 2.0
     7Stable tag: 2.1
    88
    99Enable to add Custom CSS Code via admin panel (with syntax and tab support by CodeMirror)
     
    4747== Upgrade Notice ==
    4848
    49 = 2.0 =
     49= 2.1 =
    5050
    51 * Now use "$wp_filesystem->put_contents" and "wp_mkdir_p" instead of "file_put_contents" and "mkdir" (fix issue permission)...
     51* Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)!
     52* More other change in code...
    5253
    5354== Changelog ==
     55
     56= 2.1 =
     57
     58* Now my_style.css and backup will be saved in content directory! (no more delete on upgrade)!
     59* More other change in code...
    5460
    5561= 2.0 =
Note: See TracChangeset for help on using the changeset viewer.