Skip to content

Commit 3748756

Browse files
Update the styling of every php file
1 parent 506ee45 commit 3748756

File tree

14 files changed

+2570
-2459
lines changed

14 files changed

+2570
-2459
lines changed

includes/Actions.php

Lines changed: 84 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,89 @@
88
* @package WordPress
99
* @subpackage Chipmunk
1010
*/
11-
class Actions {
12-
13-
/**
14-
* Class constructor
15-
*
16-
* @return void
17-
*/
18-
function __construct() {
19-
// Lazy loading posts
20-
add_action( 'wp_ajax_chipmunk_load_posts', array( $this, 'load_posts' ) );
21-
add_action( 'wp_ajax_nopriv_chipmunk_load_posts', array( $this, 'load_posts' ) );
22-
23-
// Submissions
24-
add_action( 'wp_ajax_chipmunk_submit_resource', array( $this, 'submit_resource' ) );
25-
add_action( 'wp_ajax_nopriv_chipmunk_submit_resource', array( $this, 'submit_resource' ) );
26-
27-
// Bookmarks
28-
add_action( 'wp_ajax_chipmunk_toggle_bookmark', array( $this, 'toggle_bookmark' ) );
29-
add_action( 'wp_ajax_nopriv_chipmunk_toggle_bookmark', array( $this, 'toggle_bookmark' ) );
30-
31-
// Upvotes
32-
add_action( 'wp_ajax_chipmunk_toggle_upvote', array( $this, 'toggle_upvote' ) );
33-
add_action( 'wp_ajax_nopriv_chipmunk_toggle_upvote', array( $this, 'toggle_upvote' ) );
34-
}
35-
36-
/**
37-
* Process lazy loading posts
38-
*/
39-
public static function load_posts() {
40-
$template = '';
41-
42-
$query_vars = json_decode( stripslashes( $_REQUEST['queryVars'] ), true );
43-
$query_vars['paged'] = $_REQUEST['page'];
44-
45-
$query = new \WP_Query( $query_vars );
46-
$GLOBALS['wp_query'] = $query;
47-
48-
if ( $query->have_posts() ) {
49-
while ( $query->have_posts() ) : $query->the_post();
50-
if ( isset( $query->query['s'] ) ) {
51-
$template .= Helpers::get_template_part( array( 'sections/entry', 'resource' ), array(), false );
52-
}
53-
else {
54-
$template .= Helpers::get_template_part( 'sections/tile-' . get_post_type(), array(), false );
55-
}
56-
endwhile;
57-
}
58-
59-
if ( ! empty( $template ) ) {
60-
wp_send_json_success( $template );
61-
}
62-
63-
wp_send_json_error( __( 'No more results found.', 'chipmunk' ) );
64-
}
65-
66-
/**
67-
* Process submission callback
68-
*/
69-
public static function submit_resource() {
70-
// Validate nonce token.
71-
check_ajax_referer( 'submit_resource', 'nonce' );
72-
73-
$submissions = new Extensions\Submissions( $_REQUEST );
74-
$submissions->process();
75-
}
76-
77-
/**
78-
* Process bookmark callback
79-
*/
80-
public static function toggle_bookmark() {
81-
$bookmarks = new Extensions\Bookmarks( $_REQUEST['actionPostId'] );
11+
class Actions
12+
{
13+
/**
14+
* Class constructor
15+
*
16+
* @return void
17+
*/
18+
function __construct()
19+
{
20+
// Lazy loading posts
21+
add_action('wp_ajax_chipmunk_load_posts', array($this, 'load_posts'));
22+
add_action('wp_ajax_nopriv_chipmunk_load_posts', array($this, 'load_posts'));
23+
24+
// Submissions
25+
add_action('wp_ajax_chipmunk_submit_resource', array($this, 'submit_resource'));
26+
add_action('wp_ajax_nopriv_chipmunk_submit_resource', array($this, 'submit_resource'));
27+
28+
// Bookmarks
29+
add_action('wp_ajax_chipmunk_toggle_bookmark', array($this, 'toggle_bookmark'));
30+
add_action('wp_ajax_nopriv_chipmunk_toggle_bookmark', array($this, 'toggle_bookmark'));
31+
32+
// Upvotes
33+
add_action('wp_ajax_chipmunk_toggle_upvote', array($this, 'toggle_upvote'));
34+
add_action('wp_ajax_nopriv_chipmunk_toggle_upvote', array($this, 'toggle_upvote'));
35+
}
36+
37+
/**
38+
* Process lazy loading posts
39+
*/
40+
public static function load_posts()
41+
{
42+
$template = '';
43+
44+
$query_vars = json_decode(stripslashes($_REQUEST['queryVars']), true);
45+
$query_vars['paged'] = $_REQUEST['page'];
46+
47+
$query = new \WP_Query($query_vars);
48+
$GLOBALS['wp_query'] = $query;
49+
50+
if ($query->have_posts()) {
51+
while ($query->have_posts()) : $query->the_post();
52+
if (isset($query->query['s'])) {
53+
$template .= Helpers::get_template_part(array('sections/entry', 'resource'), array(), false);
54+
} else {
55+
$template .= Helpers::get_template_part('sections/tile-' . get_post_type(), array(), false);
56+
}
57+
endwhile;
58+
}
59+
60+
if (!empty($template)) {
61+
wp_send_json_success($template);
62+
}
63+
64+
wp_send_json_error(__('No more results found.', 'chipmunk'));
65+
}
66+
67+
/**
68+
* Process submission callback
69+
*/
70+
public static function submit_resource()
71+
{
72+
// Validate nonce token.
73+
check_ajax_referer('submit_resource', 'nonce');
74+
75+
$submissions = new Extensions\Submissions($_REQUEST);
76+
$submissions->process();
77+
}
78+
79+
/**
80+
* Process bookmark callback
81+
*/
82+
public static function toggle_bookmark()
83+
{
84+
$bookmarks = new Extensions\Bookmarks($_REQUEST['actionPostId']);
8285
$bookmarks->process();
83-
}
84-
85-
/**
86-
* Process upvote callback
87-
*/
88-
public static function toggle_upvote() {
89-
$upvotes = new Extensions\Upvotes( $_REQUEST['actionPostId'] );
90-
$upvotes->process();
91-
}
86+
}
87+
88+
/**
89+
* Process upvote callback
90+
*/
91+
public static function toggle_upvote()
92+
{
93+
$upvotes = new Extensions\Upvotes($_REQUEST['actionPostId']);
94+
$upvotes->process();
95+
}
9296
}

0 commit comments

Comments
 (0)