-
Notifications
You must be signed in to change notification settings - Fork 2
/
loadgo.php
85 lines (69 loc) · 2.88 KB
/
loadgo.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
Plugin Name: LoadGo for WP
Text Domain: loadgo-for-wp
Domain Path: /languages
Plugin URI: http://franverona.com/loadgo
Description: Create an automatic page load progress bar using <a href="http://github.hubspot.com/pace/docs/welcome/">PACE</a> and <a href="http://franverona.com/loadgo">Loadgo</a> Javascript plugin.
Version: 1.4
Author: Fran Verona
Author URI: http://franverona.com
*/
class loadgo {
// Constructor for the class.
public function __construct () {
// Add default options when activate
register_activation_hook( __FILE__ , array( $this, 'loadgo_add_defaults' ) );
// Remove plugin options when uninstall
register_uninstall_hook( __FILE__, array( $this, 'loadgo_delete_plugin_options' ) );
add_action( 'init', array( $this, 'loadgo_translation' ) );
add_action( 'init', array( $this, 'loadgo_options_page' ) );
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'loadgo_add_settings_link') );
add_action( 'wp_enqueue_scripts', array( $this, 'loadgo_sitewide' ) );
}
public function loadgo_options_page () {
require_once( dirname( __FILE__ ) . '/loadgo-options.php' );
}
public function loadgo_translation () {
$domain = 'loadgo-for-wp';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ) ) {
return $loaded;
} else {
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
}
static function loadgo_add_defaults () {
$opt = get_option('loadgo_options');
if ( !is_array($opt) ) {
// First time activation
delete_option('loadgo_options');
$arr = array(
"loadgo-visibility" => "admin",
"loadgo-image" => plugin_dir_url( __FILE__ ) . "img/example.png",
"loadgo-progress" => "true",
"loadgo-progress-color" => "#000000",
"loadgo-message" => "false",
"loadgo-bgcolor" => "#FFFFFF",
"loadgo-size" => "100",
"loadgo-opacity" => "0.5",
"loadgo-direction" => "lr"
);
update_option('loadgo_options', $arr);
}
}
static function loadgo_delete_plugin_options () {
delete_option('loadgo_options');
}
public function loadgo_add_settings_link ($links) {
$settings_link = '<a href="options-general.php?page=loadgo-for-wp/loadgo-options.php">LoadGo for WP</a>';
$help_link = '<a href="http://franverona.com/loadgo/">Help</a>';
array_push( $links, $settings_link, $help_link );
return $links;
}
public function loadgo_sitewide () {
include_once('methods/loadgo_sitewide.php');
}
}
$loadgo = new loadgo();