├── 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 .= "
"; 28 | $html .= "

"; 29 | $html .= "" ; 30 | $html .= get_the_title(); 31 | 32 | $html .= ""; 33 | $html .= "

"; 34 | 35 | 36 | $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 ""; 27 | 28 | echo ""; 33 | 34 | echo ""; 35 | echo ""; 36 | echo ""; 39 | 40 | echo ""; 45 | 46 | echo ""; 47 | echo ""; 48 | echo ""; 51 | 52 | echo ""; 57 | 58 | echo ""; 59 | echo "
"; 25 | echo __('Ingredients', 'lwn-recipe-custom-type'); 26 | echo ""; 29 | echo ""; 32 | echo "
"; 37 | echo __('Steps', 'lwn-recipe-custom-type'); 38 | echo ""; 41 | echo ""; 44 | echo "
"; 49 | echo __('Notes', 'lwn-recipe-custom-type'); 50 | echo ""; 53 | echo ""; 56 | 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 ""; 30 | echo ""; 31 | echo ""; 34 | 35 | echo ""; 40 | 41 | echo ""; 42 | echo ""; 43 | echo ""; 46 | 47 | echo ""; 52 | 53 | echo ""; 54 | echo ""; 55 | echo ""; 58 | 59 | echo ""; 64 | 65 | echo ""; 66 | echo ""; 67 | echo ""; 70 | 71 | echo ""; 76 | 77 | echo ""; 78 | echo ""; 79 | echo ""; 82 | 83 | echo ""; 88 | 89 | echo ""; 90 | echo ""; 91 | echo ""; 94 | 95 | echo ""; 105 | 106 | echo ""; 107 | echo "
"; 32 | echo __('Prep Time (in Minutes)', 'lwn-recipe-custom-type'); 33 | echo ""; 36 | echo ""; 39 | echo "
"; 44 | echo __('Cook Time (in Minutes)', 'lwn-recipe-custom-type'); 45 | echo ""; 48 | echo ""; 51 | echo "
"; 56 | echo __('Total Time (in Minutes)', 'lwn-recipe-custom-type'); 57 | echo ""; 60 | echo ""; 63 | echo "
"; 68 | echo __('Servings', 'lwn-recipe-custom-type'); 69 | echo ""; 72 | echo ""; 75 | echo "
"; 80 | echo __('Vegan?', 'lwn-recipe-custom-type'); 81 | echo ""; 84 | echo "'; 87 | echo "
"; 92 | echo __('Meal', 'lwn-recipe-custom-type'); 93 | echo ""; 96 | echo ""; 104 | 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 .= '
'; 17 | $new_content .= '
'; 18 | $new_content .= get_the_post_thumbnail($id, 'medium'); 19 | $new_content .= '
'; 20 | $new_content .= '

'; 21 | $new_content .= get_the_title(); 22 | $new_content .= '

'; 23 | $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 "
"; 20 | settings_fields('lwn_script_tag_settings'); 21 | do_settings_sections('lwn-script-tag'); 22 | echo ""; 23 | 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 "
"; 21 | settings_fields('lwn_settings_api_settings'); 22 | 23 | do_settings_sections('lwn-settings-api'); 24 | echo ""; 25 | 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 .= '
'; 71 | $html .= '
'; 72 | $html .= ' '; 75 | $html .= ""; 76 | $html .= '
'; 77 | $html .= '
'; 78 | $html .= ' '; 81 | $html .= ""; 82 | $html .= '
'; 83 | $html .= '
'; 84 | $html .= ""; 110 | } 111 | -------------------------------------------------------------------------------- /meta-settings-2/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-3/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-3/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | '; 54 | $html .= '

'; 55 | $html .= __('Meta Tags', 'meta-settings-3'); 56 | $html .= '

'; 57 | $html .= '

'; 58 | $html .= __('Your current meta name is: ', 'meta-settings-3'); 59 | $html .= $tag_name; 60 | $html .= '

'; 61 | $html .= '

'; 62 | $html .= __('Your current meta content is: ', 'meta-settings-3'); 63 | $html .= $tag_content; 64 | $html .= '

'; 65 | $html .= '
'; 66 | $html .= '

'; 67 | $html .= __('Add your tags here', 'meta-settings-3'); 68 | $html .= '

'; 69 | // add your form here 70 | $html .= ''; 71 | $html .= ''; 72 | $html .= wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 73 | $html .= '
'; 74 | $html .= ' '; 77 | $html .= ""; 78 | $html .= '
'; 79 | $html .= '
'; 80 | $html .= ' '; 83 | $html .= ""; 84 | $html .= '
'; 85 | $html .= '
'; 86 | $html .= ""; 144 | } 145 | -------------------------------------------------------------------------------- /meta-settings-3/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-4/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-4/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | 'description', 38 | 'meta_content' => 'here is website description', 39 | ]; 40 | if (empty($options)) { 41 | update_option('lwn_meta_tags_options', $default_options); 42 | } 43 | return $options; 44 | } 45 | 46 | /** Add plugin menu to settings */ 47 | add_action('admin_menu', 'lwn_meta_settings_menu'); 48 | function lwn_meta_settings_menu() 49 | { 50 | add_options_page( 51 | 'LWN Meta Tags', 52 | 'LWN Meta', 53 | 'manage_options', 54 | 'lwn-meta-tags', 55 | 'lwn_meta_tags_config_page' 56 | ); 57 | } 58 | 59 | /**HTML Code for configuration page*/ 60 | function lwn_meta_tags_html_code($tag_name, $tag_content) 61 | { 62 | if (isset($_GET['message']) && ($_GET['message'] = 'ok')) { 63 | $message_text = 64 | '
'; 65 | $message_text .= '

