-
Notifications
You must be signed in to change notification settings - Fork 1
/
to-the-top copy.php
56 lines (50 loc) · 1.49 KB
/
to-the-top copy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
* Plugin Name: To the Top
* Description: Adds a 'back to top' link
* Version: 0.0.1
* Requires at least: 6.2
* Requires PHP: 8.0
* Author: Carrie Dils
* Author URI: https://carriedils.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: to-the-top
* Domain Path: /languages
*/
/**
* Output the "back to top" link to footer.
*
*/
function ttt_add_link() {
// Define the 'back to top' link text.
$link_text = __( 'Back to top (PHP)', 'to-the-top' );
// Output the 'back to top' link.
printf( '<a href="#" id="to-the-top">%s</a>', $link_text );
}
add_action( 'wp_footer', 'ttt_add_link' );
/**
* Load scripts.
*
* @return void
*/
function ttt_load_scripts() {
wp_enqueue_script( 'to-the-top', plugin_dir_url(__FILE__) . 'js/to-the-top.js', array( 'wp-i18n', 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'ttt_load_scripts' );
/**
* Load javascript translations.
*
* @return void
*/
function ttt_load_js_translations() {
wp_set_script_translations( 'to-the-top', 'to-the-top', plugin_basename( __FILE__ ) . '/languages' );
}
add_action( 'wp_enqueue_scripts', 'ttt_load_js_translations', 100 );
/**
* Load plugin textdomain (for PHP translations).
*/
function ttt_load_php_translations() {
$text = load_plugin_textdomain( 'to-the-top', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'init', 'ttt_load_php_translations' );