-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-all-first-images-as-featured.php
136 lines (93 loc) · 3.28 KB
/
set-all-first-images-as-featured.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
Plugin Name: Set All First Images As Featured
Description: Sets the first image of your posts, pages or custom post types as the featured image.
Version: 1.2.2
Author: Lucy Tomás
Author URI: https://wordpress.org/support/profile/lucymtc
License: GPLv2
*/
/* Copyright 2014 Lucy Tomás (email: [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// If this file is called directly, exit.
if ( !defined( 'ABSPATH' ) ) exit;
if( !class_exists('SFIF') ) {
/**
* Main class
* @since 1.0
*/
final class SFIF {
private static $instance = null;
public $default_options = array();
/**
* Instance
* This functions returns the only one true instance of the plugin main class
*
* @return object instance
* @since 1.0
*/
public static function instance (){
if( self::$instance == null ){
self::$instance = new SFIF;
self::$instance->constants();
self::$instance->includes();
self::$instance->load_textdomain();
}
return self::$instance;
}
/**
* Class Contructor
*
* @since 1.0
*/
private function __construct () {
$this->default_options = array(
'run_for' => 'post',
'overwrite' => false
);
ini_set('max_execution_time', 300);
add_action( 'admin_init', array( 'Sfif_Core', 'register_plugin_settings' ));
add_action( 'admin_menu', array( 'Sfif_Core', 'add_admin_menu_links' ));
add_action('wp_ajax_sfif_request', array('Sfif_Core', 'search_and_update'));
add_action('wp_ajax_nopriv_sfif_request', array('Sfif_Core', 'search_and_update'));
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array('Sfif_Core', 'add_action_links') );
}
/**
* includes
*
* @since 1.0
*/
private function includes () {
require_once( SFIF_PLUGIN_DIR . '/includes/class-core.php');
}
/**
* constants
* @since 1.0
*/
private function constants () {
if( !defined('SFIF_PLUGIN_DIR') ) { define('SFIF_PLUGIN_DIR', plugin_dir_path( __FILE__ )); }
if( !defined('SFIF_PLUGIN_URL') ) { define('SFIF_PLUGIN_URL', plugin_dir_url( __FILE__ )); }
if( !defined('SFIF_PLUGIN_FILE') ) { define('SFIF_PLUGIN_FILE', __FILE__ ); }
if( !defined('SFIF_PLUGIN_VERSION') ) { define('SFIF_PLUGIN_VERSION', '1.2.2'); }
}
/**
* load_textdomain
* @since 1.0
*/
public function load_textdomain() {
load_plugin_textdomain('sfif_domain', false, dirname( plugin_basename( SFIF_PLUGIN_FILE ) ) . '/languages/' );
}
}// class
}// if !class_exists
SFIF::instance();