AJAX on Front-End Button Click not working – Custom Plugin

Ok, so it’s pretty easy error – just a typo 😉 You use this line to localize your script: wp_localize_script( ‘ajax-script’, ‘my_foobar_client’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), ‘we_value’ => 1234 ) ); So you use ajax_url field to store url to admin-ajax.php But you use this line in your js file: my_foobar_client.ajaxurl, and there … Read more

Saving frontend form data in wordpress

Also, how are you processing your image upload? That function only sets the enctype. By adding the following beneath your call to wp_insert_post you will be able to process your image upload, if (!function_exists(‘wp_generate_attachment_metadata’)){ require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); } if ($_FILES) { foreach ($_FILES … Read more

how to make nsfw post with thumbanil

get_post_meta is your friend: if ( has_post_thumbnail() ) { if ( ‘yes’ == get_post_meta( $post->ID, ‘NFSWEG’, true ) ) { echo ‘<img src=”https://wordpress.stackexchange.com/questions/82422/YOUR-IMAGE-HERE”>’; } else { the_post_thumbnail( array( 400, 400, true ), array( “class” => “aligncenter featured_image” ) ); } }

How do I apply/target CSS to a specific user role or roles?

If you’re looking for a way to add the roles into the body class, like here: <body class=” … role-administrator role-jedi role-knight … “> then you could try the following: add_filter( ‘body_class’, function( $classes ) { if( is_user_logged_in() ) { $classes = array_merge( (array) $classes, array_map( function( $class ) { return ‘role-‘ . $class; // … Read more

Best way to use ajax front-end?

Never ever use your theme/plugin files directly for ajax calls, always use admin-ajax.php. This is the only recommended way of doing ajax to ensure maximum compatibility with wordpress (including future versions) & 3rd party plugins/themes The best/easiest way depends on the situation & is debatable but i would ask you to use admin-ajax.php even if … Read more

Is it secure to use admin-ajax.php in front?

I would like to know if it is secure to use admin-ajax.php for your ajax requests on the front. There is nothing fundamentally insecure about using it for AJAX requests as a protocol. So is it secure? That question makes little sense, in the same way that “Is a coin flip secure?” doesn’t make a … Read more

Fullscreen Video/GIF Intro

The following code uses HTML5 Video, with the muted & autoplay attributes set. It takes the video, which I uploaded through the media gallery and displays it fullscreen. I’m using a script that detects when the video is done playing, then it fades out and is removed from the DOM. HTML <div class=”fullscreen-bg”> <video muted … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)