'; 66 | $message_text .= ''; 67 | $message_text .= __('Settings Saved', 'meta-settings-4'); 68 | $message_text .= ''; 69 | $message_text .= '

'; 70 | 71 | $message_text .= '
'; 72 | } else { 73 | $message_text = ''; 74 | } 75 | $html = '
'; 76 | $html .= $message_text; 77 | $html .= '

'; 78 | $html .= __('Meta Tags', 'meta-settings-4'); 79 | $html .= '

'; 80 | $html .= '

'; 81 | $html .= __('Your current meta name is: ', 'meta-settings-4'); 82 | $html .= $tag_name; 83 | $html .= '

'; 84 | $html .= '

'; 85 | $html .= __('Your current meta content is: ', 'meta-settings-4'); 86 | $html .= $tag_content; 87 | $html .= '

'; 88 | $html .= '
'; 89 | $html .= '

'; 90 | $html .= __('Add your tags here', 'meta-settings-4'); 91 | $html .= '

'; 92 | // add your form here 93 | $html .= ''; 94 | $html .= ''; 95 | $html .= wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 96 | $html .= '
'; 97 | $html .= ' '; 100 | $html .= ""; 101 | $html .= '
'; 102 | $html .= '
'; 103 | $html .= ' '; 106 | $html .= ""; 107 | $html .= '
'; 108 | $html .= '
'; 109 | $html .= " 'lwn-meta-tags', 'message' => 'ok'], 167 | admin_url('options-general.php') 168 | ) 169 | ); 170 | exit(); 171 | } 172 | 173 | /** Add meta tag to the head */ 174 | add_action('wp_head', 'lwn_add_meta_tag'); 175 | 176 | function lwn_add_meta_tag() 177 | { 178 | $meta_name = get_option('lwn_meta_tag_name'); 179 | $meta_content = get_option('lwn_meta_tag_content'); 180 | echo ""; 181 | } 182 | -------------------------------------------------------------------------------- /meta-settings-4/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-5/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-5/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | 'description', 38 | 'meta_content' => 'here is website description', 39 | ]; 40 | if (empty($options)) { 41 | update_option('lwn_meta_tags_options', $default_options); 42 | } 43 | return $options; 44 | } 45 | 46 | /** Add plugin menu to settings */ 47 | add_action('admin_menu', 'lwn_meta_settings_menu'); 48 | function lwn_meta_settings_menu() 49 | { 50 | add_options_page( 51 | 'LWN Meta Tags', 52 | 'LWN Meta', 53 | 'manage_options', 54 | 'lwn-meta-tags', 55 | 'lwn_meta_tags_config_page' 56 | ); 57 | } 58 | 59 | /**HTML Code for configuration page*/ 60 | function lwn_meta_tags_html_code($tag_name, $tag_content) 61 | { 62 | if (isset($_GET['message']) && $_GET['message'] === 'ok') { 63 | $message_text = 64 | '
'; 65 | $message_text .= '

'; 66 | $message_text .= ''; 67 | $message_text .= __('Settings Saved', 'meta-settings-5'); 68 | $message_text .= ''; 69 | $message_text .= '

'; 70 | 71 | $message_text .= '
'; 72 | } elseif (isset($_GET['message']) && $_GET['message'] === 'notOk') { 73 | $message_text = 74 | '
'; 75 | $message_text .= '

'; 76 | $message_text .= ''; 77 | $message_text .= __( 78 | 'Something wrong happened, or you did not change the values.', 79 | 'meta-settings-5' 80 | ); 81 | $message_text .= ''; 82 | $message_text .= '

'; 83 | 84 | $message_text .= '
'; 85 | } else { 86 | $message_text = ''; 87 | } 88 | $html = '
'; 89 | $html .= $message_text; 90 | $html .= '

'; 91 | $html .= __('Meta Tags', 'meta-settings-5'); 92 | $html .= '

'; 93 | $html .= '
'; 94 | $html .= __('Your current meta name is: ', 'meta-settings-5'); 95 | $html .= $tag_name; 96 | $html .= '
'; 97 | $html .= '
'; 98 | $html .= __('Your current meta content is: ', 'meta-settings-5'); 99 | $html .= $tag_content; 100 | $html .= '
'; 101 | $html .= '
'; 102 | $html .= '

'; 103 | $html .= __('Add your tags here', 'meta-settings-5'); 104 | $html .= '

