__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Plugin Name: Google Translate Widget for WordPress.com
* Plugin URI: https://automattic.com
* Description: Add a widget for automatic translation
* Author: Artur Piszek
* Version: 0.1
* Author URI: https://automattic.com
* Text Domain: jetpack
*/
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
use Automattic\Jetpack\Assets;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Jetpack_Google_Translate_Widget main class.
*/
class Jetpack_Google_Translate_Widget extends WP_Widget {
/**
* Singleton instance of the widget, not to show more than once.
*
* @var array
*/
public static $instance = null;
/**
* Default widget title.
*
* @var string $default_title
*/
public $default_title;
/**
* Register widget with WordPress.
*/
public function __construct() {
parent::__construct(
'google_translate_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Google Translate', 'jetpack' ) ),
array(
'description' => __( 'Provide your readers with the option to translate your site into their preferred language.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
$this->default_title = esc_html__( 'Translate', 'jetpack' );
}
/**
* Enqueue frontend JS scripts.
*/
public function enqueue_scripts() {
wp_register_script(
'google-translate-init',
Assets::get_file_url_for_environment(
'_inc/build/widgets/google-translate/google-translate.min.js',
'modules/widgets/google-translate/google-translate.js'
),
array(),
JETPACK__VERSION,
false
);
wp_register_script(
'google-translate',
'//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit',
array( 'google-translate-init' ),
JETPACK__VERSION,
false
);
// Admin bar is also displayed on top of the site which causes google translate bar to hide beneath.
// Overwrite position of body.admin-bar
// This is a hack to show google translate bar a bit lower.
$lower_translate_bar = '
.admin-bar {
position: inherit !important;
top: auto !important;
}
.admin-bar .goog-te-banner-frame {
top: 32px !important
}
@media screen and (max-width: 782px) {
.admin-bar .goog-te-banner-frame {
top: 46px !important;
}
}
@media screen and (max-width: 480px) {
.admin-bar .goog-te-banner-frame {
position: absolute;
}
}
';
wp_add_inline_style( 'admin-bar', $lower_translate_bar );
wp_add_inline_style( 'wpcom-admin-bar', $lower_translate_bar );
}
/**
* Display the Widget.
*
* @see WP_Widget::widget()
*
* @param array $args Display arguments.
* @param array $instance The settings for the particular instance of the widget.
*/
public function widget( $args, $instance ) {
// We never should show more than 1 instance of this.
if ( null === self::$instance ) {
$instance = wp_parse_args(
$instance,
array(
'title' => $this->default_title,
)
);
/**
* Filter the layout of the Google Translate Widget.
*
* 3 different integers are accepted.
* 0 for the vertical layout.
* 1 for the horizontal layout.
* 2 for the dropdown only.
*
* @see https://translate.google.com/manager/website/
*
* @module widgets
*
* @since 5.5.0
*
* @param string $layout layout of the Google Translate Widget.
*/
$button_layout = apply_filters( 'jetpack_google_translate_widget_layout', 0 );
if (
! is_int( $button_layout )
|| 0 > $button_layout
|| 2 < $button_layout
) {
$button_layout = 0;
}
wp_localize_script(
'google-translate-init',
'_wp_google_translate_widget',
array(
'lang' => get_locale(),
'layout' => (int) $button_layout,
)
);
wp_enqueue_script( 'google-translate-init' );
wp_enqueue_script( 'google-translate' );
$title = $instance['title'];
if ( ! isset( $title ) ) {
$title = $this->default_title;
}
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title );
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '<div id="google_translate_element"></div>';
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
self::$instance = $instance;
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'google-translate' );
}
}
/**
* Widget form in the dashboard.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
$title = isset( $instance['title'] ) ? $instance['title'] : false;
if ( false === $title ) {
$title = $this->default_title;
}
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
*
* @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database.
*
* @return array $instance Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
if ( $instance['title'] === $this->default_title ) {
$instance['title'] = false; // Store as false in case of language change.
}
return $instance;
}
}
/**
* Register the widget for use in Appearance -> Widgets.
*/
function jetpack_google_translate_widget_init() {
register_widget( 'Jetpack_Google_Translate_Widget' );
}
add_action( 'widgets_init', 'jetpack_google_translate_widget_init' );
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| authors | Folder | 0755 |
|
|
| contact-info | Folder | 0755 |
|
|
| eu-cookie-law | Folder | 0755 |
|
|
| facebook-likebox | Folder | 0755 |
|
|
| flickr | Folder | 0755 |
|
|
| gallery | Folder | 0755 |
|
|
| goodreads | Folder | 0755 |
|
|
| google-translate | Folder | 0755 |
|
|
| image-widget | Folder | 0755 |
|
|
| Folder | 0755 |
|
||
| internet-defense-league | Folder | 0755 |
|
|
| migrate-to-core | Folder | 0755 |
|
|
| milestone | Folder | 0755 |
|
|
| my-community | Folder | 0755 |
|
|
| simple-payments | Folder | 0755 |
|
|
| social-icons | Folder | 0755 |
|
|
| social-media-icons | Folder | 0755 |
|
|
| top-posts | Folder | 0755 |
|
|
| wordpress-post-widget | Folder | 0755 |
|
|
| authors.php | File | 9.1 KB | 0644 |
|
| blog-stats.php | File | 5.39 KB | 0644 |
|
| class-jetpack-eu-cookie-law-widget.php | File | 10.51 KB | 0644 |
|
| class-jetpack-instagram-widget.php | File | 24.19 KB | 0644 |
|
| contact-info.php | File | 17.95 KB | 0644 |
|
| customizer-controls.css | File | 165 B | 0644 |
|
| customizer-utils.js | File | 4.07 KB | 0644 |
|
| facebook-likebox.php | File | 15.28 KB | 0644 |
|
| flickr.php | File | 7.24 KB | 0644 |
|
| gallery.php | File | 16.02 KB | 0644 |
|
| goodreads.php | File | 8.25 KB | 0644 |
|
| google-translate.php | File | 6.44 KB | 0644 |
|
| gravatar-profile.css | File | 1.23 KB | 0644 |
|
| gravatar-profile.php | File | 15.97 KB | 0644 |
|
| image-widget.php | File | 12.24 KB | 0644 |
|
| internet-defense-league.php | File | 5.65 KB | 0644 |
|
| mailchimp.php | File | 4.29 KB | 0644 |
|
| milestone.php | File | 346 B | 0644 |
|
| my-community.php | File | 11.07 KB | 0644 |
|
| rsslinks-widget.php | File | 10.6 KB | 0644 |
|
| simple-payments.php | File | 21.88 KB | 0644 |
|
| social-icons.php | File | 21.42 KB | 0644 |
|
| social-media-icons.php | File | 10.78 KB | 0644 |
|
| top-posts.php | File | 27.02 KB | 0644 |
|
| twitter-timeline-admin.js | File | 2.2 KB | 0644 |
|
| twitter-timeline.php | File | 19.9 KB | 0644 |
|
| upcoming-events.php | File | 6.47 KB | 0644 |
|
| wordpress-post-widget.php | File | 3.71 KB | 0644 |
|