'; } if(get_option('add_cbutton_twitter')) { $twitter = ''; } if(get_option('add_cbutton_googlebk')) { $google = 'Google Bookmarks に追加'; } if(get_option('add_cbutton_hatena')) { $hatena = 'このエントリーをはてなブックマークに追加'; } if(get_option('add_cbutton_feed')) { $rss2 = ''; } if(get_option('add_cbutton_comment')) { $comment = '
' . get_comments_popup_link( '', '', '' ) . '
' . get_comments_number('0','1','%','') . '
'; } $add_buttons = $facebook . $twitter . $google . $hatena . $rss2 . $comment; if(get_option('add_cbutton_position') == 1) : return '
' . $add_buttons . '
' . $content; elseif (get_option('add_cbutton_position') == 0 ) : return $content . '
' . $add_buttons . '
'; elseif (get_option('add_cbutton_position') == 2 ) : return '
' . $add_buttons . '
' .$content; elseif (get_option('add_cbutton_position') == 3 ) : return $content . '
' . $add_buttons . '
'; endif; } // 設定ページ登録 function add_contentbutton_plugin_menu() { add_options_page('Add Button To Post', 'Add Button To Post', 8, __FILE__, 'add_contentbutton_plugin_options'); } add_action('admin_menu', 'add_contentbutton_plugin_menu'); // プラグイン有効化時の設定 function add_contentbutton_setting() { add_option('add_cbutton_facebook', 1, '', no); add_option('add_cbutton_twitter', 1, '', no); add_option('add_cbutton_hatena', 1, '', no); add_option('add_cbutton_googlebk', 1, '', no); add_option('add_cbutton_feed', 1, '', no); add_option('add_cbutton_position', 1, '', no); add_option('add_cbutton_comment', 1, '', no); } register_activation_hook( __FILE__, 'add_contentbutton_setting'); // プラグイン無効化時の処理 function add_contentbutton_deactive() { } register_deactivation_hook( __FILE__, 'add_contentbutton_deactive'); // register設定 function admin_addbuttontopost_option() { register_setting('add-cbutton-group', 'add_cbutton_facebook'); register_setting('add-cbutton-group', 'add_cbutton_twitter'); register_setting('add-cbutton-group', 'add_cbutton_hatena'); register_setting('add-cbutton-group', 'add_cbutton_googlebk'); register_setting('add-cbutton-group', 'add_cbutton_feed'); register_setting('add-cbutton-group', 'add_cbutton_position'); register_setting('add-cbutton-group', 'add_cbutton_comment'); } add_action( 'admin_init', 'admin_addbuttontopost_option' ); // 「設定ページ」表示設定 function add_contentbutton_plugin_options() { include 'add_button_to_post_setting.php'; } // get_comments_popup_list関数 function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { global $wpcommentspopupfile, $wpcommentsjavascript; $id = get_the_ID(); if ( false === $zero ) $zero = __( 'No Comments' ); if ( false === $one ) $one = __( '1 Comment' ); if ( false === $more ) $more = __( '% Comments' ); if ( false === $none ) $none = __( 'Comments Off' ); $number = get_comments_number( $id ); $str = ''; if ( 0 == $number && !comments_open() && !pings_open() ) { $str = '' . $none . ''; return $str; } if ( post_password_required() ) { $str = __('Enter your password to view comments.'); return $str; } $str = ' 0 ) ); $str .= apply_filters( 'comments_popup_link_attributes', '' ); $str .= ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; $str .= get_comments_number_str( $zero, $one, $more ); $str .= ''; return $str; } function get_comments_number_str( $zero = false, $one = false, $more = false, $deprecated = '' ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '1.3' ); $number = get_comments_number(); if ( $number > 1 ) $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more); elseif ( $number == 0 ) $output = ( false === $zero ) ? __('No Comments') : $zero; else // must be one $output = ( false === $one ) ? __('1 Comment') : $one; return apply_filters('comments_number', $output, $number); }