├── README.md
├── custom-meta
└── index.php
├── custom-script
├── index.php
└── js
│ └── script.js
├── custom-style
├── css
│ └── style.css
└── index.php
├── filter-content
└── index.php
├── first-plugin
└── index.php
├── head-plugin
└── headPlugin.php
├── index.php
├── lwn-clean-plugin
├── admin
│ └── index.php
├── includes
│ └── index.php
├── languages
│ └── index.php
├── lwn-clean-plugin.php
├── public
│ └── index.php
└── uninstall.php
├── lwn-recipe-custom-post
├── includes
│ ├── add-recipe-template.php
│ ├── add-shortcode.php
│ ├── admin-menus.php
│ ├── details-meta-box.php
│ ├── general-meta-box.php
│ ├── recipe-custom-post.php
│ ├── recipe-custom-taxonomy.php
│ └── save-meta-box.php
├── lwn-recipe-custom-post.php
├── notes.txt
├── public
│ └── css
│ │ └── style.css
├── templates
│ └── single-lwn_recipe.php
└── uninstall.php
├── lwn-script-tag
├── admin
│ └── css
│ │ └── style.css
├── includes
│ ├── admin-menus.php
│ ├── display-script.php
│ ├── enqueue-scripts.php
│ ├── settings-api.php
│ └── setup-options.php
├── lwn-script-tag.php
└── uninstall.php
├── lwn-settings-api
├── admin
│ └── index.php
├── includes
│ ├── admin-menus.php
│ ├── config-settings-api.php
│ ├── index.php
│ └── setup-options.php
├── languages
│ └── index.php
├── lwn-settings-api.php
├── public
│ └── index.php
└── uninstall.php
├── meta-settings-2
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-3
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-4
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-5
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-6
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-7
├── css
│ └── style.css
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-8
├── css
│ └── style.css
├── js
│ └── checkbox-script.js
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings-9
├── css
│ └── style.css
├── js
│ └── checkbox-script.js
├── lwn-meta-settings.php
└── meta-settings-2.pot
├── meta-settings
└── lwn-meta-settings.php
└── shortcode-plugin
└── index.php
/README.md:
--------------------------------------------------------------------------------
1 | # wordPress-plugin-development-
2 | How to develop a WordPress plugin? Step by Step Tutorial
3 |
--------------------------------------------------------------------------------
/custom-meta/index.php:
--------------------------------------------------------------------------------
1 | ";
14 | }
15 |
--------------------------------------------------------------------------------
/custom-script/index.php:
--------------------------------------------------------------------------------
1 | ";
13 | }
14 |
--------------------------------------------------------------------------------
/custom-script/js/script.js:
--------------------------------------------------------------------------------
1 | console.log('hi from custom plugin');
2 |
--------------------------------------------------------------------------------
/custom-style/css/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | background: red;
3 | color: #f4f4f4;
4 | }
5 |
--------------------------------------------------------------------------------
/custom-style/index.php:
--------------------------------------------------------------------------------
1 | ";
17 | }
18 |
--------------------------------------------------------------------------------
/filter-content/index.php:
--------------------------------------------------------------------------------
1 | Thank you for reading our post
';
12 | $new_content = $the_content . $footer_content;
13 | return $new_content;
14 | }
15 |
--------------------------------------------------------------------------------
/first-plugin/index.php:
--------------------------------------------------------------------------------
1 | alert('Hi from plugin') ";
13 | }
14 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | ';
37 | $new_content .= '';
38 | $new_content .= '
';
39 | $new_content .= __('Prep time', 'lwn-recipe-custom-type') . ": " . $prep_time ;
40 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
41 | $new_content .= '
';
42 | $new_content .= '
';
43 | $new_content .= __('Cook time', 'lwn-recipe-custom-type') . ": " . $cook_time;
44 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
45 | $new_content .= '
';
46 | $new_content .= '
';
47 | $new_content .= __('Total time', 'lwn-recipe-custom-type') . ": " . $total_time;
48 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
49 | $new_content .= '
';
50 | $new_content .= '
';
51 | $new_content .= __('Servings', 'lwn-recipe-custom-type') . ": " . $servings;
52 | $new_content .= '
';
53 | $new_content .= '
';
54 | $new_content .= __('Meal', 'lwn-recipe-custom-type') . ": " . $meal;
55 | $new_content .= '
';
56 | $new_content .= '
';
57 | $new_content .= __('Vegan', 'lwn-recipe-custom-type') . ": ";
58 | $new_content .= $vegan === 'on' ? 'Yes' : 'No' ;
59 | $new_content .= '
';
60 | $new_content .= '
';
61 | $new_content .= '';
62 | $new_content .= $content;
63 |
64 | $new_content .= '
';
65 |
66 |
67 | $new_content .= '';
68 | return $new_content;
69 | }
70 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/add-shortcode.php:
--------------------------------------------------------------------------------
1 | 'lwn_recipe', 'post_status' => "publish",
9 | 'posts_per_page' => 6
10 | );
11 | $recipes_query->query($query_params);
12 | if ($recipes_query->have_posts()) {
13 | $html = "";
14 | while ($recipes_query->have_posts()) {
15 | $recipes_query->the_post();
16 | $recipes_types = wp_get_post_terms(get_the_ID(), 'lwn_recipe_type');
17 | if ($recipes_types) {
18 | $types = array();
19 | foreach ($recipes_types as $recipe_type) {
20 | $types[] = $recipe_type->name;
21 | }
22 | $terms = esc_html(implode(', ', $types));
23 | } else {
24 | $terms = __('Not classifed', 'lwn-recipe-custom-type');
25 | }
26 | $html .= "
";
27 | $html .= "";
37 | $html .= "
";
38 | $html .= "" . __('Prep Time: ', 'lwn-recipe-custom-type');
39 | $html .= esc_html(get_post_meta(get_the_ID(), 'lwn_recipe_prep_time', true));
40 | $html .= "";
41 | $html .= "" . __('Cook Time: ', 'lwn-recipe-custom-type');
42 | $html .= esc_html(get_post_meta(get_the_ID(), 'lwn_recipe_cook_time', true));
43 | $html .= "";
44 | $html .= "" . __('Servings: ', 'lwn-recipe-custom-type');
45 | $html .= esc_html(get_post_meta(get_the_ID(), 'lwn_recipe_servings', true));
46 | $html .= "";
47 | $html .= "
";
48 | $html .= "
";
49 | $html .= "" . __('Types: ', 'lwn-recipe-custom-type');
50 | $html .= esc_html($terms);
51 | $html .= "";
52 | $html .= "
";
53 | $html .= "
";
54 | }
55 | $html .= "
";
56 | } else {
57 | $html = __('There are no recipes', 'lwn-recipe-custom-type');
58 | }
59 |
60 | wp_reset_postdata();
61 |
62 |
63 | return $html;
64 | }
65 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/admin-menus.php:
--------------------------------------------------------------------------------
1 | ";
20 | echo "Recipe Plugin";
21 | echo "";
22 | echo "";
23 | echo "Please go to the recipe option in the sidebar";
24 | echo "
";
25 | }
26 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/details-meta-box.php:
--------------------------------------------------------------------------------
1 | ID, 'lwn_recipe_ingredients', true);
19 | $steps = get_post_meta($recipe->ID, 'lwn_recipe_steps', true);
20 | $notes = get_post_meta($recipe->ID, 'lwn_recipe_notes', true);
21 |
22 | echo "";
23 | echo "";
24 | echo "";
25 | echo __('Ingredients', 'lwn-recipe-custom-type');
26 | echo " | ";
27 |
28 | echo "";
29 | echo "";
32 | echo " | ";
33 |
34 | echo "
";
35 | echo "";
36 | echo "";
37 | echo __('Steps', 'lwn-recipe-custom-type');
38 | echo " | ";
39 |
40 | echo "";
41 | echo "";
44 | echo " | ";
45 |
46 | echo "
";
47 | echo "";
48 | echo "";
49 | echo __('Notes', 'lwn-recipe-custom-type');
50 | echo " | ";
51 |
52 | echo "";
53 | echo "";
56 | echo " | ";
57 |
58 | echo "
";
59 | echo "
";
60 | }
61 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/general-meta-box.php:
--------------------------------------------------------------------------------
1 | ID, 'lwn_recipe_prep_time', true);
21 | $cook_time = get_post_meta($recipe->ID, 'lwn_recipe_cook_time', true);
22 | $total_time = get_post_meta($recipe->ID, 'lwn_recipe_total_time', true);
23 | $servings = get_post_meta($recipe->ID, 'lwn_recipe_servings', true);
24 | $vegan = get_post_meta($recipe->ID, 'lwn_recipe_vegan', true);
25 | $meal = get_post_meta($recipe->ID, 'lwn_recipe_meal', true);
26 | $meals = array('Breakfast', 'Lunch', 'Dinner');
27 |
28 |
29 | echo "";
108 | }
109 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/recipe-custom-post.php:
--------------------------------------------------------------------------------
1 | array(
8 | 'name' => __('LWN Recipes', 'lwn-recipe-custom-post'),
9 | 'singular_name' => __('LWN Recipe', 'lwn-recipe-custom-post'),
10 | 'add_new' => __('Add New', 'lwn-recipe-custom-post'),
11 | 'add_new_item' => __('Add New Recipe', 'lwn-recipe-custom-post'),
12 | 'edit' => __('Edit', 'lwn-recipe-custom-post'),
13 | 'edit_item' => __('Edit LWN Recipe', 'lwn-recipe-custom-post'),
14 | 'view' => __('View', 'lwn-recipe-custom-post'),
15 | 'view_item' => __('View LWN Recipe', 'lwn-recipe-custom-post'),
16 | 'search_items' => __('Search LWN Recipes', 'lwn-recipe-custom-post'),
17 | 'not_found' => __('No LWN Recipes Foudn', 'lwn-recipe-custom-post'),
18 | 'not_found_in_trash' => __('No LWN Recipes Found in Trash', 'lwn-recipe-custom-post'),
19 |
20 | ),
21 | 'public' => true,
22 | 'supports' => array('title', 'editor', 'thumbnail', 'comments'),
23 | 'taxonomies' => array(),
24 | 'has_archive' => false,
25 | 'exclude_from_search' => true,
26 | 'menu_icon' => 'dashicons-food',
27 | 'menu_position' => 100,
28 | 'rewrite' => array('slug' => 'recipe')
29 |
30 | );
31 | register_post_type('lwn_recipe', $args);
32 | }
33 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/recipe-custom-taxonomy.php:
--------------------------------------------------------------------------------
1 | array(
13 | 'name' => __('Recipe Type', 'lwn-recipe-custom-post'),
14 | 'add_new_item' => __('Add New Recipe Type', 'lwn-recipe-custom-post'),
15 | 'add_item_name' => __('New Recipe Type Name', 'lwn-recipe-custom-post'),
16 | ),
17 | 'show_ui' => true,
18 | 'show_tagcloud' => false,
19 | 'hierarchical' => true
20 | )
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/includes/save-meta-box.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ';
16 | $new_content .= '';
24 |
25 | $new_content .= '';
26 | $new_content .= '
';
27 | $new_content .= __('Prep time', 'lwn-recipe-custom-type') . ": " . $prep_time ;
28 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
29 | $new_content .= '
';
30 | $new_content .= '
';
31 | $new_content .= __('Cook time', 'lwn-recipe-custom-type') . ": " . $cook_time;
32 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
33 | $new_content .= '
';
34 | $new_content .= '
';
35 | $new_content .= __('Total time', 'lwn-recipe-custom-type') . ": " . $total_time;
36 | $new_content .= " " . __('Minutes', 'lwn-recipe-custom-type') ;
37 | $new_content .= '
';
38 | $new_content .= '
';
39 | $new_content .= __('Servings', 'lwn-recipe-custom-type') . ": " . $servings;
40 | $new_content .= '
';
41 | $new_content .= '
';
42 | $new_content .= __('Meal', 'lwn-recipe-custom-type') . ": " . $meal;
43 | $new_content .= '
';
44 | $new_content .= '
';
45 | $new_content .= __('Vegan', 'lwn-recipe-custom-type') . ": ";
46 | $new_content .= $vegan === 'on' ? 'Yes' : 'No' ;
47 | $new_content .= '
';
48 | $new_content .= '
';
49 | $new_content .= '';
50 | $new_content .= get_the_content();
51 | $new_content .= '
';
52 | $new_content .= '';
53 | $new_content .= $notes;
54 | $new_content .= '
';
55 |
56 |
57 | $new_content .= '';
58 |
59 | echo $new_content;
60 | ?>
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/lwn-recipe-custom-post/uninstall.php:
--------------------------------------------------------------------------------
1 | ";
19 | echo "";
24 | echo "";
25 | }
26 |
--------------------------------------------------------------------------------
/lwn-script-tag/includes/display-script.php:
--------------------------------------------------------------------------------
1 | ";
11 | echo $script_content;
12 | echo "";
13 | } else {
14 | return;
15 | }
16 | }
17 |
18 | add_action('wp_head', 'lwn_script_tag_display_in_head');
19 | function lwn_script_tag_display_in_head()
20 | {
21 | $options = lwn_script_tag_get_options();
22 | $script_location = $options['script_location'];
23 | $script_content = $options['script_content'];
24 | if ($script_location === 'Head') {
25 | echo "";
28 | } else {
29 | return;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lwn-script-tag/includes/enqueue-scripts.php:
--------------------------------------------------------------------------------
1 | 'array',
8 | 'sanitize_callback' => 'lwn_script_tag_sanitize_input'
9 | );
10 | register_setting(
11 | 'lwn_script_tag_settings',
12 | 'lwn_script_tag_options',
13 | $args
14 | );
15 |
16 | add_settings_section(
17 | 'lwn_script_tag_main_section',
18 | __('Main Section', 'lwn-script-tag'),
19 | 'lwn_script_tag_main_section_code',
20 | 'lwn-script-tag'
21 | );
22 | add_settings_field(
23 | 'script_location',
24 | __('Script Location', 'lwn-script-tag'),
25 | 'lwn_script_tag_select_script_location',
26 | 'lwn-script-tag',
27 | 'lwn_script_tag_main_section',
28 | array('name' => 'script_location', 'locations' => array('Head', 'Footer'))
29 | );
30 | add_settings_field(
31 | 'script_content',
32 | __('Script Content', 'lwn-script-tag'),
33 | 'lwn_script_tag_textarea_script_content',
34 | 'lwn-script-tag',
35 | 'lwn_script_tag_main_section',
36 | array('name' => 'script_content')
37 | );
38 | }
39 |
40 | //sanitize function
41 | function lwn_script_tag_sanitize_input($input)
42 | {
43 | //sanitize
44 | /* $option1 = 'script_location'; */
45 | /* $option2 = 'script_content'; */
46 | /* if (isset($input[$option1])) { */
47 | /* $input[$option1] = sanitize_text_field($input[$option1]); */
48 | /* } */
49 | /* if (isset($input[$option2])) { */
50 | /* $input[$option2] = sanitize_text_field($input[$option2]); */
51 | /* } */
52 | return $input;
53 | }
54 |
55 | // Main Section
56 | function lwn_script_tag_main_section_code()
57 | {
58 | echo "Main Section
";
59 | }
60 |
61 | // Select Script Location
62 | function lwn_script_tag_select_script_location($data)
63 | {
64 | extract($data);
65 | $options = lwn_script_tag_get_options();
66 | $html = '';
67 | $html .= sprintf('";
76 | echo $html;
77 | }
78 |
79 |
80 | // Script Content
81 | function lwn_script_tag_textarea_script_content($data)
82 | {
83 | extract($data);
84 | $options = lwn_script_tag_get_options();
85 | $html = '';
86 | $html .= sprintf(
87 | '',
88 | esc_html($name),
89 | $options[$name]
90 | );
91 | echo $html;
92 | }
93 |
--------------------------------------------------------------------------------
/lwn-script-tag/includes/setup-options.php:
--------------------------------------------------------------------------------
1 | 'console.log("hii from lwn script tag");',
8 | 'script_location' => 'Footer'
9 |
10 | );
11 |
12 | if (empty($options)) {
13 | update_option('lwn_script_tag_options', $default_options);
14 | }
15 |
16 | return $options;
17 | }
18 |
--------------------------------------------------------------------------------
/lwn-script-tag/lwn-script-tag.php:
--------------------------------------------------------------------------------
1 | ';
19 | echo "Config Page
";
20 | echo "";
26 |
27 | echo "";
28 | }
29 |
--------------------------------------------------------------------------------
/lwn-settings-api/includes/config-settings-api.php:
--------------------------------------------------------------------------------
1 | 'array',
11 | 'description' => 'Example of settings api options',
12 | 'sanitize_callback' => 'lwn_settings_api_sanitize_callback'
13 | )
14 | );
15 |
16 | // Add Section
17 | add_settings_section(
18 | 'lwn_settings_api_main_section',
19 | __('Our Main Settings', 'lwn-settings-api'),
20 | 'lwn_settings_api_display_main_section',
21 | 'lwn-settings-api'
22 | ) ;
23 |
24 | // Add Field
25 | add_settings_field(
26 | 'lwn_text_field',
27 | __('Text Field', 'lwn-settings-api'),
28 | 'lwn_settings_api_display_text_field',
29 | 'lwn-settings-api',
30 | 'lwn_settings_api_main_section',
31 | array(
32 | 'name' => 'lwn_text_field'
33 | )
34 | );
35 | // Add Field
36 | add_settings_field(
37 | 'lwn_checkbox_field',
38 | __('Checkbox Field', 'lwn-settings-api'),
39 | 'lwn_settings_api_display_checkbox_field',
40 | 'lwn-settings-api',
41 | 'lwn_settings_api_main_section',
42 | array(
43 | 'name' => 'lwn_checkbox_field'
44 | )
45 | );
46 | }
47 |
48 | // Sanitize Callback
49 | function lwn_settings_api_sanitize_callback($input)
50 | {
51 | $option1 = 'lwn_text_field';
52 | $option2 = 'lwn_checkbox_field';
53 |
54 | if (isset($input[$option1])) {
55 | $input[$option1] = sanitize_text_field($input[$option1]);
56 | }
57 |
58 | if (isset($input[$option2])) {
59 | $input[$option2] =true;
60 | } else {
61 | $input[$option2] =false;
62 | }
63 |
64 |
65 | return $input;
66 | }
67 |
68 |
69 | // Main Section
70 | function lwn_settings_api_display_main_section()
71 | {
72 | // html to display on main section
73 | echo "Main Section
";
74 | }
75 |
76 | // Text Field HTML
77 | function lwn_settings_api_display_text_field($data)
78 | {
79 | extract($data);
80 | $options = lwn_settings_api_get_options(); ?>
81 |
82 |
83 |
84 |
91 | />
92 |
93 |
94 |
95 | 'Default text',
9 | 'lwn_checkbox_field' => false
10 | );
11 | if (empty($options)) {
12 | update_option('lwn_settings_api_options', $default_options);
13 | }
14 |
15 | return $options;
16 | }
17 |
--------------------------------------------------------------------------------
/lwn-settings-api/languages/index.php:
--------------------------------------------------------------------------------
1 | ';
54 | $html .= '';
55 | $html .= __('Meta Tags', 'meta-settings-2');
56 | $html .= '
';
57 | $html .= '';
58 | $html .= __('Your current meta name is: ', 'meta-settings-2');
59 | $html .= $tag_name;
60 | $html .= '
';
61 | $html .= '';
62 | $html .= __('Your current meta content is: ', 'meta-settings-2');
63 | $html .= $tag_content;
64 | $html .= '
';
65 | $html .= '
';
66 | $html .= '';
67 | $html .= __('Add your tags here', 'meta-settings-2');
68 | $html .= '
';
69 | // add your form here
70 | $html .= '