File tree Expand file tree Collapse file tree 1 file changed +20
-20
lines changed
Expand file tree Collapse file tree 1 file changed +20
-20
lines changed Original file line number Diff line number Diff line change 55 >
66 <standard >
77 <![CDATA[
8- Avoid touching the database directly with PHP library functions. Use the $wpdb object and associated functions instead.
8+ Avoid touching the database directly with PHP library functions. Use the $wpdb object and associated functions instead.
99 ]]>
1010 </standard >
1111 <code_comparison >
12- <code title =" Invalid: Using MySQLi library to fetch posts" >
13- <![CDATA[
14- $results = <em>mysqli_query</em>(
15- $mysql,
16- "SELECT * FROM wp_posts LIMIT 5"
17- );
18- ]]>
19- </code >
20- <code title =" Valid: Use WordPress functions" >
12+ <code title =" Valid: Using a WordPress function to fetch posts." >
2113 <![CDATA[
2214$results = <em>get_posts()</em>;
2315 ]]>
2416 </code >
25- </code_comparison >
26- <code_comparison >
27- <code title =" Invalid: Using MySQLi library to insert a post" >
17+ <code title =" Invalid: Using the MySQLi library to fetch posts." >
2818 <![CDATA[
29- <em>mysqli_query</em>(
19+ $results = <em>mysqli_query</em>(
3020 $mysql,
31- "INSERT INTO wp_posts (post_title)
32- VALUES ('Title')"
21+ "SELECT * FROM wp_posts LIMIT 5"
3322);
3423 ]]>
3524 </code >
36- <code title =" Valid: Use WordPress functions" >
25+ </code_comparison >
26+ <code_comparison >
27+ <code title =" Valid: Using WordPress functions to insert a post" >
3728 <![CDATA[
38- <em>wp_insert_post</em>(
29+ <em>wp_insert_post</em>(
3930 array( 'post_title' => 'Title' )
4031);
4132
4233// or...
4334
4435global $wpdb;
45- <em>$wpdb->insert</em>(
36+ <em>$wpdb->insert</em>(
4637 "{$wpdb->prefix}_posts",
4738 array( 'post_title' => 'Title' ),
48- array( '%s' )
39+ array( '%s' )
40+ );
41+ ]]>
42+ </code >
43+ <code title =" Invalid: Using MySQLi library to insert a post" >
44+ <![CDATA[
45+ <em>mysqli_query</em>(
46+ $mysql,
47+ "INSERT INTO wp_posts (post_title)
48+ VALUES ('Title')"
4949);
5050 ]]>
5151 </code >
You can’t perform that action at this time.
0 commit comments