'; 105 | // add your form here 106 | $html .= ''; 107 | $html .= ''; 108 | $html .= wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 109 | $html .= '
'; 110 | $html .= ' '; 113 | $html .= ""; 114 | $html .= '
'; 115 | $html .= '
'; 116 | $html .= ' '; 119 | $html .= ""; 120 | $html .= '
'; 121 | $html .= '
'; 122 | $html .= " 'lwn-meta-tags', 'message' => $msg], 181 | admin_url('options-general.php') 182 | ) 183 | ); 184 | exit(); 185 | } 186 | 187 | /** Add meta tag to the head */ 188 | add_action('wp_head', 'lwn_add_meta_tag'); 189 | 190 | function lwn_add_meta_tag() 191 | { 192 | $meta_name = get_option('lwn_meta_tag_name'); 193 | $meta_content = get_option('lwn_meta_tag_content'); 194 | echo ""; 195 | } 196 | -------------------------------------------------------------------------------- /meta-settings-5/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-6/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-6/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | 'description', 39 | 'content' => 'here is website description', 40 | ], 41 | [ 42 | 'name' => 'author', 43 | 'content' => 'Nawras Ali', 44 | ], 45 | [ 46 | 'name' => 'extra 1', 47 | 'content' => 'Extra 1 content here', 48 | ], 49 | [ 50 | 'name' => 'extra 2', 51 | 'content' => 'Extra 2 content here', 52 | ], 53 | [ 54 | 'name' => 'extra 3', 55 | 'content' => 'Extra 3 content here', 56 | ], 57 | ]; 58 | if (empty($options)) { 59 | update_option('lwn_meta_tags_options', $default_options); 60 | } 61 | return $options; 62 | } 63 | 64 | /** Add plugin menu to settings */ 65 | add_action('admin_menu', 'lwn_meta_settings_menu'); 66 | function lwn_meta_settings_menu() 67 | { 68 | add_options_page( 69 | 'LWN Meta Tags', 70 | 'LWN Meta', 71 | 'manage_options', 72 | 'lwn-meta-tags', 73 | 'lwn_meta_tags_config_page' 74 | ); 75 | } 76 | 77 | /**HTML Code for configuration page*/ 78 | function lwn_meta_tags_html_code($tags) 79 | { 80 | if (isset($_GET['message']) && $_GET['message'] === 'ok') { 81 | $message_text = 82 | '
'; 83 | $message_text .= '

'; 84 | $message_text .= ''; 85 | $message_text .= __('Settings Saved', 'meta-settings-6'); 86 | $message_text .= ''; 87 | $message_text .= '

'; 88 | 89 | $message_text .= '
'; 90 | } elseif (isset($_GET['message']) && $_GET['message'] === 'notOk') { 91 | $message_text = 92 | '
'; 93 | $message_text .= '

'; 94 | $message_text .= ''; 95 | $message_text .= __( 96 | 'Something wrong happened, or you did not change the values.', 97 | 'meta-settings-6' 98 | ); 99 | $message_text .= ''; 100 | $message_text .= '

'; 101 | 102 | $message_text .= '
'; 103 | } else { 104 | $message_text = ''; 105 | } 106 | echo '
'; 107 | echo $message_text; 108 | echo '

'; 109 | echo __('Meta Tags', 'meta-settings-6'); 110 | echo '

'; 111 | echo '
'; 112 | echo '

'; 113 | echo __('Add your tags here', 'meta-settings-6'); 114 | echo '

'; 115 | // add your form here 116 | echo ''; 117 | echo ''; 118 | echo wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 119 | foreach ($tags as $index => $tag) { 120 | foreach ($tag as $key => $value) { 121 | if ($key === 'name') { 122 | $label = __('Meta Name', 'meta-settings-6'); 123 | } elseif ($key === 'content') { 124 | $label = __('Meta Content', 'meta-settings-6'); 125 | } else { 126 | $label = __('Unknown Meta Label', 'meta-settings-6'); 127 | } 128 | echo '
'; 129 | echo " '; 132 | echo ""; 133 | echo '
'; 134 | } 135 | echo '
'; 136 | } 137 | echo '
'; 138 | echo ""; 141 | echo '
'; 142 | 143 | echo ''; 144 | 145 | echo '
'; 146 | } 147 | function lwn_meta_tags_config_page() 148 | { 149 | $meta_tags = lwn_get_options(); 150 | 151 | lwn_meta_tags_html_code($meta_tags); 152 | } 153 | 154 | /* Save Meta to Database**/ 155 | add_action('admin_init', 'lwn_meta_tags_admin_init'); 156 | function lwn_meta_tags_admin_init() 157 | { 158 | add_action('admin_post_lwn_save_meta_tags', 'lwn_save_options_to_db'); 159 | } 160 | function lwn_save_options_to_db() 161 | { 162 | if (!current_user_can('manage_options')) { 163 | wp_die( 164 | __('You have no authorization to do this action.', 'meta-settings-6') 165 | ); 166 | } 167 | check_admin_referer('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 168 | 169 | // Get options 170 | $options = lwn_get_options(); 171 | $updated_options = []; 172 | if (isset($_POST)) { 173 | foreach ($options as $index => $meta_tag) { 174 | $posted_data = []; 175 | foreach ($meta_tag as $key => $value) { 176 | $field_name = 'lwn-meta-' . $key . '-' . $index; 177 | if (isset($_POST[$field_name])) { 178 | $clean = sanitize_text_field($_POST[$field_name]); 179 | $posted_data[$key] = $clean; 180 | } 181 | } 182 | 183 | $updated_options[$index] = $posted_data; 184 | } 185 | // save to db 186 | $isUpdated = update_option('lwn_meta_tags_options', $updated_options); 187 | 188 | // Homework: 189 | // if the option is updated, show ok message; 190 | // otherwise, show error message 191 | $msg = $isUpdated ? 'ok' : 'notOk'; 192 | 193 | wp_redirect( 194 | add_query_arg( 195 | ['page' => 'lwn-meta-tags', 'message' => $msg], 196 | admin_url('options-general.php') 197 | ) 198 | ); 199 | exit(); 200 | } 201 | } 202 | 203 | /** Add meta tag to the head */ 204 | add_action('wp_head', 'lwn_add_meta_tag'); 205 | 206 | function lwn_add_meta_tag() 207 | { 208 | $options = lwn_get_options(); 209 | foreach ($options as $index => $option) { 210 | $meta_name = $option['name']; 211 | $meta_content = $option['content']; 212 | echo ""; 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /meta-settings-6/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-7/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-7/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | '; */ 37 | /* } */ 38 | 39 | /** Add options to db upon plugin activation */ 40 | register_activation_hook(__FILE__, 'lwn_set_meta_options'); 41 | function lwn_set_meta_options() 42 | { 43 | lwn_get_options(); 44 | } 45 | 46 | /**Get Options */ 47 | function lwn_get_options() 48 | { 49 | $options = get_option('lwn_meta_tags_options', []); 50 | $default_options = [ 51 | [ 52 | 'name' => 'description', 53 | 'content' => 'here is website description', 54 | 'show' => 'no', 55 | ], 56 | [ 57 | 'name' => 'author', 58 | 'content' => 'Nawras Ali', 59 | 'show' => 'no', 60 | ], 61 | [ 62 | 'name' => 'extra 1', 63 | 'content' => 'Extra 1 content here', 64 | 'show' => 'no', 65 | ], 66 | [ 67 | 'name' => 'extra 2', 68 | 'content' => 'Extra 2 content here', 69 | 'show' => 'no', 70 | ], 71 | [ 72 | 'name' => 'extra 3', 73 | 'content' => 'Extra 3 content here', 74 | 'show' => 'no', 75 | ], 76 | ]; 77 | if (empty($options)) { 78 | update_option('lwn_meta_tags_options', $default_options); 79 | } 80 | return $options; 81 | } 82 | 83 | /** Add plugin menu to settings */ 84 | add_action('admin_menu', 'lwn_meta_settings_menu'); 85 | function lwn_meta_settings_menu() 86 | { 87 | add_options_page( 88 | 'LWN Meta Tags', 89 | 'LWN Meta', 90 | 'manage_options', 91 | 'lwn-meta-tags', 92 | 'lwn_meta_tags_config_page' 93 | ); 94 | } 95 | 96 | /**HTML Code for configuration page*/ 97 | function lwn_meta_tags_html_code($tags) 98 | { 99 | if (isset($_GET['message']) && $_GET['message'] === 'ok') { 100 | $message_text = 101 | '
'; 102 | $message_text .= '

