shortcoder
Last commit date
images
10 years ago
js
10 years ago
languages
10 years ago
readme.txt
10 years ago
sc-admin-css.css
10 years ago
sc-admin-js.js
10 years ago
sc-insert.php
10 years ago
screenshot-1.png
10 years ago
screenshot-2.png
10 years ago
screenshot-3.png
10 years ago
screenshot-4.png
10 years ago
shortcoder.php
10 years ago
sc-insert.php
227 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shortcoder include for inserting and editing shortcodes in post and pages |
| 4 | * v1.3 |
| 5 | **/ |
| 6 | |
| 7 | if ( ! isset( $_GET['TB_iframe'] ) ) |
| 8 | define( 'IFRAME_REQUEST' , true ); |
| 9 | |
| 10 | |
| 11 | // Load WordPress |
| 12 | require_once('../../../wp-load.php'); |
| 13 | |
| 14 | if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) |
| 15 | wp_die(__('You do not have permission to edit posts.')); |
| 16 | |
| 17 | // Load all created shortodes |
| 18 | $sc_options = get_option('shortcoder_data'); |
| 19 | |
| 20 | if( empty($sc_options) ) |
| 21 | die( "Sorry !! No Shortcodes to Insert<br/><a href='" . SC_ADMIN . "' target='_blank'>Create Shortcodes</a>" ); |
| 22 | |
| 23 | ?> |
| 24 | |
| 25 | <html> |
| 26 | <head> |
| 27 | <title>Shortcodes created</title> |
| 28 | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> |
| 29 | <style type="text/css"> |
| 30 | body{ |
| 31 | font: 13px Arial, Helvetica, sans-serif; |
| 32 | padding: 10px; |
| 33 | background: #f2f2f2; |
| 34 | } |
| 35 | h2{ |
| 36 | font-size: 23px; |
| 37 | font-weight: normal; |
| 38 | } |
| 39 | h4{ |
| 40 | margin: 0 0 20px 0; |
| 41 | } |
| 42 | hr{ |
| 43 | border-width: 0px; |
| 44 | margin: 15px 0; |
| 45 | border-bottom: 1px solid #DFDFDF; |
| 46 | } |
| 47 | .sc_wrap{ |
| 48 | border: 1px solid #DFDFDF; |
| 49 | box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); |
| 50 | } |
| 51 | .sc_shortcode{ |
| 52 | border-bottom: 1px solid #CCC; |
| 53 | padding: 0px; |
| 54 | background: #FFF; |
| 55 | } |
| 56 | .sc_shortcode_name{ |
| 57 | cursor: pointer; |
| 58 | padding: 10px; |
| 59 | } |
| 60 | .sc_shortcode_name:hover{ |
| 61 | background: #fbfbfb; |
| 62 | } |
| 63 | .sc_params{ |
| 64 | border: 1px solid #DFDFDF; |
| 65 | background: #F9F9F9; |
| 66 | margin: 0 -1px -1px; |
| 67 | padding: 20px; |
| 68 | display: none; |
| 69 | } |
| 70 | .sc_insert{ |
| 71 | background: linear-gradient(to bottom, #09C, #0087B4); |
| 72 | color: #FFF; |
| 73 | padding: 5px 15px; |
| 74 | border: 1px solid #006A8D; |
| 75 | font-weight: bold; |
| 76 | } |
| 77 | |
| 78 | .sc_insert:hover{ |
| 79 | opacity: 0.8; |
| 80 | } |
| 81 | input[type=text], textarea{ |
| 82 | padding: 5px; |
| 83 | border: 1px solid #CCC; |
| 84 | width: 120px; |
| 85 | margin: 0px 25px 10px 0px; |
| 86 | } |
| 87 | .sc_toggle{ |
| 88 | background: url(images/toggle-arrow.png) no-repeat; |
| 89 | float: right; |
| 90 | width: 16px; |
| 91 | height: 16px; |
| 92 | opacity: 0.4; |
| 93 | } |
| 94 | |
| 95 | .sc_share_iframe{ |
| 96 | background: #FFFFFF; |
| 97 | border: 1px solid #dfdfdf; |
| 98 | -webkit-border-radius: 5px; |
| 99 | -moz-border-radius: 5px; |
| 100 | border-radius: 5px; |
| 101 | -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); |
| 102 | -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); |
| 103 | box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); |
| 104 | } |
| 105 | .sc_credits{ |
| 106 | background: url(images/aw.png) no-repeat; |
| 107 | padding-left: 23px; |
| 108 | color: #8B8B8B; |
| 109 | margin-left: -5px; |
| 110 | font-size: 13px; |
| 111 | text-decoration: none; |
| 112 | } |
| 113 | </style> |
| 114 | <script type="text/javascript"> |
| 115 | $(document).ready(function(){ |
| 116 | |
| 117 | $('.sc_shortcode_name').append('<span class="sc_toggle"></span>'); |
| 118 | |
| 119 | $('.sc_insert').click(function(){ |
| 120 | var params = ''; |
| 121 | var scname = $(this).attr('data-name'); |
| 122 | var sc = ''; |
| 123 | |
| 124 | $(this).parent().children().find('input[type="text"]').each(function(){ |
| 125 | if($(this).val() != ''){ |
| 126 | attr = $(this).attr('data-param'); |
| 127 | val = $(this).val(); |
| 128 | params += attr + '="' + val + '" '; |
| 129 | } |
| 130 | }); |
| 131 | |
| 132 | // Not used |
| 133 | if(wsc(scname)){ |
| 134 | name = '"' + scname + '"'; |
| 135 | }else{ |
| 136 | name = scname; |
| 137 | } |
| 138 | // |
| 139 | |
| 140 | sc = '[sc name="' + scname + '" ' + params + ']'; |
| 141 | |
| 142 | if( typeof parent.send_to_editor !== undefined ){ |
| 143 | parent.send_to_editor(sc); |
| 144 | } |
| 145 | |
| 146 | }); |
| 147 | |
| 148 | $('.sc_share_bar img').mouseenter(function(){ |
| 149 | $this = $(this); |
| 150 | $('.sc_share_iframe').remove(); |
| 151 | $('body').append('<iframe class="sc_share_iframe"></iframe>'); |
| 152 | $('.sc_share_iframe').css({ |
| 153 | position: 'absolute', |
| 154 | top: $this.offset()['top'] - $this.attr('data-height') - 15, |
| 155 | left: $this.offset()['left'] - $this.attr('data-width')/2 , |
| 156 | width: $this.attr('data-width'), |
| 157 | height: $this.attr('data-height'), |
| 158 | }).attr('src', $this.attr('data-url')).hide().fadeIn(); |
| 159 | |
| 160 | }); |
| 161 | |
| 162 | $('.sc_shortcode_name').click(function(e){ |
| 163 | $('.sc_params').slideUp(); |
| 164 | if($(this).next('.sc_params').is(':visible')){ |
| 165 | $(this).next('.sc_params').slideUp(); |
| 166 | }else{ |
| 167 | $(this).next('.sc_params').slideDown(); |
| 168 | } |
| 169 | }) |
| 170 | |
| 171 | }); |
| 172 | |
| 173 | var sc_closeiframe = function(){ |
| 174 | $('.sc_share_iframe').remove(); |
| 175 | } |
| 176 | |
| 177 | function wsc(s){ |
| 178 | if(s == null) |
| 179 | return ''; |
| 180 | return s.indexOf(' ') >= 0; |
| 181 | } |
| 182 | </script> |
| 183 | </head> |
| 184 | <body> |
| 185 | <?php sc_admin_buttons('fbrec'); ?> |
| 186 | <h2><img src="images/shortcoder.png" align="absmiddle" alt="Shortcoder" width="35px"/> Insert shortcode to editor</h2> |
| 187 | |
| 188 | <div class="sc_wrap"> |
| 189 | <?php |
| 190 | foreach($sc_options as $key=>$value){ |
| 191 | if($key != '_version_fix'){ |
| 192 | echo '<div class="sc_shortcode"><div class="sc_shortcode_name">' . $key; |
| 193 | echo '</div>'; |
| 194 | preg_match_all('/%%[^%\s]+%%/', $value['content'], $matches); |
| 195 | echo '<div class="sc_params">'; |
| 196 | if(!empty($matches[0])){ |
| 197 | echo '<h4>Available parameters: </h4>'; |
| 198 | $temp = array(); |
| 199 | foreach($matches[0] as $k=>$v){ |
| 200 | $cleaned = str_replace('%', '', $v); |
| 201 | if(!in_array($cleaned, $temp)){ |
| 202 | array_push($temp, $cleaned); |
| 203 | echo '<label>' . $cleaned . ': <input type="text" data-param="' . $cleaned . '"/></label> '; |
| 204 | } |
| 205 | } |
| 206 | echo'<hr/>'; |
| 207 | }else{ |
| 208 | echo 'No parameters avaialble - '; |
| 209 | } |
| 210 | echo '<input type="button" class="sc_insert cupid-blue" data-name="' . $key . '" value="Insert Shortcode"/>'; |
| 211 | echo '</div>'; |
| 212 | echo '</div>'; |
| 213 | } |
| 214 | } |
| 215 | ?> |
| 216 | </div> |
| 217 | |
| 218 | <p class="sc_share_bar" align="center"> |
| 219 | <img class="sc_donate" src="images/donate.png" data-width="300" data-height="220" data-url="<?php echo SC_URL . '/js/share.php?i=1'; ?>"/> |
| 220 | |
| 221 | <img class="sc_share" src="images/share.png" data-width="350" data-height="85" data-url="<?php echo SC_URL . '/js/share.php?i=2'; ?>"/> |
| 222 | </p> |
| 223 | |
| 224 | <p align="center"><a class="sc_credits" href="http://www.aakashweb.com/" target="_blank">a Aakash Web plugin</a></p> |
| 225 | |
| 226 | </body> |
| 227 | </html> |