| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Extra Metas |
|---|
| 4 | Plugin URI: http://core.trac.wordpress.org/ticket/9657 |
|---|
| 5 | Description: Extra Meta Links Test Plugin. Activate to add an additional Meta Links for testing. Needs a patched template.php to work. |
|---|
| 6 | Version: 0.1 |
|---|
| 7 | Author: hakre |
|---|
| 8 | Author URI: http://codex.wordpress.org/User:Hakre |
|---|
| 9 | */ |
|---|
| 10 | /* Copyright 2009 by the authors |
|---|
| 11 | |
|---|
| 12 | This program is free software; you can redistribute it and/or modify |
|---|
| 13 | it under the terms of the GNU General Public License as published by |
|---|
| 14 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 15 | (at your option) any later version. |
|---|
| 16 | |
|---|
| 17 | This program is distributed in the hope that it will be useful, |
|---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | GNU General Public License for more details. |
|---|
| 21 | |
|---|
| 22 | You should have received a copy of the GNU General Public License |
|---|
| 23 | along with this program; if not, write to the Free Software |
|---|
| 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * extra-metas plugin class |
|---|
| 29 | * |
|---|
| 30 | */ |
|---|
| 31 | class pluginExtraMetas |
|---|
| 32 | { |
|---|
| 33 | /** |
|---|
| 34 | * constructor |
|---|
| 35 | * |
|---|
| 36 | * @return this |
|---|
| 37 | */ |
|---|
| 38 | function pluginExtraMetas() { |
|---|
| 39 | // Add Hook for admin head |
|---|
| 40 | add_filter('admin_head', array($this, 'admin_head')); |
|---|
| 41 | |
|---|
| 42 | // Add Hook for adding extra meta links |
|---|
| 43 | add_filter('screen_meta_extra_metas', array($this, 'screen_meta_extra_metas'), 10, 2); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * admin_head hook function |
|---|
| 48 | * |
|---|
| 49 | * @return void |
|---|
| 50 | */ |
|---|
| 51 | function admin_head() { |
|---|
| 52 | ?> |
|---|
| 53 | <style type="text/css"> |
|---|
| 54 | /** |
|---|
| 55 | * Extra Metas Test Plugin (CSS) |
|---|
| 56 | * |
|---|
| 57 | * my additional styles (diverse color-xyz.css files need to be adopted) |
|---|
| 58 | */ |
|---|
| 59 | #screen-meta-links div.screen-meta-toggle { |
|---|
| 60 | background:transparent url(images/screen-options-left.gif) no-repeat scroll 0 0; |
|---|
| 61 | float:right; |
|---|
| 62 | font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; |
|---|
| 63 | height:22px; |
|---|
| 64 | margin:0 6px 0 0; |
|---|
| 65 | padding:0; |
|---|
| 66 | } |
|---|
| 67 | #screen-meta-links div.screen-meta-toggle a { |
|---|
| 68 | background:transparent url(images/screen-options-right.gif) no-repeat scroll right bottom; |
|---|
| 69 | color:#606060; |
|---|
| 70 | display:block; |
|---|
| 71 | font-size:10px; |
|---|
| 72 | height:22px; |
|---|
| 73 | line-height:22px; |
|---|
| 74 | padding:0 16px 0 6px; |
|---|
| 75 | text-decoration:none; |
|---|
| 76 | text-shadow:0 1px 0 rgba(255, 255, 255, 0.7); |
|---|
| 77 | z-index:1; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | #screen-meta .screen-metas-wrap { |
|---|
| 81 | background-color:#F1F1F1; |
|---|
| 82 | border-color:#DFDFDF; |
|---|
| 83 | -moz-border-radius-bottomleft:4px; |
|---|
| 84 | -moz-border-radius-bottomright:0; |
|---|
| 85 | -moz-border-radius-topleft:0; |
|---|
| 86 | -moz-border-radius-topright:0; |
|---|
| 87 | border-style:none solid solid; |
|---|
| 88 | border-top:0 none; |
|---|
| 89 | border-width:0 1px 1px; |
|---|
| 90 | margin:0 15px; |
|---|
| 91 | padding:8px 12px 12px; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | #screen-meta .screen-metas-wrap h5 { |
|---|
| 95 | font-size:13px; |
|---|
| 96 | margin:8px 0; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | </style> |
|---|
| 100 | <script type="text/javascript"> |
|---|
| 101 | /* <![CDATA[ */ |
|---|
| 102 | /** |
|---|
| 103 | * Extra Metas Test Plugin (javascript/jQuery) |
|---|
| 104 | */ |
|---|
| 105 | jQuery(function($) |
|---|
| 106 | { |
|---|
| 107 | $('#screen-meta-links div.screen-meta-toggle a').click(function() { |
|---|
| 108 | |
|---|
| 109 | var thisLink = $(this); |
|---|
| 110 | var thisWrap = $(this).parent().get(0); |
|---|
| 111 | |
|---|
| 112 | var thisOpened = ($(this).css('background-image').substr($(this).css('background-image').length - 8) == '-up.gif)') ? true : false; |
|---|
| 113 | |
|---|
| 114 | // the simplest mission: handle own (wordpress default links should be added here as well). |
|---|
| 115 | if ($(thisWrap).hasClass('screen-metas-link-wrap')) { |
|---|
| 116 | // clicked on one of 'ours' |
|---|
| 117 | // get thisMeta (the wrap that contains this meta stuff) |
|---|
| 118 | var thisMeta = $('#' + $(thisWrap).attr('id').replace(/-link/, '')); |
|---|
| 119 | // hide others |
|---|
| 120 | if (!thisOpened) { |
|---|
| 121 | $('#contextual-help-link-wrap, #screen-options-link-wrap, .screen-metas-link-wrap').each(function(){ |
|---|
| 122 | if (this != thisWrap) |
|---|
| 123 | $(this).addClass('invisible'); |
|---|
| 124 | }); |
|---|
| 125 | } |
|---|
| 126 | // slide in thisMeta |
|---|
| 127 | $(thisMeta).slideToggle('fast', function(){ |
|---|
| 128 | if ( $(this).hasClass('screen-options-open') ) { |
|---|
| 129 | // update me |
|---|
| 130 | $(thisLink).css({'backgroundImage':'url("images/screen-options-right.gif")'}); |
|---|
| 131 | $(this).removeClass('screen-options-open'); |
|---|
| 132 | // show others |
|---|
| 133 | $('#contextual-help-link-wrap, #screen-options-link-wrap, .screen-metas-link-wrap').removeClass('invisible'); |
|---|
| 134 | } else { |
|---|
| 135 | // update me |
|---|
| 136 | $(thisLink).css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); |
|---|
| 137 | $(this).addClass('screen-options-open'); |
|---|
| 138 | } |
|---|
| 139 | }); |
|---|
| 140 | } else { |
|---|
| 141 | // clicked on others: toggle all of our collection |
|---|
| 142 | $('.screen-metas-link-wrap').toggleClass('invisible'); |
|---|
| 143 | } |
|---|
| 144 | }); |
|---|
| 145 | }); |
|---|
| 146 | </script> |
|---|
| 147 | <?php |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | /** |
|---|
| 151 | * screen_meta_extra_metas hook function |
|---|
| 152 | * |
|---|
| 153 | * @param array $extra_metas extra meta links array |
|---|
| 154 | * @param string $screen current screen |
|---|
| 155 | * @return array filtered extra meta links array |
|---|
| 156 | */ |
|---|
| 157 | function screen_meta_extra_metas($extra_metas, $screen) |
|---|
| 158 | { |
|---|
| 159 | // sample everwhere additional link |
|---|
| 160 | $extra_metas[] = array(__('Extra Meta Test'), '<h5>Test Content</h5><div>This is an Extra Meta Test content</div>'); |
|---|
| 161 | |
|---|
| 162 | return $extra_metas; |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | $oExtraMetas = new pluginExtraMetas(); |
|---|