Issues (80)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

inc/load-more.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Load More layout.
4
 *
5
 * @package spurs
6
 */
7
8
// Exit if accessed directly.
9
defined( 'ABSPATH' ) || exit;
10
11
if ( ! function_exists( 'spurs_load_more' ) ) {
12
13
	function spurs_load_more() {
14
		global $wp_query; // you can remove this line if everything works for you
15
16
		// don't display the button if there are not enough posts
17
		if (  $wp_query->max_num_pages > 1 )
18
			echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; // you can use <a> as well
19
	}
20
}
21
22
function jd_my_load_more_scripts() {
23
 
24
	global $wp_query; 
25
 
26
	// In most cases it is already included on the page and this line can be removed
27
	wp_enqueue_script('jquery');
28
 
29
	// register our main script but do not enqueue it yet
30
	//wp_register_script( 'my_loadmore', get_stylesheet_directory_uri() . '/js/myloadmore.js', array('jquery') );
31
 
32
	// now the most interesting part
33
	// we have to pass parameters to myloadmore.js script but we can get the parameters values only in PHP
34
	// you can define variables directly in your HTML but I decided that the most proper way is wp_localize_script()
35
	wp_localize_script( 'spurs-scripts', 'spurs_loadmore_params', array(
36
		'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX
37
		'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here
38
		'current_page' => get_query_var( 'paged' ) ? get_query_var('paged') : 1,
39
		'max_page' => $wp_query->max_num_pages
40
	) );
41
 
42
 	wp_enqueue_script( 'my_loadmore' );
43
}
44
add_action( 'wp_enqueue_scripts', 'jd_my_load_more_scripts' );
45
46
function spurs_loadmore_ajax_handler(){
47
 
48
	// prepare our arguments for the query
49
	$args = json_decode( stripslashes( $_POST['query'] ), true );
50
	$args['paged'] = $_POST['page'] + 1; // we need next page to be loaded
51
	$args['post_status'] = 'publish';
52
	$search_page = $_POST['search_page'];
53
 
54
	// it is always better to use WP_Query but not here
55
	query_posts( $args );
56
 
57 View Code Duplication
	if( have_posts() ) :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
 
59
		// run the loop
60
		while( have_posts() ): the_post();
0 ignored issues
show
Please always use braces to surround the code block of WHILE statements.
Loading history...
61
 
62
			// look into your theme code how the posts are inserted, but you can use your own HTML of course
63
			// do you remember? - my example is adapted for Twenty Seventeen theme
64
			if( true == $search_page ){
65
				get_template_part( 'templates/loop/content', 'search' );
66
			} else {
67
				get_template_part( 'templates/loop/content', get_post_format() );
68
			}
69
			// for the test purposes comment the line above and uncomment the below one
70
			// the_title();
71
 
72
 
73
		endwhile;
74
 
75
	endif;
76
	die; // here we exit the script and even no wp_reset_query() required!
77
}
78
add_action('wp_ajax_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_{action}
79
add_action('wp_ajax_nopriv_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_nopriv_{action}