@@ -575,33 +575,31 @@ public function renderChartPages() {
575575 do_action ( 'visualizer_pro_new_chart_defaults ' , $ chart_id );
576576 }
577577 } else {
578- if ( current_user_can ( 'edit_posts ' ) ) {
579- $ parent_chart_id = isset ( $ _GET ['parent_chart_id ' ] ) ? filter_var ( $ _GET ['parent_chart_id ' ], FILTER_VALIDATE_INT ) : '' ;
580- $ success = false ;
581- if ( $ parent_chart_id ) {
582- $ parent_chart = get_post ( $ parent_chart_id );
583- $ success = $ parent_chart && $ parent_chart ->post_type === Visualizer_Plugin::CPT_VISUALIZER ;
584- }
585- if ( $ success ) {
586- $ new_chart_id = wp_insert_post (
587- array (
588- 'post_type ' => Visualizer_Plugin::CPT_VISUALIZER ,
589- 'post_title ' => 'Visualization ' ,
590- 'post_author ' => get_current_user_id (),
591- 'post_status ' => $ parent_chart ->post_status ,
592- 'post_content ' => $ parent_chart ->post_content ,
593- )
594- );
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+ );
595594
596- if ( is_wp_error ( $ new_chart_id ) ) {
597- 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__ );
598- } else {
599- $ post_meta = get_post_meta ( $ parent_chart_id );
600- $ chart_id = $ new_chart_id ;
601- foreach ( $ post_meta as $ key => $ value ) {
602- if ( strpos ( $ key , 'visualizer- ' ) !== false ) {
603- add_post_meta ( $ new_chart_id , $ key , maybe_unserialize ( $ value [0 ] ) );
604- }
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 ] ) );
605603 }
606604 }
607605 }
0 commit comments