'; 103 | $message_text .= ''; 104 | $message_text .= __('Settings Saved', 'meta-settings-7'); 105 | $message_text .= ''; 106 | $message_text .= '

'; 107 | 108 | $message_text .= '
'; 109 | } elseif (isset($_GET['message']) && $_GET['message'] === 'notOk') { 110 | $message_text = 111 | '
'; 112 | $message_text .= '

'; 113 | $message_text .= ''; 114 | $message_text .= __( 115 | 'Something wrong happened, or you did not change the values.', 116 | 'meta-settings-7' 117 | ); 118 | $message_text .= ''; 119 | $message_text .= '

'; 120 | 121 | $message_text .= '
'; 122 | } else { 123 | $message_text = ''; 124 | } 125 | echo '
'; 126 | echo $message_text; 127 | echo '

'; 128 | echo __('Meta Tags', 'meta-settings-7'); 129 | echo '

'; 130 | echo '
'; 131 | echo '

'; 132 | echo __('Add your tags here', 'meta-settings-7'); 133 | echo '

'; 134 | // add your form here 135 | echo '
'; 136 | echo ''; 137 | echo wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 138 | foreach ($tags as $index => $tag) { 139 | foreach ($tag as $key => $value) { 140 | if ($key === 'name') { 141 | $label = __('Meta Name', 'meta-settings-7'); 142 | $type = 'text'; 143 | $checked = ''; 144 | } elseif ($key === 'content') { 145 | $label = __('Meta Content', 'meta-settings-7'); 146 | $type = 'text'; 147 | $checked = ''; 148 | } elseif ($key === 'show') { 149 | $label = __('Show Meta?', 'meta-settings-7'); 150 | $type = 'checkbox'; 151 | $checked = $value === 'yes' ? "checked='checked'" : ''; 152 | } else { 153 | $label = __('Unknown Meta Label', 'meta-settings-7'); 154 | $type = 'text'; 155 | $checked = ''; 156 | } 157 | echo '
'; 158 | echo " '; 161 | echo ""; 162 | echo '
'; 163 | } 164 | echo '
'; 165 | } 166 | echo '
'; 167 | echo ""; 170 | echo '
'; 171 | 172 | echo '
'; 173 | 174 | echo '
'; 175 | } 176 | function lwn_meta_tags_config_page() 177 | { 178 | $meta_tags = lwn_get_options(); 179 | 180 | lwn_meta_tags_html_code($meta_tags); 181 | } 182 | 183 | /* Save Meta to Database**/ 184 | add_action('admin_init', 'lwn_meta_tags_admin_init'); 185 | function lwn_meta_tags_admin_init() 186 | { 187 | add_action('admin_post_lwn_save_meta_tags', 'lwn_save_options_to_db'); 188 | } 189 | function lwn_save_options_to_db() 190 | { 191 | if (!current_user_can('manage_options')) { 192 | wp_die( 193 | __('You have no authorization to do this action.', 'meta-settings-7') 194 | ); 195 | } 196 | check_admin_referer('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 197 | 198 | // Get options 199 | $options = lwn_get_options(); 200 | $updated_options = []; 201 | if (isset($_POST)) { 202 | foreach ($options as $index => $meta_tag) { 203 | $posted_data = []; 204 | foreach ($meta_tag as $key => $value) { 205 | $field_name = 'lwn-meta-' . $key . '-' . $index; 206 | if (isset($_POST[$field_name])) { 207 | if ($key === 'show') { 208 | $new_value = $value === 'no' ? 'yes' : 'no'; 209 | // change value in dom directly 210 | // a possible jquery solution 211 | // it needs more work 212 | /* lwn_change_checkbox_value($field_name, $new_value); */ 213 | $posted_data[$key] = $new_value; 214 | } else { 215 | $clean = sanitize_text_field($_POST[$field_name]); 216 | $posted_data[$key] = $clean; 217 | } 218 | } 219 | } 220 | 221 | $updated_options[$index] = array_merge($options[$index], $posted_data); 222 | } 223 | // save to db 224 | $isUpdated = update_option('lwn_meta_tags_options', $updated_options); 225 | 226 | // Homework: 227 | // if the option is updated, show ok message; 228 | // otherwise, show error message 229 | $msg = $isUpdated ? 'ok' : 'notOk'; 230 | 231 | wp_redirect( 232 | add_query_arg( 233 | ['page' => 'lwn-meta-tags', 'message' => $msg], 234 | admin_url('options-general.php') 235 | ) 236 | ); 237 | exit(); 238 | } 239 | } 240 | 241 | /** Add meta tag to the head */ 242 | add_action('wp_head', 'lwn_add_meta_tag'); 243 | 244 | function lwn_add_meta_tag() 245 | { 246 | $options = lwn_get_options(); 247 | foreach ($options as $index => $option) { 248 | $meta_name = $option['name']; 249 | $meta_content = $option['content']; 250 | $meta_show = $option['show']; 251 | if ($meta_show === 'yes') { 252 | echo ""; 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /meta-settings-7/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-8/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-8/js/checkbox-script.js: -------------------------------------------------------------------------------- 1 | const form = document.getElementById('lwn-meta-form'); 2 | form.addEventListener('change', function (event) { 3 | if (event.target.name.startsWith('lwn-meta-show')) { 4 | event.target.value = event.target.value === 'yes' ? 'no' : 'yes'; 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /meta-settings-8/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | '; */ 37 | /* echo 'console.log("hiiiiiiiiii from func");'; */ 38 | /* echo ''; */ 39 | } 40 | 41 | /** Add options to db upon plugin activation */ 42 | register_activation_hook(__FILE__, 'lwn_set_meta_options'); 43 | function lwn_set_meta_options() 44 | { 45 | lwn_get_options(); 46 | } 47 | 48 | /**Get Options */ 49 | function lwn_get_options() 50 | { 51 | $options = get_option('lwn_meta_tags_options', []); 52 | $default_options = [ 53 | [ 54 | 'name' => 'description', 55 | 'content' => 'here is website description', 56 | 'show' => 'no', 57 | ], 58 | [ 59 | 'name' => 'author', 60 | 'content' => 'Nawras Ali', 61 | 'show' => 'no', 62 | ], 63 | [ 64 | 'name' => 'extra 1', 65 | 'content' => 'Extra 1 content here', 66 | 'show' => 'no', 67 | ], 68 | [ 69 | 'name' => 'extra 2', 70 | 'content' => 'Extra 2 content here', 71 | 'show' => 'no', 72 | ], 73 | [ 74 | 'name' => 'extra 3', 75 | 'content' => 'Extra 3 content here', 76 | 'show' => 'no', 77 | ], 78 | ]; 79 | if (empty($options)) { 80 | update_option('lwn_meta_tags_options', $default_options); 81 | } 82 | return $options; 83 | } 84 | 85 | /** Add plugin menu to settings */ 86 | add_action('admin_menu', 'lwn_meta_settings_menu'); 87 | function lwn_meta_settings_menu() 88 | { 89 | add_options_page( 90 | 'LWN Meta Tags', 91 | 'LWN Meta', 92 | 'manage_options', 93 | 'lwn-meta-tags', 94 | 'lwn_meta_tags_config_page' 95 | ); 96 | } 97 | 98 | /**HTML Code for configuration page*/ 99 | function lwn_meta_tags_html_code($tags) 100 | { 101 | if (isset($_GET['message']) && $_GET['message'] === 'ok') { 102 | $message_text = 103 | '
'; 104 | $message_text .= '

