Plugin Directory

Changeset 1299322


Ignore:
Timestamp:
12/02/2015 09:08:12 PM (10 years ago)
Author:
DarkWolf
Message:

New release 2.8

Location:
my-custom-css
Files:
68 added
7 edited

Legend:

Unmodified
Added
Removed
  • my-custom-css/trunk/editor/ace_custom.css

    r1287044 r1299322  
    1616    display: none;
    1717    z-index: 10000;
     18}
     19.wrap {
     20    min-width: 820px;
    1821}
    1922.wrap h2 {
     
    7780    right: 25px;
    7881    top: 45px;
    79     z-index: 50;
     82    z-index: 9999;
    8083    font-size: 30px !important;
    8184    border-radius: 10% !important;
    8285}
     86.ace_gutter, .ace_scroller {
     87    top: 35px;
     88}
     89.ace_autocomplete > .ace_scroller {
     90    top: 0px;
     91}
     92.ace_search {
     93    max-width: 100% !important;
     94    position: static !important;
     95}
    8396.ace_search.right {
    8497    font-size: 9px !important;
     98    border-radius: 0 !important;
    8599}
    86100.ace_search_options {
    87101    float: left;
    88     line-height: 20px;
    89     font-size: 12px !important;
     102    line-height: 25px;
     103    font-size: 14px !important;
    90104}
    91 .ace_search_options::after {
    92     color: #000;
    93     content: " (CTRL|CMD+F = Replace Form!)";
    94     font-style: italic;
     105.ace_search.right::after {
     106    color: #000;
     107    content: "Help: CTRL|CMD+Space = Autocomplete!";
     108    float: right;
     109    font-size: 12px;
     110    font-style: italic;
     111    padding-right: 5px;
     112    line-height: 30px;
     113}
     114.ace_search_field {
     115    width: 150px !important;
     116}
     117.ace_searchbtn_close {
     118    display: none !important;
     119}
     120.ace_search, .ace_search_form, .ace_replace_form {
     121    display: block !important;
    95122}
    96123#my_custom_css {
     
    98125    border-radius: 3px;
    99126    width: 100%;
    100     height: 400px;
     127    padding-bottom: 35px;
    101128    position: relative;
    102     top: -5px;
    103129    font-size: 14px;
    104130    line-height: 150% !important;
    105131}
    106 #thememenu {
    107     float: left;
     132form#thememenu, form#backup {
     133    float: left;
    108134    margin-left: 10px;
    109135    margin-top: -5px;
    110136}
     137form#thememenu > select {
     138    height: 28px;
     139}
     140.backup_list {
     141    border: 1px dotted gray;
     142    margin-top: 30px;
     143    padding: 15px;
     144    background: #fff;
     145}
    111146/* Fix wordpress footer */
    112 #wpfooter {
    113     position: relative;
    114 }
    115147#footer-upgrade {
    116148    float: left;
     
    120152#mccss_credit {
    121153    float: right;
     154    margin: 5px 2px 0 0;
    122155    font-style: italic;
    123156}
  • my-custom-css/trunk/lang/default.pot

    r1286435 r1299322  
    33"Project-Id-Version: My Custom CSS\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2015-11-14 18:11+0100\n"
     5"POT-Creation-Date: 2015-11-19 23:42+0100\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: Salvatore Noschese (DarkWolf) <[email protected]>\n"
     
    1717"X-Poedit-SearchPath-0: E:\\WordPress\\my-custom-css\\trunk\n"
    1818
    19 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:108
     19#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:66
    2020msgid "Settings"
    2121msgstr ""
    2222
    23 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:111
     23#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:69
    2424msgid "Support"
    2525msgstr ""
    2626
    27 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:176
    28 msgid "My custom CSS - Backup"
    29 msgstr ""
    30 
    31 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:182
    32 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:192
    33 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:226
    34 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:235
    35 msgid "Close now!"
    36 msgstr ""
    37 
    38 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:185
    39 msgid "I can't list any *.css: 'No file found'... "
    40 msgstr ""
    41 
    42 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:194
    43 msgid "Erase all backup"
    44 msgstr ""
    45 
    46 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:194
    47 msgid "Do you want really delete all backup?"
    48 msgstr ""
    49 
    50 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:200
    51 msgid "File:"
    52 msgstr ""
    53 
    54 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:201
    55 msgid "Path:"
    56 msgstr ""
    57 
    58 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:202
    59 msgid "Saved:"
    60 msgstr ""
    61 
    62 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:203
    63 msgid "Size:"
    64 msgstr ""
    65 
    66 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:219
    67 msgid "My custom CSS - Erase Backup"
    68 msgstr ""
    69 
    70 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:229
    71 msgid "I can't delete any *.css: 'No file found'... "
    72 msgstr ""
    73 
    74 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:241
    75 msgid "bytes, was successfully deleted!!!"
    76 msgstr ""
    77 
    78 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:337
    79 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:472
     27#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:231
     28#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:399
    8029msgid "My Custom CSS Panel"
    8130msgstr ""
    8231
    83 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:339
     32#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:233
    8433msgid "Font Size:"
    8534msgstr ""
    8635
    87 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:349
     36#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:243
    8837msgid "Theme:"
    8938msgstr ""
    9039
    91 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:350
     40#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:244
    9241msgid ""
    9342"Warning!!! This will refresh entire page (Unsaved data will be lost) - "
     
    9544msgstr ""
    9645
    97 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:388
     46#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:245
    9847msgid "Bright:"
    9948msgstr ""
    10049
    101 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:405
     50#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:262
    10251msgid "Dark:"
    10352msgstr ""
    10453
    105 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:442
     54#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:292
     55msgid "No backup found..."
     56msgstr ""
     57
     58#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:296
     59msgid "View backups :)"
     60msgstr ""
     61
     62#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:296
     63msgid "Click to view all backups!"
     64msgstr ""
     65
     66#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:300
     67msgid "Backup:"
     68msgstr ""
     69
     70#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:312
    10671msgid "Save"
    10772msgstr ""
    10873
    109 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:449
    110 msgid "No backup found..."
     74#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:333
     75msgid "My custom CSS - Backup"
    11176msgstr ""
    11277
    113 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:450
    114 msgid "View backups :)"
     78#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:336
     79#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:357
     80msgid "Close now!"
    11581msgstr ""
    11682
    117 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:450
    118 msgid "Click to view all backups!"
     83#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:338
     84msgid "Erase all backup"
    11985msgstr ""
    12086
    121 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:472
     87#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:338
     88msgid "Do you want really delete all backup?"
     89msgstr ""
     90
     91#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:344
     92msgid "File:"
     93msgstr ""
     94
     95#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:345
     96msgid "Path:"
     97msgstr ""
     98
     99#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:346
     100msgid "Saved:"
     101msgstr ""
     102
     103#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:347
     104msgid "Size:"
     105msgstr ""
     106
     107#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:355
     108msgid "My custom CSS - Erase Backup"
     109msgstr ""
     110
     111#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:363
     112msgid "bytes, was successfully deleted!!!"
     113msgstr ""
     114
     115#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:399
    122116msgid "My Custom CSS"
    123117msgstr ""
  • my-custom-css/trunk/lang/my-custom-css-it_IT.po

    r1286435 r1299322  
    33"Project-Id-Version: My Custom CSS\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2015-11-14 22:16+0100\n"
     5"POT-Creation-Date: 2015-11-19 23:43+0100\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: Salvatore Noschese (DarkWolf) <[email protected]>\n"
     
    1717"X-Poedit-SearchPath-0: E:\\WordPress\\my-custom-css\\trunk\n"
    1818
    19 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:106
     19#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:66
    2020msgid "Settings"
    2121msgstr "Opzioni"
    2222
    23 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:109
     23#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:69
    2424msgid "Support"
    2525msgstr "Supporto"
    2626
    27 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:174
    28 msgid "My custom CSS - Backup"
    29 msgstr "My custom CSS - Backup"
    30 
    31 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:180
    32 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:190
    33 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:224
    34 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:233
    35 msgid "Close now!"
    36 msgstr "Chiudi ora!"
    37 
    38 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:183
    39 msgid "I can't list any *.css: 'No file found'... "
    40 msgstr "Non posso elencare nessun *.css: 'File non trovato' ..."
    41 
    42 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:192
    43 msgid "Erase all backup"
    44 msgstr "Cancellare tutti i backup"
    45 
    46 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:192
    47 msgid "Do you want really delete all backup?"
    48 msgstr "Vuoi davvero eliminare tutti i backup?"
    49 
    50 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:198
    51 msgid "File:"
    52 msgstr "File:"
    53 
    54 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:199
    55 msgid "Path:"
    56 msgstr "Percorso:"
    57 
    58 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:200
    59 msgid "Saved:"
    60 msgstr "Salvato:"
    61 
    62 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:201
    63 msgid "Size:"
    64 msgstr "Dimensioni:"
    65 
    66 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:217
    67 msgid "My custom CSS - Erase Backup"
    68 msgstr "My custom CSS - Cancella i backup"
    69 
    70 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:227
    71 msgid "I can't delete any *.css: 'No file found'... "
    72 msgstr "Non posso eliminare nessun *.css: 'File non trovato' ..."
    73 
    74 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:239
    75 msgid "bytes, was successfully deleted!!!"
    76 msgstr "byte, &egrave; stato cancellato con successo!!!"
    77 
    78 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:336
    79 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:471
     27#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:231
     28#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:399
    8029msgid "My Custom CSS Panel"
    8130msgstr "Pannello My Custom CSS"
    8231
    83 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:338
     32#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:233
    8433msgid "Font Size:"
    8534msgstr "Dimensione dei font:"
    8635
    87 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:348
     36#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:243
    8837msgid "Theme:"
    8938msgstr "Tema:"
    9039
    91 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:349
     40#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:244
    9241msgid ""
    9342"Warning!!! This will refresh entire page (Unsaved data will be lost) - "
     
    9746"andranno persi) - Continuare?"
    9847
    99 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:387
     48#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:245
    10049msgid "Bright:"
    10150msgstr "Luminoso:"
    10251
    103 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:404
     52#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:262
    10453msgid "Dark:"
    10554msgstr "Scuro:"
    10655
    107 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:441
     56#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:292
     57msgid "No backup found..."
     58msgstr "Nessun backup trovato..."
     59
     60#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:296
     61msgid "View backups :)"
     62msgstr "Visualizza i backup :)"
     63
     64#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:296
     65msgid "Click to view all backups!"
     66msgstr "Clicca per vedere tutti i backup!"
     67
     68#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:300
     69msgid "Backup:"
     70msgstr "Backup:"
     71
     72#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:312
    10873msgid "Save"
    10974msgstr "Salva"
    11075
    111 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:448
    112 msgid "No backup found..."
    113 msgstr "Nessun backup trovato..."
     76#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:333
     77msgid "My custom CSS - Backup"
     78msgstr "My custom CSS - Backup"
    11479
    115 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:449
    116 msgid "View backups :)"
    117 msgstr "Visualizza i backup :)"
     80#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:336
     81#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:357
     82msgid "Close now!"
     83msgstr "Chiudi ora!"
    11884
    119 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:449
    120 msgid "Click to view all backups!"
    121 msgstr "Clicca per vedere tutti i backup!"
     85#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:338
     86msgid "Erase all backup"
     87msgstr "Cancellare tutti i backup"
    12288
    123 #: E:\WordPress\my-custom-css\trunk/my-custom-css.php:471
     89#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:338
     90msgid "Do you want really delete all backup?"
     91msgstr "Vuoi davvero eliminare tutti i backup?"
     92
     93#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:344
     94msgid "File:"
     95msgstr "File:"
     96
     97#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:345
     98msgid "Path:"
     99msgstr "Percorso:"
     100
     101#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:346
     102msgid "Saved:"
     103msgstr "Salvato:"
     104
     105#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:347
     106msgid "Size:"
     107msgstr "Dimensioni:"
     108
     109#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:355
     110msgid "My custom CSS - Erase Backup"
     111msgstr "My custom CSS - Cancella i backup"
     112
     113#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:363
     114msgid "bytes, was successfully deleted!!!"
     115msgstr "byte, &egrave; stato cancellato con successo!!!"
     116
     117#: E:\WordPress\my-custom-css\trunk/my-custom-css.php:399
    124118msgid "My Custom CSS"
    125119msgstr "My Custom CSS"
     120
     121#~ msgid "I can't list any *.css: 'No file found'... "
     122#~ msgstr "Non posso elencare nessun *.css: 'File non trovato' ..."
     123
     124#~ msgid "I can't delete any *.css: 'No file found'... "
     125#~ msgstr "Non posso eliminare nessun *.css: 'File non trovato' ..."
    126126
    127127#~ msgid "No backup here..."
  • my-custom-css/trunk/my-custom-css.php

    r1287048 r1299322  
    88PS: support file backup and - very important - static css file (fantastic for performance) ;)
    99Author: DarkWolf
    10 Version: 2.7
     10Version: 2.8
    1111Author URI: https://laltroweb.it/
    1212Text Domain: my-custom-css
     
    1414
    1515// Prevent Direct Access with homepage redirect
    16 if (!defined('DB_NAME'))
     16if (defined('DB_NAME'))
    1717{
    18     header('Location: http://'.$_SERVER['SERVER_NAME'].'/');
     18
     19    // Text Domain: my-custom-css
     20    load_plugin_textdomain('my-custom-css', false, dirname(plugin_basename(__FILE__)) . '/lang/');
     21
     22    // Generate basedir and baseurl
     23    function plugin_basedir() { $upload_dir = wp_upload_dir(); $plugin_basedir = $upload_dir['basedir']; return $plugin_basedir; }
     24    function plugin_url() { $upload_dir = wp_upload_dir(); $plugin_url = set_url_scheme($upload_dir['baseurl']); return $plugin_url; }
     25
     26    // Generate my_style_id url:
     27    function my_style_id() { $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null; $my_style_id = "/my_custom_css/my_style".$cssid.".css"; return $my_style_id; }
     28
     29    // Generate css url and css path
     30    function css_url() { $css_url = plugin_url().my_style_id(); return $css_url; }
     31    function css_path() { $css_path = plugin_basedir().my_style_id(); return $css_path; }
     32
     33    // make my_style.css and write write css code!
     34    function getdata() { $getdata = strip_tags(get_option('my_custom_css')); return $getdata; }
     35
     36    // Write in source!
     37    function mycustomcss_head()
     38    {
     39        $data = getdata();
     40        if (!empty($data))
     41        {
     42            echo "\n<!-- My Custom CSS -->\n<link rel='stylesheet' id='mccss_stylesheet' href='".css_url()."?".@filemtime(css_path())."' type='text/css' media='all' />\n<!-- My Custom CSS -->\n";
     43        }
     44    }
     45
     46    // Make css file
     47    function makecss()
     48    {
     49        $makecss = file_put_contents(css_path(), "/******* Do not edit this file *******/\n/*\nMy Custom CSS - by Salvatore Noschese\naka L'altroWeb - https://laltroweb.it/\n/*\nSaved: ".date("M d Y | h:i:s (a)",current_time('timestamp'))."\n/*\n/******* Do not edit this file *******/\n\n".getdata());
     50        return $makecss;
     51    }
     52
     53    // Fix first upgrade from old release or manual my_style.css deletion!
     54    if (!file_exists(css_path()) || isset($_POST['save'])) { makecss(); }
     55   
     56    // Fix old backup folder or no exist
     57    if (!is_dir(plugin_basedir().'/my_custom_css/bkk')) { wp_mkdir_p(plugin_basedir().'/my_custom_css/bkk'); }
     58    // And Blank index.php to prevent listing directory
     59    else if(!file_exists(plugin_basedir()."/my_custom_css/index.php") || !file_exists(plugin_basedir()."/my_custom_css/bkk/index.php"))
     60    { file_put_contents(plugin_basedir()."/my_custom_css/index.php", "<?php \n// Prevent Directory Listing...");    file_put_contents(plugin_basedir()."/my_custom_css/bkk/index.php", "<?php \n// Prevent Directory Listing..."); }
     61
     62    // Start Add link on plugins page
     63    function mycustomcss_links($links)
     64    {
     65        # Settings:
     66        $settings_link = '<a href="admin.php?page=my_custom_css" title="My Custom CSS">'.__('Settings','my-custom-css').'</a>';
     67        array_unshift($links, $settings_link);
     68        # Support:
     69        $support_forum = '<a href="https://laltroweb.it/" title="laltroweb.it">'.__('Support','my-custom-css').'</a>';
     70        array_unshift($links, $support_forum);
     71        # return:
     72        return $links;
     73    }
     74    function add_plugin_meta_links($links, $file)
     75    {
     76        if ($file == plugin_basename(__FILE__))
     77        {
     78            $links[] = '<a href="https://www.paypal.me/SalvatoreN" title="Buy Me a Beer ;)">Donate :)</a>';
     79        }
     80        return $links;
     81    }
     82
     83
     84    // Change the CSS for this plugin on admin plugins page
     85    function mycustomcss_admin_style()
     86    {
     87        global $pagenow;
     88        if ($pagenow == "plugins.php")
     89        {
     90            echo "<style type='text/css'>\n#my-custom-css td.plugin-title strong {\n\tbackground: url('".plugin_dir_url(__FILE__)."/mccss.png') no-repeat scroll 115px 2px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n";
     91        }
     92    }
     93   
     94    // Set Theme
     95    function thl() { $thl = $_POST["themelist"]; return $thl; }
     96    $thl = thl(); if (isset($thl) && !empty($thl)) { setcookie('_mccss_ace_themelist_', $thl, time()+31556926 ,'/');    }
     97    function sth()
     98    {
     99        $thl = thl();
     100        if (isset($thl) && !empty($thl))
     101        {
     102            $sth = $thl;
     103        }
     104        else if (!isset($_COOKIE['_mccss_ace_themelist_']))
     105        {
     106            $sth = 'ace/theme/textmate';
     107        }
     108        else
     109        {
     110            $sth = $_COOKIE['_mccss_ace_themelist_'];
     111        }
     112        return $sth;
     113    }
     114
     115           
     116    // Option page code:
     117    function mycustomcss_scripts()
     118    {
     119        echo '
     120        <!-- Start My Custom CSS Code -->
     121        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/_scrolltop.js"></script>';
     122        if(!isset($_POST['viewbackup']) && !isset($_POST['erasebackup']))
     123        {
     124        echo '
     125        <!-- Ace Editor -->
     126        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ace.js" charset="utf-8"></script>
     127        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ext-searchbox.js" charset="utf-8"></script>
     128        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ext-language_tools.js" charset="utf-8"></script>
     129        <script type="text/javascript">
     130        // Ace Setting
     131        ( function( global, $ ) {
     132            var editor,
     133                syncCSS = function() {
     134                    $("#my_custom_css_textarea").val(editor.getSession().getValue());
     135                },
     136                loadAce = function() {
     137                    editor = ace.edit("my_custom_css");
     138                    global.safecss_editor = editor;
     139                    editor.session.setMode("ace/mode/css");
     140                    editor.$blockScrolling = Infinity;
     141                    editor.getSession().setUseWrapMode(true);
     142                    editor.getSession().setValue($("#my_custom_css_textarea").val());
     143                    editor.getSession().setUseSoftTabs(true);
     144                    editor.setHighlightActiveLine(true);
     145                    editor.setOptions({maxLines: Infinity});
     146                    editor.setTheme("'.sth().'");
     147                    editor.setOptions({minLines: 10});
     148                    editor.setOption("firstLineNumber", 1)
     149                    editor.setShowPrintMargin(true);
     150                    editor.setShowInvisibles(true);
     151                    editor.execCommand("find");
     152                    // enable autocompletion and snippets
     153                    ace.require("ace/ext/language_tools");
     154                        editor.setOptions({
     155                        enableBasicAutocompletion: true,
     156                        enableSnippets: true,
     157                        enableLiveAutocompletion: true
     158                    });
     159                    jQuery.fn.spin&&$("#my_custom_css_container").spin(false);
     160                    $("#my-custom-css").submit(syncCSS);
     161                };
     162            if ($.browser.msie&&parseInt($.browser.version, 10) <= 7) {
     163                $("#my_custom_css_container").hide();
     164                $("#my_custom_css_textarea").show();
     165                return false;
     166            } else {
     167                $(global).load(loadAce);
     168            }
     169            global.aceSyncCSS = syncCSS;
     170        } )(this, jQuery);
     171        </script>
     172        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/cookie.js"></script>
     173        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/textresizer.min.js"></script>
     174        <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/textresizer_target.js"></script>';
     175        }
     176        echo '
     177        <!-- CSS Code -->
     178        <link rel="stylesheet" id="ace-editor-custom-css" href="'.plugin_dir_url(__FILE__).'editor/ace_custom.css" type="text/css" media="all" />
     179        <!-- End My Custom CSS Code -->';
     180    }
     181
     182    // Textarea/Form:
     183    function mccss_admin_page()
     184    {
     185        // Get plugin version:
     186        $plugin_data = get_plugin_data(__FILE__);
     187        $plugin_version = $plugin_data['Version'];
     188        echo '
     189        <script type="text/javascript" src="http://www.vegamami.it/wp-content/plugins/my-custom-css/editor/ace.js" charset="utf-8"></script>
     190        <div class="wrap">';
     191            if(!isset($_POST['viewbackup']) && !isset($_POST['erasebackup']))
     192            {
     193            $at = "ace/theme/";
     194            // BrightTheme
     195            $b1 = $at."chrome";
     196            $b2 = $at."clouds";
     197            $b3 = $at."crimson_editor";
     198            $b4 = $at."dawn";
     199            $b5 = $at."dreamweaver";
     200            $b6 = $at."eclipse";
     201            $b7 = $at."github";
     202            $b8 = $at."iplastic";
     203            $b9 = $at."solarized_light";
     204            $b10 = $at."textmate";
     205            $b11 = $at."tomorrow";
     206            $b12 = $at."xcode";
     207            $b13 = $at."kuroir";
     208            $b14 = $at."katzenmilch";
     209            $b15 = $at."sqlserver";
     210            // DarkTheme
     211            $d1 = $at."ambiance";
     212            $d2 = $at."chaos";
     213            $d3 = $at."clouds_midnight";
     214            $d4 = $at."cobalt";
     215            $d5 = $at."idle_fingers";
     216            $d6 = $at."kr_theme";
     217            $d7 = $at."merbivore";
     218            $d8 = $at."merbivore_soft";
     219            $d9 = $at."mono_industrial";
     220            $d10 = $at."monokai";
     221            $d11 = $at."pastel_on_dark";
     222            $d12 = $at."solarized_dark";
     223            $d13 = $at."terminal";
     224            $d14 = $at."tomorrow_night";
     225            $d15 = $at."tomorrow_night_blue";
     226            $d16 = $at."tomorrow_night_bright";
     227            $d17 = $at."tomorrow_night_eighties";
     228            $d18 = $at."twilight";
     229            $d19 = $at."vibrant_ink";
     230            echo '
     231                <h2>' .  __('My Custom CSS Panel','my-custom-css') . ' - v'.$plugin_version.'</h2>
     232                    <div id="textsizer">
     233                        <p>' .  __('Font Size:','my-custom-css') . '</p>
     234                            <ul class="textresizer">
     235                              <li><a href="#nogo" class="small-text" title="12px (Small)">A-</a></li>
     236                              <li><a href="#nogo" class="medium-text" title="14px (Medium)">A</a></li>
     237                              <li><a href="#nogo" class="large-text" title="16px (Large)">A+</a></li>
     238                              <li><a href="#nogo" class="larger-text" title="18px (Larger)">A++</a></li>
     239                              <li><a href="#nogo" class="giga-text" title="26px (Giga)">A+++</a></li>
     240                            </ul>
     241                    </div>
     242                        <form action="" method="post" id="thememenu">
     243                        <label for="theme">' .  __('Theme:','my-custom-css') . '</label>
     244                            <select name="themelist" id="themelist" onchange="if(confirm(\'' .  __('Warning!!! This will refresh entire page (Unsaved data will be lost) - Continue?','my-custom-css') . '\')){this.form.submit()}">
     245                                <optgroup label="' .  __('Bright:','my-custom-css') . '">
     246                                    <option value="'.$b1.'"'.(sth() == $b1 ? ' selected' : false).'>Chrome</option>
     247                                    <option value="'.$b2.'"'.(sth() == $b2 ? ' selected' : false).'>Clouds</option>
     248                                    <option value="'.$b3.'"'.(sth() == $b3 ? ' selected' : false).'>Crimson Editor</option>
     249                                    <option value="'.$b4.'"'.(sth() == $b4 ? ' selected' : false).'>Dawn</option>
     250                                    <option value="'.$b5.'"'.(sth() == $b5 ? ' selected' : false).'>Dreamweaver</option>
     251                                    <option value="'.$b6.'"'.(sth() == $b6 ? ' selected' : false).'>Eclipse</option>
     252                                    <option value="'.$b7.'"'.(sth() == $b7 ? ' selected' : false).'>GitHub</option>
     253                                    <option value="'.$b8.'"'.(sth() == $b8 ? ' selected' : false).'>IPlastic</option>
     254                                    <option value="'.$b9.'"'.(sth() == $b9 ? ' selected' : false).'>Solarized Light</option>
     255                                    <option value="'.$b10.'"'.(sth() == $b10 ? ' selected' : false).'>TextMate</option>
     256                                    <option value="'.$b11.'"'.(sth() == $b11 ? ' selected' : false).'>Tomorrow</option>
     257                                    <option value="'.$b12.'"'.(sth() == $b12 ? ' selected' : false).'>XCode</option>
     258                                    <option value="'.$b13.'"'.(sth() == $b13 ? ' selected' : false).'>Kuroir</option>
     259                                    <option value="'.$b14.'"'.(sth() == $b14 ? ' selected' : false).'>KatzenMilch</option>
     260                                    <option value="'.$b15.'"'.(sth() == $b15 ? ' selected' : false).'>SQL Server</option>
     261                                </optgroup>
     262                                <optgroup label="' .  __('Dark:','my-custom-css') . '">
     263                                    <option value="'.$d1.'"'.(sth() == $d1 ? ' selected' : false).'>Ambiance</option>
     264                                    <option value="'.$d2.'"'.(sth() == $d2 ? ' selected' : false).'>Chaos</option>
     265                                    <option value="'.$d3.'"'.(sth() == $d3 ? ' selected' : false).'>Clouds Midnight</option>
     266                                    <option value="'.$d4.'"'.(sth() == $d4 ? ' selected' : false).'>Cobalt</option>
     267                                    <option value="'.$d5.'"'.(sth() == $d5 ? ' selected' : false).'>idle Fingers</option>
     268                                    <option value="'.$d6.'"'.(sth() == $d6 ? ' selected' : false).'>krTheme</option>
     269                                    <option value="'.$d7.'"'.(sth() == $d7 ? ' selected' : false).'>Merbivore</option>
     270                                    <option value="'.$d8.'"'.(sth() == $d8 ? ' selected' : false).'>Merbivore Soft</option>
     271                                    <option value="'.$d9.'"'.(sth() == $d9 ? ' selected' : false).'>Mono Industrial</option>
     272                                    <option value="'.$d10.'"'.(sth() == $d10 ? ' selected' : false).'>Monokai</option>
     273                                    <option value="'.$d11.'"'.(sth() == $d11 ? ' selected' : false).'>Pastel on dark</option>
     274                                    <option value="'.$d12.'"'.(sth() == $d12 ? ' selected' : false).'>Solarized Dark</option>
     275                                    <option value="'.$d13.'"'.(sth() == $d13 ? ' selected' : false).'>Terminal</option>
     276                                    <option value="'.$d14.'"'.(sth() == $d14 ? ' selected' : false).'>Tomorrow Night</option>
     277                                    <option value="'.$d15.'"'.(sth() == $d15 ? ' selected' : false).'>Tomorrow Night Blue</option>
     278                                    <option value="'.$d16.'"'.(sth() == $d16 ? ' selected' : false).'>Tomorrow Night Bright</option>
     279                                    <option value="'.$d17.'"'.(sth() == $d17 ? ' selected' : false).'>Tomorrow Night 80s</option>
     280                                    <option value="'.$d18.'"'.(sth() == $d18 ? ' selected' : false).'>Twilight</option>
     281                                    <option value="'.$d19.'"'.(sth() == $d19 ? ' selected' : false).'>Vibrant Ink</option>
     282                                </optgroup>
     283                            </select>
     284                        </form>';
     285                        // Hidden view/erase button for blog id > 1 (security fix in multisite)
     286                        if(get_current_blog_id() == 1)
     287                        {
     288                            // If no backup exist, disable button!
     289                            $glob = glob(plugin_basedir()."/my_custom_css/bkk/*.css");
     290                            if ($glob == false)
     291                            {
     292                                $submit_backup = 'value="' .  __('No backup found...','my-custom-css') . '" title="' .  __('No backup found...','my-custom-css') . '" disabled';
     293                            }
     294                            else
     295                            {
     296                                $submit_backup = 'value="' .  __('View backups :)','my-custom-css') . '" title="' .  __('Click to view all backups!','my-custom-css') . '" ';
     297                            }
     298                        echo '
     299                        <form id="backup" method="post" action="'.admin_url( 'admin.php' ).'?page=my_custom_css">
     300                            <label for="backup">' .  __('Backup:','my-custom-css') . '</label>
     301                            <input type="submit" style="vertical-align: middle" name="viewbackup" class="button-secondary" '.$submit_backup.' />
     302                        </form>';
     303                        }       
     304                    echo'
     305                    <form id="my-custom-css" method="post" action="options.php">';
     306                    settings_fields( 'mccss_settings' );
     307                    echo "
     308                        <div id=\"my_custom_css_container\">
     309                            <div name=\"my_custom_css\" id=\"my_custom_css\"></div>
     310                        </div>
     311                        <textarea id=\"my_custom_css_textarea\" name=\"my_custom_css\" style=\"display: none;\">".get_option('my_custom_css')."</textarea>
     312                        <input type=\"submit\" name=\"save\" class=\"button-primary\" value=\"" .  __('Save','my-custom-css') . "\" />
     313                    </form>";
     314            }
     315
     316            // View backup (view only css)
     317            else if(isset($_POST['viewbackup']))
     318            {
     319                date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
     320                $bd = plugin_basedir()."/my_custom_css/bkk/";
     321                $files=array();
     322                if ($dh=opendir($bd))
     323                {
     324                    while (($file=readdir($dh))!==false)
     325                    if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file))
     326                        $files[filemtime($bd.$file)]=$file;
     327                    closedir($dh);
     328                }
     329                krsort($files);
     330                reset($files);
     331                $href = plugin_url()."/my_custom_css/bkk/";
     332                echo '
     333                    <h2 style="float:left">' .  __('My custom CSS - Backup','my-custom-css') . '</h2>';
     334                echo '
     335                    <form method="post" action="" style="float: right; margin-top: 10px;">
     336                        <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="location.reload();" style="padding: 2px 5px" />
     337                         |
     338                        <input type="submit" name="erasebackup" class="button" value="' .  __('Erase all backup','my-custom-css') . '" style="color: red; padding: 2px 5px" onclick="return confirm(\'' .  __('Do you want really delete all backup?','my-custom-css') . '\');" />
     339                    </form>
     340                    <br />';
     341                while (list($date,$file)=each($files))
     342                echo '
     343                    <div class="backup_list">
     344                        <p><b>' .  __('File:','my-custom-css') . '</b> <a href="'.$href.$file.'">'.$href.$file.'</a></p>
     345                        <p><b>' .  __('Path:','my-custom-css') . '</b> '.$bd.$file.'</p>
     346                        <p><b>' .  __('Saved:','my-custom-css') . '</b> '.date("M d Y | h:i:s (a)",current_time($date)).'</p>
     347                        <p><b>' .  __('Size:','my-custom-css') . '</b> '.(round(filesize($bd.$file). " bytes")).' bytes</p>
     348                    </div>';
     349            }
     350
     351            // Erase backup:
     352            else if(isset($_POST['erasebackup']))
     353            {
     354            echo '
     355                <h2 style="float:left">' .  __('My custom CSS - Erase Backup','my-custom-css') . '</h2>';
     356            echo '
     357                <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="location.reload();" style="float: right; margin-top: 10px;" />
     358                <br />';
     359                foreach (glob(plugin_basedir()."/my_custom_css/bkk/*.css") as $filename)
     360                {
     361                echo '
     362                    <div class="backup_list">
     363                        '.$filename.' - ' . filesize($filename) . '' .  __('bytes, was successfully deleted!!!','my-custom-css') . '
     364                    </div>';
     365                    unlink($filename);
     366                }
     367            }
     368            echo '
     369            <div id="mccss_credit">
     370                <a href="https://wordpress.org/plugins/my-custom-css/" title="My Custom CSS">My Custom CSS v'.$plugin_version.'</a> | Author: <a href="https://laltroweb.it/" title="Salvatore Noschese - (L\'AltroWeb)">Salvatore Noschese</a> - Support my work: <a href="https://www.paypal.me/SalvatoreN" title="Even 1$ can help... :)">Donate :)</a>
     371            </div>
     372            <!-- Smooth Scroll --><a href="#" class="scrollup">&#9650;</a><!-- Smooth Scroll -->
     373        </div>';
     374    }
     375   
     376    // Make backup when save!
     377    if(isset($_POST['save']))
     378    {
     379        $directory = plugin_basedir()."/my_custom_css/bkk/*.css";
     380        if (glob($directory) != false)
     381        {
     382            $filecount = count(glob($directory))+1;
     383        }
     384        else
     385        {
     386            $filecount = 1;
     387        }
     388        $oldname = css_path();
     389        $newname = plugin_basedir().'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
     390        rename($oldname, $newname);
     391    }
     392
     393    // Register Settings
     394    function mycustomcss_registersetting() { register_setting('mccss_settings','my_custom_css'); }
     395
     396    // Admin section:
     397    function mycustomcss_admin()
     398    {
     399        $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_admin_page', plugin_dir_url(__FILE__).'/mccss.png', 61);
     400        add_action('admin_init', 'mycustomcss_registersetting');
     401        add_action('admin_head-'. $plugin_page, 'mycustomcss_scripts');
     402        // Disable "WP Editor" in this page if is active: http://wordpress.org/extend/plugins/wp-editor/
     403    }
     404
     405    add_action('admin_menu', 'mycustomcss_admin');
     406    add_action('wp_head', 'mycustomcss_head', 99999);
     407    add_action('admin_print_styles', 'mycustomcss_admin_style');
     408    add_filter('plugin_row_meta', 'add_plugin_meta_links', 10, 2);
     409    add_filter('plugin_action_links_'.plugin_basename(__FILE__).'', 'mycustomcss_links');
     410   
    19411}
    20 
    21 // Text Domain: my-custom-css
    22 load_plugin_textdomain('my-custom-css', false, dirname(plugin_basename(__FILE__)) . '/lang/');
    23 
    24 
    25 function mystylecss_basedir()
    26 {
    27     $upload_dir = wp_upload_dir();
    28     $mystylecss_basedir = $upload_dir['basedir'];
    29     return $mystylecss_basedir;
    30 }
    31 function mystylecss_url()
    32 {
    33     $upload_dir = wp_upload_dir();
    34     $mystylecss_url = set_url_scheme($upload_dir['baseurl']);
    35     return $mystylecss_url;
    36 }
    37 
    38 // Fix old backup folder or no exist
    39 if (!is_dir(mystylecss_basedir().'/my_custom_css/bkk'))
    40 {
    41     wp_mkdir_p(mystylecss_basedir().'/my_custom_css/bkk');
    42 }
    43 // And Blank index.html to prevent listing directory
    44 else if(!file_exists(mystylecss_basedir()."/my_custom_css/index.html") || !file_exists(mystylecss_basedir()."/my_custom_css/bkk/index.html"))
    45 {
    46     file_put_contents(mystylecss_basedir()."/my_custom_css/index.html", "<!-- Prevent Directory Listing -->");
    47     file_put_contents(mystylecss_basedir()."/my_custom_css/bkk/index.html", "<!-- Prevent Directory Listing -->");
    48 }
    49 
    50 // Generate my_style_id url:
    51 function my_style_id()
    52 {
    53     $blog_id = get_current_blog_id(); $cssid = ( $blog_id > "1" ) ? $cssid = "_id-".$blog_id : $cssid = null;
    54     $my_style_id = "/my_custom_css/my_style".$cssid.".css";
    55     return $my_style_id;
    56 }
    57 
    58 // Generate css url:
    59 function css_url()
    60 {
    61     $css_url = mystylecss_url().my_style_id();
    62     return $css_url;
    63 }
    64 
    65 // Generate css path:
    66 function css_path()
    67 {
    68     $css_path = mystylecss_basedir().my_style_id();
    69     return $css_path;
    70 }
    71 
    72 // make my_style.css and write write css code!
    73 function mycustomcss()
    74 {
    75     // Strip tag for security reason!
    76     $mycustomcss = strip_tags(get_option('my_custom_css'));
    77     return $mycustomcss;
    78 }
    79 
    80 function mycustomcss_head()
    81 {
    82     $mycustomcss = mycustomcss();
    83     if (!empty($mycustomcss))
    84     {
    85         // Write in source!
    86         echo "\n<!-- My Custom CSS -->\n<link rel='stylesheet' id='mccss_stylesheet' href='".css_url()."?".@filemtime(css_path())."' type='text/css' media='all' />\n<!-- My Custom CSS -->\n";
    87     }
    88 }
    89 
    90 function makecss()
    91 {
    92     $makecss = file_put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. L'altroWeb - https://laltroweb.it/\n*/\n/********* Do not edit this file *********/\n\n".mycustomcss());
    93     return $makecss;
    94 }
    95 
    96 // Fix first upgrade from old release or manual my_style.css deletion!
    97 if (!file_exists(css_path()))
    98 {
    99     makecss();
    100 }
    101 
    102 // Start Add link on plugins page
    103 function mycustomcss_links($links)
    104 {
    105     # Settings:
    106     $settings_link = '<a href="admin.php?page=my_custom_css" title="My Custom CSS">'.__('Settings','my-custom-css').'</a>';
    107     array_unshift($links, $settings_link);
    108     # Support:
    109     $support_forum = '<a href="https://laltroweb.it/" title="laltroweb.it">'.__('Support','my-custom-css').'</a>';
    110     array_unshift($links, $support_forum);
    111     # return:
    112     return $links;
    113 }
    114 function add_plugin_meta_links($links, $file)
    115 {
    116     if ($file == plugin_basename(__FILE__))
    117     {
    118         $links[] = '<a href="https://www.paypal.me/SalvatoreN" title="Buy Me a Beer ;)">Donate :)</a>';
    119     }
    120     return $links;
    121 }
    122 // End Add link on plugins page
    123 
    124 // Change the CSS for this plugin on admin plugins page
    125 function mycustomcss_admin_style()
    126 {
    127     global $pagenow;
    128     if ($pagenow == "plugins.php")
    129     {
    130         echo "<style type='text/css'>\n#my-custom-css td.plugin-title strong {\n\tbackground: url('".plugin_dir_url(__FILE__)."/mccss.png') no-repeat scroll 115px 2px;\n}\n#my-custom-css div.row-actions-visible {\n\tpadding-top: 15px;\n}\n#my-custom-css div.plugin-version-author-uri {\n\tbackground-color: #EAEAEA;\n\tborder-radius: 5px;\n\tbox-shadow: 0 8px 6px -6px gray; \n\tfont-weight: bold; \n\tpadding: 7px; \n\tmargin-bottom: 12px;\n}\n</style>\n";
    131     }
    132 }
    133 
    134 
    135 // Make backup when save!
    136 if(isset($_POST['save']))
    137 {
    138     $directory = mystylecss_basedir()."/my_custom_css/bkk/*.css";
    139     if (glob($directory) != false)
    140     {
    141         $filecount = count(glob($directory))+1;
    142     }
    143     else
    144     {
    145         $filecount = 1;
    146     }
    147     $oldname = css_path();
    148     $newname = mystylecss_basedir().'/my_custom_css/bkk/' . ( $filecount ++ ) . $cssid . '_' . filemtime($oldname) .'.css';
    149     rename($oldname, $newname);
    150 }
    151 
    152 // View backup (view only css)
    153 if(isset($_POST['viewbackup']))
    154 {
    155     $directory = mystylecss_basedir()."/my_custom_css/bkk/";
    156     $files=array();
    157     if ($dh=opendir($directory))
    158     {
    159         while (($file=readdir($dh))!==false)
    160         if ($file!="." && $file!=".." && preg_match("/\.(css)$/", $file))
    161             $files[filemtime($directory.$file)]=$file;
    162         closedir($dh);
    163     }
    164 
    165     krsort($files);
    166     reset($files);
    167     $href = mystylecss_url()."/my_custom_css/bkk/";
    168     date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
    169 
    170 echo '
    171 <!DOCTYPE html>
    172 <html>
    173   <head>
    174     <title>' .  __('My custom CSS - Backup','my-custom-css') . '</title>
    175   </head>
    176     <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">';
    177     if (glob($directory."*.css") == false)
    178     {
    179     echo '
    180     <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="self.close()" style="margin: 0px 20px; float: right" />
    181     <br />
    182     <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff">
    183         ' .  __("I can't list any *.css: 'No file found'... ","my-custom-css") . '
    184     </div>';
    185     }
    186     else
    187     {
    188     echo '
    189     <form method="post" action="'. admin_url( 'admin.php' ) .'?action=my_custom_css?erase_backup" style="margin-right: 20px; float: right">
    190         <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="self.close()" style="padding: 2px 5px" />
    191          |
    192         <input type="submit" name="erasebackup" class="button" value="' .  __('Erase all backup','my-custom-css') . '" style="color: red; padding: 2px 5px" onclick="return confirm(\'' .  __('Do you want really delete all backup?','my-custom-css') . '\');" />
    193     </form>
    194     <br />';
    195     while (list($date,$file)=each($files))
    196     echo '
    197     <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff">
    198     <p><b>' .  __('File:','my-custom-css') . '</b> <a href="'.$href.$file.'">'.$href.$file.'</a></p>
    199     <p><b>' .  __('Path:','my-custom-css') . '</b> '.$directory.$file.'</p>
    200     <p><b>' .  __('Saved:','my-custom-css') . '</b> '.date("M d Y | h:i:s (a)",current_time($date)).'</p>
    201     <p><b>' .  __('Size:','my-custom-css') . '</b> '.(round(filesize($directory.$file). " bytes")).' bytes</p>
    202     </div>';
    203     }
    204     echo '
    205   </body>
    206 </html>';
    207 }
    208 
    209 
    210 // Erase backup:
    211 if(isset($_POST['erasebackup']))
    212 {
    213 echo '
    214 <!DOCTYPE html>
    215 <html>
    216   <head>
    217     <title>' .  __('My custom CSS - Erase Backup','my-custom-css') . '</title>
    218   </head>
    219     <body style="background: #F1F1F1; padding: 20px; width: 90%; margin: 20px auto; border: 1px 0 dotted gray">';
    220     $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css");
    221     if ($glob == false)
    222     {
    223     echo '
    224     <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="self.close()" style="margin: 0px 20px; float: right" />
    225     <br />
    226     <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff">
    227         ' .  __("I can't delete any *.css: 'No file found'... ","my-custom-css") . '
    228     </div>';
    229     }
    230     else
    231     {
    232         echo '
    233         <input type="button" value="' .  __('Close now!','my-custom-css') . '" onclick="self.close()" style="margin: 0px 20px; float: right" />
    234         <br />';
    235         foreach (glob(mystylecss_basedir()."/my_custom_css/bkk/*.css") as $filename)
    236         {
    237         echo '
    238         <div style="border: 1px dotted gray; margin: 20px; padding: 10px; background: #fff">
    239             '.$filename.' - ' . filesize($filename) . '' .  __('bytes, was successfully deleted!!!','my-custom-css') . '
    240         </div>';
    241         unlink($filename);
    242         }
    243     }
    244         echo '
    245   </body>
    246 </html>';
    247 }
    248 
    249 function set_theme()
    250 {
    251     if (isset($_POST["themelist"]) && !empty($_POST["themelist"]))
    252     {
    253         $settheme = $_POST["themelist"];
    254     }
    255     else if (!isset($_COOKIE['_mccss_ace_themelist_']))
    256     {
    257         $settheme = 'ace/theme/chrome';
    258     }
    259     else
    260     {
    261         $settheme = $_COOKIE['_mccss_ace_themelist_'];
    262     }
    263     return $settheme;
    264 }
    265 
    266 // Option page code:
    267 function mycustomcss_scripts()
    268 {
    269 echo '
    270 <!-- Start My Custom CSS Code -->
    271 <!-- Ace Editor -->
    272 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ace.js" charset="utf-8"></script>
    273 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ext-searchbox.js" charset="utf-8"></script>
    274 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/ext-language_tools.js" charset="utf-8"></script>
    275 <script type="text/javascript">
    276 // Ace Setting
    277 ( function( global, $ ) {
    278     var editor,
    279         syncCSS = function() {
    280             $( \'#my_custom_css_textarea\' ).val( editor.getSession().getValue() );
    281         },
    282         loadAce = function() {
    283             editor = ace.edit( \'my_custom_css\' );
    284             editor.session.setMode("ace/mode/css");
    285             global.safecss_editor = editor;
    286             editor.getSession().setUseWrapMode( true );
    287             editor.setShowPrintMargin( false );
    288             editor.getSession().setValue( $( \'#my_custom_css_textarea\' ).val() );
    289             editor.setOptions({maxLines: Infinity});
    290             editor.setTheme("'.set_theme().'");
    291             editor.setOptions({minLines: 10});
    292             editor.execCommand("find");
    293             // enable autocompletion and snippets
    294             ace.require("ace/ext/language_tools");
    295                 editor.setOptions({
    296                 enableBasicAutocompletion: true,
    297                 enableSnippets: true,
    298                 enableLiveAutocompletion: true
    299             });
    300             jQuery.fn.spin&&$( \'#my_custom_css_container\' ).spin( false );
    301             $( \'#my-custom-css\' ).submit( syncCSS );
    302         };
    303     if ( $.browser.msie&&parseInt( $.browser.version, 10 ) <= 7 ) {
    304         $( \'#my_custom_css_container\' ).hide();
    305         $( \'#my_custom_css_textarea\' ).show();
    306         return false;
    307     } else {
    308         $( global ).load( loadAce );
    309     }
    310     global.aceSyncCSS = syncCSS;
    311 } )( this, jQuery );
    312 </script>
    313 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/_scrolltop.js"></script>
    314 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/cookie.js"></script>
    315 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/textresizer.min.js"></script>
    316 <script type="text/javascript" src="'.plugin_dir_url(__FILE__).'editor/textresizer/textresizer_target.js"></script>
    317 <!-- CSS Code -->
    318 <link rel="stylesheet" id="ace-editor-custom-css" href="'.plugin_dir_url(__FILE__).'editor/ace_custom.css" type="text/css" media="all" />
    319 <!-- End My Custom CSS Code -->
    320 ';
    321 }
    322 // Register Settings
    323 function mycustomcss_registersetting()
    324 {
    325     register_setting('mccss_settings','my_custom_css');
    326 }
    327 
    328 // Textarea/Form:
    329 function mccss_options()
    330 {
    331     // Get plugin version:
    332     $plugin_data = get_plugin_data(__FILE__);
    333     $plugin_version = $plugin_data['Version'];
    334    
    335     // BrightTheme
    336     $chrome = 'ace/theme/chrome';
    337     $clouds = 'ace/theme/clouds';
    338     $crimson_editor = 'ace/theme/crimson_editor';
    339     $dawn = 'ace/theme/dawn';
    340     $dreamweaver = 'ace/theme/dreamweaver';
    341     $eclipse = 'ace/theme/eclipse';
    342     $github = 'ace/theme/github';
    343     $iplastic = 'ace/theme/iplastic';
    344     $solarized_light = 'ace/theme/solarized_light';
    345     $textmate = 'ace/theme/textmate';
    346     $tomorrow = 'ace/theme/tomorrow';
    347     $xcode = 'ace/theme/xcode';
    348     $kuroir = 'ace/theme/kuroir';
    349     $katzenmilch = 'ace/theme/katzenmilch';
    350     $sqlserver = 'ace/theme/sqlserver';
    351     // DarkTheme
    352     $ambiance = 'ace/theme/ambiance';
    353     $chaos = 'ace/theme/chaos';
    354     $clouds_midnight = 'ace/theme/clouds_midnight';
    355     $cobalt = 'ace/theme/cobalt';
    356     $idle_fingers = 'ace/theme/idle_fingers';
    357     $kr_theme = 'ace/theme/kr_theme';
    358     $merbivore = 'ace/theme/merbivore';
    359     $merbivore_soft = 'ace/theme/merbivore_soft';
    360     $mono_industrial = 'ace/theme/mono_industrial';
    361     $monokai = 'ace/theme/monokai';
    362     $pastel_on_dark = 'ace/theme/pastel_on_dark';
    363     $solarized_dark = 'ace/theme/solarized_dark';
    364     $terminal = 'ace/theme/terminal';
    365     $tomorrow_night = 'ace/theme/tomorrow_night';
    366     $tomorrow_night_blue = 'ace/theme/tomorrow_night_blue';
    367     $tomorrow_night_bright = 'ace/theme/tomorrow_night_bright';
    368     $tomorrow_night_eighties = 'ace/theme/tomorrow_night_eighties';
    369     $twilight = 'ace/theme/twilight';
    370     $vibrant_ink = 'ace/theme/vibrant_ink';
    371 
    372 echo '
    373 <div class="wrap">
    374     <h2>' .  __('My Custom CSS Panel','my-custom-css') . ' - v'.$plugin_version.'</h2>
    375         <div id="textsizer">
    376             <p>' .  __('Font Size:','my-custom-css') . '</p>
    377                 <ul class="textresizer">
    378                   <li><a href="#nogo" class="small-text" title="12px (Small)">A-</a></li>
    379                   <li><a href="#nogo" class="medium-text" title="14px (Medium)">A</a></li>
    380                   <li><a href="#nogo" class="large-text" title="16px (Large)">A+</a></li>
    381                   <li><a href="#nogo" class="larger-text" title="18px (Larger)">A++</a></li>
    382                   <li><a href="#nogo" class="giga-text" title="26px (Giga)">A+++</a></li>
    383                 </ul>
    384         </div>
    385         <form action="'.admin_url( 'admin.php' ).'?page=my_custom_css" method="post" id="thememenu">
    386             <label for="theme">' .  __('Theme:','my-custom-css') . '</label>
    387                 <select name="themelist" id="themelist" onchange="if(confirm(\'' .  __('Warning!!! This will refresh entire page (Unsaved data will be lost) - Continue?','my-custom-css') . '\')){this.form.submit()}">
    388                     <optgroup label="' .  __('Bright:','my-custom-css') . '">
    389                         <option value="'.$chrome.'"'.(set_theme() == $chrome ? ' selected="selected"' : false).'>Chrome</option>
    390                         <option value="'.$clouds.'"'.(set_theme() == $clouds ? ' selected="selected"' : false).'>Clouds</option>
    391                         <option value="'.$crimson_editor.'"'.(set_theme() == $crimson_editor ? ' selected="selected"' : false).'>Crimson Editor</option>
    392                         <option value="'.$dawn.'"'.(set_theme() == $dawn ? ' selected="selected"' : false).'>Dawn</option>
    393                         <option value="'.$dreamweaver.'"'.(set_theme() == $dreamweaver ? ' selected="selected"' : false).'>Dreamweaver</option>
    394                         <option value="'.$eclipse.'"'.(set_theme() == $eclipse ? ' selected="selected"' : false).'>Eclipse</option>
    395                         <option value="'.$github.'"'.(set_theme() == $github ? ' selected="selected"' : false).'>GitHub</option>
    396                         <option value="'.$iplastic.'"'.(set_theme() == $iplastic ? ' selected="selected"' : false).'>IPlastic</option>
    397                         <option value="'.$solarized_light.'"'.(set_theme() == $solarized_light ? ' selected="selected"' : false).'>Solarized Light</option>
    398                         <option value="'.$textmate.'"'.(set_theme() == $textmate ? ' selected="selected"' : false).'>TextMate</option>
    399                         <option value="'.$tomorrow.'"'.(set_theme() == $tomorrow ? ' selected="selected"' : false).'>Tomorrow</option>
    400                         <option value="'.$xcode.'"'.(set_theme() == $xcode ? ' selected="selected"' : false).'>XCode</option>
    401                         <option value="'.$kuroir.'"'.(set_theme() == $kuroir ? ' selected="selected"' : false).'>Kuroir</option>
    402                         <option value="'.$katzenmilch.'"'.(set_theme() == $katzenmilch ? ' selected="selected"' : false).'>KatzenMilch</option>
    403                         <option value="'.$sqlserver.'"'.(set_theme() == $sqlserver ? ' selected="selected"' : false).'>SQL Server</option>
    404                     </optgroup>
    405                     <optgroup label="' .  __('Dark:','my-custom-css') . '">
    406                         <option value="'.$ambiance.'"'.(set_theme() == $ambiance ? ' selected="selected"' : false).'>Ambiance</option>
    407                         <option value="'.$chaos.'"'.(set_theme() == $chaos ? ' selected="selected"' : false).'>Chaos</option>
    408                         <option value="'.$clouds_midnight.'"'.(set_theme() == $clouds_midnight ? ' selected="selected"' : false).'>Clouds Midnight</option>
    409                         <option value="'.$cobalt.'"'.(set_theme() == $cobalt ? ' selected="selected"' : false).'>Cobalt</option>
    410                         <option value="'.$idle_fingers.'"'.(set_theme() == $idle_fingers ? ' selected="selected"' : false).'>idle Fingers</option>
    411                         <option value="'.$kr_theme.'"'.(set_theme() == $kr_theme ? ' selected="selected"' : false).'>krTheme</option>
    412                         <option value="'.$merbivore.'"'.(set_theme() == $merbivore ? ' selected="selected"' : false).'>Merbivore</option>
    413                         <option value="'.$merbivore_soft.'"'.(set_theme() == $merbivore_soft ? ' selected="selected"' : false).'>Merbivore Soft</option>
    414                         <option value="'.$mono_industrial.'"'.(set_theme() == $mono_industrial ? ' selected="selected"' : false).'>Mono Industrial</option>
    415                         <option value="'.$monokai.'"'.(set_theme() == $monokai ? ' selected="selected"' : false).'>Monokai</option>
    416                         <option value="'.$pastel_on_dark.'"'.(set_theme() == $pastel_on_dark ? ' selected="selected"' : false).'>Pastel on dark</option>
    417                         <option value="'.$solarized_dark.'"'.(set_theme() == $solarized_dark ? ' selected="selected"' : false).'>Solarized Dark</option>
    418                         <option value="'.$terminal.'"'.(set_theme() == $terminal ? ' selected="selected"' : false).'>Terminal</option>
    419                         <option value="'.$tomorrow_night.'"'.(set_theme() == $tomorrow_night ? ' selected="selected"' : false).'>Tomorrow Night</option>
    420                         <option value="'.$tomorrow_night_blue.'"'.(set_theme() == $tomorrow_night_blue ? ' selected="selected"' : false).'>Tomorrow Night Blue</option>
    421                         <option value="'.$tomorrow_night_bright.'"'.(set_theme() == $tomorrow_night_bright ? ' selected="selected"' : false).'>Tomorrow Night Bright</option>
    422                         <option value="'.$tomorrow_night_eighties.'"'.(set_theme() == $tomorrow_night_eighties ? ' selected="selected"' : false).'>Tomorrow Night 80s</option>
    423                         <option value="'.$twilight.'"'.(set_theme() == $twilight ? ' selected="selected"' : false).'>Twilight</option>
    424                         <option value="'.$vibrant_ink.'"'.(set_theme() == $vibrant_ink ? ' selected="selected"' : false).'>Vibrant Ink</option>
    425                     </optgroup>
    426                 </select>
    427         </form>';
    428         if (isset($_POST["themelist"]) && !empty($_POST["themelist"]))
    429         {
    430             setcookie('_mccss_ace_themelist_', $_POST['themelist'], time()+31556926 ,'/');
    431         }
    432     echo'
    433     <form id="my-custom-css" method="post" action="options.php">';
    434     settings_fields( 'mccss_settings' );
    435 echo '
    436         <div id="my_custom_css_container">
    437             <div name="my_custom_css" id="my_custom_css"></div>
    438         </div>
    439         <textarea id="my_custom_css_textarea" name="my_custom_css" style="display: none;">'.get_option('my_custom_css').'</textarea>
    440         <input type="submit" name="save" class="button-primary" value="' .  __('Save','my-custom-css') . '" />
    441     </form>
    442     <div id="mccss_credit">
    443         <a href="https://wordpress.org/plugins/my-custom-css/" title="My Custom CSS">My Custom CSS v'.$plugin_version.'</a> | Author: <a href="https://laltroweb.it/" title="Salvatore Noschese - (L\'AltroWeb)">Salvatore Noschese</a> - Support my work: <a href="https://www.paypal.me/SalvatoreN" title="Even 1$ can help... :)">Donate :)</a>
    444     </div>';
    445 
    446 // Hidden view/erase button for blog id > 1 (security fix in multisite)
    447 $blog_id = get_current_blog_id();
    448 if($blog_id == 1)
    449 {
    450     // If no backup exist, disable button!
    451     $glob = glob(mystylecss_basedir()."/my_custom_css/bkk/*.css");
    452     if ($glob == false) { $submit_backup = 'value="' .  __('No backup found...','my-custom-css') . '" title="' .  __('No backup found...','my-custom-css') . '" disabled'; }
    453     else { $submit_backup = 'value="' .  __('View backups :)','my-custom-css') . '" title="' .  __('Click to view all backups!','my-custom-css') . '" '; }
    454 echo '
    455     <form method="post" action="'.admin_url( 'admin.php' ).'?action=my_custom_css?show_backup" target="_blank">
    456         <input type="submit" name="viewbackup" class="button-secondary" '.$submit_backup.' />
    457     </form>';
    458 }
    459 echo '
    460     <!-- Smooth Scroll -->
    461         <a href="#" class="scrollup">&#9650;</a>
    462     <!-- Smooth Scroll -->
    463 </div>';
    464 
    465     // Ok, save css!!!     
    466     makecss();
    467 }
    468 
    469 
    470 // Admin section:
    471 function mycustomcss_admin()
    472 {
    473     $plugin_page = add_menu_page(__('My Custom CSS Panel','my-custom-css'),__('My Custom CSS','my-custom-css'), 'manage_options', 'my_custom_css', 'mccss_options', plugin_dir_url(__FILE__).'/mccss.png', 61);
    474     add_action('admin_init', 'mycustomcss_registersetting');
    475     add_action('admin_head-'. $plugin_page, 'mycustomcss_scripts');
    476     // Disable "WP Editor" in this page if is active: http://wordpress.org/extend/plugins/wp-editor/
    477     If (is_plugin_active("wp-editor/wpeditor.php") && $_SERVER['QUERY_STRING'] == 'page=my_custom_css')
    478     {
    479         function remove_wpeditor_header_info()
    480         {
    481         // Wp Editor Style
    482         wp_deregister_style('wpeditor');
    483         wp_deregister_style('fancybox');
    484         wp_deregister_style('codemirror');
    485         wp_deregister_style('codemirror_dialog');
    486         wp_deregister_style('codemirror_themes');
    487         // Wp Editor Script
    488         wp_deregister_script('wpeditor');
    489         wp_deregister_script('wp-editor-posts-jquery');
    490         wp_deregister_script('fancybox');
    491         wp_deregister_script('codemirror');
    492         wp_deregister_script('codemirror_php');
    493         wp_deregister_script('codemirror_javascript');
    494         wp_deregister_script('codemirror_css');
    495         wp_deregister_script('codemirror_xml');
    496         wp_deregister_script('codemirror_clike');
    497         wp_deregister_script('codemirror_dialog');
    498         wp_deregister_script('codemirror_search');
    499         wp_deregister_script('codemirror_searchcursor');
    500         wp_deregister_script('codemirror_mustache');
    501         }
    502     add_action('admin_init', 'remove_wpeditor_header_info', 20);
    503     }
    504 }
    505 add_action('admin_menu', 'mycustomcss_admin');
    506 add_action('wp_head', 'mycustomcss_head', 99999);
    507 add_action('admin_print_styles', 'mycustomcss_admin_style');
    508 add_filter('plugin_row_meta', 'add_plugin_meta_links', 10, 2);
    509 add_filter('plugin_action_links_'.plugin_basename(__FILE__).'', 'mycustomcss_links');
    510 
    511 ?>
  • my-custom-css/trunk/readme.txt

    r1287044 r1299322  
    33Donate link: https://www.paypal.me/SalvatoreN
    44Tags: css, style, custom, theme, plugin, stylesheet, darkwolf, laltroweb, ace, cloud9 editor
    5 Requires at least: 3.0
     5Requires at least: 4.0
    66Tested up to: 4.3.1
    7 Stable tag: 2.7
     7Stable tag: 2.8
    88
    99Enable to add Custom CSS Code via admin panel with Ace (Ajax.org Cloud9 Editor)
     
    4949== Upgrade Notice ==
    5050
    51 = 2.7 =
     51= 2.8 =
    5252
    53 * Search bar no longer fixed (caused graphics problems in some circumstances)
     53* More code change/fix (expecially in textarea and search bar).
    5454
    5555== Changelog ==
     56
     57= 2.8 =
     58
     59* More code change/fix/clean (expecially in textarea and search bar) + removed old codemirror fix.
    5660
    5761= 2.7 =
Note: See TracChangeset for help on using the changeset viewer.