Changeset 1393213
- Timestamp:
- 04/12/2016 06:58:07 PM (10 years ago)
- Location:
- per-post-language/trunk
- Files:
-
- 2 edited
-
ppl_core.php (modified) (5 diffs)
-
ppl_settings_page.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
per-post-language/trunk/ppl_core.php
r1393152 r1393213 7 7 * Text Domain: perpostlanguage 8 8 * License: GPLv3 9 * Version: 1. 09 * Version: 1.1 10 10 * Author: Fahad Alduraibi 11 11 * Author URI: http://www.fadvisor.net/blog/ … … 37 37 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'ppl_add_settings_links' ); 38 38 39 function ppl_add_settings_page(){ 40 add_option( "ppl_selected_languages"); 39 // Run this function once when the plugin is activated to create an entry in the database to store the settings 40 function ppl_add_options_entry(){ 41 add_option( "ppl_options"); // This is not actually needed since 'update_option" also creates the entry if it doesn't exist. 41 42 } 42 register_activation_hook( __FILE__, "ppl_add_ settings_page" );43 register_activation_hook( __FILE__, "ppl_add_options_entry" ); 43 44 45 // Set the post language when loading up the page based on the store meta 44 46 function ppl_set_post_language() { 45 47 $postID = url_to_postid( $_SERVER["REQUEST_URI"] ); … … 58 60 function ppl_save_post_meta( $post_id ) { 59 61 global $post; 60 if( $post->post_type == "post" ) {62 if( isset( $post ) && $post->post_type == "post" ) { 61 63 if (isset( $_POST ) && isset($_POST['pplPostLang']) ) { 62 64 update_post_meta( $post_id, '_ppl_post_language', strip_tags( $_POST['pplPostLang'] ) ); … … 66 68 add_action( 'save_post', 'ppl_save_post_meta' ); 67 69 70 // List of languages that are shown in the Post Language box 68 71 function ppl_get_language_list( $post ) { 69 72 $postID = $post->ID; … … 86 89 } 87 90 88 function ppl_register_meta_boxes() { 91 // Post Language box is shown when editing a post, it shows on the left side by default ('high' makes it show on the top) 92 function ppl_register_meta_boxes( $post ) { 89 93 if(current_user_can( 'edit_posts' ) ){ 90 94 add_meta_box( 'ppl_meta_box', esc_html__( 'Post Language', 'perpostlanguage' ), 'ppl_get_language_list', 'post', 'side', 'high', null ); 91 95 } 92 96 } 93 add_action( 'add_meta_boxes ', 'ppl_register_meta_boxes' );97 add_action( 'add_meta_boxes_post', 'ppl_register_meta_boxes' ); 94 98 95 99 // Load plugin textdomain (translation file). -
per-post-language/trunk/ppl_settings_page.php
r1393152 r1393213 20 20 21 21 // Add settings page entry under WordPress default Settings menu 22 add_action( 'admin_menu', 'ppl_settings_menu' );23 22 function ppl_settings_menu() { 24 23 add_options_page( … … 30 29 ); 31 30 } 31 add_action( 'admin_menu', 'ppl_settings_menu' ); 32 32 33 33 // The settings page for the plugin
Note: See TracChangeset
for help on using the changeset viewer.