'; 105 | $message_text .= ''; 106 | $message_text .= __('Settings Saved', 'meta-settings-8'); 107 | $message_text .= ''; 108 | $message_text .= '

'; 109 | 110 | $message_text .= '
'; 111 | } elseif (isset($_GET['message']) && $_GET['message'] === 'notOk') { 112 | $message_text = 113 | '
'; 114 | $message_text .= '

'; 115 | $message_text .= ''; 116 | $message_text .= __( 117 | 'Something wrong happened, or you did not change the values.', 118 | 'meta-settings-8' 119 | ); 120 | $message_text .= ''; 121 | $message_text .= '

'; 122 | 123 | $message_text .= '
'; 124 | } else { 125 | $message_text = ''; 126 | } 127 | echo '
'; 128 | echo $message_text; 129 | echo '

'; 130 | echo __('Meta Tags', 'meta-settings-8'); 131 | echo '

'; 132 | echo '
'; 133 | echo '

'; 134 | echo __('Add your tags here', 'meta-settings-8'); 135 | echo '

'; 136 | // add your form here 137 | echo '
'; 138 | echo ''; 139 | echo wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 140 | foreach ($tags as $index => $tag) { 141 | foreach ($tag as $key => $value) { 142 | if ($key === 'name') { 143 | $label = __('Meta Name', 'meta-settings-8'); 144 | $type = 'text'; 145 | $checked = ''; 146 | } elseif ($key === 'content') { 147 | $label = __('Meta Content', 'meta-settings-8'); 148 | $type = 'text'; 149 | $checked = ''; 150 | } elseif ($key === 'show') { 151 | $label = __('Show Meta?', 'meta-settings-8'); 152 | $type = 'checkbox'; 153 | $checked = $value === 'yes' ? "checked='checked'" : ''; 154 | } else { 155 | $label = __('Unknown Meta Label', 'meta-settings-8'); 156 | $type = 'text'; 157 | $checked = ''; 158 | } 159 | echo '
'; 160 | echo " '; 163 | echo ""; 164 | echo '
'; 165 | } 166 | echo '
'; 167 | } 168 | echo '
'; 169 | echo ""; 172 | echo '
'; 173 | 174 | echo '
'; 175 | lwn_change_checkbox_value(); 176 | 177 | echo '
'; 178 | } 179 | function lwn_meta_tags_config_page() 180 | { 181 | $meta_tags = lwn_get_options(); 182 | 183 | lwn_meta_tags_html_code($meta_tags); 184 | } 185 | 186 | /* Save Meta to Database**/ 187 | add_action('admin_init', 'lwn_meta_tags_admin_init'); 188 | function lwn_meta_tags_admin_init() 189 | { 190 | add_action('admin_post_lwn_save_meta_tags', 'lwn_save_options_to_db'); 191 | } 192 | function lwn_save_options_to_db() 193 | { 194 | if (!current_user_can('manage_options')) { 195 | wp_die( 196 | __('You have no authorization to do this action.', 'meta-settings-8') 197 | ); 198 | } 199 | check_admin_referer('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 200 | 201 | // Get options 202 | $options = lwn_get_options(); 203 | $updated_options = []; 204 | if (isset($_POST)) { 205 | foreach ($options as $index => $meta_tag) { 206 | $posted_data = [ 207 | 'name' => '', 208 | 'content' => '', 209 | 'show' => '', 210 | ]; 211 | foreach ($meta_tag as $key => $value) { 212 | $field_name = 'lwn-meta-' . $key . '-' . $index; 213 | if (isset($_POST[$field_name])) { 214 | $clean = sanitize_text_field($_POST[$field_name]); 215 | $posted_data[$key] = $clean; 216 | } 217 | } 218 | 219 | $updated_options[$index] = array_merge($options[$index], $posted_data); 220 | } 221 | // save to db 222 | $isUpdated = update_option('lwn_meta_tags_options', $updated_options); 223 | 224 | // Homework: 225 | // if the option is updated, show ok message; 226 | // otherwise, show error message 227 | $msg = $isUpdated ? 'ok' : 'notOk'; 228 | 229 | wp_redirect( 230 | add_query_arg( 231 | ['page' => 'lwn-meta-tags', 'message' => $msg], 232 | admin_url('options-general.php') 233 | ) 234 | ); 235 | exit(); 236 | } 237 | } 238 | 239 | /** Add meta tag to the head */ 240 | add_action('wp_head', 'lwn_add_meta_tag'); 241 | 242 | function lwn_add_meta_tag() 243 | { 244 | $options = lwn_get_options(); 245 | foreach ($options as $index => $option) { 246 | $meta_name = $option['name']; 247 | $meta_content = $option['content']; 248 | $meta_show = $option['show']; 249 | if ($meta_show === 'yes') { 250 | echo ""; 251 | } 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /meta-settings-8/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings-9/css/style.css: -------------------------------------------------------------------------------- 1 | .lwn-container { 2 | background: #f4f4f4; 3 | max-width: 80%; 4 | margin: 1rem auto; 5 | padding: 1rem; 6 | border: 1px solid black; 7 | border-radius: 10px; 8 | } 9 | 10 | .lwn-title { 11 | text-align: center; 12 | border-bottom: 1rem; 13 | } 14 | 15 | .lwn-heading { 16 | color: darkblue; 17 | } 18 | 19 | .lwn-form-control { 20 | margin: 1rem 0; 21 | } 22 | 23 | .lwn-label { 24 | margin: 0 1rem; 25 | } 26 | 27 | .lwn-button { 28 | outline: none; 29 | border: none; 30 | width: 100%; 31 | margin: 1rem auto; 32 | padding: 0.8rem 0; 33 | font-size: 1.2rem; 34 | font-weight: bold; 35 | background: green; 36 | color: white; 37 | border-radius: 10px; 38 | } 39 | 40 | .lwn-button:hover { 41 | opacity: 0.8; 42 | cursor: pointer; 43 | } 44 | -------------------------------------------------------------------------------- /meta-settings-9/js/checkbox-script.js: -------------------------------------------------------------------------------- 1 | const form = document.getElementById('lwn-meta-form'); 2 | form.addEventListener('change', function (event) { 3 | if (event.target.name.startsWith('lwn-meta-show')) { 4 | event.target.value = event.target.value === 'yes' ? 'no' : 'yes'; 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /meta-settings-9/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | 'description', 42 | 'content' => 'here is website description', 43 | 'show' => 'no', 44 | ], 45 | [ 46 | 'name' => 'author', 47 | 'content' => 'Nawras Ali', 48 | 'show' => 'no', 49 | ], 50 | [ 51 | 'name' => 'extra 1', 52 | 'content' => 'Extra 1 content here', 53 | 'show' => 'no', 54 | ], 55 | [ 56 | 'name' => 'extra 2', 57 | 'content' => 'Extra 2 content here', 58 | 'show' => 'no', 59 | ], 60 | [ 61 | 'name' => 'extra 3', 62 | 'content' => 'Extra 3 content here', 63 | 'show' => 'no', 64 | ], 65 | ]; 66 | if (empty($options)) { 67 | update_option('lwn_meta_tags_options', $default_options); 68 | } 69 | return $options; 70 | } 71 | 72 | /** Add plugin menu to settings */ 73 | add_action('admin_menu', 'lwn_meta_settings_menu'); 74 | function lwn_meta_settings_menu() 75 | { 76 | $options_page = add_options_page( 77 | 'LWN Meta Tags', 78 | 'LWN Meta', 79 | 'manage_options', 80 | 'lwn-meta-tags', 81 | 'lwn_meta_tags_config_page' 82 | ); 83 | if (!empty($options_page)) { 84 | add_action('load-' . $options_page, 'lwn_meta_help_pages'); 85 | } 86 | } 87 | 88 | // Help pages for our plugin 89 | function lwn_meta_help_pages() 90 | { 91 | $screen = get_current_screen(); 92 | $screen->add_help_tab([ 93 | 'id' => 'lwn-meta-intro', 94 | 'title' => 'Introduction', 95 | 'content' => 'hiiiiiiiiiiiiiiiiiiiiii', 96 | 'callback' => 'lwn_meta_help_introduction', 97 | ]); 98 | $screen->add_help_tab([ 99 | 'id' => 'lwn-meta-faq', 100 | 'title' => 'FAQ', 101 | 'content' => 'ur questions', 102 | ]); 103 | $screen->set_help_sidebar('

