Changeset 1422879
- Timestamp:
- 05/24/2016 06:34:57 AM (10 years ago)
- Location:
- wp-shortcode-creator/trunk
- Files:
-
- 6 edited
-
bw-shortcode-creator.php (modified) (5 diffs)
-
inc/add_shortcodes.php (modified) (1 diff)
-
inc/bwshortcodecreator-dbcreate.php (modified) (1 diff)
-
inc/options-page-wrapper.php (modified) (4 diffs)
-
js/bwshortcodecreator_js.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-shortcode-creator/trunk/bw-shortcode-creator.php
r1420591 r1422879 61 61 $bwshortcodecreator_timestamp = time(); 62 62 $bwshortcodecreator_shortcode_attributes = ''; 63 $bwshortcodecreator_shortcode_enable_php = ''; 64 $bwshortcodecreator_shortcode_php = ''; 63 65 $bwshortcodecreator_shortcode_nicename = esc_sql($_POST['bwshortcodecreator_shortcode_nicename']); 64 66 … … 72 74 'shortcode_content' => $bwshortcodecreator_shortcode_content, 73 75 'shortcode_nicename' => $bwshortcodecreator_shortcode_nicename, 74 'shortcode_attributes' => $bwshortcodecreator_shortcode_attributes 76 'shortcode_attributes' => $bwshortcodecreator_shortcode_attributes, 77 'shortcode_enable_php' => $bwshortcodecreator_shortcode_enable_php, 78 'shortcode_php' => $bwshortcodecreator_shortcode_php 75 79 ) 76 80 ); … … 89 93 $bwshortcodecreator_shortcode_nicename = esc_sql($_POST['bwshortcodecreator_shortcode_nicename']); 90 94 $bwshortcodecreator_id = esc_sql($_POST['bwshortcodecreator_edit_shortcode_id']); 91 95 if(isset($_POST['bwshortcodecreator_shortcode_enable_php'])) { 96 $bwshortcodecreator_shortcode_enable_php = 1; 97 $bwshortcodecreator_shortcode_php = esc_sql($_POST['bwshortcodecreator_shortcode_php']); 98 } else { 99 $bwshortcodecreator_shortcode_enable_php = 0; 100 $bwshortcodecreator_shortcode_php = esc_sql($_POST['bwshortcodecreator_shortcode_php']); 101 } 102 92 103 $table_name = $wpdb->prefix.'bwshortcodecreator'; 93 104 … … 99 110 'shortcode_content' => $bwshortcodecreator_shortcode_content, 100 111 'shortcode_nicename' => $bwshortcodecreator_shortcode_nicename, 101 'shortcode_attributes' => $bwshortcodecreator_shortcode_attributes 112 'shortcode_attributes' => $bwshortcodecreator_shortcode_attributes, 113 'shortcode_enable_php' => $bwshortcodecreator_shortcode_enable_php, 114 'shortcode_php' => $bwshortcodecreator_shortcode_php 102 115 ), 103 116 array( 'id' => $bwshortcodecreator_id ) … … 117 130 $wpdb->delete( 118 131 $table_name, 119 array( 'id' => $bwshortcodecreator_id)132 array('id' => $bwshortcodecreator_id) 120 133 ); 121 134 } -
wp-shortcode-creator/trunk/inc/add_shortcodes.php
r1420591 r1422879 9 9 $bwshortcodecreator_shortcode_content= $row->shortcode_content; 10 10 $bwshortcodecreator_shortcode_attributes = $row->shortcode_attributes; 11 $bwshortcodecreator_shortcode_enable_php = $row->shortcode_enable_php; 12 $bwshortcodecreator_shortcode_php = $row->shortcode_php; 11 13 $id = $row->id; 12 14 $bwshortcodecreator_function_name = 'bwshortcodecreator_'.$id; 13 15 eval("add_shortcode( '".$bwshortcodecreator_shortcode_title."', '".$bwshortcodecreator_function_name."' );"); 14 eval(" function ".$bwshortcodecreator_function_name."() { 15 return '".bwshortcodecreator_mynl2br($bwshortcodecreator_shortcode_content)."'; 16 }" 17 ); 16 if($bwshortcodecreator_shortcode_enable_php == 1) { 17 eval(" function ".$bwshortcodecreator_function_name."() { 18 \$custom_php = ".$bwshortcodecreator_shortcode_php."; 19 return bwshortcodecreator_mynl2br(\$custom_php); 20 }" 21 ); 22 } else { 23 eval(" function ".$bwshortcodecreator_function_name."() { 24 return '".bwshortcodecreator_mynl2br($bwshortcodecreator_shortcode_content)."'; 25 }" 26 ); 27 } 18 28 } 19 29 } -
wp-shortcode-creator/trunk/inc/bwshortcodecreator-dbcreate.php
r1420591 r1422879 1 1 <?php 2 3 4 5 2 function bwshortcodecreator_dbcreate() { 6 7 3 global $wpdb; 8 4 $table_name = $wpdb->prefix . "bwshortcodecreator"; 5 $charset_collate = $wpdb->get_charset_collate(); 9 6 10 11 $table_name = $wpdb->prefix . "bwshortcodecreator"; 12 7 $sql = "CREATE TABLE $table_name ( 8 id mediumint(9) NOT NULL AUTO_INCREMENT, 9 timestamp varchar(30) NOT NULL, 10 shortcode_title varchar(100) NOT NULL, 11 shortcode_nicename varchar(100) NOT NULL, 12 shortcode_attributes varchar(500) NOT NULL, 13 shortcode_enable_php int(1) NOT NULL, 14 shortcode_php varchar(5000) NOT NULL, 15 shortcode_content varchar(5000) NOT NULL, 16 UNIQUE KEY id (id) 17 ) $charset_collate;"; 13 18 14 15 $charset_collate = $wpdb->get_charset_collate();16 17 18 19 $sql = "CREATE TABLE $table_name (20 21 id mediumint(9) NOT NULL AUTO_INCREMENT,22 23 timestamp varchar(30) NOT NULL,24 25 shortcode_title varchar(100) NOT NULL,26 27 shortcode_nicename varchar(100) NOT NULL,28 29 shortcode_attributes varchar(500) NOT NULL,30 31 shortcode_content varchar(10000) NOT NULL,32 33 UNIQUE KEY id (id)34 35 ) $charset_collate;";36 37 38 39 19 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 40 41 20 dbDelta( $sql ); 42 43 44 45 $bwshortcodecreator_title = 'exampleshortcode';46 47 $bwshortcodecreator_content = 'This is an example shortcode';48 49 $bwshortcodecreator_timestamp = time();50 51 $bwshortcodecreator_nicename = 'Example Shortcode';52 53 $bwshortcodecreator_attributes = '';54 55 56 57 $wpdb->insert(58 59 $table_name,60 61 array(62 63 'timestamp' => $bwshortcodecreator_timestamp,64 65 'shortcode_title' => $bwshortcodecreator_title,66 67 'shortcode_content' => $bwshortcodecreator_content,68 69 'shortcode_nicename' => $bwshortcodecreator_nicename,70 71 'shortcode_attributes' => $bwshortcodecreator_attributes72 73 )74 75 );76 77 21 } 78 79 22 ?> -
wp-shortcode-creator/trunk/inc/options-page-wrapper.php
r1420591 r1422879 4 4 ?> 5 5 <div class="wrap"> 6 <h1 class="bwsc_title"><?php esc_attr_e( ' Video DropdownSettings', 'wp_admin_style' ); ?></h1>6 <h1 class="bwsc_title"><?php esc_attr_e( 'Shortcode Creator Settings', 'wp_admin_style' ); ?></h1> 7 7 <div id="bwsc_menu"> 8 8 <?php … … 22 22 $shortcode_attributes = $row->shortcode_attributes; 23 23 $shortcode_nicename = $row->shortcode_nicename; 24 $shortcode_enable_php = $row->shortcode_enable_php; 25 $shortcode_php = $row->shortcode_php; 24 26 $shortcode_timestamp = $row->timestamp; 25 27 $shortcode_id = $row->id; … … 46 48 <label for="bwshortcodecreator_shortcode_content">Shortcode Content</label> 47 49 <div id="poststuff"> 48 <?php the_editor(bwshortcodecreator_mynl2br($shortcode_content),'bwshortcodecreator_shortcode_content'); ?>50 <?php the_editor(bwshortcodecreator_mynl2br($shortcode_content),'bwshortcodecreator_shortcode_content'); ?> 49 51 </div> 50 52 … … 60 62 <br /> 61 63 <br />--> 64 65 <?php 66 if($shortcode_enable_php == 1) { 67 ?> 68 <input type="checkbox" name="bwshortcodecreator_shortcode_enable_php" id="bwshortcodecreator_shortcode_enable_php" checked /> <label>Enable custom PHP</label> 69 <?php 70 } else { 71 ?> 72 <input type="checkbox" name="bwshortcodecreator_shortcode_enable_php" id="bwshortcodecreator_shortcode_enable_php" /> <label>Enable custom PHP</label> 73 <?php 74 } 75 ?> 76 77 <p>Please note, checking this box will disable the text box above. It will still be saved, but not used until you uncheck the box, upon which the same will happen to the boc below</p> 78 79 <br /> 80 81 <label for="bwshortcodecreator_shortcode_php">Shortcode PHP (Advanced)</label> 82 83 <br /> 84 85 <?php 86 if($shortcode_enable_php == 1) { 87 ?> 88 <input type="text" name="bwshortcodecreator_shortcode_php" id="bwshortcodecreator_shortcode_php" class="regular-text" value="<?php echo $shortcode_php; ?>"> 89 <?php 90 } else { 91 ?> 92 <input type="text" name="bwshortcodecreator_shortcode_php" id="bwshortcodecreator_shortcode_php" class="regular-text" value="<?php echo $shortcode_php; ?>" disabled="disabled"> 93 <?php 94 } 95 ?> 96 <h3>How to use PHP in Shortcode Creator</h3> 97 <p>Inside your function you must <strong>return</strong> your visible output, if any.</p> 98 <ol> 99 <li>Navigate to 'Appearance->Editor'</li> 100 <li>On the top right, choose your current theme in the dropdown box and hit select</li> 101 <li>On the right side, find your theme's 'functions.php' file</li> 102 <li>In that file, create a function with any name you want, and write your PHP code within that function. If you need to include variables/parameters, set them before you define your function</li> 103 <li>Now, you just have to call the function in the input above</li> 104 </ol> 105 <p>An example of correct use of the line above: <strong><i>my_fucntion();</i></strong> or <strong><i>my_fucntion($param1, $param2);</i></strong></p> 106 <p><strong>WARNING:</strong> Do not type anything besides your function in the above input. You could break something otherwise.</p> 107 <br /> 108 <br /> 62 109 63 110 <input class="button-primary" type="submit" name="bwshortcodecreator_edit_shortcode_submit" value="Save" /> -
wp-shortcode-creator/trunk/js/bwshortcodecreator_js.js
r1420591 r1422879 12 12 jQuery(this).next('.bwsc_content').slideDown('fast'); 13 13 }); 14 15 jQuery('#bwshortcodecreator_shortcode_enable_php').change(function() { 16 if(this.checked) { 17 jQuery('#bwshortcodecreator_shortcode_php').removeAttr("disabled"); 18 jQuery('#bwshortcodecreator_shortcode_content').attr("disabled", "disabled"); 19 } else { 20 jQuery('#bwshortcodecreator_shortcode_php').attr("disabled", "disabled"); 21 jQuery('#bwshortcodecreator_shortcode_content').removeAttr("disabled"); 22 } 23 }); 14 24 }); -
wp-shortcode-creator/trunk/readme.txt
r1420591 r1422879 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 This plugin allows users to create and customize shortcodes to their liking 12 11 13 == Description == 12 14 … … 15 17 With Shortcode Creator you are able to create shortcodes to be used anywhere in the wordpress system. 16 18 You can simply use the wordpress rich text editor to customize your shortcodes output without needing to know a single line of code. 19 Or if you know how to write php code you can even use your own cutom functions in php! 17 20 18 21 == Installation ==
Note: See TracChangeset
for help on using the changeset viewer.