Ejemplo n.º 1
0
 function wpCustomGoogleSearchInit()
 {
     require plugin_dir_path(__FILE__) . "/CustomGoogleSearchOptions.php";
     CustomGoogleSearchOptions::loadLanguage();
     if (is_admin()) {
         include plugin_dir_path(__FILE__) . "/CustomGoogleSearchAdmin.php";
         $admin = new CustomGoogleSearchAdmin();
         add_action('init', array(&$admin, 'init'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Render the google search template for posts.
  *
  * Display the google search view for the current post.
  *
  * @global object $post 
  * @access public
  */
 public static function renderPostGoogleSearch()
 {
     global $post;
     if ($post) {
         $body_data = CustomGoogleSearchOptions::getAdminBodyData();
         $admin_options = get_option(CustomGoogleSearchOptions::OPTION_NAME);
         $admin_options = maybe_unserialize($admin_options);
         $user_options = get_post_meta($post->ID, CustomGoogleSearchOptions::USER_GOOGLE_SEARCH_OPTIONS, true);
         $user_options = maybe_unserialize($user_options);
         if (!is_array($admin_options) && !is_array($user_options)) {
             return false;
         }
         if (empty($admin_options[$body_data['ADMIN_MENU_OPTIONS_GS']]['ID']) && empty($user_options['lang']) && empty($user_options['theme']) && empty($user_options['search_text']) && empty($user_options['search_active'])) {
             return false;
         }
         if ($user_options['search_active'] != 'on') {
             return false;
         }
         $data = CustomGoogleSearchOptions::getUserGoogleSearchData();
         $options = array("GOOGLE_SEARCH_ID" => $admin_options[$body_data['ADMIN_MENU_OPTIONS_GS']]['ID'], "GOOGLE_SEARCH_LANG" => $user_options['lang'], "GOOGLE_SEARCH_THEME" => $user_options['theme'], "GOOGLE_SEARCH_TEXT" => $user_options['search_text'], "GOOGLE_SEARCH_LOADING_TEXT" => $data['USER_GOOGLE_SEARCH_LOADING_TEXT']);
         self::render(CustomGoogleSearchOptions::USER_GOOGLE_SEARCH_TPL, $options);
     }
 }
Ejemplo n.º 3
0
 /**
  * Display the metabox view template for the plugin into the post editor,
  * render the necessary templates and data for this view.
  * 
  * @global object $post
  * @access public
  */
 public function postMetaboxSearchText()
 {
     global $post;
     $user_options = get_post_meta($post->ID, CustomGoogleSearchOptions::USER_GOOGLE_SEARCH_OPTIONS, true);
     $user_options = maybe_unserialize($user_options);
     $data = CustomGoogleSearchOptions::getAdminGoogleMetaboxData();
     $this->render(CustomGoogleSearchOptions::ADMIN_POST_METABOX_TPL . '-0', $data[0]);
     $lang_selected = isset($user_options) ? $user_options['lang'] : "";
     foreach ($data[1] as $options) {
         if ($lang_selected == $options['VALUE']) {
             $options['SELECTED'] = 'selected="selected"';
         }
         $this->render(CustomGoogleSearchOptions::ADMIN_POST_METABOX_TPL . '-1', $options);
     }
     $this->render(CustomGoogleSearchOptions::ADMIN_POST_METABOX_TPL . '-2', $data[2]);
     $theme_selected = isset($user_options) ? $user_options['theme'] : "";
     foreach ($data[3] as $options) {
         if ($theme_selected == $options['VALUE']) {
             $options['SELECTED'] = 'selected="selected"';
         }
         $this->render(CustomGoogleSearchOptions::ADMIN_POST_METABOX_TPL . '-1', $options);
     }
     $text_value = isset($user_options) ? $user_options['search_text'] : "";
     if (isset($text_value)) {
         $data[4]['ADMIN_SEARCH_TEXT_INPUT'] = $text_value;
     }
     $check = isset($user_options) ? $user_options['search_active'] : "";
     if ($check == 'on') {
         $data[4]['ADMIN_SEARCH_TEXT_CHECK'] = 'checked="yes"';
     }
     $this->render(CustomGoogleSearchOptions::ADMIN_POST_METABOX_TPL . '-3', $data[4]);
 }