sidebaaaaaaaaaaaaaar

'); 104 | } 105 | 106 | function lwn_meta_help_introduction() 107 | { 108 | echo '

Introduction

'; 109 | echo '

Amet adipisci possimus sunt saepe id. Repellendus autem eos dolorum minus voluptatibus Neque aliquid distinctio beatae ex deleniti? Sit natus

'; 110 | echo __('hiiiiiiiiiiii', 'text domain'); 111 | } 112 | /**HTML Code for configuration page*/ 113 | function lwn_meta_tags_html_code($tags) 114 | { 115 | if (isset($_GET['message']) && $_GET['message'] === 'ok') { 116 | $message_text = 117 | '
'; 118 | $message_text .= '

'; 119 | $message_text .= ''; 120 | $message_text .= __('Settings Saved', 'meta-settings-9'); 121 | $message_text .= ''; 122 | $message_text .= '

'; 123 | 124 | $message_text .= '
'; 125 | } elseif (isset($_GET['message']) && $_GET['message'] === 'notOk') { 126 | $message_text = 127 | '
'; 128 | $message_text .= '

'; 129 | $message_text .= ''; 130 | $message_text .= __( 131 | 'Something wrong happened, or you did not change the values.', 132 | 'meta-settings-9' 133 | ); 134 | $message_text .= ''; 135 | $message_text .= '

