MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once '../../../wp-config.php'; require_once '../../../wp-admin/includes/admin.php'; include_once 'wp-css-files-list.php'; if ($_GET['action'] == "add" && $_GET['file']) { add_post_meta($_GET['id'], 'wp_css_file', $_GET['file']); wp_css_files($_GET['id']); } else { if ($_GET['action'] == "delete" && $_GET['string']) { delete_post_meta($_GET['id'], 'wp_css_file', $_GET['string']); if ($_GET['ajax']) { wp_css_files($_GET['id'], FALSE); } } else { if ($_GET['ajax'] && $_GET['action'] == "view") { wp_css_files($_GET['id']); } else { if ($_GET['action'] == "apply_children_pages") { echo '<a href="javascript:void(0)" onclick="wp_css.applyChildren(this);return false;">Unapply from children pages</a>'; } } } } if (!$_GET['ajax']) { wp_redirect($_SERVER['HTTP_REFERER']); }
function wp_css_files_display() { global $post; ?> <style type="text/css" media="screen"> div#wp-css { position: relative; margin-bottom: 12px; padding: 12px; } div#wp-css h4 { font-size: 14px; } div#wp-css form { } div#wp-css legend { font-size: 14px; font-weight: bold; } div#wp-css label { display: block; float: left; font-size: 12px; width: 80px; } div.wp_css_panel { border: 1px solid #999; font-size: 12px; float: left; padding: 12px; overflow-y: scroll; top: 22px; right: 22px; width: 310px; height: 350px; } div#wp_css_files_added_panel { float: right; } div#wp_css_files_panel { } div.wp_css_panel h4 { font-size: 12px; margin-top: 0; } div.wp_css_panel ul { padding: 0 0 0 14px; margin: 0; } div.wp_css_panel strong { display: block; } div#wp_css_files_list ul, div#wp_css_course_dates_list ul { list-style-type: none; margin: 0; padding: 0; } div#wp_css_files_list ul ul { padding-left: 15px; } div#wp_css_files_list ul ul li { margin: 0; padding: 0; } div#wp_css_files_list a, div#wp_css_course_dates_list a { padding: 8px 0 8px 20px; display: block; text-decoration: none; } div#wp_css_files_list a.add-file, div#wp_css_course_dates_list a { background: url('<?php echo WP_JS_URL; ?> /images/js-file.png') no-repeat center left; } div#wp_css_files_list a.add-file:hover { background: url('<?php echo WP_JS_URL; ?> /images/add.png') no-repeat center left; color: #1CCD00; } div#wp_css_course_dates_list a:hover { background: url('<?php echo WP_JS_URL; ?> /images/delete.png') no-repeat center left; color: #f00; } div#wp_css_files_list a.folder { background: url('<?php echo WP_JS_URL; ?> /images/folder.png') no-repeat center left; padding: 0; } div#wp_css_files_list a.folder span.sign { padding: 0 12px 0 6px; } div#wp_css_loading { background: #fff; display: block; position: absolute; padding: 12px 12px 12px 12px; border: 1px solid #ccc; width: 310px; height: 352px; text-align: center; z-index: 99; } .spinner, div#wp_css_loading span { background: url('<?php echo WP_JS_URL; ?> /images/spinner.gif') no-repeat center left; padding-left: 20px; } div#wp_css_loading span { display: block; font-size: 18px; font-weight: bold; margin: 150px auto 0px auto; width: 210px; } div.wp_css_loading_remove { left: 362px !important } div.wp_css_loading_remove span { width: 240px !important } p#wp_css_apply_to_children span { padding-top: 2px; padding-bottom: 2px; margin-left: 8px; } </style> <div id="wp-css" class="postbox closed"> <h3>WP CSS</h3> <div class="inside"> <h4>Add a CSS file to this <?php echo $post->post_type; ?> </h4> <p>Theme path: /wp-content/themes/<?php echo get_stylesheet(); ?> /</p> <div id="wp_css_files_panel" class="wp_css_panel"> <h4>CSS files in your theme</h4> <div><?php wp_css_files($post->ID, FALSE); ?> </div> </div> <div id="wp_css_files_added_panel" class="wp_css_panel"> <h4>CSS files added</h4> <div><?php wp_css_files($post->ID); ?> </div> </div> <script type="text/javascript" charset="utf-8"> var wp_css = {}; jQuery('#wp_css_files_panel').before('<div id="wp_css_loading"></div>'); jQuery('#wp_css_loading').hide(); wp_css.add = function (a) { jQuery.ajax({ url: a.href+'&ajax=true&action=add', type: 'GET', beforeSend: function() { jQuery('#wp_css_loading').removeClass('wp_css_loading_remove').html('<span>Adding CSS file</span>').fadeIn(); }, complete: function() { jQuery('#wp_css_loading').fadeOut(); }, success: function(txt) { jQuery('#wp_css_files_added_panel div').html(txt); jQuery(a).parent().remove(); }, error: function() { //called when there is an error } }); return false; }; wp_css.remove = function (a) { jQuery.ajax({ url: a.href+'&ajax=true&action=delete', type: 'GET', beforeSend: function() { jQuery('#wp_css_loading').addClass('wp_css_loading_remove').html('<span>Removing CSS file</span>').fadeIn(); }, complete: function() { jQuery('#wp_css_loading').fadeOut(); jQuery('div#wp_css_files_list ul ul').hide(); }, success: function(txt) { jQuery('#wp_css_files_panel div').html(txt); jQuery(a).parent().remove(); }, error: function() { //called when there is an error } }); } jQuery('div#wp_css_files_list ul ul').hide(); wp_css.toogleFolderVar = false; wp_css.toogleFolder = function (a) { var ul = jQuery(jQuery(a).next('ul')); var span = jQuery(jQuery(a).children('span.sign')); if (wp_css.toogleFolderVar == false) { ul.show(); span.html('-'); wp_css.toogleFolderVar = true; } else { ul.hide(); span.html('+'); wp_css.toogleFolderVar = false; } } </script> <br clear="all" /> </div></div> <?php }