@@ -524,6 +524,10 @@ private function deleteOldCharts() {
524524 * @access public
525525 */
526526 public function renderChartPages () {
527+ if ( ! current_user_can ( 'edit_posts ' ) ) {
528+ wp_die ( __ ( 'You do not have permission to access this page. ' , 'visualizer ' ) );
529+ }
530+
527531 defined ( 'IFRAME_REQUEST ' ) || define ( 'IFRAME_REQUEST ' , 1 );
528532 if ( ! defined ( 'ET_BUILDER_PRODUCT_VERSION ' ) && function_exists ( 'et_get_theme_version ' ) ) {
529533 define ( 'ET_BUILDER_PRODUCT_VERSION ' , et_get_theme_version () );
@@ -571,33 +575,31 @@ public function renderChartPages() {
571575 do_action ( 'visualizer_pro_new_chart_defaults ' , $ chart_id );
572576 }
573577 } else {
574- if ( current_user_can ( 'edit_posts ' ) ) {
575- $ parent_chart_id = isset ( $ _GET ['parent_chart_id ' ] ) ? filter_var ( $ _GET ['parent_chart_id ' ], FILTER_VALIDATE_INT ) : '' ;
576- $ success = false ;
577- if ( $ parent_chart_id ) {
578- $ parent_chart = get_post ( $ parent_chart_id );
579- $ success = $ parent_chart && $ parent_chart ->post_type === Visualizer_Plugin::CPT_VISUALIZER ;
580- }
581- if ( $ success ) {
582- $ new_chart_id = wp_insert_post (
583- array (
584- 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
585- 'post_title ' => 'Visualization ' ,
586- 'post_author ' => get_current_user_id (),
587- 'post_status ' => $ parent_chart ->post_status ,
588- 'post_content ' => $ parent_chart ->post_content ,
589- )
590- );
578+ $ parent_chart_id = isset ( $ _GET ['parent_chart_id ' ] ) ? filter_var ( $ _GET ['parent_chart_id ' ], FILTER_VALIDATE_INT ) : '' ;
579+ $ success = false ;
580+ if ( $ parent_chart_id ) {
581+ $ parent_chart = get_post ( $ parent_chart_id );
582+ $ success = $ parent_chart && $ parent_chart ->post_type === Visualizer_Plugin::CPT_VISUALIZER ;
583+ }
584+ if ( $ success ) {
585+ $ new_chart_id = wp_insert_post (
586+ array (
587+ 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
588+ 'post_title ' => 'Visualization ' ,
589+ 'post_author ' => get_current_user_id (),
590+ 'post_status ' => $ parent_chart ->post_status ,
591+ 'post_content ' => $ parent_chart ->post_content ,
592+ )
593+ );
591594
592- if ( is_wp_error ( $ new_chart_id ) ) {
593- do_action ( 'themeisle_log_event ' , Visualizer_Plugin::NAME , sprintf ( 'Error while cloning chart %d = %s ' , $ parent_chart_id , print_r ( $ new_chart_id , true ) ), 'error ' , __FILE__ , __LINE__ );
594- } else {
595- $ post_meta = get_post_meta ( $ parent_chart_id );
596- $ chart_id = $ new_chart_id ;
597- foreach ( $ post_meta as $ key => $ value ) {
598- if ( strpos ( $ key , 'visualizer- ' ) !== false ) {
599- add_post_meta ( $ new_chart_id , $ key , maybe_unserialize ( $ value [0 ] ) );
600- }
595+ if ( is_wp_error ( $ new_chart_id ) ) {
596+ do_action ( 'themeisle_log_event ' , Visualizer_Plugin::NAME , sprintf ( 'Error while cloning chart %d = %s ' , $ parent_chart_id , print_r ( $ new_chart_id , true ) ), 'error ' , __FILE__ , __LINE__ );
597+ } else {
598+ $ post_meta = get_post_meta ( $ parent_chart_id );
599+ $ chart_id = $ new_chart_id ;
600+ foreach ( $ post_meta as $ key => $ value ) {
601+ if ( strpos ( $ key , 'visualizer- ' ) !== false ) {
602+ add_post_meta ( $ new_chart_id , $ key , maybe_unserialize ( $ value [0 ] ) );
601603 }
602604 }
603605 }
0 commit comments