'; 136 | 137 | $message_text .= '
'; 138 | } else { 139 | $message_text = ''; 140 | } 141 | echo '
'; 142 | echo $message_text; 143 | echo '

'; 144 | echo __('Meta Tags', 'meta-settings-9'); 145 | echo '

'; 146 | echo '
'; 147 | echo '

'; 148 | echo __('Add your tags here', 'meta-settings-9'); 149 | echo '

'; 150 | // add your form here 151 | echo '
'; 152 | echo ''; 153 | echo wp_nonce_field('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 154 | foreach ($tags as $index => $tag) { 155 | foreach ($tag as $key => $value) { 156 | if ($key === 'name') { 157 | $label = __('Meta Name', 'meta-settings-9'); 158 | $type = 'text'; 159 | $checked = ''; 160 | } elseif ($key === 'content') { 161 | $label = __('Meta Content', 'meta-settings-9'); 162 | $type = 'text'; 163 | $checked = ''; 164 | } elseif ($key === 'show') { 165 | $label = __('Show Meta?', 'meta-settings-9'); 166 | $type = 'checkbox'; 167 | $checked = $value === 'yes' ? "checked='checked'" : ''; 168 | } else { 169 | $label = __('Unknown Meta Label', 'meta-settings-9'); 170 | $type = 'text'; 171 | $checked = ''; 172 | } 173 | echo '
'; 174 | echo " '; 177 | echo ""; 178 | echo '
'; 179 | } 180 | echo '
'; 181 | } 182 | echo '
'; 183 | echo ""; 186 | echo '
'; 187 | 188 | echo '
'; 189 | lwn_change_checkbox_value(); 190 | 191 | echo '
'; 192 | } 193 | function lwn_meta_tags_config_page() 194 | { 195 | $meta_tags = lwn_get_options(); 196 | 197 | lwn_meta_tags_html_code($meta_tags); 198 | } 199 | 200 | /* Save Meta to Database**/ 201 | add_action('admin_init', 'lwn_meta_tags_admin_init'); 202 | function lwn_meta_tags_admin_init() 203 | { 204 | add_action('admin_post_lwn_save_meta_tags', 'lwn_save_options_to_db'); 205 | } 206 | function lwn_save_options_to_db() 207 | { 208 | if (!current_user_can('manage_options')) { 209 | wp_die( 210 | __('You have no authorization to do this action.', 'meta-settings-9') 211 | ); 212 | } 213 | check_admin_referer('lwnMetaTags', '_lwn_meta_tags_form_nonce'); 214 | 215 | // Get options 216 | $options = lwn_get_options(); 217 | $updated_options = []; 218 | if (isset($_POST)) { 219 | foreach ($options as $index => $meta_tag) { 220 | $posted_data = [ 221 | 'name' => '', 222 | 'content' => '', 223 | 'show' => '', 224 | ]; 225 | foreach ($meta_tag as $key => $value) { 226 | $field_name = 'lwn-meta-' . $key . '-' . $index; 227 | if (isset($_POST[$field_name])) { 228 | $clean = sanitize_text_field($_POST[$field_name]); 229 | $posted_data[$key] = $clean; 230 | } 231 | } 232 | 233 | $updated_options[$index] = array_merge($options[$index], $posted_data); 234 | } 235 | // save to db 236 | $isUpdated = update_option('lwn_meta_tags_options', $updated_options); 237 | 238 | // Homework: 239 | // if the option is updated, show ok message; 240 | // otherwise, show error message 241 | $msg = $isUpdated ? 'ok' : 'notOk'; 242 | 243 | wp_redirect( 244 | add_query_arg( 245 | ['page' => 'lwn-meta-tags', 'message' => $msg], 246 | admin_url('options-general.php') 247 | ) 248 | ); 249 | exit(); 250 | } 251 | } 252 | 253 | /** Add meta tag to the head */ 254 | add_action('wp_head', 'lwn_add_meta_tag'); 255 | 256 | function lwn_add_meta_tag() 257 | { 258 | $options = lwn_get_options(); 259 | foreach ($options as $index => $option) { 260 | $meta_name = $option['name']; 261 | $meta_content = $option['content']; 262 | $meta_show = $option['show']; 263 | if ($meta_show === 'yes') { 264 | echo ""; 265 | } 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /meta-settings-9/meta-settings-2.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: LWN Meta Tags 2\n" 5 | "Report-Msgid-Bugs-To: \n" 6 | "POT-Creation-Date: 2022-10-23 07:08+0000\n" 7 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 | "Last-Translator: FULL NAME \n" 9 | "Language-Team: \n" 10 | "Language: \n" 11 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Loco https://localise.biz/\n" 16 | "X-Loco-Version: 2.6.2; wp-6.0.3\n" 17 | "X-Domain: meta-settings-2" 18 | 19 | #. Description of the plugin 20 | msgid "Add custom meta tags from settings page" 21 | msgstr "" 22 | 23 | #: lwn-meta-settings.php:67 24 | msgid "Add your tags here" 25 | msgstr "" 26 | 27 | #. Name of the plugin 28 | msgid "LWN Meta Tags 2" 29 | msgstr "" 30 | 31 | #: lwn-meta-settings.php:79 32 | msgid "Meta Content" 33 | msgstr "" 34 | 35 | #: lwn-meta-settings.php:73 36 | msgid "Meta Name" 37 | msgstr "" 38 | 39 | #: lwn-meta-settings.php:55 40 | msgid "Meta Tags" 41 | msgstr "" 42 | 43 | #. Author of the plugin 44 | msgid "Nawras Ali" 45 | msgstr "" 46 | 47 | #: lwn-meta-settings.php:85 48 | msgid "Save" 49 | msgstr "" 50 | 51 | #: lwn-meta-settings.php:62 52 | msgid "Your current meta content is: " 53 | msgstr "" 54 | 55 | #: lwn-meta-settings.php:58 56 | msgid "Your current meta name is: " 57 | msgstr "" 58 | -------------------------------------------------------------------------------- /meta-settings/lwn-meta-settings.php: -------------------------------------------------------------------------------- 1 | Meta Tags'; 37 | $html .= '

Add your tags here:

'; 38 | $html .= '

Your meta name is:

'; 39 | $html .= $lwn_meta_name; 40 | $html .= '

Your meta content is:

'; 41 | $html .= $lwn_meta_content; 42 | 43 | echo $html; 44 | } 45 | 46 | /** Add meta tag to the head */ 47 | add_action('wp_head', 'lwn_add_meta_tag'); 48 | 49 | function lwn_add_meta_tag() 50 | { 51 | $meta_name = get_option('lwn_meta_tag_name'); 52 | $meta_content = get_option('lwn_meta_tag_content'); 53 | echo ""; 54 | } 55 | -------------------------------------------------------------------------------- /shortcode-plugin/index.php: -------------------------------------------------------------------------------- 1 | {$content}
"; 15 | } else { 16 | $output = 'you can NOT view this content'; 17 | } 18 | return $output; 19 | } 20 | 21 | /** Twitter 2 Shortcode*/ 22 | add_shortcode('lwn-twitter-2', 'lwn_add_twitter_2_shortcode'); 23 | function lwn_add_twitter_2_shortcode($attributes) 24 | { 25 | /* print_r($attributes); */ 26 | /* echo $attributes['username']; */ 27 | extract($attributes); 28 | if (empty($username)) { 29 | $username = 'barackObama'; 30 | } else { 31 | $username = sanitize_text_field($username); 32 | } 33 | $output = " "; 34 | 35 | return $output; 36 | } 37 | /** Twitter 1 Shortcode*/ 38 | add_shortcode('lwn-twitter-1', 'lwn_add_twitter_1_shortcode'); 39 | function lwn_add_twitter_1_shortcode() 40 | { 41 | $output = 42 | " "; 43 | 44 | return $output; 45 | } 46 | 47 | /** Simple Shortcode*/ 48 | add_shortcode('lwn-simple', 'lwn_add_simple_shortcode'); 49 | function lwn_add_simple_shortcode() 50 | { 51 | $output = '

simple shortcode

'; 52 | return $output; 53 | } 54 | --------------------------------------------------------------------------------