Issues (130)

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.

includes/post-types.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 21 and the first side effect is on line 11.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Post Type Functions
4
 *
5
 * @package     PrintCenter\Scripts
6
 * @since       1.0.0
7
 */
8
9
// Exit if accessed directly
10
if( ! defined( 'ABSPATH' ) ) {
11
	exit;
12
}
13
14
15
/**
16
 * Registers custom post types
17
 *
18
 * @since       1.0.0
19
 * @return      void
20
 */
21
function printcenter_setup_post_types() {
22
	$ssi_product_labels = apply_filters( 'printcenter_ssi_product_labels', array(
23
		'name'               => _x( 'SSI Products', 'ssi product post type name', 'printcenter' ),
24
		'singular_name'      => _x( 'SSI Product', 'singular ssi product post type name', 'printcenter' ),
25
		'add_new'            => __( 'Add New', 'printcenter' ),
26
		'add_new_item'       => __( 'Add New SSI Product', 'printcenter' ),
27
		'edit_item'          => __( 'Edit SSI Product', 'printcenter' ),
28
		'new_item'           => __( 'New SSI Product', 'printcenter' ),
29
		'all_items'          => __( 'All SSI Products', 'printcenter' ),
30
		'view_item'          => __( 'View SSI Product', 'printcenter' ),
31
		'search_items'       => __( 'Search SSI Products', 'printcenter' ),
32
		'not_found'          => __( 'No SSI Products found', 'printcenter' ),
33
		'not_found_in_trash' => __( 'No SSI Products found in Trash', 'printcenter' ),
34
		'parent_item_colon'  => '',
35
		'menu_name'          => _x( 'SSI Products', 'ssi product post type menu name', 'printcenter' )
36
	) );
37
38
	$ssi_product_args = array(
39
		'labels'             => $ssi_product_labels,
40
		'public'             => true,
41
		'publicly_queryable' => true,
42
		'show_ui'            => true,
43
		'show_in_menu'       => false,
44
		'has_archive'        => false,
45
		'hierarchical'       => false,
46
		'supports'           => apply_filters( 'printcenter_ssi_product_supports', array( 'title' ) ),
47
	);
48
	register_post_type( 'ssi_product', apply_filters( 'printcenter_ssi_product_post_type_args', $ssi_product_args ) );
49
}
50
add_action( 'init', 'printcenter_setup_post_types', 1 );
51
52
53
/**
54
 * Change default "Enter title here" input
55
 *
56
 * @since       1.0.0
57
 * @param       string $title Default title placeholder text
58
 * @return      string $title New placeholder text
59
 */
60
function printcenter_change_default_title( $title ) {
61
	$screen = get_current_screen();
62
63
	if( $screen->post_type == 'ssi_product' ) {
64
		$title = __( 'Enter product name here', 'printcenter' );
65
	}
66
67
	return $title;
68
}
69
add_filter( 'enter_title_here', 'printcenter_change_default_title' );
70
71
72
/**
73
 * Updated Messages
74
 *
75
 * @since       1.0.0
76
 * @param       array $messages Post updated message
77
 * @return      array $messages New post updated messages
78
 */
79
function printcenter_updated_messages( $messages ) {
80
	$messages['ssi_product'] = array(
81
		1 => __( 'Product updated.', 'printcenter' ),
82
		4 => __( 'Product updated.', 'printcenter' ),
83
		6 => __( 'Product published.', 'printcenter' ),
84
		7 => __( 'Product saved.', 'printcenter' ),
85
		8 => __( 'Product submitted.', 'printcenter' )
86
	);
87
88
	return $messages;
89
}
90
add_filter( 'post_updated_messages', 'printcenter_updated_messages' );
91
92
93
/**
94
 * Updated bulk messages
95
 *
96
 * @since       1.0.0
97
 * @param       array $bulk_messages Post updated messages
98
 * @param       array $bulk_counts Post counts
99
 * @return      array $bulk_messages New post updated messages
100
 */
101
function printcenter_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
102
	$singular = __( 'Product', 'printcenter' );
103
	$plural   = __( 'Products', 'printcenter' );
104
105
	$bulk_messages['download'] = array(
106
		'updated'   => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'printcenter' ), $bulk_counts['updated'], $singular, $plural ),
107
		'locked'    => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'printcenter' ), $bulk_counts['locked'], $singular, $plural ),
108
		'deleted'   => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'printcenter' ), $bulk_counts['deleted'], $singular, $plural ),
109
		'trashed'   => sprintf( _n( '%1$s %2$s moved to the Trash.', '%1$s %3$s moved to the Trash.', $bulk_counts['trashed'], 'printcenter' ), $bulk_counts['trashed'], $singular, $plural ),
110
		'untrashed' => sprintf( _n( '%1$s %2$s restored from the Trash.', '%1$s %3$s restored from the Trash.', $bulk_counts['untrashed'], 'printcenter' ), $bulk_counts['untrashed'], $singular, $plural )
111
	);
112
113
	return $bulk_messages;
114
}
115
add_filter( 'bulk_post_updated_messages', 'printcenter_bulk_updated_messages', 10, 2 );
116
117
118
/**
119
 * Creates the admin submenu pages for custom post types
120
 *
121
 * @since       1.0.0
122
 * @return      void
123
 */
124
function printcenter_add_menu_items() {
125
	add_submenu_page( 'printcenter-settings', __( 'PrintCenter Settings', 'printcenter' ), __( 'Settings', 'printcenter' ), 'manage_options', 'printcenter-settings' );
126
	add_submenu_page( 'printcenter-settings', __( 'SSI Products', 'printcenter' ), __( 'SSI Products', 'printcenter' ), 'manage_options', 'edit.php?post_type=ssi_product' );
127
	add_submenu_page( 'printcenter-settings', __( 'Commissions', 'printcenter' ), __( 'Commissions', 'printcenter' ), 'manage_options', 'edit.php?post_type=shop_commission' );
128
}
129
add_action( 'admin_menu', 'printcenter_add_menu_items', 10 );
130
131
132
/**
133
 * Trick to keep menu active when editing products
134
 *
135
 * @since       1.0.0
136
 * @return      void
137
 */
138
function printcenter_fix_active_menu_item() {
139
	// Not one of our post types, bail out
140
	global $typenow;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
141
142
	if( ! in_array( $typenow, array( 'ssi_product', 'shop_commission' ) ) ) {
143
		return;
144
	}
145
	?>
146
<script type="text/javascript">
147
jQuery(document).ready( function($) {
148
	$('.wp-has-current-submenu').removeClass('wp-has-current-submenu');
149
    $('#toplevel_page_printcenter-settings').removeClass('wp-not-current-submenu').addClass('wp-has-current-submenu wp-menu-open');
150
    $('#toplevel_page_printcenter-settings a[href="admin.php?page=printcenter-settings"]:first').removeClass('wp-not-current-submenu').addClass('wp-has-current-submenu wp-menu-open');
151
    $('#toplevel_page_printcenter-settings a[href="edit.php?post_type=<?php echo $typenow; ?>"]').addClass('current');
152
    $('#toplevel_page_printcenter-settings a[href="edit.php?post_type=<?php echo $typenow; ?>"]').closest('li').addClass('current');
153
});
154
</script>
155
	<?php
156
}
157
add_action( 'admin_head-post-new.php', 'printcenter_fix_active_menu_item' );
158
add_action( 'admin_head-post.php', 'printcenter_fix_active_menu_item' );
159