File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -927,7 +927,19 @@ public static function ppom_install_demo_meta() {
927927
928928 function ppom_attach_meta () {
929929
930- $ product_id = isset ( $ _GET ['productid ' ] ) ? intval ( $ _GET ['productid ' ] ) : '' ;
930+ $ product_id = isset ( $ _GET ['productid ' ] ) ? intval ( $ _GET ['productid ' ] ) : '' ;
931+ $ product_url = get_permalink ( $ product_id );
932+
933+ if ( ! isset ( $ _GET ['nonce ' ] ) || empty ( $ _GET ['nonce ' ] ) || ! wp_verify_nonce ( $ _GET ['nonce ' ], 'ppom_attach ' ) ) {
934+ wp_redirect ( $ product_url );
935+ exit ;
936+ }
937+
938+ if ( ! current_user_can ( 'edit_post ' , $ product_id ) ) {
939+ wp_redirect ( $ product_url );
940+ exit ;
941+ }
942+
931943 $ meta_id = isset ( $ _GET ['metaid ' ] ) ? intval ( $ _GET ['metaid ' ] ) : '' ;
932944 $ meta_title = isset ( $ _GET ['metatitle ' ] ) ? sanitize_title ( $ _GET ['metatitle ' ] ) : '' ;
933945
Original file line number Diff line number Diff line change @@ -808,6 +808,7 @@ function ppom_admin_bar_menu() {
808808 'metaid ' => $ meta ->productmeta_id ,
809809 'metatitle ' => $ meta ->productmeta_name ,
810810 'action ' => 'ppom_attach ' ,
811+ 'nonce ' => wp_create_nonce ( 'ppom_attach ' ),
811812 );
812813 $ apply_link = add_query_arg ( $ apply_arg , $ apply_link );
813814 $ bar_title = "Apply {$ meta ->productmeta_name }" ;
You can’t perform that action at this time.
0 commit comments