Changeset 1660954
- Timestamp:
- 05/19/2017 04:08:47 PM (9 years ago)
- Location:
- cmc-hook/trunk
- Files:
-
- 9 edited
-
include/class-cmc-hook-project-table.php (modified) (12 diffs)
-
include/class-cmc-hook-table.php (modified) (19 diffs)
-
include/functions.php (modified) (1 diff)
-
index.php (modified) (1 diff)
-
pages/admin.php (modified) (6 diffs)
-
pages/sections/hook_editor.php (modified) (4 diffs)
-
pages/sections/plugin_form.php (modified) (1 diff)
-
pages/sections/project.php (modified) (5 diffs)
-
pages/sections/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cmc-hook/trunk/include/class-cmc-hook-project-table.php
r1648459 r1660954 31 31 32 32 global $wpdb; 33 $sql = "SELECT p.*, h.title hk_title FROM ` {$wpdb->prefix}cmc_hook_project`34 p left join `{$wpdb->prefix}cmc_hook` h on p.file_run = h.id where ";33 $sql = "SELECT p.*, h.title hk_title FROM `".CMCHK_TABLE_PROJECT."` ". 34 "p left join `".CMCHK_TABLE_HOOK."` h on p.file_run = h.id where "; 35 35 //$sql = "SELECT * FROM {$wpdb->prefix}cmc_hook_project"; 36 36 37 if( $_REQUEST[' cmchk_status'] == 'trash' ){37 if( $_REQUEST['status'] == 'trash' ){ 38 38 $sql .= " p.status = 'trash' "; 39 39 }else{ … … 60 60 if( $id > 0){ 61 61 $wpdb->delete( 62 "{$wpdb->prefix}cmc_hook",62 CMCHK_TABLE_HOOK, 63 63 [ 'project_id' => esc_sql($id) ], 64 64 [ '%d' ] 65 65 ); 66 66 $wpdb->delete( 67 "{$wpdb->prefix}cmc_hook_project",67 CMCHK_TABLE_PROJECT, 68 68 [ 'id' => esc_sql($id) ], 69 69 [ '%d' ] … … 77 77 global $wpdb; 78 78 79 $sql ="SELECT COUNT(*) FROM {$wpdb->prefix}cmc_hook_projectwhere ";79 $sql ="SELECT COUNT(*) FROM ".CMCHK_TABLE_PROJECT." where "; 80 80 81 if( $_REQUEST[' cmchk_status'] == 'trash' ){81 if( $_REQUEST['status'] == 'trash' ){ 82 82 $sql .= " status = 'trash' "; 83 83 }else{ … … 91 91 global $wpdb; $count = array(); 92 92 93 $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}cmc_hook_projectwhere ";93 $sql = "SELECT COUNT(*) FROM ".CMCHK_TABLE_PROJECT." where "; 94 94 95 95 $sqlall = $sql . " status != 'trash' "; … … 112 112 $actions = []; 113 113 114 if( $_REQUEST[' cmchk_status'] == 'trash' ){115 $actions['restore'] = sprintf( '<a href="?page=cmc-hook& cmchk_page=project&cmchk_status=trash&cmchk_id=%1$s&action=restore&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Restore', 'cmchk'), $nonce );116 $actions['delete'] = sprintf( '<a href="?page=cmc-hook& cmchk_page=project&action=delete&cmchk_status=trash&cmchk_id=%1$s&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Delete', 'cmchk'), $nonce );114 if( $_REQUEST['status'] == 'trash' ){ 115 $actions['restore'] = sprintf( '<a href="?page=cmc-hook&tab=project&status=trash&id=%1$s&action=restore&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Restore', 'cmchk'), $nonce ); 116 $actions['delete'] = sprintf( '<a href="?page=cmc-hook&tab=project&action=delete&status=trash&id=%1$s&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Delete', 'cmchk'), $nonce ); 117 117 }else{ 118 $actions['view'] = sprintf( '<a href="?page=cmc-hook& cmchk_page=project&cmchk_section=project&cmchk_id=%1$s">%2$s</a>', absint( $item['id'] ), __('View', 'cmchk'), $nonce );119 $actions['trash'] = sprintf( '<a href="?page=cmc-hook& cmchk_page=project&cmchk_id=%1$s&action=trash&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Trash', 'cmchk'), $nonce );118 $actions['view'] = sprintf( '<a href="?page=cmc-hook&tab=project§ion=project&id=%1$s">%2$s</a>', absint( $item['id'] ), __('View', 'cmchk'), $nonce ); 119 $actions['trash'] = sprintf( '<a href="?page=cmc-hook&tab=project&id=%1$s&action=trash&_wpnonce=%3$s&XDEBUG_SESSION_START">%2$s</a>', absint( $item['id'] ), __('Trash', 'cmchk'), $nonce ); 120 120 } 121 121 … … 173 173 public function get_bulk_actions() { 174 174 $actions = []; 175 if( $_REQUEST[' cmchk_status'] == 'trash' ){175 if( $_REQUEST['status'] == 'trash' ){ 176 176 $actions['bulk-restore'] = 'Restore'; 177 177 $actions['bulk-delete'] = 'Delete Permanently'; … … 189 189 protected function get_views() { 190 190 $count = $this->cmchk_get_counts(); 191 $trash = $_REQUEST[' cmchk_status'] == 'trash'? 'current':'';192 $all = empty($_REQUEST[' cmchk_status'])? 'current':'';191 $trash = $_REQUEST['status'] == 'trash'? 'current':''; 192 $all = empty($_REQUEST['status'])? 'current':''; 193 193 $views = array( 194 'all'=>"<a href='?page=cmc-hook& cmchk_page=project' class='$all'>All <span class='count'>($count[all])</span></a> ",194 'all'=>"<a href='?page=cmc-hook&tab=project' class='$all'>All <span class='count'>($count[all])</span></a> ", 195 195 ); 196 196 197 $views['trash']="<a href='?page=cmc-hook& cmchk_page=project&cmchk_status=trash' class='$trash'>Trash <span class='count'>($count[trash])</span></a>";197 $views['trash']="<a href='?page=cmc-hook&tab=project&status=trash' class='$trash'>Trash <span class='count'>($count[trash])</span></a>"; 198 198 199 199 return $views; … … 219 219 } 220 220 221 public function cmc_admin_view(){ 222 $count = $this->cmchk_get_counts(); $proj_id = intval( $_REQUEST['id'] ); 223 echo "<div id='cmchk_section_projects' class='cmchk_section'>"; 224 echo '<h3>'. __('All Projects', 'cmchk').'</h3>'; 225 $this->prepare_items(); 226 $this->views(); 227 echo "<form method='post' action='?page=cmc-hook&tab=project&id=$proj_id'>"; 228 echo "<input type='hidden' name='XDEBUG_SESSION_START' />"; 229 $this->display(); 230 echo "</form>"; 231 echo "<div>"; 232 } 233 221 234 public function process_bulk_action() { 222 223 235 //Detect when a bulk action is being triggered... 224 236 if ( 'delete' === $this->current_action() ) { … … 230 242 } 231 243 else { 232 self::delete_hook( absint( $_GET['cmchk_id'] ) ); 233 wp_redirect( '?page=cmc-hook&cmchk_page=project&cmchk_status=trash' ); 244 $proj_id = absint( $_REQUEST['id'] ); 245 self::delete_hook( $proj_id ); 246 wp_redirect( '?page=cmc-hook&tab=project&status=trash' ); 234 247 exit; 235 248 } 236 249 } 237 250 238 if ( in_array($this->current_action(), array('trash', 'restore')) ) { 239 $action = $this->current_action(); $nonce = esc_attr( $_REQUEST['_wpnonce'] );240 251 $action = $this->current_action(); 252 if ( in_array($action, array('trash', 'restore')) ) { 253 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 241 254 if ( ! wp_verify_nonce( $nonce, 'sp_delete_hook' ) ) { 242 255 die( 'Go get a life script kiddies' ); 243 256 } 244 257 else { 245 global $wpdb; $data = array(); 258 global $wpdb; $data = array(); $proj_id = $_REQUEST['id']; 246 259 $data['status'] = ($action == 'trash')? 'trash':'publish'; 247 260 if( $action == 'trash' ) $data['active'] = 0; 248 $wpdb->update( $wpdb->prefix.'cmc_hook_project', $data, array('id'=> $_GET['cmchk_id']) );249 $restoreurl = $action == 'restore'? '& cmchk_status=trash':'';250 wp_redirect( '?page=cmc-hook& cmchk_page=project'.$restoreurl );261 $wpdb->update( CMCHK_TABLE_PROJECT, $data, array( 'id'=> $proj_id ) ); 262 $restoreurl = $action == 'restore'? '&status=trash':''; 263 wp_redirect( '?page=cmc-hook&tab=project'.$restoreurl ); 251 264 exit; 252 265 } … … 256 269 $action = !empty($_POST['action'])? $_POST['action']: $_POST['action2']; 257 270 if ( in_array( $action, array('bulk-trash', 'bulk-restore', 'bulk-delete')) ){ 258 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 271 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 272 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 259 273 die("Security Breach"); 260 274 } 261 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] );275 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); 262 276 263 277 foreach ( $ids as $id ) { … … 268 282 $data['status'] = ($action == 'bulk-trash')? 'trash':'publish'; 269 283 if( $action == 'bulk-trash' ) $data['active'] = 0; 270 $wpdb->update( $wpdb->prefix.'cmc_hook_project', $data, array('id'=> $id) );284 $wpdb->update( CMCHK_TABLE_PROJECT, $data, array('id'=> $id) ); 271 285 } 272 286 } 273 $restoreurl = in_array($action, array('bulk-delete', 'bulk-restore')) ? '& cmchk_status=trash':'';274 wp_redirect( '?page=cmc-hook& cmchk_page=project'.$restoreurl );287 $restoreurl = in_array($action, array('bulk-delete', 'bulk-restore')) ? '&status=trash':''; 288 wp_redirect( '?page=cmc-hook&tab=project'.$restoreurl ); 275 289 exit; 276 290 } 277 291 278 292 if( in_array($action, array('bulk-activate', 'bulk-deactivate', 'bulk-safe_mode')) ){ 279 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 293 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 294 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 280 295 die("Security Breach"); 281 296 } … … 285 300 $data = array(); 286 301 $data['active'] = ($action == 'bulk-activate')? 1: (($action == 'bulk-deactivate')? 0 : -1); 287 $wpdb->update( $wpdb->prefix.'cmc_hook_project', $data, array('id'=> $id) );288 } 289 wp_redirect( '?page=cmc-hook& cmchk_page=project' );302 $wpdb->update( CMCHK_TABLE_PROJECT, $data, array('id'=> $id) ); 303 } 304 wp_redirect( '?page=cmc-hook&tab=project' ); 290 305 exit; 291 306 } 292 307 293 308 if( $action == 'bulk-clone'){ 294 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 295 die("Security Breach"); 309 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 310 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 311 die("Security Breach"); 296 312 } 297 313 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); $id = implode(', ', $ids); 298 $sql = "SELECT * FROM {$wpdb->prefix}cmc_hook_projectwhere id IN($id) ";314 $sql = "SELECT * FROM ".CMCHK_TABLE_PROJECT." where id IN($id) "; 299 315 $projs = $wpdb->get_results( $sql, 'ARRAY_A' ); 300 316 if( $projs ){ 301 317 foreach( $projs as $p){ 302 $p_id = $p['id']; $filerun = $p['file_run']; unset($p['id']); $p['active'] = 0; 303 $p['slug'] = cmc_hook::get_slug( $wpdb->prefix.'cmc_hook_project', 0, $p['slug'], 0 ); 304 $wpdb->insert( $wpdb->prefix.'cmc_hook_project', $p ); $proj_id = $wpdb->insert_id; 318 $p_id = $p['id']; $filerun = $p['file_run']; unset($p['id']); unset($p['datetimecreated']); 319 $p['active'] = 0; $h['datetimeupdated'] = date('Y-m-d H:i:s'); 320 $p['slug'] = cmc_hook::get_slug( CMCHK_TABLE_PROJECT, 0, $p['slug'], 0 ); 321 $wpdb->insert( CMCHK_TABLE_PROJECT, $p ); $proj_id = $wpdb->insert_id; 305 322 if(!$proj_id)continue; 306 $sql = "SELECT * FROM {$wpdb->prefix}cmc_hookwhere project_id = $p_id";323 $sql = "SELECT * FROM ".CMCHK_TABLE_HOOK." where project_id = $p_id"; 307 324 $hooks = $wpdb->get_results( $sql, 'ARRAY_A' ); 308 325 if( !$hooks )continue; 309 326 foreach($hooks as $h){ 310 $h_id = $h['id']; unset($h['id']); $h['active'] = 0; $h['project_id'] = $proj_id;311 $wpdb->insert( $wpdb->prefix.'cmc_hook', $h ); $hook_id = $wpdb->insert_id;312 if( $filerun == $h_id ){313 $wpdb->update( $wpdb->prefix.'cmc_hook_project', array('file_run'=>$hook_id), array('id'=> $proj_id) );314 }327 $h_id = $h['id']; unset($h['id']); $h['active'] = 0; $h['project_id'] = $proj_id; 328 $wpdb->insert( CMCHK_TABLE_HOOK, $h ); $hook_id = $wpdb->insert_id; 329 if( $filerun == $h_id ){ 330 $wpdb->update( CMCHK_TABLE_PROJECT, array('file_run'=>$hook_id), array('id'=> $proj_id) ); 331 } 315 332 } 316 333 } 317 334 } 318 wp_redirect( '?page=cmc-hook& cmchk_page=project' );335 wp_redirect( '?page=cmc-hook&tab=project' ); 319 336 exit; 320 337 } -
cmc-hook/trunk/include/class-cmc-hook-table.php
r1648459 r1660954 16 16 17 17 class cmc_hook_List extends WP_List_Table { 18 public function __construct() { 18 19 public function __construct() { 19 20 parent::__construct( [ 20 21 'singular' => __( 'Hook', 'cmchk' ), //singular name of the listed records … … 28 29 29 30 public static function get_hooks( $per_page = 5, $page_number = 1 ) { 30 global $wpdb; 31 32 $sql = "SELECT * FROM {$wpdb->prefix}cmc_hook ";33 if( $_REQUEST[' cmchk_page'] == 'project' ){34 $sql .= " where project_id = ".$ _REQUEST['cmchk_id'];31 global $wpdb; $proj_id = intval( $_REQUEST['id'] ); 32 33 $sql = "SELECT * FROM ".CMCHK_TABLE_HOOK; 34 if( $_REQUEST['tab'] == 'project' ){ 35 $sql .= " where project_id = ".$proj_id; 35 36 }else{ 36 37 $sql .= " where project_id = 0 "; 37 38 } 38 39 39 if( $_REQUEST[' cmchk_status'] == 'trash' ){40 if( $_REQUEST['status'] == 'trash' ){ 40 41 $sql .= " and status = 'trash' "; 41 42 }else{ … … 52 53 $sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page; 53 54 54 55 55 $result = $wpdb->get_results( $sql, 'ARRAY_A' ); 56 56 … … 62 62 63 63 $wpdb->delete( 64 "{$wpdb->prefix}cmc_hook",64 CMCHK_TABLE_HOOK, 65 65 [ 'ID' => $id ], 66 66 [ '%d' ] … … 69 69 70 70 public static function record_count() { 71 global $wpdb; 72 73 $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}cmc_hook";74 if( $_REQUEST[' cmchk_page'] == 'project' ){75 $sql .= " where project_id = ".$ _REQUEST['cmchk_id'];71 global $wpdb; $hook_id = intval($_REQUEST['cmchk_id']); 72 73 $sql = "SELECT COUNT(*) FROM ".CMCHK_TABLE_HOOK; 74 if( $_REQUEST['tab'] == 'project' ){ 75 $sql .= " where project_id = ".$hook_id; 76 76 }else{ 77 77 $sql .= " where project_id = 0"; … … 88 88 89 89 public function cmchk_get_counts(){ 90 global $wpdb; $count = array(); 91 92 $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}cmc_hook";93 if( $_REQUEST[' cmchk_page'] == 'project' ){94 $sql .= " where project_id = ".$ _REQUEST['cmchk_id'];90 global $wpdb; $count = array(); $proj_id = intval( $_REQUEST['id'] ); 91 92 $sql = "SELECT COUNT(*) FROM ".CMCHK_TABLE_HOOK; 93 if( $_REQUEST['tab'] == 'project' ){ 94 $sql .= " where project_id = ".$proj_id; 95 95 }else{ 96 96 $sql .= " where project_id = 0"; … … 115 115 116 116 $cmchkpage = ''; $cmchksec = ''; 117 if( $_REQUEST[' cmchk_page'] == 'project' ) {118 $cmchkpage = '& cmchk_page=project';119 $cmchksec = '& cmchk_section=project';120 $cmchkproj = '&cmchk_proj='.$_REQUEST['cmchk_id'];121 } 122 117 if( $_REQUEST['tab'] == 'project' ) { 118 $cmchkpage = '&tab=project'; 119 $cmchksec = '§ion=project'; 120 //$cmchkproj = '&cmchk_proj='.$_REQUEST['id']; 121 } 122 123 123 $actions = []; 124 if( $_REQUEST[' cmchk_status'] == 'trash' ){125 $actions['restore'] = sprintf( '<a href="?page=cmc-hook%1$s&cmchk_status=trash&cmchk_id=%2$s&action=restore&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Restore', 'cmchk'), $nonce );126 $actions['delete'] = sprintf( '<a href="?page=cmc-hook%1$s&cmchk_status=trash&cmchk_id=%2$s&action=delete&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Delete Permanently', 'cmchk'), $nonce );127 }else{ 128 $actions['edit'] = sprintf( '<a href="?page=cmc-hook%1$s&cmchk_section=hook_editor&cmchk_id=%2$s">%3$s</a>', $cmchkpage, absint( $item['id'] ), __('View', 'cmchk') );129 $actions['trash'] = sprintf( '<a href="?page=cmc-hook%1$s&cmchk_id=%2$s&action=trash&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Trash', 'cmchk'), $nonce );124 if( $_REQUEST['status'] == 'trash' ){ 125 $actions['restore'] = sprintf( '<a href="?page=cmc-hook%1$s&id=%2$s&action=restore&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Restore', 'cmchk'), $nonce ); 126 $actions['delete'] = sprintf( '<a href="?page=cmc-hook%1$s&id=%2$s&action=delete&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Delete Permanently', 'cmchk'), $nonce ); 127 }else{ 128 $actions['view'] = sprintf( '<a href="?page=cmc-hook&tab=explorer&id=%1$s">%2$s</a>', absint( $item['id'] ), __('View', 'cmchk') ); 129 $actions['trash'] = sprintf( '<a href="?page=cmc-hook%1$s&id=%2$s&action=trash&_wpnonce=%4$s&XDEBUG_SESSION_START">%3$s</a>', $cmchkpage.$cmchksec.$cmchkproj, absint( $item['id'] ), __('Trash', 'cmchk'), $nonce ); 130 130 } 131 131 … … 188 188 public function get_bulk_actions() { 189 189 $actions = []; 190 if( $_REQUEST[' cmchk_status'] == 'trash' ){190 if( $_REQUEST['status'] == 'trash' ){ 191 191 $actions['bulk-restore'] = 'Restore'; 192 192 $actions['bulk-delete'] = 'Delete Permanently'; … … 197 197 $actions['bulk-trash'] = 'Trash'; 198 198 $actions['bulk-clone'] = 'Clone'; 199 if( empty($_REQUEST[' cmchk_page']) && empty($_REQUEST['cmchk_section']) ){199 if( empty($_REQUEST['tab']) && empty($_REQUEST['section']) ){ 200 200 $actions['cmchk-hook-bulk-export'] = 'Export'; 201 201 } … … 205 205 206 206 protected function get_views() { 207 $count = $this->cmchk_get_counts(); 208 $trash = $_REQUEST[' cmchk_status'] == 'trash'? 'current':'';209 $all = empty($_REQUEST[' cmchk_status'])? 'current':'';210 $url = $_REQUEST[' cmchk_page'] == 'project'?"&cmchk_page=project&cmchk_section=project&cmchk_id=$_REQUEST[cmchk_id]":"";207 $count = $this->cmchk_get_counts(); $hook_id = intval($_REQUEST['id']); 208 $trash = $_REQUEST['status'] == 'trash'? 'current':''; 209 $all = empty($_REQUEST['status'])? 'current':''; 210 $url = $_REQUEST['tab'] == 'project'?"&tab=project§ion=project&id=$hook_id":""; 211 211 212 212 $views = array( … … 214 214 ); 215 215 216 $views['trash'] = "<a href='?page=cmc-hook{$url}& cmchk_status=trash' class='$trash'>Trash <span class='count'>($count[trash])</span></a>";216 $views['trash'] = "<a href='?page=cmc-hook{$url}&status=trash' class='$trash'>Trash <span class='count'>($count[trash])</span></a>"; 217 217 218 218 return $views; … … 238 238 } 239 239 240 public function cmc_admin_view(){ 241 $count = $this->cmchk_get_counts(); $proj_id = intval( $_REQUEST['id'] ); 242 echo "<div id='cmchk_section_hooks' class='cmchk_section'>"; 243 echo '<h3>'. __('All Hooks', 'cmchk').'</h3>'; 244 $this->prepare_items(); 245 $this->views(); 246 echo "<form method='post' action='?page=cmc-hook&id=$proj_id'>"; 247 echo "<input type='hidden' name='XDEBUG_SESSION_START' />"; 248 $this->display(); 249 echo "</form>"; 250 echo "<div>"; 251 } 252 240 253 public function process_bulk_action() { 241 242 254 //Detect when a bulk action is being triggered... 243 255 if ( 'delete' === $this->current_action() ) { 244 256 // In our file that handles the request, verify the nonce. 245 $nonce = esc_attr( $_REQUEST['_wpnonce'] ); 257 $nonce = esc_attr( $_REQUEST['_wpnonce'] ); $hook_id = absint( $_REQUEST['id'] ); 246 258 247 259 if ( ! wp_verify_nonce( $nonce, 'sp_delete_hook' ) ) { … … 249 261 } 250 262 else { 251 self::delete_hook( absint( $_GET['cmchk_id'] ) ); 252 if( $_REQUEST['cmchk_proj'] > 0){ 253 wp_redirect('?page=cmc-hook&cmchk_page=project&cmchk_section=project&cmchk_id='.$_REQUEST['cmchk_proj'].'&cmchk_status=trash'); 263 global $wpdb; 264 $sql = $wpdb->prepare( "SELECT * FROM ".CMCHK_TABLE_HOOK." WHERE id = %d", $hook_id); 265 $model = $wpdb->get_row( $sql, ARRAY_A ); 266 267 self::delete_hook( $hook_id ); 268 if( $model['project_id'] > 0){ 269 wp_redirect("?page=cmc-hook&tab=project§ion=project&id=".$model['project_id'].'&status=trash'); 254 270 }else{ 255 wp_redirect('?page=cmc-hook& cmchk_status=trash');271 wp_redirect('?page=cmc-hook&status=trash'); 256 272 } 257 273 exit; … … 260 276 261 277 if( in_array($this->current_action(), array('trash', 'restore')) ){ 262 // In our file that handles the request, verify the nonce.278 // In our file that handles the request, verify the nonce. 263 279 $action = $this->current_action(); $nonce = esc_attr( $_REQUEST['_wpnonce'] ); 264 280 … … 267 283 } 268 284 else { 269 global $wpdb; $data = array(); 285 global $wpdb; $data = array(); $hook_id = intval($_REQUEST['id']); 270 286 $data['status'] = ($action == 'trash')? 'trash':'publish'; 271 287 if( $action == 'trash' ) $data['active'] = 0; 272 288 273 $wpdb->update( $wpdb->prefix.'cmc_hook', $data, array('id'=> $_GET['cmchk_id']) ); 274 $restoreurl = $action == 'restore'? '&cmchk_status=trash':''; 275 if( $_REQUEST['cmchk_proj'] > 0){ 276 wp_redirect('?page=cmc-hook&cmchk_page=project&cmchk_section=project&cmchk_id='.$_REQUEST['cmchk_proj'].$restoreurl); 289 $sql = $wpdb->prepare( "SELECT * FROM ".CMCHK_TABLE_HOOK." WHERE id = %d", $hook_id); 290 $model = $wpdb->get_row( $sql, ARRAY_A ); 291 292 $wpdb->update( CMCHK_TABLE_HOOK, $data, array( 'id' => $hook_id ) ); 293 $restoreurl = $action == 'restore'? '&status=trash':''; 294 if( $model['project_id'] > 0){ 295 wp_redirect("?page=cmc-hook&tab=project§ion=project&id=".$model['project_id'].$restoreurl); 277 296 }else{ 278 297 wp_redirect('?page=cmc-hook'.$restoreurl); … … 281 300 } 282 301 } 283 302 284 303 $action = !empty($_POST['action'])? $_POST['action']: $_POST['action2']; 285 304 286 305 // If the delete bulk action is triggered 287 if ( in_array( $action, array('bulk-trash', 'bulk-restore', 'bulk-delete')) ){ 288 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 306 if ( in_array( $action, array('bulk-trash', 'bulk-restore', 'bulk-delete')) ){ 307 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 308 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 289 309 die("Security Breach"); 290 310 } 291 311 292 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); 312 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); $proj_id = intval($_REQUEST['id']); 293 313 294 314 foreach ( $ids as $id ) { … … 299 319 $data['status'] = ($action == 'bulk-trash')? 'trash':'publish'; 300 320 if( $action == 'bulk-trash' ) $data['active'] = 0; 301 $wpdb->update( $wpdb->prefix.'cmc_hook', $data, array('id'=> $id) );321 $wpdb->update( CMCHK_TABLE_HOOK, $data, array('id'=> $id) ); 302 322 } 303 323 } 304 $restoreurl = in_array($action, array('bulk-delete', 'bulk-restore')) ? '& cmchk_status=trash':'';305 if( $ _REQUEST['cmchk_proj']> 0){306 wp_redirect( '?page=cmc-hook&cmchk_page=project&cmchk_section=project&cmchk_id='.$_REQUEST['cmchk_proj'].$restoreurl);324 $restoreurl = in_array($action, array('bulk-delete', 'bulk-restore')) ? '&status=trash':''; 325 if( $proj_id > 0){ 326 wp_redirect("?page=cmc-hook&tab=project§ion=project&id=$proj_id".$restoreurl); 307 327 }else{ 308 328 wp_redirect('?page=cmc-hook'.$restoreurl); … … 312 332 313 333 if( in_array($action, array('bulk-activate', 'bulk-deactivate', 'bulk-safe_mode')) ){ 314 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 334 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 335 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 315 336 die("Security Breach"); 316 337 } 317 338 318 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); 339 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); $proj_id = intval($_REQUEST['id']); 319 340 foreach ( $ids as $id ) { 320 341 $data = array(); 321 342 $data['active'] = ($action == 'bulk-activate')? 1: (($action == 'bulk-deactivate')? 0 : -1); 322 $wpdb->update( $wpdb->prefix.'cmc_hook', $data, array('id'=> $id) );323 } 324 325 if( $ _REQUEST['cmchk_proj']> 0){326 wp_redirect( '?page=cmc-hook&cmchk_page=project&cmchk_section=project&cmchk_id='.$_REQUEST['cmchk_proj']);343 $wpdb->update( CMCHK_TABLE_HOOK, $data, array('id'=> $id) ); 344 } 345 346 if( $proj_id > 0){ 347 wp_redirect("?page=cmc-hook&tab=project§ion=project&id=$proj_id"); 327 348 }else{ 328 349 wp_redirect('?page=cmc-hook'); … … 332 353 333 354 if( $action == 'bulk-clone'){ 334 if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $this->_args['plural'] ) ){ 355 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); 356 if( !wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ){ 335 357 die("Security Breach"); 336 358 } 337 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); $id = implode(', ', $ids); 338 $sql = "SELECT * FROM {$wpdb->prefix}cmc_hookwhere id IN($id) ";359 global $wpdb; $ids = esc_sql( $_POST['bulk-items'] ); $id = implode(', ', $ids); $proj_id = intval($_REQUEST['id']); 360 $sql = "SELECT * FROM ".CMCHK_TABLE_HOOK." where id IN($id) "; 339 361 $hooks = $wpdb->get_results( $sql, 'ARRAY_A' ); 340 362 if( $hooks ){ 341 363 foreach( $hooks as $h){ 342 unset($h['id']); $h['active'] = 0; 343 $wpdb->insert( $wpdb->prefix.'cmc_hook', $h ); 364 $h['slug'] = cmc_hook::get_slug( CMCHK_TABLE_HOOK, 0, $h['slug'], $h['project_id'] ); 365 unset($h['id']); unset($h['datetimecreated']); 366 $h['active'] = 0; $h['datetimeupdated'] = date('Y-m-d H:i:s'); 367 $wpdb->insert( CMCHK_TABLE_HOOK, $h ); 344 368 } 345 } 369 } 370 371 if( $proj_id > 0){ 372 wp_redirect("?page=cmc-hook&tab=project§ion=project&id=$proj_id"); 373 }else{ 374 wp_redirect('?page=cmc-hook'); 375 } 376 exit; 377 346 378 } 347 379 -
cmc-hook/trunk/include/functions.php
r1648463 r1660954 36 36 return CMCHK_DIR_PROJECT. 'project_'.$id.'/'; 37 37 } 38 -
cmc-hook/trunk/index.php
r1645784 r1660954 1 <?php // Silence is Golden 2 3 ?> 1 <?php // Silence is Golden ?> -
cmc-hook/trunk/pages/admin.php
r1648459 r1660954 9 9 exit; 10 10 } 11 $menu_url = menu_page_url('cmc-hook', false); 11 if( !cmc_hook::is_user_allowed()){ 12 exit('You do not have permission to view this page'); 13 } 14 12 15 $menu = array( 13 'hook'=>array('text'=>__('Hooks', 'cmchk'), 'href'=> $menu_url, 'page'=>function(){16 'hook'=>array('text'=>__('Hooks', 'cmchk'), 'href'=>'?page=cmc-hook', 'page'=>function(){ 14 17 $sections = array( 15 'hook_editor'=>array('page'=> function(){16 echo "<div id='cmchk_section_hook_editor' class='cmchk_section'>";17 require("sections/hook_editor.php");18 echo "<div>";19 }),20 18 'hooks'=>array('page'=>function(){ 21 $count = cmc_hook::$hooks->cmchk_get_counts(); 22 echo "<div id='cmchk_section_hooks' class='cmchk_section'>"; 23 echo '<h3>'. __('All Hooks', 'cmchk').'</h3>'; 24 cmc_hook::$hooks->prepare_items(); 25 cmc_hook::$hooks->views(); 26 echo "<form method='post' action='?page=cmc-hook'>"; 27 echo "<input type='hidden' name='XDEBUG_SESSION_START' />"; 28 cmc_hook::$hooks->display(); 29 echo "</form>"; 30 echo "<div>"; 19 cmc_hook::$hooks->cmc_admin_view(); 31 20 }), 32 21 ); 33 22 $sections = apply_filters('cmchk_admin_page_section', $sections); 34 $selected = empty($_REQUEST[' cmchk_section'])? 'hooks':$_REQUEST['cmchk_section'];23 $selected = empty($_REQUEST['section'])? 'hooks':$_REQUEST['section']; 35 24 $sec_page = $sections[$selected]; 36 25 call_user_func_array( $sec_page['page'], array() ); 37 //require("sections/hook_list.php");38 26 }), 39 'project'=>array('text'=>__('Project', 'cmchk'), 'href'=>$menu_url.'&cmchk_page=project', 'page'=>function(){ 40 $addprojurl = menu_page_url('cmc-hook', false).'&cmchk_page=project&cmchk_section=project_editor'; 27 'project'=>array('text'=>__('Project', 'cmchk'), 'href'=>'?page=cmc-hook&tab=project', 'page'=>function(){ 41 28 $sections = array( 42 29 'project'=>array('page'=> function(){ … … 46 33 }), 47 34 'projects'=>array('page'=>function(){ 48 $count = cmc_hook::$projects->cmchk_get_counts(); 49 echo "<div id='cmchk_section_projects' class='cmchk_section'>"; 50 echo '<h3>'. __('All Projects', 'cmchk').'</h3>'; 51 cmc_hook::$projects->prepare_items(); 52 cmc_hook::$projects->views(); 53 echo "<form method='post' action='?page=cmc-hook&cmchk_page=project'>"; 54 echo "<input type='hidden' name='XDEBUG_SESSION_START' />"; 55 cmc_hook::$projects->display(); 56 echo "</form>"; 57 echo "<div>"; 58 }), 59 'hook_editor'=>array('page'=> function(){ 60 echo "<div id='cmchk_section_hook_editor' class='cmchk_section'>"; 61 require("sections/hook_editor.php"); 62 echo "<div>"; 35 cmc_hook::$projects->cmc_admin_view(); 63 36 }), 64 37 ); 65 38 $sections = apply_filters('cmchk_admin_page_section', $sections); 66 $selected = empty($_REQUEST[' cmchk_section'])? 'projects':$_REQUEST['cmchk_section'];39 $selected = empty($_REQUEST['section'])? 'projects':$_REQUEST['section']; 67 40 $sec_page = $sections[$selected]; 68 41 call_user_func_array( $sec_page['page'], array() ); 69 42 }), 70 'settings'=>array('text'=>__('Settings', 'cmchk'), 'href'=> $menu_url.'&cmchk_page=settings', 'page'=>function(){ 71 echo "<div id='cmchk_section_settings' class='cmchk_section'>"; 72 require("sections/settings.php"); 73 echo "<div>"; 43 'explorer'=>array('text'=>__('Explorer', 'cmchk'), 'href'=>'?page=cmc-hook&tab=explorer', 'page'=>function(){ 44 $sections = array( 45 'explorer'=>array('page'=> function(){ 46 echo "<div id='cmchk_section_explorer' class='cmchk_section'>"; 47 require("sections/hook_editor.php"); 48 echo "<div>"; 49 }), 50 ); 51 $sections = apply_filters('cmchk_admin_page_section', $sections); 52 $selected = empty($_REQUEST['section'])? 'explorer':$_REQUEST['section']; 53 $sec_page = $sections[$selected]; 54 call_user_func_array( $sec_page['page'], array() ); 55 }), 56 'settings'=>array('text'=>__('Settings', 'cmchk'), 'href'=>'?page=cmc-hook&tab=settings', 'page'=>function(){ 57 $sections = array( 58 'settings'=>array('page'=> function(){ 59 echo "<div id='cmchk_section_settings' class='cmchk_section'>"; 60 require("sections/settings.php"); 61 echo "<div>"; 62 }), 63 ); 64 $sections = apply_filters('cmchk_admin_page_section', $sections); 65 $selected = empty($_REQUEST['section'])? 'settings':$_REQUEST['section']; 66 $sec_page = $sections[$selected]; 67 call_user_func_array( $sec_page['page'], array() ); 68 74 69 }), 75 70 ); 76 71 77 $sel_ page = empty($_REQUEST['cmchk_page']) ? 'hook': $_REQUEST['cmchk_page'];72 $sel_tab = empty($_REQUEST['tab']) ? 'hook': $_REQUEST['tab']; 78 73 79 74 ?> … … 82 77 <h1> 83 78 <?php echo __('CMC Hooks', 'cmchk'); ?> 84 <?php //echo $menu_url.'&cmchk_section=hook_editor'?> 85 <?php //echo $menu_url.'&cmchk_page=project&cmchk_section=project_editor' ?> 86 <button id="cmchk-form-hook-btn" class="page-title-action cmchk-help-tip" type="button" data-tip="Add New Hook" onclick=" jQuery('#cmchk-form-hook').slideToggle('fast').find(':text').focus(); " > 79 <button id="cmchk-hook-add-form-btn" class="page-title-action cmchk-help-tip" type="button" data-tip="Add New Hook" onclick=" jQuery('#cmchk-hook-add-form').slideToggle('fast').find(':text').focus(); " > 87 80 <?php echo __('Add Hook', 'cmchk'); ?> 88 81 </button> 89 <button id="cmchk- form-project-btn" class="page-title-action cmchk-help-tip" type="button" onclick="jQuery('#cmchk-form-project').slideToggle('fast').find(':text').focus();">82 <button id="cmchk-project-add-form-btn" class="page-title-action cmchk-help-tip" type="button" onclick="jQuery('#cmchk-project-add-form').slideToggle('fast').find(':text').focus();"> 90 83 <?php echo __('Add Project', 'cmchk'); ?> 91 84 </button> … … 94 87 </button> 95 88 <?php $nonce = wp_create_nonce( 'cmchk-project-export-nonce' ); ?> 96 <a href="?page=cmc-hook&cmchk_action=export&XDEBUG_SESSION_START&_wpnonce=<?php echo $nonce; ?>& cmchk_id=all" id="cmchk-form-project-export-btn" class="page-title-action cmchk-help-tip" data-tip="Export All Projects" target="_blank" >89 <a href="?page=cmc-hook&cmchk_action=export&XDEBUG_SESSION_START&_wpnonce=<?php echo $nonce; ?>&id=all" id="cmchk-form-project-export-btn" class="page-title-action cmchk-help-tip" data-tip="Export All Projects" target="_blank" > 97 90 <?php echo __('Export', 'cmchk'); ?> 98 91 </a> … … 108 101 </p> 109 102 </form> 110 <form id="cmchk- form-hook" class="cmchk-hook-add-form" style="display:none;" action="<?php echo admin_url('admin-ajax.php').'?action=cmchk_hook_editor'; ?>" >103 <form id="cmchk-hook-add-form" class="cmchk-hook-project-add-form" style="display:none;" action="<?php echo admin_url('admin-ajax.php').'?action=cmchk_hook_editor&tab='.$_REQUEST['tab']; ?>" > 111 104 <p> 112 105 <?php wp_nonce_field( 'cmc-hook-nonce','_wpnonce', true, true ); ?> 113 106 <input name="XDEBUG_SESSION_START" type="hidden" /> 114 107 <input type="text" name="title" class="widefat" style="width:70%" placeholder="<?php echo __("Hook Title", "cmchk"); ?>" /> 115 <button type=" button" class="button button-primary cmchk-hook-add-form-btn" style="width:15%;"><?php echo __('Save', 'cmchk'); ?></button>108 <button type="submit" class="button button-primary" style="width:15%;"><?php echo __('Save', 'cmchk'); ?></button> 116 109 </p> 117 110 </form> 118 <form id="cmchk- form-project" class="cmchk-hook-add-form" style="display:none;" action="<?php echo admin_url('admin-ajax.php').'?action=cmchk_project_editor'; ?>">111 <form id="cmchk-project-add-form" class="cmchk-hook-project-add-form" style="display:none;" action="<?php echo admin_url('admin-ajax.php').'?action=cmchk_project_editor&tab='.$_REQUEST['tab']; ?>"> 119 112 <p> 120 113 <?php wp_nonce_field( 'cmc-hook-project-nonce','_wpnonce', true, true ); ?> 121 114 <input name="XDEBUG_SESSION_START" type="hidden" /> 122 115 <input type="text" name="title" class="widefat" style="width:70%" placeholder="<?php echo __("Project Title", "cmchk"); ?>" /> 123 <button type=" button" class="button button-primary cmchk-hook-add-form-btn" style="width:15%;" ><?php echo __('Save', 'cmchk'); ?></button>116 <button type="submit" class="button button-primary" style="width:15%;" ><?php echo __('Save', 'cmchk'); ?></button> 124 117 </p> 125 118 </form> 126 119 </div> 127 <h2 id="cmchk_ page_menu" class="nav-tab-wrapper wp-clearfix">120 <h2 id="cmchk_tab_menu" class="nav-tab-wrapper wp-clearfix"> 128 121 <?php 129 122 $menu = apply_filters('cmchk_admin_page_menu', $menu); 130 123 foreach($menu as $k => $m){ 131 124 if( $m['active'] === false) continue; 132 $s = ($sel_ page== $k)? "nav-tab-active":""; $m['class'] = is_array($m['class'])? implode(' ', $m['class']):$m['class'];125 $s = ($sel_tab == $k)? "nav-tab-active":""; $m['class'] = is_array($m['class'])? implode(' ', $m['class']):$m['class']; 133 126 echo sprintf('<a href="%s" class="nav-tab %s %s" %s > %s </a>', $m['href'], $m['class'], $s, $m['atts'], $m['text'] ); 134 127 } 135 128 ?> 136 129 </h2> 137 <div id="cmchk_ page" class="cmchk_page_<?php echo $sel_page; ?>">130 <div id="cmchk_tab" class="cmchk_tab_<?php echo $sel_tab; ?>"> 138 131 <?php 139 $page = $menu[$sel_ page];132 $page = $menu[$sel_tab]; 140 133 call_user_func_array( $page['page'], array() ); 141 134 ?> … … 158 151 (function($, cmchk){ 159 152 cmchk_page_load( $(document) ); 160 $('.cmchk-hook- add-form-btn').click(function(){153 $('.cmchk-hook-project-add-form :submit').click(function(){ 161 154 var $btn = $(this), $form = $btn.closest('form'); 162 155 $btn.prop('disabled', true); var data = $form.serializeArray(); 163 if( $form.is('#cmchk- form-hook')) data.push({name: 'project_id', value: $('#cmchk_project_id').val() || 0});156 if( $form.is('#cmchk-hook-add-form')) data.push({name: 'project_id', value: $('#cmchk_project_id').val() || 0}); 164 157 $.post($form.attr('action'), data, function(data){ 165 158 if( data.url )document.location = data.url; -
cmc-hook/trunk/pages/sections/hook_editor.php
r1648459 r1660954 4 4 file: admin/hooks_editor.php 5 5 */ 6 7 global $wpdb; 8 if( $_REQUEST['cmchk_id'] > 0 ){ 9 $model = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$wpdb->prefix}cmc_hook WHERE id = %s", $_REQUEST['cmchk_id']), ARRAY_A ); 6 if(!defined('ABSPATH')) { 7 header('HTTP/1.0 403 Forbidden'); 8 exit; 10 9 } 11 else if( empty( $model ) ){ 12 $model['id'] = 0; 13 $model['type'] = 'filter'; 14 $model['active'] = 1; 15 $model['title'] = ''; 16 $model['description'] = ''; 17 $model['hookname'] = ''; 18 $model['args'] = 1; 19 $model['priority'] = 10; 20 $model['code'] = ''; 21 $model['safe_mode'] = 1; 22 $model['enable_shortcode'] = 1; 23 $model['slug'] = ''; 24 $model['file_run'] = 0; 10 if( !cmc_hook::is_user_allowed()){ 11 exit('You do not have permission to view this page'); 25 12 } 26 13 27 if( $model ){ 28 $proj = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$wpdb->prefix}cmc_hook_project WHERE id = %d", $model['project_id']), ARRAY_A ); 14 global $wpdb; $hook_id = intval( $_REQUEST['id'] ); 15 if( $hook_id > 0 ){ 16 $sql = $wpdb->prepare( "SELECT * FROM ".CMCHK_TABLE_HOOK." WHERE id = %d", $hook_id); 17 $model = $wpdb->get_row( $sql, ARRAY_A ); 29 18 } 30 $files = $wpdb->get_results( $wpdb->prepare("SELECT id, title, slug FROM {$wpdb->prefix}cmc_hook WHERE project_id = %d", !empty($model['project_id'])?$model['project_id']:0), ARRAY_A );31 $projects = $wpdb->get_results( "SELECT p.*, h.title hk_title, h.slug hk_slug FROM `{$wpdb->prefix}cmc_hook_project` ".32 " p left join `{$wpdb->prefix}cmc_hook` h on p.file_run = h.id where p.project_id = 0 and p.status != 'trash' ", ARRAY_A );33 19 34 if( $proj ){ 35 36 } 37 $types = array('filter'=>'Filter', 'action'=>'Action', 'file'=>'Php file'); 20 //if( empty( $model ) ){ 21 //echo "Hook Not found"; return; 22 //} 23 24 $sql = $wpdb->prepare("SELECT * FROM ".CMCHK_TABLE_PROJECT." WHERE id = %d", $model['project_id']); 25 $proj = $wpdb->get_row( $sql, ARRAY_A ); 26 38 27 $projid = $proj? $proj['id']: 0; 39 $hk_files = $wpdb->get_results( "SELECT `id`, `slug` FROM {$wpdb->prefix}cmc_hook where project_id = $projid and type = 'file' ", 'ARRAY_A' );40 $cmc_wp_funcs = array(41 'admin_menu'=>'Admin Menu', 'menu'=>'Menu', 'post_type'=>'Post Type', 'taxonomy'=>'Taxonomy',42 'script'=>'Script', 'style'=>'Style', 'meta_box'=>'Meta Box',43 );44 $cmc_wp_funcs = apply_filters( 'cmchk_admin_page_hook_editor_wp_funcs', $cmc_wp_funcs );45 28 ?> 46 < form id="cmchk_hook_editor_form" action="" method="post">29 <div id="cmchk_hook_editor_form" action="" method="post" > 47 30 <style> 48 31 #cmchk_hook_editor_code_editor .CodeMirror { 49 border: 1px solid #eee;32 /* border: 1px solid #eee; */ 50 33 height: 100%; 51 34 } … … 57 40 #cmchk_hook_editor_code_editor .cm-matchhighlight {background-color: lightgreen} 58 41 #cmchk_hook_editor_code_editor .CodeMirror-selection-highlight-scrollbar {background-color: green} 42 .cmchk-current-project > a, .cmchk-current-hook > a{ color:red !important; } 59 43 </style> 60 44 <div style="margin: 10px 5px;"> 61 45 <h4 style="float:left; margin:5px 0px;"> 62 46 <span style="margin-left:5px;"> 63 <button id="cmchk_hook_editor_project_files_btn" data-step="2" data-intro="Related hooks" type="button" class="button button-secondary" style="padding: 1px 3px; height: 20px;" onclick="jQuery('#cmchk_hook_editor_project_files').slideToggle('fast');">64 <span class="dashicons dashicons-admin-tools" style="font-size: 16px;"></span>65 </button>66 <button id="cmchk_hook_editor_project_list_btn" data-step="3" data-intro="Project List" type="button" class="button button-secondary" style="padding: 1px 3px; height: 20px;" onclick="jQuery('#cmchk_hook_editor_project_list').slideToggle('fast');">67 <span class="dashicons dashicons-admin-plugins" style="font-size: 16px;"></span>68 </button>69 47 </span> 70 48 <?php if( $proj ){ ?> 71 <label >Project : </label>72 <a href="<?php echo '?page=cmc-hook& cmchk_page=project&cmchk_section=project&cmchk_id='.$proj['id']; ?>">49 <label>Project : </label> 50 <a href="<?php echo '?page=cmc-hook&tab=project§ion=project&id='.$proj['id']; ?>"> 73 51 <?php echo $proj['title']; ?> 74 52 </a> 75 53 <?php } ?> 76 </h4> 77 <div style="float:right;"> 78 <button type="button" class="button button-secondary" onclick="javascript:introJs().start();" ><?php echo __('Help', 'cmchk') ?></button> 79 <button type="submit" name="cmchk_action" value="hook_editor" class="button button-primary" > <?php echo __('Submit', 'cmchk') ?></button> 80 </div> 54 <span id="cmchk-hook-code-spin" class="fa fa-spin fa-spinner" style="margin-left:10px; display:none;"></span> 55 </h4> 81 56 </div> 82 57 <div id="poststuff"> 83 58 <div id="post-body" class="metabox-holder columns-2"> 84 59 <div id="post-body-content" style="position: relative"> 85 <div> 86 <div style="float:left; width:250px;"> 87 <div id="cmchk_hook_editor_project_files" class="" style="overflow-x: auto;max-height: 200px; display: none; border: 1px solid black;padding: 5px; border-radius: 5px; box-shadow: black 2px 2px;"> 88 <h4 style="margin:5px;font-weight: bold;"><?php echo __('Related Hooks', 'cmchk'); ?></h4> 89 <table class="wp-list-table widefat fixed striped"> 90 <thead> 91 <tr><th>Title</th><th>Slug</th></tr> 92 </thead> 93 <tbody> 94 <?php foreach( $files as $f){ ?> 95 <tr> 96 <td> 97 <a href="?page=cmc-hook<?php if($proj)echo "&cmchk_page=project"; ?>&cmchk_section=hook_editor&cmchk_id=<?php echo $f['id']; ?>" > 98 <?php echo $f['id'] == $model['id']? "<b style='font-weight: bold;'>$f[title]</b>" : $f['title']; ?> 99 </a> 100 </td> 101 <td><?php echo $f['id'] == $model['id']? "<b style='font-weight: bold;'>$f[slug]</b>" : $f['slug']; ?></td> 102 </tr> 103 <?php } ?> 104 </tbody> 105 </table> 106 </div> 107 </div> 108 <div style="float:left; width:250px; margin-left:10px;"> 109 <div id="cmchk_hook_editor_project_list" class="" style="overflow-x: auto;max-height: 200px; display: none; border: 1px solid black;padding: 5px; border-radius: 5px; box-shadow: black 2px 2px;"> 110 <h4 style="margin:5px;font-weight: bold;"><?php echo __('Project List', 'cmchk'); ?></h4> 111 <table class="wp-list-table widefat fixed striped"> 112 <thead> 113 <tr><th>Title</th><th>File Run</th></tr> 114 </thead> 115 <tbody> 116 <?php foreach( $projects as $f){ ?> 117 <tr> 118 <td> 119 <a href="?page=cmc-hook&cmchk_page=project&cmchk_section=project&cmchk_id=<?php echo $f['id']; ?>" > 120 <?php echo $f['id'] == $proj['id']? "<b style='font-weight: bold;'>$f[title]</b>" : $f['title']; ?> 121 </a> 122 </td> 123 124 <td> 125 <?php if( !empty($f['file_run']) ){ ?> 126 <a href="?page=cmc-hook&cmchk_page=project&cmchk_section=hook_editor&cmchk_id=<?php echo $f['file_run']; ?>" > 127 <?php echo $f['id'] == $proj['id']? "<b style='font-weight: bold;'>$f[hk_title]</b>" : $f['hk_title']; ?> 128 </a> 129 <?php } ?> 130 </td> 131 </tr> 132 <?php } ?> 133 </tbody> 134 135 </table> 136 </div> 137 </div> 138 <div style="clear:both;"></div> 139 </div> 140 <div> 141 <?php do_action('cmchk_admin_page_editor_controls_top'); ?> 142 </div> 143 <div id="cmchk_hook_editor_code_editor" style="height:450px;"> 144 <textarea id="cmc-hook-code" name="code" class="widefat" data-cmchk-theme="<?php echo self::get_setting('codemirror_theme', ''); ?>" style="height:100%;" ><?php echo $model['code']; ?></textarea> 145 </div> 146 <p> 147 <label data-step="4" data-intro="Select Hook Record to run"> 148 <?php echo __('Php File', 'cmchk') ?> 149 <select id="cmc-hk-phpfile" > 150 <?php 151 foreach( $hk_files as $k => $v){ 152 echo sprintf('<option value="%1$s" >%2$s</option>', $v['id'], $v['slug'] ); 153 } 154 ?> 155 </select> 156 <a id="cmc-hk-phpfile-insert" class="button button-secondary" href="javascript:void(0);"> 157 <span class="dashicons dashicons-download" style="margin-top:4px;" ></span> 158 </a> 159 </label> 160 <label data-step="5" data-intro="Select Wordpress Function"> 161 <?php echo __('WP functions', 'cmchk') ?> 162 <select id="cmc-hk-wpfunc" > 163 <?php 164 foreach( $cmc_wp_funcs as $k => $v){ 165 echo sprintf('<option value="%1$s" >%2$s</option>', $k, $v ); 166 } 167 ?> 168 </select> 169 <a id="cmc-hk-wpfunc-insert" class="button button-secondary" href="javascript:void(0);"> 170 <span class="dashicons dashicons-download" style="margin-top:4px;"></span> 171 </a> 172 </label> 173 <a id="cmc-hk-media-insert" class="button button-primary" href="javascript:void(0);" data-step="6" data-intro="Add Media Files"> 174 <i class="dashicons dashicons-admin-media" style="margin-top:4px;"></i> 175 </a> 176 </p> 177 60 <?php 61 if( !empty( $model ) ){ 62 cmc_hook::include_file( CMCHK_DIR."pages/sections/hook_code.php", array('hook_id'=>$hook_id) ); 63 } 64 ?> 178 65 </div> 179 66 <div id="postbox-container-1" class="postbox-container"> … … 182 69 <span> <?php echo __('Attributes', 'cmchk') ?> </span> 183 70 </h2> 184 <div class="inside"> 185 <p data-step="7" data-intro="Enter The Title"> 186 <label>Title</label><br/> 187 <input type="text" name="title" class="widefat" value="<?php echo $model['title']; ?>" /> 188 <?php wp_nonce_field( 'cmc-hook-nonce','_wpnonce', true, true ); ?> 189 <input name="XDEBUG_SESSION_START" type="hidden" /> 190 <input name="id" type="hidden" value="<?php echo $model['id']; ?>" /> 191 <input name="cmchk_id" type="hidden" value="<?php echo $model['id']; ?>" /> 192 <input id="cmc-hook-table" name="table" type="hidden" value="hook" /> 193 <?php if( $proj ){ ?> 194 <input id="cmchk_project_id" name="project_id" type="hidden" value="<?php echo $proj['id']; ?>" /> 195 <?php } ?> 196 </p> 197 <p> 198 <label><?php echo __("Hook ID") ?></label><br> 199 <input type="text" class="widefat" readonly="true" value="<?php echo $model['id']; ?>" /> 200 </p> 201 <p data-step="8" data-intro="Select Type: Hook or php file"> 202 <label><?php echo __('Type', 'cmchk') ?></label><br/> 203 <select id="cmc-hk-type" name="type" class="widefat" onchange="var r = /filter|action/.test(this.value); jQuery('#cmc-hk-hook-box').toggle( r );" > 204 <?php 205 foreach( $types as $k => $v){ 206 echo sprintf('<option value="%1$s" %3$s >%2$s</option>', $k, $v, selected($model['type'], $k, false)); 207 } 208 ?> 209 </select> 210 </p> 211 <?php if( !empty( $_REQUEST['cmchk_id'] ) ){ ?> 212 <p> 213 <label><?php echo __('Slug', 'cmchk') ?></label><br/> 214 <input id="cmc-hk-slug" type="text" name="slug" class="widefat" readonly="readonly" value="<?php echo $model['slug']; ?>" style="width:80%;" /> 215 <button id="cmc-hk-slug-btn" type="button" class="button" style="width:15%; padding:0px;" data-cmchkid='<?php echo $_REQUEST['cmchk_id'] ?>'>Edit</button> 216 </p> 217 <?php } ?> 218 <p data-step="9" data-intro="Describe the record"> 219 <label><?php echo __('Description', 'cmchk') ?></label><br/> 220 <textarea name="description" row="3" class="widefat" style="vertical-align: top;" ><?php echo $model['description']; ?></textarea> 221 </p> 222 223 <p data-step="10" data-intro="Activation and Shortcode"> 224 <label> 225 <?php echo __('Active', 'cmchk') ?> 226 <input type="radio" name="active" <?php checked( $model['active'], 1); ?> value="1" /> 227 </label> 228 <label> 229 <?php echo __('Inactive', 'cmchk') ?> 230 <input type="radio" name="active" <?php checked( $model['active'], 0); ?> value="0" /> 231 </label> 232 <label> 233 <?php echo __('Safe Mode', 'cmchk') ?> 234 <input type="radio" name="active" <?php checked( $model['active'], -1); ?> value ="-1" /> 235 </label> 236 <?php if( !$proj ){ ?> 237 <label> 238 <?php echo __('Shortcode', 'cmchk') ?> 239 <input type="checkbox" name="enable_shortcode" <?php checked( $model['enable_shortcode'], 1); ?> /> 240 </label> 241 <?php } ?> 242 </p> 243 244 <p data-step="11" data-intro="Run record in safe mode"> 245 <?php global $wp; //$wp->request ?> 246 <a class="page-title-action" target="_blank" href="<?php echo add_query_arg( array(), cmc_hook::current_url()); ?>" > 247 <?php echo __('Run', 'cmchk') ?> 248 </a> 249 <a class="page-title-action" target="_blank" href="<?php echo add_query_arg(array('cmchk_safe'=>$model['id']),cmc_hook::current_url()); ?>" > 250 <?php echo __('Run In Safe Mode', 'cmchk') ?> 251 </a> 252 </p> 253 </p> 254 </div> 255 </div> 256 <div id="cmc-hk-hook-box" class="postbox" style="display:<?php echo preg_match('/filter|action/', $model['type'])?'block':'none' ?>;"> 257 <h2 class="hndle ui-sortable-handle"> 258 <span><?php echo __('Hook Settings', 'cmchk') ?></span> 259 </h2> 260 <div class="inside"> 261 <p> 262 <label><?php echo __('Hook Name', 'cmchk') ?></label><br/> 263 <input type="text" name="hookname" class="widefat" value="<?php echo $model['hookname']; ?>"/> 264 </p> 265 <p > 266 <label><?php echo __('Priority', 'cmchk') ?></label> 267 <input type="number" name="priority" class="widefat" value="<?php echo $model['priority']; ?>" /> 268 </p> 269 <p> 270 <label><?php echo __('Arguments', 'cmchk') ?></label> 271 <input type="number" name="args" class="widefat" value="<?php echo $model['args']; ?>" /> 272 </p> 273 </div> 274 </div> 71 <div class="inside"> 72 <div id="cmchk-hookeditor-attributes-tabs"> 73 <ul> 74 <li><a href="#tabs-1">Explorer</a></li> 75 <li><a href="#tabs-2">Hook</a></li> 76 <li><a href="#tabs-3">Project</a></li> 77 </ul> 78 <div id="tabs-1" style="padding:5px;"> 79 <div id="cmchk_hook_editor_project_explorer" class="" style="overflow-x: auto;"> 80 <h4 style="margin:5px;font-weight: bold;"><?php echo __('Project Explorer', 'cmchk'); ?></h4> 81 <div id="cmchk_hook_editor_project_explorer_jft" class="" data-cmchk_url="<?php echo "?page=cmc-hook&cmchk_action=jfiletree&proj=$projid&id=$model[id]&XDEBUG_SESSION_START" ?>"></div> 82 </div> 83 </div> 84 <div id="tabs-2" style="padding:5px;" > 85 <?php 86 if( !empty( $model ) ){ 87 cmc_hook::include_file( CMCHK_DIR."pages/sections/hook_attributes.php", array('hook_id'=>$hook_id) ); 88 } 89 ?> 90 </div> 91 <div id="tabs-3" style="padding:5px;" > 92 <?php 93 if( $projid > 0){ 94 cmc_hook::include_file( CMCHK_DIR."pages/sections/project_attributes.php", array('proj_id'=>$projid) );// require_once("project_attributes.php"); 95 } 96 ?> 97 </div> 98 99 </div> 100 </div> 101 </div> 275 102 </div> 276 103 <div id="postbody-content-2" class="postbox-container"> … … 282 109 <br class="clear"/> 283 110 </div> 284 285 <div style="float:right;"> 286 <button type="button" class="button button-secondary" onclick="javascript:introJs().start();" ><?php echo __('Help', 'cmchk') ?></button> 287 <button type="submit" name="cmchk_action" value="hook_editor" class="button button-primary" > <?php echo __('Submit', 'cmchk') ?></button> 288 </div> 289 </form> 111 </div> 290 112 <script> 291 113 var cmchk = cmchk || {}; 292 114 (function($, w, cmchk){ 293 115 $(function(){ 294 if( !CodeMirror )return; 295 var textarea = document.getElementById("cmc-hook-code"); 296 var codeMirrorOpt = { 297 lineWrapping: false, 298 lineNumbers: true, 299 styleActiveLine: true, 300 matchBrackets: true, 301 mode: "application/x-httpd-php", 302 matchTags: {bothTags: true}, 303 indentUnit: 4, 304 indentWithTabs: true, 305 foldGutter: true, 306 gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], 307 highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: false}, 308 }; 116 $('#cmchk-hookeditor-attributes-tabs').tabs(); 309 117 310 var theme = $(textarea).data('cmchk-theme'); 311 if(theme) codeMirrorOpt.theme = theme; 118 $filetree = $('#cmchk_hook_editor_project_explorer_jft'); 119 $filetree.fileTree({ 120 root: '-2', 121 script: $filetree.data('cmchk_url'),//'connectors/jqueryFileTree.php?XDEBUG_SESSION_START', 122 expandSpeed: 1000, 123 collapseSpeed: 1000, 124 multiFolder: true 125 }, function(file){ 126 var file = file.replace(/\/$/, ''), data = file.split('/') 127 url = '?page=cmc-hook&tab=explorer&id='+data[1]; 128 window.location = url; 129 //alert(url); 130 }); 312 131 313 uiOptions = {314 path : 'ui/',315 searchMode : 'inline', //'popup'316 buttons : ['save','undo','redo','jump','reindent','about'],317 saveCallback : function(){ alert("Some saving goes here. Probably AJAX or something fancy."); }318 };319 320 var editor = CodeMirror.fromTextArea(textarea, codeMirrorOpt);321 cmchk.editor = editor;322 323 324 325 $('.CodeMirror').attr({'data-step':"1",326 'data-intro':"Enter Php Codes;"+327 "\n Use php tags when using php codes "+328 "\n Javascript and css can be used in thier tags "+329 "\n Don't Define functions and classes when using action and filter types"330 });331 332 132 }); 333 133 })(jQuery, window, cmchk); 334 134 </script> 335 <script>336 (function( $, cmchk ){337 $('#cmc-hk-phpfile-insert').click(function(){338 var file = $('#cmc-hk-phpfile'), opt = file.find('option:selected');339 var doc = cmchk.editor.getDoc(), cursor = doc.getCursor(), proj = $('#cmchk_project_id'), pid = proj.val();340 doc.replaceRange(" cmchk_include( '"+opt.text()+".php', "+( pid? pid: 0)+" ); ", cursor);341 return false;342 });343 344 $('#cmc-hk-wpfunc-insert').click(function(){345 var btn = $(this), $file = $('#cmc-hk-wpfunc'), doc = cmchk.editor.getDoc();346 var cursor = doc.getCursor(), str = '';347 348 switch( $file.val() ){349 case "admin_menu":350 str = "add_menu_page( __('Custom Menu Title'), 'custom menu', 'manage_options', 'myplugin/myplugin-admin.php');"; break;351 case "menu":352 str = "register_nav_menus( array(\n"+353 "\t'menu_1' => 'This is menu 1',\n"+354 "\t'menu_2' => 'This is menu 2',\n"+355 ") );"; break;356 case "post_type":357 str = "register_post_type( 'book', array(\n"+358 "\t'public' => true,\n"+359 "'\tlabel' => 'Books'\n"+360 "));"361 break;362 case "taxonomy":363 str = "register_taxonomy( 'tax_name', 'obj_type', array('plublic'=>true) );";364 break;365 case "script":366 str = "wp_register_script( 'handle', 'src', 'deps', 'ver', 'in_footer' );";367 break;368 case "style":369 str = "wp_register_style( 'handle', 'src', 'deps', 'ver', 'media' );";370 break;371 case "meta_box":372 str = "add_meta_box( 'rm-meta-box-id', esc_html__( 'RM MetaBox Title', 'text-domain' ), 'rm_meta_box_callback', 'post', 'advanced', 'high' );"373 break;374 }375 doc.replaceRange(' '+ str +' \n', cursor);376 return false;377 });378 379 $('#cmc-hk-media-insert').click(function(e) {380 e.preventDefault();381 var button = $(this);382 var id = button.prev();383 wp.media.editor.send.attachment = function(props, attachment) {384 var doc = cmchk.editor.getDoc();385 var cursor = doc.getCursor();386 doc.replaceRange(' '+attachment.url+' ', cursor);387 //id.val(attachment.id);388 };389 wp.media.editor.open(button);390 return false;391 });392 393 })(jQuery, cmchk);394 </script>395 <script>396 (function($){397 $('#cmc-hk-slug-btn').click(function(){398 var $btn = $(this), $slug = $('#cmc-hk-slug'), $table = $('#cmc-hook-table'), $proj = $('#cmchk_project_id');399 if( $btn.text() == 'Edit' ){400 $slug.attr('readonly', false);401 $btn.text('ok');402 }else if($btn.text() == 'ok'){403 $slug.attr('readonly', true);404 $btn.prop('disabled', true);405 var data = {action:'cmchk_slug', cmchk_id: $btn.data('cmchkid'), cmchk_slug:$slug.val(), cmchk_table:$table.val(), XDEBUG_SESSION_START:'xdebug'};406 data.cmchk_proj = $proj.val();407 ajax = $.post(ajaxurl, data, function( data ){408 $slug.val(data.slug);409 $btn.text("Edit")410 }).always(function(){$btn.prop('disabled', false);})411 .fail(function(){alert("Network Error");});412 }413 });414 415 $('#cmchk_hook_editor_form :submit').click(function(e){416 e.preventDefault();417 var $btn = $(this), $form = $btn.closest('form');418 var url = ajaxurl+'?action=cmchk_hook_editor&XDEBUG_SESSION_START=';419 $form.find(':submit').prop('disabled', true);420 var items = []; items = $form.serializeArray(); items.push({name:'code', value:cmchk.editor.getValue()});421 $.post(url, items, function(data){422 if(data.message)alert(data.message);423 if(data.replace && typeof(data.replace) == 'string'){424 $('#cmchk_section_hook_editor').html(data.replace);425 }426 }).always(function(){427 $form.find(':submit').prop('disabled', false);428 }).fail(function(){ alert("Network Error"); });429 return false;430 });431 432 })(jQuery);433 </script> -
cmc-hook/trunk/pages/sections/plugin_form.php
r1645784 r1660954 7 7 */ 8 8 9 if(!defined('ABSPATH')) { 10 header('HTTP/1.0 403 Forbidden'); 11 exit; 12 } 13 if( !cmc_hook::is_user_allowed()){ 14 exit('You do not have permission to view this page'); 15 } 9 16 ?> 10 17 -
cmc-hook/trunk/pages/sections/project.php
r1648459 r1660954 10 10 exit; 11 11 } 12 if( !cmc_hook::is_user_allowed()){ 13 exit('You do not have permission to view this page'); 14 } 12 15 13 global $wpdb; 14 if( $_REQUEST['cmchk_id'] > 0 ){ 15 $model = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$wpdb->prefix}cmc_hook_project WHERE id = %s", $_REQUEST['cmchk_id']), ARRAY_A ); 16 global $wpdb; $proj_id = (int)$_REQUEST['id']; 17 if( $proj_id > 0 ){ 18 $sql = $wpdb->prepare("SELECT * FROM ".CMCHK_TABLE_PROJECT." WHERE id = %d", $proj_id); 19 $model = $wpdb->get_row( $sql, ARRAY_A ); 16 20 } 17 21 else if( empty( $model ) ){ 18 $model['id'] = -1; 22 echo "project Not found"; 23 return; 19 24 } 20 25 ?> … … 22 27 <h3 style="margin-bottom: 5px;"> 23 28 <?php echo __('Project Hooks', 'cmchk'); ?> 24 <!-- 25 <a id="cmchk-form-project-hook-btn" class="page-title-action" href="javascript:void(0);"> 26 <?php echo __('Add Hook To Project', 'cmchk'); ?> 27 </a> 28 --> 29 30 <!-- 29 31 <div style="float:right;margin-top:-5px;"> 30 32 <button href="javascript:void(0);" class="button button-secondary" onclick="javascript:introJs().start();" >Help</button> 31 33 <button type="button" name="cmchk_action" value="project_editor" class="button button-primary cmchk_project_editor_form_submit" > <?php echo __('Submit', 'cmchk') ?></button> 32 34 </div> 35 --> 33 36 </h3> 34 37 <div id="poststuff"> 35 38 <div id="post-body" class="metabox-holder columns-2"> 36 39 <div id="post-body-content" style="position: relative"> 37 <?php if( $ _REQUEST['cmchk_id']> 0 ){ ?>40 <?php if( $proj_id > 0 ){ ?> 38 41 <div> 39 <form id="cmchk-form-project-hook" class="cmchk-hook-add-form" style="width:400px; display:none;" data-url="<?php echo admin_url('admin-ajax.php').'?action=cmchk_hook_editor'; ?>">40 <?php wp_nonce_field( 'cmc-hook-project-nonce','_wpnonce', true, true ); ?>41 <p>42 <input type="text" name="hoook_title" class="widefat" placeholder="<?php echo __("Hook Title", "cmchk"); ?>" style="width:70%" />43 <button id="cmchk-form-project-hook-submit" type="button" class="button button-primary" style="width:15%;">Save</button>44 </p>45 </form>46 42 <?php 47 43 cmc_hook::$hooks->prepare_items(); 48 44 cmc_hook::$hooks->views(); 49 45 ?> 50 <form method="post" action="?page=cmc-hook& cmchk_page=project&cmchk_section=project&cmchk_id=<?php echo $model['id']; ?>" >46 <form method="post" action="?page=cmc-hook&tab=project§ion=project&id=<?php echo $model['id']; ?>" > 51 47 <input type="hidden" name="XDEBUG_SESSION_START" /> 52 <input type="hidden" name="cmchk_proj" value="<?php echo $_REQUEST['cmchk_id']; ?>" />53 48 <?php 54 49 cmc_hook::$hooks->display(); … … 65 60 </h2> 66 61 <div class="inside"> 62 <?php 63 cmc_hook::include_file( CMCHK_DIR."pages/sections/project_attributes.php", array('proj_id'=>$proj_id) ); 64 ?> 67 65 <div id="cmchk_project_editor_form_container"> 68 <?php require('project_editor.php'); ?>66 <?php //require('project_editor.php'); ?> 69 67 </div> 70 68 </div> 71 69 72 </div> 70 </div> 73 71 74 <div id="" class="postbox">75 <h2 class="hndle ui-sortable-handle" >76 <span> <?php echo __('Export', 'cmchk') ?> </span>77 </h2>78 <div class="inside" >79 <p>80 <?php $nonce = wp_create_nonce( 'cmchk-project-export-nonce' ); ?>81 <a href="?page=cmc-hook&cmchk_page=project&cmc_section-project&cmchk_action=export&XDEBUG_SESSION_START&_wpnonce=<?php echo $nonce; ?>&cmchk_id=<?php echo $model['id']; ?>" target="_blank" class="button button-secondary">Export</a>82 <a href="javascript:void(0);" class="button button-secondary" style="float:right;" onclick="jQuery('#cmchk_project_export_form_container').slideToggle('fast');">83 WP Plugin84 <span class="dashicons dashicons-arrow-down" style="float:right;" ></span>85 </a>86 </p>87 88 <div id="cmchk_project_export_form_container" style="display: none;">89 <p style="background: #ccc; padding: 5px;">90 <span> <b><?php echo __('Create Plugin', 'cmchk') ?> </b></span>91 </p>92 <?php require('plugin_form.php') ?>93 </div>94 </div>95 96 </div>97 72 </div> 98 73 <div id="postbody-content-2" class="postbox-container"> … … 102 77 <br class="clear"/> 103 78 </div> 104 79 <!-- 105 80 <div style="float:right;margin-top:-5px;"> 106 81 <button href="javascript:void(0);" class="button button-secondary" onclick="javascript:introJs().start();" >Help</button> 107 82 <button type="button" name="cmchk_action" value="project_editor" class="button button-primary cmchk_project_editor_form_submit" > <?php echo __('Submit', 'cmchk') ?></button> 108 83 </div> 109 84 --> 110 85 <script> 111 86 (function($){ … … 125 100 }).always(function(){$btn.prop('disabled', false);}) 126 101 .fail(function(){alert("Network Error:");}); 127 }); 128 129 $('.cmchk_project_editor_form_submit').click(function(e){ 130 e.preventDefault(); 131 var $btn = $(this), $form = $('.cmchk_project_editor_form'); 132 var url = ajaxurl+'?action=cmchk_project_editor&XDEBUG_SESSION_START='; 133 $('.cmchk_project_editor_form_submit').prop('disabled', true); 134 $.post(url, $form.serialize(), function(data){ 135 if(data.message)alert(data.message); 136 if(data.replace && typeof(data.replace) == 'string'){ 137 $('#cmchk_project_editor_form_container').html(data.replace); 138 } 139 if(data.replace2 && typeof(data.replace2) == 'string'){ 140 $('#cmchk_project_editor_form_container_2').html(data.replace2); 141 } 142 }).always(function(){ 143 $('.cmchk_project_editor_form_submit').prop('disabled', false); 144 }).fail(function(){ alert("Network Error"); }); 145 return false; 146 }); 102 }); 103 147 104 })(jQuery); 148 105 </script> -
cmc-hook/trunk/pages/sections/settings.php
r1648459 r1660954 9 9 exit; 10 10 } 11 if( !cmc_hook::is_user_allowed()){ 12 exit('You do not have permission to view this page'); 13 } 14 11 15 global $cmchk_settings_default; 12 16 $model = get_option('cmc_hook_settings', $cmchk_settings_default);
Note: See TracChangeset
for help on using the changeset viewer.