Version Description
- Date: 22.November.2017
- NEW: Global switch to enable or disable the plugin.
- NEW: Test button.
- NEW: Stop Bulk Updater button.
- NEW: Support tab.
- Improvement: Changed source of filename from guid to wp_get_attachment_url() to prevent conflicts with other plugins. GUID was being replaced by other plugins. Thanks to @niresh12495 for bringing this up.
- Impreovement: Added checks to check if attachment is image before processing.
- FIX: Added boolval() function for backwards compatibility with servers with PHP older than PHP 5.5.
- Added preview of premium options that ship with Image Attributes Pro
- UI Improvements.
- Code improvements.
Download this release
Release Info
Developer | arunbasillal |
Plugin | Auto Image Attributes From Filename With Bulk Updater (Add Alt Text, Image Title For Image SEO) |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.4
- admin/css/iaff-style.css +132 -18
- admin/css/index.php +1 -2
- admin/iaff_image-attributes-from-filename-admin-setup.php +303 -40
- admin/iaff_image-attributes-from-filename-admin-ui-render.php +1026 -138
- admin/iaff_image-attributes-from-filename-basic-setup.php +17 -10
- admin/iaff_image-attributes-from-filename-do.php +429 -162
- admin/iaff_image-attributes-from-filename-loader.php +6 -9
- admin/img/black-traingles.png +0 -0
- admin/img/checkerboardflyer.jpeg +0 -0
- admin/img/iaff-icon.png +0 -0
- admin/index.php +1 -2
- admin/js/iaff-js.js +23 -0
- iaff_image-attributes-from-filename.php +41 -20
- includes/index.php +1 -2
- index.php +1 -2
- public/index.php +1 -2
- readme.txt +79 -9
- uninstall.php +1 -5
admin/css/iaff-style.css
CHANGED
@@ -1,20 +1,22 @@
|
|
1 |
-
#iaff-pro
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
4 |
}
|
5 |
|
6 |
-
#iaff-pro .
|
7 |
-
|
8 |
-
margin: 5px 0 15px;
|
9 |
-
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
10 |
-
background: #fff none repeat scroll 0 0;
|
11 |
-
border-left: 4px solid #DC3232;
|
12 |
-
|
13 |
}
|
14 |
|
15 |
-
#iaff-pro .
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
#iaff-pro #bulk-updater-results {
|
@@ -24,14 +26,11 @@
|
|
24 |
#iaff-pro #bulk-updater-log-wrapper {
|
25 |
border: 1px solid #aaa;
|
26 |
margin: 10px auto;
|
27 |
-
|
28 |
-
|
29 |
-
#iaff-pro fieldset {
|
30 |
-
padding: 20px;
|
31 |
}
|
32 |
|
33 |
#iaff-pro #bulk-updater-log {
|
34 |
-
border: 1px solid #
|
35 |
height: 300px;
|
36 |
overflow: auto;
|
37 |
}
|
@@ -45,10 +44,125 @@
|
|
45 |
background: #DFDFDF;
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
48 |
#iaff-pro p.iaff-green {
|
49 |
color: #46B450;
|
50 |
}
|
51 |
|
52 |
#iaff-pro p.iaff-red {
|
53 |
color: #DC3232;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
1 |
+
#iaff-pro {
|
2 |
+
min-width: 900px;
|
3 |
+
}
|
4 |
+
|
5 |
+
#iaff-pro h2 {
|
6 |
+
display: none;
|
7 |
}
|
8 |
|
9 |
+
#iaff-pro h2.showh2 {
|
10 |
+
display: block;
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
12 |
|
13 |
+
#iaff-pro .iaff-bulk-updater-buttons {
|
14 |
+
margin-right: 5px;
|
15 |
+
}
|
16 |
+
|
17 |
+
#iaff-pro .reset-counter-button .submit {
|
18 |
+
margin-top: 0px !important;
|
19 |
+
padding-top: 0px !important;
|
20 |
}
|
21 |
|
22 |
#iaff-pro #bulk-updater-results {
|
26 |
#iaff-pro #bulk-updater-log-wrapper {
|
27 |
border: 1px solid #aaa;
|
28 |
margin: 10px auto;
|
29 |
+
padding: 20px;
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
#iaff-pro #bulk-updater-log {
|
33 |
+
border: 1px solid #aaa;
|
34 |
height: 300px;
|
35 |
overflow: auto;
|
36 |
}
|
44 |
background: #DFDFDF;
|
45 |
}
|
46 |
|
47 |
+
#iaff-pro #bulk-updater-log a {
|
48 |
+
color: #444;
|
49 |
+
}
|
50 |
+
|
51 |
#iaff-pro p.iaff-green {
|
52 |
color: #46B450;
|
53 |
}
|
54 |
|
55 |
#iaff-pro p.iaff-red {
|
56 |
color: #DC3232;
|
57 |
+
}
|
58 |
+
|
59 |
+
#iaff-pro a.nav-tab:focus {
|
60 |
+
box-shadow: none;
|
61 |
+
}
|
62 |
+
|
63 |
+
#iaff-pro #iaff-support-tab {
|
64 |
+
float: right;
|
65 |
+
margin-right: 8px;
|
66 |
+
}
|
67 |
+
|
68 |
+
#iaff-pro .iaff-columns-2 {
|
69 |
+
margin-right: 320px;
|
70 |
+
}
|
71 |
+
|
72 |
+
#iaff-pro .iaff-admin-options-main {
|
73 |
+
float: left;
|
74 |
+
width: 100%;
|
75 |
+
}
|
76 |
+
|
77 |
+
#iaff-pro .iaff-admin-options-sidebar {
|
78 |
+
float: right;
|
79 |
+
width: 280px;
|
80 |
+
margin-left: 20px;
|
81 |
+
padding-right: 20px;
|
82 |
+
margin-right: -320px;
|
83 |
+
}
|
84 |
+
|
85 |
+
#iaff-pro .iaff-icon {
|
86 |
+
background: url('../img/iaff-icon.png') no-repeat;
|
87 |
+
height: 128px;
|
88 |
+
width: 128px;
|
89 |
+
margin: 0 auto;
|
90 |
+
}
|
91 |
+
|
92 |
+
#iaff-pro .iaff-upgrade-header {
|
93 |
+
padding: 30px;
|
94 |
+
background: linear-gradient(135deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9)), url('../img/black-traingles.png') repeat;
|
95 |
+
margin-top: 9px;
|
96 |
+
}
|
97 |
+
|
98 |
+
#iaff-pro .patua {
|
99 |
+
font-family: 'Patua One', cursive;
|
100 |
+
letter-spacing: 1px;
|
101 |
+
}
|
102 |
+
|
103 |
+
#iaff-pro .iaff-upgrade-header h1 {
|
104 |
+
color: #fff;
|
105 |
+
font-size: 30px;
|
106 |
+
text-align: center;
|
107 |
+
}
|
108 |
+
|
109 |
+
#iaff-pro .iaff-upgrade-header a {
|
110 |
+
color: #fff;
|
111 |
+
text-decoration: none;
|
112 |
+
font-size: 14px;
|
113 |
+
}
|
114 |
+
|
115 |
+
#iaff-pro .iaff-upgrade-form {
|
116 |
+
background: #fff;
|
117 |
+
padding: 20px 30px;
|
118 |
+
}
|
119 |
+
|
120 |
+
#iaff-pro .iaff-upgrade-form input {
|
121 |
+
width: 100%;
|
122 |
+
}
|
123 |
+
|
124 |
+
#iaff-pro .opacity-75 {
|
125 |
+
opacity: 0.75;
|
126 |
+
}
|
127 |
+
|
128 |
+
#iaff-pro .iaff-upgrade-review-stars {
|
129 |
+
text-align: center;
|
130 |
+
}
|
131 |
+
|
132 |
+
#iaff-pro .iaff-upgrade-review-avatar {
|
133 |
+
border-radius: 50px;
|
134 |
+
}
|
135 |
+
|
136 |
+
#iaff-pro .iaff-upgrade-review-detail {
|
137 |
+
display: inline-block;
|
138 |
+
}
|
139 |
+
|
140 |
+
#iaff-pro .iaff-upgrade-review-detail-left {
|
141 |
+
float: left;
|
142 |
+
width: 75px;
|
143 |
+
margin-top: 14px;
|
144 |
+
margin-right: 20px;
|
145 |
+
}
|
146 |
+
|
147 |
+
#iaff-pro .iaff-upgrade-review-detail a {
|
148 |
+
color: #444;
|
149 |
+
text-decoration: none;
|
150 |
+
font-size: 14px;
|
151 |
+
}
|
152 |
+
|
153 |
+
#iaff-pro .iaff-support-block {
|
154 |
+
width: 280px;
|
155 |
+
background: linear-gradient(135deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9)), url('../img/black-traingles.png') repeat;
|
156 |
+
float: left;
|
157 |
+
margin-right: 30px;
|
158 |
+
}
|
159 |
+
|
160 |
+
#iaff-pro .iaff-support-block-inner {
|
161 |
+
padding: 30px;
|
162 |
+
color: #fff;
|
163 |
+
}
|
164 |
+
|
165 |
+
#iaff-pro .iaff-support-block-inner h2, #iaff-pro .iaff-support-block-inner a {
|
166 |
+
color: #fff;
|
167 |
+
text-decoration: none;
|
168 |
}
|
admin/css/index.php
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
<?php
|
2 |
-
// Silence is golden
|
3 |
-
?>
|
1 |
<?php
|
2 |
+
// Silence is golden
|
|
admin/iaff_image-attributes-from-filename-admin-setup.php
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
* @since 1.3
|
6 |
* @function iaff_add_menu_links() Add admin menu pages
|
7 |
* @function iaff_register_settings() Register Settings
|
|
|
8 |
* @function iaff_enqueue_js_and_css() Load Admin Side Js and CSS
|
9 |
*/
|
10 |
|
@@ -20,7 +21,16 @@ if ( !defined('ABSPATH') ) exit;
|
|
20 |
* @refer https://developer.wordpress.org/plugins/administration-menus/
|
21 |
*/
|
22 |
function iaff_add_menu_links() {
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
add_action( 'admin_menu', 'iaff_add_menu_links' );
|
26 |
|
@@ -35,58 +45,296 @@ function iaff_register_settings() {
|
|
35 |
// Register Setting
|
36 |
register_setting(
|
37 |
'iaff_settings_group', // Group Name
|
38 |
-
'iaff_settings' // Setting Name = HTML form <input> name on settings form
|
|
|
39 |
);
|
40 |
|
41 |
-
// Register
|
42 |
add_settings_section(
|
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 |
add_action( 'admin_init', 'iaff_register_settings' );
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
/**
|
72 |
-
* Set default values for settings
|
73 |
*
|
74 |
-
* @since 1.
|
|
|
75 |
*/
|
76 |
-
|
77 |
-
$defaults = array(
|
78 |
-
'image_title' => '1',
|
79 |
-
'image_caption' => '1',
|
80 |
-
'image_description' => '1',
|
81 |
-
'image_alttext' => '1',
|
82 |
-
'image_title_to_html' => '0',
|
83 |
-
'hyphens' => '1',
|
84 |
-
'under_score' => '1',
|
85 |
-
'full_stop' => '0',
|
86 |
-
'commas' => '0',
|
87 |
-
'all_numbers' => '0',
|
88 |
-
);
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
/**
|
92 |
* Load Admin Side Js and CSS
|
@@ -95,8 +343,23 @@ $defaults = array(
|
|
95 |
* @since 1.3
|
96 |
*/
|
97 |
function iaff_enqueue_js_and_css() {
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
-
add_action( 'admin_enqueue_scripts', 'iaff_enqueue_js_and_css' );
|
101 |
-
|
102 |
-
?>
|
5 |
* @since 1.3
|
6 |
* @function iaff_add_menu_links() Add admin menu pages
|
7 |
* @function iaff_register_settings() Register Settings
|
8 |
+
* @function iaff_get_settings() Set global default values for settings
|
9 |
* @function iaff_enqueue_js_and_css() Load Admin Side Js and CSS
|
10 |
*/
|
11 |
|
21 |
* @refer https://developer.wordpress.org/plugins/administration-menus/
|
22 |
*/
|
23 |
function iaff_add_menu_links() {
|
24 |
+
|
25 |
+
if ( iaff_is_pro() ) {
|
26 |
+
$iaff_plugin_title = 'Image Attributes Pro';
|
27 |
+
$iaff_menu_title = 'Image Attributes Pro';
|
28 |
+
} else {
|
29 |
+
$iaff_plugin_title = 'Auto Image Attributes';
|
30 |
+
$iaff_menu_title = 'Image Attributes';
|
31 |
+
}
|
32 |
+
|
33 |
+
add_options_page( $iaff_plugin_title, $iaff_menu_title, 'manage_options', 'image-attributes-from-filename','iaff_admin_interface_render' );
|
34 |
}
|
35 |
add_action( 'admin_menu', 'iaff_add_menu_links' );
|
36 |
|
45 |
// Register Setting
|
46 |
register_setting(
|
47 |
'iaff_settings_group', // Group Name
|
48 |
+
'iaff_settings', // Setting Name = HTML form <input> name on settings form
|
49 |
+
'iaff_settings_validater_and_sanitizer'
|
50 |
);
|
51 |
|
52 |
+
// Register Basic Settings Section
|
53 |
add_settings_section(
|
54 |
+
'iaff_basic_settings_section_id', // ID
|
55 |
+
__('Basic Settings','abl_iaff_td'), // Title
|
56 |
+
'__return_false', // Callback Function
|
57 |
+
'iaff_basic_settings_section' // Page slug
|
58 |
);
|
59 |
|
60 |
+
// Global Switch
|
61 |
+
add_settings_field(
|
62 |
+
'iaff_global_switch', // ID
|
63 |
+
__('Global Switch', 'abl_iaff_td'), // Title
|
64 |
+
'iaff_global_switch_callback', // Callback function
|
65 |
+
'iaff_basic_settings_section', // Page slug
|
66 |
+
'iaff_basic_settings_section_id' // Settings Section ID
|
67 |
+
);
|
68 |
+
|
69 |
+
// General Settings
|
70 |
+
add_settings_field(
|
71 |
+
'iaff_general_settings', // ID
|
72 |
+
__('General Settings', 'abl_iaff_td'), // Title
|
73 |
+
'iaff_general_settings_callback', // Callback function
|
74 |
+
'iaff_basic_settings_section', // Page slug
|
75 |
+
'iaff_basic_settings_section_id' // Settings Section ID
|
76 |
+
);
|
77 |
+
|
78 |
+
// Filter Settings
|
79 |
+
add_settings_field(
|
80 |
+
'iaff_filter_settings', // ID
|
81 |
+
__('Filter Settings', 'abl_iaff_td'), // Title
|
82 |
+
'iaff_filter_settings_callback', // Callback function
|
83 |
+
'iaff_basic_settings_section', // Page slug
|
84 |
+
'iaff_basic_settings_section_id' // Settings Section ID
|
85 |
+
);
|
86 |
+
|
87 |
+
// Basic SEO Settings
|
88 |
+
add_settings_field(
|
89 |
+
'iaff_basic_seo_settings', // ID
|
90 |
+
__('Basic SEO Settings', 'abl_iaff_td'), // Title
|
91 |
+
'iaff_basic_seo_settings_callback', // Callback function
|
92 |
+
'iaff_basic_settings_section', // Page slug
|
93 |
+
'iaff_basic_settings_section_id' // Settings Section ID
|
94 |
+
);
|
95 |
+
|
96 |
+
// Preview Pro Features
|
97 |
+
if ( ! iaff_is_pro() ) {
|
98 |
+
|
99 |
+
add_settings_field(
|
100 |
+
'iaff_preview_pro_settings', // ID
|
101 |
+
__('Preview Pro Features', 'abl_iaff_td'), // Title
|
102 |
+
'iaff_preview_pro_settings_callback', // Callback function
|
103 |
+
'iaff_basic_settings_section', // Page slug
|
104 |
+
'iaff_basic_settings_section_id' // Settings Section ID
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
// Register Advanced Settings Section
|
109 |
+
add_settings_section(
|
110 |
+
'iaff_advanced_settings_section_id', // ID
|
111 |
+
__('Advanced Settings','abl_iaff_td'), // Title
|
112 |
+
'__return_false', // Callback Function
|
113 |
+
'iaff_advanced_settings_section' // Page slug
|
114 |
);
|
115 |
|
116 |
+
// Advanced Filter
|
117 |
+
add_settings_field(
|
118 |
+
'iaff_advanced_filter_settings', // ID
|
119 |
+
__('Advanced Filter', 'abl_iaff_td'), // Title
|
120 |
+
'iaff_advanced_filter_callback', // Callback function
|
121 |
+
'iaff_advanced_settings_section', // Page slug
|
122 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
123 |
+
);
|
124 |
+
|
125 |
+
// Custom Filter
|
126 |
+
add_settings_field(
|
127 |
+
'iaff_custom_filter_settings', // ID
|
128 |
+
__('Custom Filter', 'abl_iaff_td'), // Title
|
129 |
+
'iaff_custom_filter_callback', // Callback function
|
130 |
+
'iaff_advanced_settings_section', // Page slug
|
131 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
132 |
+
);
|
133 |
+
|
134 |
+
// Capitalization Settings
|
135 |
+
add_settings_field(
|
136 |
+
'iaff_capitalization_settings', // ID
|
137 |
+
__('Capitalization Settings', 'abl_iaff_td'),// Title
|
138 |
+
'iaff_capitalization_callback', // Callback function
|
139 |
+
'iaff_advanced_settings_section', // Page slug
|
140 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
141 |
+
);
|
142 |
+
|
143 |
+
// Image Title Settings
|
144 |
+
add_settings_field(
|
145 |
+
'iaff_image_title_settings', // ID
|
146 |
+
__('Image Title Settings', 'abl_iaff_td'), // Title
|
147 |
+
'iaff_advanced_image_title_callback', // Callback function
|
148 |
+
'iaff_advanced_settings_section', // Page slug
|
149 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
150 |
+
);
|
151 |
+
|
152 |
+
// Image Alt Text Settings
|
153 |
+
add_settings_field(
|
154 |
+
'iaff_image_alt_text_settings', // ID
|
155 |
+
__('Image Alt Text Settings', 'abl_iaff_td'),// Title
|
156 |
+
'iaff_advanced_image_alt_text_callback', // Callback function
|
157 |
+
'iaff_advanced_settings_section', // Page slug
|
158 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
159 |
+
);
|
160 |
+
|
161 |
+
// Image Caption Settings
|
162 |
+
add_settings_field(
|
163 |
+
'iaff_image_caption_settings', // ID
|
164 |
+
__('Image Caption Settings', 'abl_iaff_td'),// Title
|
165 |
+
'iaff_advanced_image_caption_callback', // Callback function
|
166 |
+
'iaff_advanced_settings_section', // Page slug
|
167 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
168 |
+
);
|
169 |
+
|
170 |
+
// Image Description Settings
|
171 |
+
add_settings_field(
|
172 |
+
'iaff_image_description_settings', // ID
|
173 |
+
__('Image Description Settings', 'abl_iaff_td'),// Title
|
174 |
+
'iaff_advanced_image_description_callback', // Callback function
|
175 |
+
'iaff_advanced_settings_section', // Page slug
|
176 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
177 |
+
);
|
178 |
+
|
179 |
+
// Miscellaneous Settings
|
180 |
+
add_settings_field(
|
181 |
+
'iaff_miscellaneous_settings', // ID
|
182 |
+
__('Miscellaneous Settings', 'abl_iaff_td'),// Title
|
183 |
+
'iaff_miscellaneous_callback', // Callback function
|
184 |
+
'iaff_advanced_settings_section', // Page slug
|
185 |
+
'iaff_advanced_settings_section_id' // Settings Section ID
|
186 |
+
);
|
187 |
+
|
188 |
+
// Register Bulk Updater Settings Section
|
189 |
+
add_settings_section(
|
190 |
+
'iaff_bu_settings_section_id', // ID
|
191 |
+
__('Bulk Updater Settings','abl_iaff_td'), // Title
|
192 |
+
'__return_false', // Callback Function
|
193 |
+
'iaff_bu_settings_section' // Page slug
|
194 |
);
|
195 |
|
196 |
+
// General Settings
|
197 |
+
add_settings_field(
|
198 |
+
'iaff_bu_general_settings', // ID
|
199 |
+
__('General Settings', 'abl_iaff_td'), // Title
|
200 |
+
'iaff_bu_general_settings_callback', // Callback function
|
201 |
+
'iaff_bu_settings_section', // Page slug
|
202 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
203 |
+
);
|
204 |
+
|
205 |
+
// Filter Settings
|
206 |
+
add_settings_field(
|
207 |
+
'iaff_bu_filter_settings', // ID
|
208 |
+
__('Filter Settings', 'abl_iaff_td'), // Title
|
209 |
+
'iaff_bu_filter_settings_callback', // Callback function
|
210 |
+
'iaff_bu_settings_section', // Page slug
|
211 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
212 |
+
);
|
213 |
+
|
214 |
+
// Custom Filter
|
215 |
+
add_settings_field(
|
216 |
+
'iaff_bu_custom_filter_settings', // ID
|
217 |
+
__('Custom Filter', 'abl_iaff_td'), // Title
|
218 |
+
'iaff_bu_custom_filter_callback', // Callback function
|
219 |
+
'iaff_bu_settings_section', // Page slug
|
220 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
221 |
+
);
|
222 |
+
|
223 |
+
// Capitalization Settings
|
224 |
+
add_settings_field(
|
225 |
+
'iaff_bu_capitalization_settings', // ID
|
226 |
+
__('Capitalization Settings', 'abl_iaff_td'), // Title
|
227 |
+
'iaff_bu_capitalization_settings_callback', // Callback function
|
228 |
+
'iaff_bu_settings_section', // Page slug
|
229 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
230 |
+
);
|
231 |
+
|
232 |
+
// Image Title Settings
|
233 |
+
add_settings_field(
|
234 |
+
'iaff_bu_image_title_settings', // ID
|
235 |
+
__('Image Title Settings', 'abl_iaff_td'), // Title
|
236 |
+
'iaff_bu_image_title_settings_callback', // Callback function
|
237 |
+
'iaff_bu_settings_section', // Page slug
|
238 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
239 |
+
);
|
240 |
+
|
241 |
+
// Image Alt Text Settings
|
242 |
+
add_settings_field(
|
243 |
+
'iaff_bu_alt_text_settings', // ID
|
244 |
+
__('Image Alt Text Settings', 'abl_iaff_td'), // Title
|
245 |
+
'iaff_bu_alt_text_settings_callback', // Callback function
|
246 |
+
'iaff_bu_settings_section', // Page slug
|
247 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
248 |
+
);
|
249 |
+
|
250 |
+
// Image Caption Settings
|
251 |
+
add_settings_field(
|
252 |
+
'iaff_bu_image_caption_settings', // ID
|
253 |
+
__('Image Caption Settings', 'abl_iaff_td'), // Title
|
254 |
+
'iaff_bu_image_caption_settings_callback', // Callback function
|
255 |
+
'iaff_bu_settings_section', // Page slug
|
256 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
257 |
+
);
|
258 |
+
|
259 |
+
// Image Description Settings
|
260 |
+
add_settings_field(
|
261 |
+
'iaff_bu_image_description_settings', // ID
|
262 |
+
__('Image Description Settings', 'abl_iaff_td'),// Title
|
263 |
+
'iaff_bu_image_description_settings_callback', // Callback function
|
264 |
+
'iaff_bu_settings_section', // Page slug
|
265 |
+
'iaff_bu_settings_section_id' // Settings Section ID
|
266 |
+
);
|
267 |
+
|
268 |
}
|
269 |
add_action( 'admin_init', 'iaff_register_settings' );
|
270 |
|
271 |
+
/**
|
272 |
+
* Input validator and sanitizer
|
273 |
+
*
|
274 |
+
* @since 1.4
|
275 |
+
* @param Array $settings An array that contains all the settings
|
276 |
+
* @return Array Array containing all the settings
|
277 |
+
*/
|
278 |
+
function iaff_settings_validater_and_sanitizer( $settings ) {
|
279 |
+
|
280 |
+
// Sanitize Custom Filter
|
281 |
+
$settings['custom_filter'] = sanitize_text_field($settings['custom_filter']);
|
282 |
+
$settings['bu_custom_filter'] = sanitize_text_field($settings['bu_custom_filter']);
|
283 |
+
|
284 |
+
// Validating Regex
|
285 |
+
if( @preg_match($settings['regex_filter'], null) === false ) {
|
286 |
+
unset($settings['regex_filter']);
|
287 |
+
}
|
288 |
+
|
289 |
+
// Validating Bulk Updater Regex
|
290 |
+
if( @preg_match($settings['bu_regex_filter'], null) === false ) {
|
291 |
+
unset($settings['bu_regex_filter']);
|
292 |
+
}
|
293 |
+
|
294 |
+
return $settings;
|
295 |
+
}
|
296 |
|
297 |
/**
|
298 |
+
* Set global default values for settings
|
299 |
*
|
300 |
+
* @since 1.4
|
301 |
+
* @return Array A merged array of default and settings saved in database.
|
302 |
*/
|
303 |
+
function iaff_get_settings() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
+
$iaff_defaults = array(
|
306 |
+
'global_switch' => '1',
|
307 |
+
'image_title' => '1',
|
308 |
+
'image_caption' => '1',
|
309 |
+
'image_description' => '1',
|
310 |
+
'image_alttext' => '1',
|
311 |
+
'image_title_to_html' => '1',
|
312 |
+
'preview_pro' => '0',
|
313 |
+
'hyphens' => '1',
|
314 |
+
'under_score' => '1',
|
315 |
+
'capitalization' => '0',
|
316 |
+
'title_source' => '0',
|
317 |
+
'alt_text_source' => '0',
|
318 |
+
'caption_source' => '0',
|
319 |
+
'description_source' => '0',
|
320 |
+
'clean_filename' => '1',
|
321 |
+
'bu_image_title' => '1',
|
322 |
+
'bu_image_caption' => '1',
|
323 |
+
'bu_image_description' => '1',
|
324 |
+
'bu_image_alttext' => '1',
|
325 |
+
'bu_capitalization' => '0',
|
326 |
+
'bu_title_source' => '0',
|
327 |
+
'bu_titles_in_post' => '0',
|
328 |
+
'bu_alt_text_source' => '0',
|
329 |
+
'bu_alt_text_in_post' => '0',
|
330 |
+
'bu_caption_source' => '0',
|
331 |
+
'bu_description_source' => '0',
|
332 |
+
);
|
333 |
+
|
334 |
+
$settings = get_option('iaff_settings', $iaff_defaults);
|
335 |
+
|
336 |
+
return $settings;
|
337 |
+
}
|
338 |
|
339 |
/**
|
340 |
* Load Admin Side Js and CSS
|
343 |
* @since 1.3
|
344 |
*/
|
345 |
function iaff_enqueue_js_and_css() {
|
346 |
+
|
347 |
+
// Load files only on plugin screens
|
348 |
+
$screen = get_current_screen();
|
349 |
+
if ( $screen->id !== "settings_page_image-attributes-from-filename" ) {
|
350 |
+
return;
|
351 |
+
}
|
352 |
+
|
353 |
+
// Custom IAFF Styling
|
354 |
+
wp_enqueue_style( 'iaff-style', plugins_url( '/css/iaff-style.css', __FILE__ ), '', IAFF_VERSION_NUM );
|
355 |
+
|
356 |
+
// Custom IAFF JS
|
357 |
+
wp_enqueue_script( 'iaff-js', plugins_url('/js/iaff-js.js', __FILE__), array( 'jquery', 'jquery-ui-dialog' ), IAFF_VERSION_NUM, true );
|
358 |
+
|
359 |
+
// jQuery Dialog CSS
|
360 |
+
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
361 |
+
|
362 |
+
// Google Fonts
|
363 |
+
wp_enqueue_style('iaff-google-font', 'https://fonts.googleapis.com/css?family=Patua+One', array(), null, 'all');
|
364 |
}
|
365 |
+
add_action( 'admin_enqueue_scripts', 'iaff_enqueue_js_and_css' );
|
|
|
|
admin/iaff_image-attributes-from-filename-admin-ui-render.php
CHANGED
@@ -3,207 +3,1095 @@
|
|
3 |
* Admin UI setup and render
|
4 |
*
|
5 |
* @since 1.3
|
6 |
-
* @function
|
7 |
-
* @function
|
8 |
-
* @function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
// Exit if accessed directly
|
13 |
-
if ( !defined('ABSPATH') ) exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
*
|
19 |
* @since 1.0
|
20 |
*/
|
21 |
-
function
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
*
|
29 |
-
* @since
|
30 |
*/
|
31 |
-
function
|
32 |
-
|
33 |
-
// Default Values For Settings
|
34 |
-
global $defaults;
|
35 |
|
36 |
// Get Settings
|
37 |
-
$settings =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
//
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
<input type="checkbox" name="iaff_settings[image_caption]" id="iaff_settings[image_caption]" value="1"
|
49 |
-
<?php if ( isset( $settings['image_caption'] ) ) { checked( '1', $settings['image_caption'] ); } ?>>
|
50 |
-
<label for="iaff_settings[image_caption]"><?php _e('Set Image Caption from filename for new uploads', 'abl_iaff_td') ?></label>
|
51 |
-
<br>
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
<label for="iaff_settings[
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
<?php
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
*
|
78 |
-
* @since 1.
|
79 |
*/
|
80 |
-
function
|
81 |
|
82 |
-
//
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
// Get Settings
|
86 |
-
$settings =
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
<br>
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
<br>
|
111 |
|
112 |
-
|
113 |
-
<input type="checkbox" name="iaff_settings[all_numbers]" id="iaff_settings[all_numbers]" value="1"
|
114 |
-
<?php if ( isset( $settings['all_numbers'] ) ) { checked( '1', $settings['all_numbers'] ); } ?>>
|
115 |
-
<label for="iaff_settings[all_numbers]"><?php _e('Remove all numbers ( 0-9 ) from filename', 'abl_iaff_td') ?></label>
|
116 |
-
<br>
|
117 |
|
118 |
<?php
|
119 |
}
|
120 |
-
|
121 |
|
122 |
/**
|
123 |
-
*
|
124 |
*
|
125 |
-
* @since
|
126 |
-
*/
|
127 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
-
|
134 |
-
|
|
|
|
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
|
141 |
-
|
142 |
-
<a class="nav-tab <?php echo $active_tab == 'new-upload-settings' ? 'nav-tab-active' : ''; ?>" href="?page=image-attributes-from-filename&tab=new-upload-settings" style="margin-left: 0px;">New Upload Settings</a>
|
143 |
-
<a class="nav-tab <?php echo $active_tab == 'bulk-updater' ? 'nav-tab-active' : ''; ?>" href="?page=image-attributes-from-filename&tab=bulk-updater">Bulk Updater</a>
|
144 |
-
</h2>
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
// Output save settings button
|
159 |
-
submit_button( __('Save Settings', 'abl_iaff_td') );
|
160 |
-
?>
|
161 |
-
</form>
|
162 |
-
<?php
|
163 |
-
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
|
181 |
-
|
|
|
|
|
|
|
|
|
182 |
|
183 |
-
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
195 |
|
196 |
-
<
|
|
|
|
|
|
|
197 |
</div>
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
<?php
|
207 |
-
}
|
208 |
-
|
209 |
-
?>
|
3 |
* Admin UI setup and render
|
4 |
*
|
5 |
* @since 1.3
|
6 |
+
* @function iaff_global_switch_callback() Global Switch Callback
|
7 |
+
* @function iaff_general_settings_callback() General Settings field Callback
|
8 |
+
* @function iaff_filter_settings_callback() Filter Settings field callback
|
9 |
+
* @function iaff_basic_seo_settings_callback() Basic SEO Settings Callback
|
10 |
+
* @function iaff_preview_pro_settings_callback()Preview Pro Features Callback
|
11 |
+
* @function iaff_advanced_filter_callback() Advanced Filter Settings Callback
|
12 |
+
* @function iaff_custom_filter_callback() Custom Filter Callback
|
13 |
+
* @function iaff_capitalization_callback() Capitalization Settings Callback
|
14 |
+
* @function iaff_advanced_image_title_callback() Image Title Settings Callback
|
15 |
+
* @function iaff_advanced_image_alt_text_callback() Image Alt Text Settings Callback
|
16 |
+
* @function iaff_advanced_image_caption_callback() Image Caption Settings Callback
|
17 |
+
* @function iaff_advanced_image_description_callback() Image Description Settings Callback
|
18 |
+
* @function iaff_miscellaneous_callback() Miscellaneous Settings Callback
|
19 |
+
* @function iaff_bu_general_settings_callback() Bulk Updater General Settings Callback
|
20 |
+
* @function iaff_bu_filter_settings_callback() Bulk Updater Filter Settings Callback
|
21 |
+
* @function iaff_bu_custom_filter_callback() Bulk Updater Custom Filter Callback
|
22 |
+
* @function iaff_bu_capitalization_settings_callback() Bulk Updater Capitalization Settings Callback
|
23 |
+
* @function iaff_bu_image_title_settings_callback() Bulk Updater Image Title Settings Callback
|
24 |
+
* @function iaff_bu_alt_text_settings_callback() Bulk Updater Image Alt Text Settings Callback
|
25 |
+
* @function iaff_bu_image_caption_settings_callback() Bulk Updater Image Caption Settings Callback
|
26 |
+
* @function iaff_bu_image_description_settings_callback() Bulk Updater Image Description Settings Callback
|
27 |
+
* @function iaff_admin_interface_render() Admin interface renderer
|
28 |
*/
|
29 |
|
|
|
30 |
// Exit if accessed directly
|
31 |
+
if ( ! defined('ABSPATH') ) exit;
|
32 |
|
33 |
+
/**
|
34 |
+
* Global Switch Callback
|
35 |
+
*
|
36 |
+
* @since 1.4
|
37 |
+
*/
|
38 |
+
function iaff_global_switch_callback() {
|
39 |
+
|
40 |
+
// Get Settings
|
41 |
+
$settings = iaff_get_settings();
|
42 |
+
?>
|
43 |
+
|
44 |
+
<fieldset>
|
45 |
+
|
46 |
+
<label for="iaff_settings[global_switch]">
|
47 |
+
<input type="checkbox" name="iaff_settings[global_switch]" id="iaff_settings[global_switch]" value="1" <?php if ( isset($settings['global_switch']) ) checked( '1', $settings['global_switch'] ); ?>>
|
48 |
+
<span><?php _e('Globally enable or disable Auto Image Attributes. Should be checked for the plugin to work.', 'abl_iaff_td') ?></span>
|
49 |
+
</label><br>
|
50 |
+
|
51 |
+
</fieldset>
|
52 |
+
|
53 |
+
<?php
|
54 |
+
}
|
55 |
|
56 |
/**
|
57 |
+
* General Settings field Callback
|
58 |
*
|
59 |
* @since 1.0
|
60 |
*/
|
61 |
+
function iaff_general_settings_callback() {
|
62 |
+
|
63 |
+
// Get Settings
|
64 |
+
$settings = iaff_get_settings();
|
65 |
+
|
66 |
+
// General Settings. Name of form element should be same as the setting name in register_setting().
|
67 |
+
?>
|
68 |
+
|
69 |
+
<fieldset>
|
70 |
+
|
71 |
+
<!-- Auto Add Image Title -->
|
72 |
+
<label for="iaff_settings[image_title]">
|
73 |
+
<input type="checkbox" name="iaff_settings[image_title]" id="iaff_settings[image_title]" value="1" <?php if ( isset($settings['image_title']) ) checked( '1', $settings['image_title'] ); ?>>
|
74 |
+
<span><?php _e('Set Image Title for new uploads', 'abl_iaff_td') ?></span>
|
75 |
+
</label><br>
|
76 |
+
|
77 |
+
<!-- Auto Add Image Caption -->
|
78 |
+
<label for="iaff_settings[image_caption]">
|
79 |
+
<input type="checkbox" name="iaff_settings[image_caption]" id="iaff_settings[image_caption]" value="1" <?php if ( isset($settings['image_caption']) ) checked( '1', $settings['image_caption'] ); ?>>
|
80 |
+
<span><?php _e('Set Image Caption for new uploads', 'abl_iaff_td') ?></span>
|
81 |
+
</label><br>
|
82 |
+
|
83 |
+
<!-- Auto Add Image Description -->
|
84 |
+
<label for="iaff_settings[image_description]">
|
85 |
+
<input type="checkbox" name="iaff_settings[image_description]" id="iaff_settings[image_description]" value="1" <?php if ( isset($settings['image_description']) ) checked( '1', $settings['image_description'] ); ?>>
|
86 |
+
<span><?php _e('Set Image Description for new uploads', 'abl_iaff_td') ?></span>
|
87 |
+
</label><br>
|
88 |
+
|
89 |
+
<!-- Auto Add Alt Text -->
|
90 |
+
<label for="iaff_settings[image_alttext]">
|
91 |
+
<input type="checkbox" name="iaff_settings[image_alttext]" id="iaff_settings[image_alttext]" value="1" <?php if ( isset($settings['image_alttext']) ) checked( '1', $settings['image_alttext'] ); ?>>
|
92 |
+
<span><?php _e('Set Image Alt Text for new uploads', 'abl_iaff_td') ?></span>
|
93 |
+
</label><br>
|
94 |
+
|
95 |
+
</fieldset>
|
96 |
+
|
97 |
+
<?php
|
98 |
}
|
99 |
|
100 |
|
101 |
/**
|
102 |
+
* Filter Settings field callback
|
103 |
*
|
104 |
+
* @since 1.0
|
105 |
*/
|
106 |
+
function iaff_filter_settings_callback() {
|
|
|
|
|
|
|
107 |
|
108 |
// Get Settings
|
109 |
+
$settings = iaff_get_settings();
|
110 |
+
?>
|
111 |
+
|
112 |
+
<fieldset>
|
113 |
+
|
114 |
+
<!-- Filter Hyphens -->
|
115 |
+
<label for="iaff_settings[hyphens]">
|
116 |
+
<input type="checkbox" name="iaff_settings[hyphens]" id="iaff_settings[hyphens]" value="1" <?php if ( isset($settings['hyphens']) ) checked( '1', $settings['hyphens'] ); ?>>
|
117 |
+
<span><?php _e('Remove hyphens ( - ) from filename', 'abl_iaff_td') ?></span>
|
118 |
+
</label><br>
|
119 |
+
|
120 |
+
<!-- Filter Underscore -->
|
121 |
+
<label for="iaff_settings[under_score]">
|
122 |
+
<input type="checkbox" name="iaff_settings[under_score]" id="iaff_settings[under_score]" value="1" <?php if ( isset($settings['under_score']) ) checked( '1', $settings['under_score'] ); ?>>
|
123 |
+
<span><?php _e('Remove underscores ( _ ) from filename', 'abl_iaff_td') ?></span>
|
124 |
+
</label><br>
|
125 |
+
|
126 |
+
<!-- Filter Full stops -->
|
127 |
+
<label for="iaff_settings[full_stop]">
|
128 |
+
<input type="checkbox" name="iaff_settings[full_stop]" id="iaff_settings[full_stop]" value="1" <?php if ( isset($settings['full_stop']) ) checked( '1', $settings['full_stop'] ); ?>>
|
129 |
+
<span><?php _e('Remove full stops ( . ) from filename', 'abl_iaff_td') ?></span>
|
130 |
+
</label><br>
|
131 |
+
|
132 |
+
<!-- Filter Commas -->
|
133 |
+
<label for="iaff_settings[commas]">
|
134 |
+
<input type="checkbox" name="iaff_settings[commas]" id="iaff_settings[commas]" value="1" <?php if ( isset($settings['commas']) ) checked( '1', $settings['commas'] ); ?>>
|
135 |
+
<span><?php _e('Remove commas ( , ) from filename', 'abl_iaff_td') ?></span>
|
136 |
+
</label><br>
|
137 |
+
|
138 |
+
<!-- Filter Numbers -->
|
139 |
+
<label for="iaff_settings[all_numbers]">
|
140 |
+
<input type="checkbox" name="iaff_settings[all_numbers]" id="iaff_settings[all_numbers]" value="1" <?php if ( isset($settings['all_numbers']) ) checked( '1', $settings['all_numbers'] ); ?>>
|
141 |
+
<span><?php _e('Remove all numbers ( 0-9 ) from filename', 'abl_iaff_td') ?></span>
|
142 |
+
</label><br>
|
143 |
+
|
144 |
+
</fieldset>
|
145 |
+
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Basic SEO Settings Callback
|
151 |
+
*
|
152 |
+
* @since 1.4
|
153 |
+
*/
|
154 |
+
function iaff_basic_seo_settings_callback() {
|
155 |
|
156 |
+
// Get Settings
|
157 |
+
$settings = iaff_get_settings();
|
158 |
+
?>
|
159 |
+
|
160 |
+
<fieldset>
|
161 |
|
162 |
+
<!-- Insert Image Title Into Post HTML -->
|
163 |
+
<label for="iaff_settings[image_title_to_html]">
|
164 |
+
<input type="checkbox" name="iaff_settings[image_title_to_html]" id="iaff_settings[image_title_to_html]" value="1" <?php if ( isset($settings['image_title_to_html']) ) checked( '1', $settings['image_title_to_html'] ); ?>>
|
165 |
+
<span><?php _e('Insert Image Title into post HTML. This will add title="Image Title" in the <img> tag.', 'abl_iaff_td') ?></span>
|
166 |
+
</label><br>
|
167 |
|
168 |
+
</fieldset>
|
|
|
|
|
|
|
|
|
169 |
|
170 |
+
<?php
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Preview Pro Features Callback
|
175 |
+
*
|
176 |
+
* @since 1.4
|
177 |
+
*/
|
178 |
+
function iaff_preview_pro_settings_callback() {
|
179 |
+
|
180 |
+
// Get Settings
|
181 |
+
$settings = iaff_get_settings();
|
182 |
+
?>
|
183 |
|
184 |
+
<fieldset>
|
185 |
+
|
186 |
+
<!-- Preview Pro Settings -->
|
187 |
+
<label for="iaff_settings[preview_pro]">
|
188 |
+
<input type="checkbox" name="iaff_settings[preview_pro]" id="iaff_settings[preview_pro]" value="1" <?php if ( isset($settings['preview_pro']) ) checked( '1', $settings['preview_pro'] ); ?>>
|
189 |
+
<span><?php printf( __( 'Check to see a preview of all the options that ship with <a href="%s" target="_blank">Image Attributes Pro</a>.', 'abl_iaff_td' ),
|
190 |
+
'https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=preview-pro-setting'
|
191 |
+
); ?></span>
|
192 |
+
</label><br>
|
193 |
|
194 |
+
</fieldset>
|
195 |
+
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Advanced Filter Settings Callback
|
201 |
+
*
|
202 |
+
* @since 1.4
|
203 |
+
*/
|
204 |
+
function iaff_advanced_filter_callback() {
|
205 |
|
206 |
+
// Get Settings
|
207 |
+
$settings = iaff_get_settings();
|
208 |
+
?>
|
209 |
+
|
210 |
+
<fieldset>
|
211 |
+
|
212 |
+
<!-- Filter Apostrophe -->
|
213 |
+
<label for="iaff_settings[apostrophe]">
|
214 |
+
<input type="checkbox" name="iaff_settings[apostrophe]" id="iaff_settings[apostrophe]" value="1" <?php if ( isset($settings['apostrophe']) ) checked( '1', $settings['apostrophe'] ); ?>>
|
215 |
+
<span><?php _e('Remove apostrophe ( \' ) from filename', 'abl_iaff_td') ?></span>
|
216 |
+
</label><br>
|
217 |
+
|
218 |
+
<!-- Filter Tilde -->
|
219 |
+
<label for="iaff_settings[tilde]">
|
220 |
+
<input type="checkbox" name="iaff_settings[tilde]" id="iaff_settings[tilde]" value="1" <?php if ( isset($settings['tilde']) ) checked( '1', $settings['tilde'] ); ?>>
|
221 |
+
<span><?php _e('Remove tilde ( ~ ) from filename', 'abl_iaff_td') ?></span>
|
222 |
+
</label><br>
|
223 |
+
|
224 |
+
<!-- Filter Plus -->
|
225 |
+
<label for="iaff_settings[plus]">
|
226 |
+
<input type="checkbox" name="iaff_settings[plus]" id="iaff_settings[plus]" value="1" <?php if ( isset($settings['plus']) ) checked( '1', $settings['plus'] ); ?>>
|
227 |
+
<span><?php _e('Remove plus ( + ) from filename', 'abl_iaff_td') ?></span>
|
228 |
+
</label><br>
|
229 |
+
|
230 |
+
<!-- Filter Pound -->
|
231 |
+
<label for="iaff_settings[pound]">
|
232 |
+
<input type="checkbox" name="iaff_settings[pound]" id="iaff_settings[pound]" value="1" <?php if ( isset($settings['pound']) ) checked( '1', $settings['pound'] ); ?>>
|
233 |
+
<span><?php _e('Remove pound ( # ) from filename', 'abl_iaff_td') ?></span>
|
234 |
+
</label><br>
|
235 |
+
|
236 |
+
<!-- Filter Ampersand -->
|
237 |
+
<label for="iaff_settings[ampersand]">
|
238 |
+
<input type="checkbox" name="iaff_settings[ampersand]" id="iaff_settings[ampersand]" value="1" <?php if ( isset($settings['ampersand']) ) checked( '1', $settings['ampersand'] ); ?>>
|
239 |
+
<span><?php _e('Remove ampersand ( & ) from filename', 'abl_iaff_td') ?></span>
|
240 |
+
</label><br>
|
241 |
+
|
242 |
+
<!-- Filter Round Brackets -->
|
243 |
+
<label for="iaff_settings[round_brackets]">
|
244 |
+
<input type="checkbox" name="iaff_settings[round_brackets]" id="iaff_settings[round_brackets]" value="1" <?php if ( isset($settings['round_brackets']) ) checked( '1', $settings['round_brackets'] ); ?>>
|
245 |
+
<span><?php _e('Remove round brackets ( ( ) ) from filename', 'abl_iaff_td') ?></span>
|
246 |
+
</label><br>
|
247 |
+
|
248 |
+
<!-- Filter Square Brackets -->
|
249 |
+
<label for="iaff_settings[square_brackets]">
|
250 |
+
<input type="checkbox" name="iaff_settings[square_brackets]" id="iaff_settings[square_brackets]" value="1" <?php if ( isset($settings['square_brackets']) ) checked( '1', $settings['square_brackets'] ); ?>>
|
251 |
+
<span><?php _e('Remove square brackets ( [ ] ) from filename', 'abl_iaff_td') ?></span>
|
252 |
+
</label><br>
|
253 |
+
|
254 |
+
<!-- Filter Curly Brackets -->
|
255 |
+
<label for="iaff_settings[curly_brackets]">
|
256 |
+
<input type="checkbox" name="iaff_settings[curly_brackets]" id="iaff_settings[curly_brackets]" value="1" <?php if ( isset($settings['curly_brackets']) ) checked( '1', $settings['curly_brackets'] ); ?>>
|
257 |
+
<span><?php _e('Remove curly brackets ( { } ) from filename', 'abl_iaff_td') ?></span>
|
258 |
+
</label><br>
|
259 |
+
|
260 |
+
</fieldset>
|
261 |
+
|
262 |
<?php
|
263 |
}
|
264 |
|
265 |
+
/**
|
266 |
+
* Custom Filter Callback
|
267 |
+
*
|
268 |
+
* @since 1.4
|
269 |
+
*/
|
270 |
+
function iaff_custom_filter_callback() {
|
271 |
+
|
272 |
+
// Get Settings
|
273 |
+
$settings = iaff_get_settings();
|
274 |
+
?>
|
275 |
+
|
276 |
+
<fieldset>
|
277 |
+
|
278 |
+
<p>Enter words or characters to filter separated by commas. Filter is case sensitive.</p>
|
279 |
+
<input type="text" name="iaff_settings[custom_filter]" placeholder="DCIM, img" class="all-options" value="<?php if ( isset( $settings['custom_filter'] ) && ( ! empty($settings['custom_filter']) ) ) esc_attr_e($settings['custom_filter']); ?>"/><br><br>
|
280 |
+
|
281 |
+
<p>Filter with regular expression</p>
|
282 |
+
<input type="text" name="iaff_settings[regex_filter]" placeholder="/regex/" class="all-options" value="<?php if ( isset( $settings['regex_filter'] ) && ( ! empty($settings['regex_filter']) ) ) esc_attr_e($settings['regex_filter']); ?>"/><br>
|
283 |
+
|
284 |
+
</fieldset>
|
285 |
+
|
286 |
+
<?php
|
287 |
+
}
|
288 |
|
289 |
/**
|
290 |
+
* Capitalization Settings Callback
|
291 |
*
|
292 |
+
* @since 1.4
|
293 |
*/
|
294 |
+
function iaff_capitalization_callback() {
|
295 |
|
296 |
+
// Get Settings
|
297 |
+
$settings = iaff_get_settings();
|
298 |
+
?>
|
299 |
+
|
300 |
+
<fieldset>
|
301 |
+
|
302 |
+
<!-- No capitalization -->
|
303 |
+
<label>
|
304 |
+
<input type="radio" name="iaff_settings[capitalization]" value="0" <?php if ( isset($settings['capitalization']) ) checked( '0', $settings['capitalization'] ); ?>/>
|
305 |
+
<span><?php esc_attr_e( 'Leave unchanged', 'abl_iaff_td' ); ?></span>
|
306 |
+
</label><br>
|
307 |
+
|
308 |
+
<!-- Lowercase -->
|
309 |
+
<label>
|
310 |
+
<input type="radio" name="iaff_settings[capitalization]" value="1" <?php if ( isset($settings['capitalization']) ) checked( '1', $settings['capitalization'] ); ?>/>
|
311 |
+
<span><?php esc_attr_e( 'convert to lowercase', 'abl_iaff_td' ); ?></span>
|
312 |
+
</label><br>
|
313 |
+
|
314 |
+
<!-- Uppercase -->
|
315 |
+
<label>
|
316 |
+
<input type="radio" name="iaff_settings[capitalization]" value="2" <?php if ( isset($settings['capitalization']) ) checked( '2', $settings['capitalization'] ); ?>/>
|
317 |
+
<span><?php esc_attr_e( 'CONVERT TO UPPERCASE', 'abl_iaff_td' ); ?></span>
|
318 |
+
</label><br>
|
319 |
+
|
320 |
+
<!-- Title Casing -->
|
321 |
+
<label>
|
322 |
+
<input type="radio" name="iaff_settings[capitalization]" value="3" <?php if ( isset($settings['capitalization']) ) checked( '3', $settings['capitalization'] ); ?>/>
|
323 |
+
<span><?php esc_attr_e( 'Use title casing. First Letter Of Each Word Will Be Capitalized.', 'abl_iaff_td' ); ?></span>
|
324 |
+
</label><br>
|
325 |
+
|
326 |
+
<!-- Sentence Casing -->
|
327 |
+
<label>
|
328 |
+
<input type="radio" name="iaff_settings[capitalization]" value="4" <?php if ( isset($settings['capitalization']) ) checked( '4', $settings['capitalization'] ); ?>/>
|
329 |
+
<span><?php esc_attr_e( 'Use sentence casing. First letter of a sentence will be capitalized.', 'abl_iaff_td' ); ?></span>
|
330 |
+
</label><br>
|
331 |
+
|
332 |
+
</fieldset>
|
333 |
+
|
334 |
+
<?php
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Image Title Settings Callback
|
339 |
+
*
|
340 |
+
* @since 1.4
|
341 |
+
*/
|
342 |
+
function iaff_advanced_image_title_callback() {
|
343 |
|
344 |
// Get Settings
|
345 |
+
$settings = iaff_get_settings();
|
346 |
+
?>
|
347 |
+
|
348 |
+
<fieldset>
|
349 |
|
350 |
+
<label>
|
351 |
+
<input type="radio" name="iaff_settings[title_source]" value="0" <?php if ( isset($settings['title_source']) ) checked( '0', $settings['title_source'] ); ?>/>
|
352 |
+
<span><?php esc_attr_e( 'Use image filename as title text', 'abl_iaff_td' ); ?></span>
|
353 |
+
</label><br>
|
|
|
354 |
|
355 |
+
<label>
|
356 |
+
<input type="radio" name="iaff_settings[title_source]" value="1" <?php if ( isset($settings['title_source']) ) checked( '1', $settings['title_source'] ); ?>/>
|
357 |
+
<span><?php esc_attr_e( 'Use post title as title text. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
358 |
+
</label><br>
|
359 |
+
|
360 |
+
</fieldset>
|
361 |
+
|
362 |
+
<?php
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Image Alt Text Settings Callback
|
367 |
+
*
|
368 |
+
* @since 1.4
|
369 |
+
*/
|
370 |
+
function iaff_advanced_image_alt_text_callback() {
|
371 |
+
|
372 |
+
// Get Settings
|
373 |
+
$settings = iaff_get_settings();
|
374 |
+
?>
|
375 |
|
376 |
+
<fieldset>
|
377 |
+
|
378 |
+
<label>
|
379 |
+
<input type="radio" name="iaff_settings[alt_text_source]" value="0" <?php if ( isset($settings['alt_text_source']) ) checked( '0', $settings['alt_text_source'] ); ?>/>
|
380 |
+
<span><?php esc_attr_e( 'Use image filename as alt text', 'abl_iaff_td' ); ?></span>
|
381 |
+
</label><br>
|
382 |
|
383 |
+
<label>
|
384 |
+
<input type="radio" name="iaff_settings[alt_text_source]" value="1" <?php if ( isset($settings['alt_text_source']) ) checked( '1', $settings['alt_text_source'] ); ?>/>
|
385 |
+
<span><?php esc_attr_e( 'Use post title as alt text. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
386 |
+
</label><br>
|
|
|
387 |
|
388 |
+
</fieldset>
|
|
|
|
|
|
|
|
|
389 |
|
390 |
<?php
|
391 |
}
|
|
|
392 |
|
393 |
/**
|
394 |
+
* Image Caption Settings Callback
|
395 |
*
|
396 |
+
* @since 1.4
|
397 |
+
*/
|
398 |
+
function iaff_advanced_image_caption_callback() {
|
399 |
+
|
400 |
+
// Get Settings
|
401 |
+
$settings = iaff_get_settings();
|
402 |
+
?>
|
403 |
+
|
404 |
+
<fieldset>
|
405 |
|
406 |
+
<label>
|
407 |
+
<input type="radio" name="iaff_settings[caption_source]" value="0" <?php if ( isset($settings['caption_source']) ) checked( '0', $settings['caption_source'] ); ?>/>
|
408 |
+
<span><?php esc_attr_e( 'Use image filename as caption', 'abl_iaff_td' ); ?></span>
|
409 |
+
</label><br>
|
410 |
+
|
411 |
+
<label>
|
412 |
+
<input type="radio" name="iaff_settings[caption_source]" value="1" <?php if ( isset($settings['caption_source']) ) checked( '1', $settings['caption_source'] ); ?>/>
|
413 |
+
<span><?php esc_attr_e( 'Use post title as caption. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
414 |
+
</label><br>
|
415 |
+
|
416 |
+
</fieldset>
|
417 |
+
|
418 |
+
<?php
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Image Description Settings Callback
|
423 |
+
*
|
424 |
+
* @since 1.4
|
425 |
+
*/
|
426 |
+
function iaff_advanced_image_description_callback() {
|
427 |
+
|
428 |
+
// Get Settings
|
429 |
+
$settings = iaff_get_settings();
|
430 |
+
?>
|
431 |
+
|
432 |
+
<fieldset>
|
433 |
|
434 |
+
<label>
|
435 |
+
<input type="radio" name="iaff_settings[description_source]" value="0" <?php if ( isset($settings['description_source']) ) checked( '0', $settings['description_source'] ); ?>/>
|
436 |
+
<span><?php esc_attr_e( 'Use image filename as description', 'abl_iaff_td' ); ?></span>
|
437 |
+
</label><br>
|
438 |
|
439 |
+
<label>
|
440 |
+
<input type="radio" name="iaff_settings[description_source]" value="1" <?php if ( isset($settings['description_source']) ) checked( '1', $settings['description_source'] ); ?>/>
|
441 |
+
<span><?php esc_attr_e( 'Use post title as description. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
442 |
+
</label><br>
|
443 |
|
444 |
+
</fieldset>
|
|
|
|
|
|
|
445 |
|
446 |
+
<?php
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Miscellaneous Settings Callback
|
451 |
+
*
|
452 |
+
* @since 1.4
|
453 |
+
*/
|
454 |
+
function iaff_miscellaneous_callback() {
|
455 |
+
|
456 |
+
// Get Settings
|
457 |
+
$settings = iaff_get_settings();
|
458 |
+
?>
|
459 |
|
460 |
+
<fieldset>
|
461 |
+
|
462 |
+
<!-- Clean filename -->
|
463 |
+
<label for="iaff_settings[clean_filename]">
|
464 |
+
<input type="checkbox" name="iaff_settings[clean_filename]" id="iaff_settings[clean_filename]" value="1" <?php if ( isset($settings['clean_filename']) ) checked( '1', $settings['clean_filename'] ); ?>>
|
465 |
+
<span><?php _e('Clean actual image filename after upload.', 'abl_iaff_td') ?></span>
|
466 |
+
</label><br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
|
468 |
+
</fieldset>
|
469 |
+
|
470 |
+
<?php
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Bulk Updater General Settings Callback
|
475 |
+
*
|
476 |
+
* @since 1.4
|
477 |
+
*/
|
478 |
+
function iaff_bu_general_settings_callback() {
|
479 |
|
480 |
+
// Get Settings
|
481 |
+
$settings = iaff_get_settings();
|
482 |
+
?>
|
483 |
+
|
484 |
+
<fieldset>
|
485 |
+
|
486 |
+
<!-- Auto Add Image Title -->
|
487 |
+
<label for="iaff_settings[bu_image_title]">
|
488 |
+
<input type="checkbox" name="iaff_settings[bu_image_title]" id="iaff_settings[bu_image_title]" value="1" <?php if ( isset($settings['bu_image_title']) ) checked( '1', $settings['bu_image_title'] ); ?>>
|
489 |
+
<span><?php _e('Update Image Title', 'abl_iaff_td') ?></span>
|
490 |
+
</label><br>
|
491 |
+
|
492 |
+
<!-- Auto Add Image Caption -->
|
493 |
+
<label for="iaff_settings[bu_image_caption]">
|
494 |
+
<input type="checkbox" name="iaff_settings[bu_image_caption]" id="iaff_settings[bu_image_caption]" value="1" <?php if ( isset($settings['bu_image_caption']) ) checked( '1', $settings['bu_image_caption'] ); ?>>
|
495 |
+
<span><?php _e('Update Image Caption', 'abl_iaff_td') ?></span>
|
496 |
+
</label><br>
|
497 |
|
498 |
+
<!-- Auto Add Image Description -->
|
499 |
+
<label for="iaff_settings[bu_image_description]">
|
500 |
+
<input type="checkbox" name="iaff_settings[bu_image_description]" id="iaff_settings[bu_image_description]" value="1" <?php if ( isset($settings['bu_image_description']) ) checked( '1', $settings['bu_image_description'] ); ?>>
|
501 |
+
<span><?php _e('Update Image Description', 'abl_iaff_td') ?></span>
|
502 |
+
</label><br>
|
503 |
|
504 |
+
<!-- Auto Add Alt Text -->
|
505 |
+
<label for="iaff_settings[bu_image_alttext]">
|
506 |
+
<input type="checkbox" name="iaff_settings[bu_image_alttext]" id="iaff_settings[bu_image_alttext]" value="1" <?php if ( isset($settings['bu_image_alttext']) ) checked( '1', $settings['bu_image_alttext'] ); ?>>
|
507 |
+
<span><?php _e('Update Image Alt Text', 'abl_iaff_td') ?></span>
|
508 |
+
</label><br>
|
509 |
+
|
510 |
+
</fieldset>
|
511 |
+
|
512 |
+
<?php
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Bulk Updater Filter Settings Callback
|
517 |
+
*
|
518 |
+
* @since 1.4
|
519 |
+
*/
|
520 |
+
function iaff_bu_filter_settings_callback() {
|
521 |
+
|
522 |
+
// Get Settings
|
523 |
+
$settings = iaff_get_settings();
|
524 |
+
?>
|
525 |
+
|
526 |
+
<fieldset>
|
527 |
+
|
528 |
+
<!-- Filter Hyphens -->
|
529 |
+
<label for="iaff_settings[bu_hyphens]">
|
530 |
+
<input type="checkbox" name="iaff_settings[bu_hyphens]" id="iaff_settings[bu_hyphens]" value="1" <?php if ( isset($settings['bu_hyphens']) ) checked( '1', $settings['bu_hyphens'] ); ?>>
|
531 |
+
<span><?php _e('Remove hyphens ( - ) from filename', 'abl_iaff_td') ?></span>
|
532 |
+
</label><br>
|
533 |
|
534 |
+
<!-- Filter Underscore -->
|
535 |
+
<label for="iaff_settings[bu_under_score]">
|
536 |
+
<input type="checkbox" name="iaff_settings[bu_under_score]" id="iaff_settings[bu_under_score]" value="1" <?php if ( isset($settings['bu_under_score']) ) checked( '1', $settings['bu_under_score'] ); ?>>
|
537 |
+
<span><?php _e('Remove underscores ( _ ) from filename', 'abl_iaff_td') ?></span>
|
538 |
+
</label><br>
|
539 |
|
540 |
+
<!-- Filter Full stops -->
|
541 |
+
<label for="iaff_settings[bu_full_stop]">
|
542 |
+
<input type="checkbox" name="iaff_settings[bu_full_stop]" id="iaff_settings[bu_full_stop]" value="1" <?php if ( isset($settings['bu_full_stop']) ) checked( '1', $settings['bu_full_stop'] ); ?>>
|
543 |
+
<span><?php _e('Remove full stops ( . ) from filename', 'abl_iaff_td') ?></span>
|
544 |
+
</label><br>
|
545 |
|
546 |
+
<!-- Filter Commas -->
|
547 |
+
<label for="iaff_settings[bu_commas]">
|
548 |
+
<input type="checkbox" name="iaff_settings[bu_commas]" id="iaff_settings[bu_commas]" value="1" <?php if ( isset($settings['bu_commas']) ) checked( '1', $settings['bu_commas'] ); ?>>
|
549 |
+
<span><?php _e('Remove commas ( , ) from filename', 'abl_iaff_td') ?></span>
|
550 |
+
</label><br>
|
551 |
|
552 |
+
<!-- Filter Numbers -->
|
553 |
+
<label for="iaff_settings[bu_all_numbers]">
|
554 |
+
<input type="checkbox" name="iaff_settings[bu_all_numbers]" id="iaff_settings[bu_all_numbers]" value="1" <?php if ( isset($settings['bu_all_numbers']) ) checked( '1', $settings['bu_all_numbers'] ); ?>>
|
555 |
+
<span><?php _e('Remove all numbers ( 0-9 ) from filename', 'abl_iaff_td') ?></span>
|
556 |
+
</label><br>
|
557 |
+
|
558 |
+
<!-- Filter Apostrophe -->
|
559 |
+
<label for="iaff_settings[bu_apostrophe]">
|
560 |
+
<input type="checkbox" name="iaff_settings[bu_apostrophe]" id="iaff_settings[bu_apostrophe]" value="1" <?php if ( isset($settings['bu_apostrophe']) ) checked( '1', $settings['bu_apostrophe'] ); ?>>
|
561 |
+
<span><?php _e('Remove apostrophe ( \' ) from filename', 'abl_iaff_td') ?></span>
|
562 |
+
</label><br>
|
563 |
+
|
564 |
+
<!-- Filter Tilde -->
|
565 |
+
<label for="iaff_settings[bu_tilde]">
|
566 |
+
<input type="checkbox" name="iaff_settings[bu_tilde]" id="iaff_settings[bu_tilde]" value="1" <?php if ( isset($settings['bu_tilde']) ) checked( '1', $settings['bu_tilde'] ); ?>>
|
567 |
+
<span><?php _e('Remove tilde ( ~ ) from filename', 'abl_iaff_td') ?></span>
|
568 |
+
</label><br>
|
569 |
+
|
570 |
+
<!-- Filter Plus -->
|
571 |
+
<label for="iaff_settings[bu_plus]">
|
572 |
+
<input type="checkbox" name="iaff_settings[bu_plus]" id="iaff_settings[bu_plus]" value="1" <?php if ( isset($settings['bu_plus']) ) checked( '1', $settings['bu_plus'] ); ?>>
|
573 |
+
<span><?php _e('Remove plus ( + ) from filename', 'abl_iaff_td') ?></span>
|
574 |
+
</label><br>
|
575 |
+
|
576 |
+
<!-- Filter Pound -->
|
577 |
+
<label for="iaff_settings[bu_pound]">
|
578 |
+
<input type="checkbox" name="iaff_settings[bu_pound]" id="iaff_settings[bu_pound]" value="1" <?php if ( isset($settings['bu_pound']) ) checked( '1', $settings['bu_pound'] ); ?>>
|
579 |
+
<span><?php _e('Remove pound ( # ) from filename', 'abl_iaff_td') ?></span>
|
580 |
+
</label><br>
|
581 |
+
|
582 |
+
<!-- Filter Ampersand -->
|
583 |
+
<label for="iaff_settings[bu_ampersand]">
|
584 |
+
<input type="checkbox" name="iaff_settings[bu_ampersand]" id="iaff_settings[bu_ampersand]" value="1" <?php if ( isset($settings['bu_ampersand']) ) checked( '1', $settings['bu_ampersand'] ); ?>>
|
585 |
+
<span><?php _e('Remove ampersand ( & ) from filename', 'abl_iaff_td') ?></span>
|
586 |
+
</label><br>
|
587 |
+
|
588 |
+
<!-- Filter Round Brackets -->
|
589 |
+
<label for="iaff_settings[bu_round_brackets]">
|
590 |
+
<input type="checkbox" name="iaff_settings[bu_round_brackets]" id="iaff_settings[bu_round_brackets]" value="1" <?php if ( isset($settings['bu_round_brackets']) ) checked( '1', $settings['bu_round_brackets'] ); ?>>
|
591 |
+
<span><?php _e('Remove round brackets ( ( ) ) from filename', 'abl_iaff_td') ?></span>
|
592 |
+
</label><br>
|
593 |
+
|
594 |
+
<!-- Filter Square Brackets -->
|
595 |
+
<label for="iaff_settings[bu_square_brackets]">
|
596 |
+
<input type="checkbox" name="iaff_settings[bu_square_brackets]" id="iaff_settings[bu_square_brackets]" value="1" <?php if ( isset($settings['bu_square_brackets']) ) checked( '1', $settings['bu_square_brackets'] ); ?>>
|
597 |
+
<span><?php _e('Remove square brackets ( [ ] ) from filename', 'abl_iaff_td') ?></span>
|
598 |
+
</label><br>
|
599 |
+
|
600 |
+
<!-- Filter Curly Brackets -->
|
601 |
+
<label for="iaff_settings[bu_curly_brackets]">
|
602 |
+
<input type="checkbox" name="iaff_settings[bu_curly_brackets]" id="iaff_settings[bu_curly_brackets]" value="1" <?php if ( isset($settings['bu_curly_brackets']) ) checked( '1', $settings['bu_curly_brackets'] ); ?>>
|
603 |
+
<span><?php _e('Remove curly brackets ( { } ) from filename', 'abl_iaff_td') ?></span>
|
604 |
+
</label><br>
|
605 |
+
|
606 |
+
</fieldset>
|
607 |
+
|
608 |
+
<?php
|
609 |
+
}
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Bulk Updater Custom Filter Callback
|
613 |
+
*
|
614 |
+
* @since 1.4
|
615 |
+
*/
|
616 |
+
function iaff_bu_custom_filter_callback() {
|
617 |
+
|
618 |
+
// Get Settings
|
619 |
+
$settings = iaff_get_settings();
|
620 |
+
?>
|
621 |
+
|
622 |
+
<fieldset>
|
623 |
+
|
624 |
+
<p>Enter words or characters to filter separated by commas. Filter is case sensitive.</p>
|
625 |
+
<input type="text" name="iaff_settings[bu_custom_filter]" placeholder="DCIM, img" class="all-options" value="<?php if ( isset( $settings['bu_custom_filter'] ) && ( ! empty($settings['bu_custom_filter']) ) ) esc_attr_e($settings['bu_custom_filter']); ?>"/><br><br>
|
626 |
+
|
627 |
+
<p>Filter with regular expression</p>
|
628 |
+
<input type="text" name="iaff_settings[bu_regex_filter]" placeholder="/regex/" class="all-options" value="<?php if ( isset( $settings['bu_regex_filter'] ) && ( ! empty($settings['bu_regex_filter']) ) ) esc_attr_e($settings['bu_regex_filter']); ?>"/><br>
|
629 |
+
|
630 |
+
</fieldset>
|
631 |
+
|
632 |
+
<?php
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Bulk Updater Capitalization Settings Callback
|
637 |
+
*
|
638 |
+
* @since 1.4
|
639 |
+
*/
|
640 |
+
function iaff_bu_capitalization_settings_callback() {
|
641 |
+
|
642 |
+
// Get Settings
|
643 |
+
$settings = iaff_get_settings();
|
644 |
+
?>
|
645 |
+
|
646 |
+
<fieldset>
|
647 |
+
|
648 |
+
<!-- No bu_capitalization -->
|
649 |
+
<label>
|
650 |
+
<input type="radio" name="iaff_settings[bu_capitalization]" value="0" <?php if ( isset($settings['bu_capitalization']) ) checked( '0', $settings['bu_capitalization'] ); ?>/>
|
651 |
+
<span><?php esc_attr_e( 'Leave unchanged', 'abl_iaff_td' ); ?></span>
|
652 |
+
</label><br>
|
653 |
+
|
654 |
+
<!-- Lowercase -->
|
655 |
+
<label>
|
656 |
+
<input type="radio" name="iaff_settings[bu_capitalization]" value="1" <?php if ( isset($settings['bu_capitalization']) ) checked( '1', $settings['bu_capitalization'] ); ?>/>
|
657 |
+
<span><?php esc_attr_e( 'convert to lowercase', 'abl_iaff_td' ); ?></span>
|
658 |
+
</label><br>
|
659 |
+
|
660 |
+
<!-- Uppercase -->
|
661 |
+
<label>
|
662 |
+
<input type="radio" name="iaff_settings[bu_capitalization]" value="2" <?php if ( isset($settings['bu_capitalization']) ) checked( '2', $settings['bu_capitalization'] ); ?>/>
|
663 |
+
<span><?php esc_attr_e( 'CONVERT TO UPPERCASE', 'abl_iaff_td' ); ?></span>
|
664 |
+
</label><br>
|
665 |
+
|
666 |
+
<!-- Title Casing -->
|
667 |
+
<label>
|
668 |
+
<input type="radio" name="iaff_settings[bu_capitalization]" value="3" <?php if ( isset($settings['bu_capitalization']) ) checked( '3', $settings['bu_capitalization'] ); ?>/>
|
669 |
+
<span><?php esc_attr_e( 'Use title casing. First Letter Of Each Word Will Be Capitalized.', 'abl_iaff_td' ); ?></span>
|
670 |
+
</label><br>
|
671 |
+
|
672 |
+
<!-- Sentence Casing -->
|
673 |
+
<label>
|
674 |
+
<input type="radio" name="iaff_settings[bu_capitalization]" value="4" <?php if ( isset($settings['bu_capitalization']) ) checked( '4', $settings['bu_capitalization'] ); ?>/>
|
675 |
+
<span><?php esc_attr_e( 'Use sentence casing. First letter of a sentence will be capitalized.', 'abl_iaff_td' ); ?></span>
|
676 |
+
</label><br>
|
677 |
+
|
678 |
+
</fieldset>
|
679 |
+
|
680 |
+
<?php
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Bulk Updater Image Title Settings Callback
|
685 |
+
*
|
686 |
+
* @since 1.4
|
687 |
+
*/
|
688 |
+
function iaff_bu_image_title_settings_callback() {
|
689 |
+
|
690 |
+
// Get Settings
|
691 |
+
$settings = iaff_get_settings();
|
692 |
+
?>
|
693 |
+
|
694 |
+
<fieldset>
|
695 |
+
|
696 |
+
<label>
|
697 |
+
<input type="radio" name="iaff_settings[bu_title_source]" value="0" <?php if ( isset($settings['bu_title_source']) ) checked( '0', $settings['bu_title_source'] ); ?>/>
|
698 |
+
<span><?php esc_attr_e( 'Use image filename as title text', 'abl_iaff_td' ); ?></span>
|
699 |
+
</label><br>
|
700 |
+
|
701 |
+
<label>
|
702 |
+
<input type="radio" name="iaff_settings[bu_title_source]" value="1" <?php if ( isset($settings['bu_title_source']) ) checked( '1', $settings['bu_title_source'] ); ?>/>
|
703 |
+
<span><?php esc_attr_e( 'Use post title as title text. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
704 |
+
</label><br>
|
705 |
+
|
706 |
+
<h4>Bulk Updater Behaviour</h4>
|
707 |
+
|
708 |
+
<label>
|
709 |
+
<input type="radio" name="iaff_settings[bu_titles_in_post]" value="0" <?php if ( isset($settings['bu_titles_in_post']) ) checked( '0', $settings['bu_titles_in_post'] ); ?>/>
|
710 |
+
<span><?php esc_attr_e( 'Update image titles in media library only. Image titles in existing posts will be left unchanged.', 'abl_iaff_td' ); ?></span>
|
711 |
+
</label><br>
|
712 |
+
|
713 |
+
<label>
|
714 |
+
<input type="radio" name="iaff_settings[bu_titles_in_post]" value="1" <?php if ( isset($settings['bu_titles_in_post']) ) checked( '1', $settings['bu_titles_in_post'] ); ?>/>
|
715 |
+
<span><?php esc_attr_e( 'Update image titles in media library and existing posts.', 'abl_iaff_td' ); ?></span>
|
716 |
+
</label><br>
|
717 |
+
|
718 |
+
<label>
|
719 |
+
<input type="radio" name="iaff_settings[bu_titles_in_post]" value="2" <?php if ( isset($settings['bu_titles_in_post']) ) checked( '2', $settings['bu_titles_in_post'] ); ?>/>
|
720 |
+
<span><?php esc_attr_e( 'Update image titles in existing posts only if no title is set. All image titles in media library will be updated.', 'abl_iaff_td' ); ?></span>
|
721 |
+
</label><br>
|
722 |
+
|
723 |
+
</fieldset>
|
724 |
+
|
725 |
+
<?php
|
726 |
+
}
|
727 |
+
|
728 |
+
/**
|
729 |
+
* Bulk Updater Image Alt Text Settings Callback
|
730 |
+
*
|
731 |
+
* @since 1.4
|
732 |
+
*/
|
733 |
+
function iaff_bu_alt_text_settings_callback() {
|
734 |
+
|
735 |
+
// Get Settings
|
736 |
+
$settings = iaff_get_settings();
|
737 |
+
?>
|
738 |
+
|
739 |
+
<fieldset>
|
740 |
+
|
741 |
+
<label>
|
742 |
+
<input type="radio" name="iaff_settings[bu_alt_text_source]" value="0" <?php if ( isset($settings['bu_alt_text_source']) ) checked( '0', $settings['bu_alt_text_source'] ); ?>/>
|
743 |
+
<span><?php esc_attr_e( 'Use filename as alt text.', 'abl_iaff_td' ); ?></span>
|
744 |
+
</label><br>
|
745 |
+
|
746 |
+
<label>
|
747 |
+
<input type="radio" name="iaff_settings[bu_alt_text_source]" value="1" <?php if ( isset($settings['bu_alt_text_source']) ) checked( '1', $settings['bu_alt_text_source'] ); ?>/>
|
748 |
+
<span><?php esc_attr_e( 'Use post title as alt text. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
749 |
+
</label><br>
|
750 |
+
|
751 |
+
<h4>Bulk Updater Behaviour</h4>
|
752 |
+
|
753 |
+
<label>
|
754 |
+
<input type="radio" name="iaff_settings[bu_alt_text_in_post]" value="0" <?php if ( isset($settings['bu_alt_text_in_post']) ) checked( '0', $settings['bu_alt_text_in_post'] ); ?>/>
|
755 |
+
<span><?php esc_attr_e( 'Update alt text in media library only. Alt text in existing posts will be left unchanged.', 'abl_iaff_td' ); ?></span>
|
756 |
+
</label><br>
|
757 |
+
|
758 |
+
<label>
|
759 |
+
<input type="radio" name="iaff_settings[bu_alt_text_in_post]" value="1" <?php if ( isset($settings['bu_alt_text_in_post']) ) checked( '1', $settings['bu_alt_text_in_post'] ); ?>/>
|
760 |
+
<span><?php esc_attr_e( 'Update alt text in media library and existing posts.', 'abl_iaff_td' ); ?></span>
|
761 |
+
</label><br>
|
762 |
+
|
763 |
+
<label>
|
764 |
+
<input type="radio" name="iaff_settings[bu_alt_text_in_post]" value="2" <?php if ( isset($settings['bu_alt_text_in_post']) ) checked( '2', $settings['bu_alt_text_in_post'] ); ?>/>
|
765 |
+
<span><?php esc_attr_e( 'Update alt text in existing posts only if no alt text is set. All alt text in media library will be updated.', 'abl_iaff_td' ); ?></span>
|
766 |
+
</label><br>
|
767 |
+
|
768 |
+
</fieldset>
|
769 |
+
|
770 |
+
<?php
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Bulk Updater Image Caption Settings Callback
|
775 |
+
*
|
776 |
+
* @since 1.4
|
777 |
+
*/
|
778 |
+
function iaff_bu_image_caption_settings_callback() {
|
779 |
+
|
780 |
+
// Get Settings
|
781 |
+
$settings = iaff_get_settings();
|
782 |
+
?>
|
783 |
+
|
784 |
+
<fieldset>
|
785 |
+
|
786 |
+
<label>
|
787 |
+
<input type="radio" name="iaff_settings[bu_caption_source]" value="0" <?php if ( isset($settings['bu_caption_source']) ) checked( '0', $settings['bu_caption_source'] ); ?>/>
|
788 |
+
<span><?php esc_attr_e( 'Use image filename as caption', 'abl_iaff_td' ); ?></span>
|
789 |
+
</label><br>
|
790 |
+
|
791 |
+
<label>
|
792 |
+
<input type="radio" name="iaff_settings[bu_caption_source]" value="1" <?php if ( isset($settings['bu_caption_source']) ) checked( '1', $settings['bu_caption_source'] ); ?>/>
|
793 |
+
<span><?php esc_attr_e( 'Use post title as caption. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
794 |
+
</label><br>
|
795 |
+
|
796 |
+
</fieldset>
|
797 |
+
|
798 |
+
<?php
|
799 |
+
}
|
800 |
+
|
801 |
+
/**
|
802 |
+
* Bulk Updater Image Description Settings Callback
|
803 |
+
*
|
804 |
+
* @since 1.4
|
805 |
+
*/
|
806 |
+
function iaff_bu_image_description_settings_callback() {
|
807 |
+
|
808 |
+
// Get Settings
|
809 |
+
$settings = iaff_get_settings();
|
810 |
+
?>
|
811 |
+
|
812 |
+
<fieldset>
|
813 |
+
|
814 |
+
<label>
|
815 |
+
<input type="radio" name="iaff_settings[bu_description_source]" value="0" <?php if ( isset($settings['bu_description_source']) ) checked( '0', $settings['bu_description_source'] ); ?>/>
|
816 |
+
<span><?php esc_attr_e( 'Use image filename as description', 'abl_iaff_td' ); ?></span>
|
817 |
+
</label><br>
|
818 |
+
|
819 |
+
<label>
|
820 |
+
<input type="radio" name="iaff_settings[bu_description_source]" value="1" <?php if ( isset($settings['bu_description_source']) ) checked( '1', $settings['bu_description_source'] ); ?>/>
|
821 |
+
<span><?php esc_attr_e( 'Use post title as description. If image is not attached to a post, image filename will be used instead.', 'abl_iaff_td' ); ?></span>
|
822 |
+
</label><br>
|
823 |
+
|
824 |
+
</fieldset>
|
825 |
+
|
826 |
+
<?php
|
827 |
+
}
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Admin interface renderer
|
831 |
+
*
|
832 |
+
* @since 1.0
|
833 |
+
*/
|
834 |
+
function iaff_admin_interface_render () {
|
835 |
+
|
836 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
837 |
+
return;
|
838 |
+
}
|
839 |
+
|
840 |
+
// Get Settings
|
841 |
+
$settings = iaff_get_settings();
|
842 |
+
?>
|
843 |
+
|
844 |
+
<div id="iaff-pro" class="wrap">
|
845 |
+
|
846 |
+
<h1>
|
847 |
+
<?php
|
848 |
+
if( iaff_is_pro() ) {
|
849 |
+
echo 'Image Attributes Pro <sup>'. IAFFPRO_VERSION_NUM .'</sup>';
|
850 |
+
} else {
|
851 |
+
echo 'Auto Image Attributes From Filename With Bulk Updater';
|
852 |
+
} ?>
|
853 |
+
</h1>
|
854 |
+
|
855 |
+
<div class="iaff-admin-options <?php if( ! iaff_is_pro() ) echo 'iaff-columns-2'; ?>">
|
856 |
+
|
857 |
+
<div class="iaff-admin-options-main">
|
858 |
+
<h2 class="nav-tab-wrapper hide-if-no-js showh2">
|
859 |
+
<a class="nav-tab" href="#iaff-basic"><?php _e('Basic', 'abl_iaff_td') ?></a>
|
860 |
+
<?php if ( (isset( $settings['preview_pro'] ) && boolval($settings['preview_pro'])) || iaff_is_pro() ) { ?>
|
861 |
+
<a class="nav-tab" href="#iaff-advanced"><?php _e('Advanced', 'abl_iaff_td') ?></a>
|
862 |
+
<a class="nav-tab" href="#iaff-bulk-updater-settings"><?php _e('Bulk Updater Settings', 'abl_iaff_td') ?></a>
|
863 |
+
<?php } ?>
|
864 |
+
<a class="nav-tab" href="#iaff-bulk-updater"><?php _e('Bulk Updater', 'abl_iaff_td') ?></a>
|
865 |
+
<a class="nav-tab" href="#iaff-support" id="iaff-support-tab"><?php _e('Support', 'abl_iaff_td') ?></a>
|
866 |
+
</h2>
|
867 |
|
868 |
+
<form id="iaff-settings" action="options.php" method="post" enctype="multipart/form-data">
|
869 |
+
|
870 |
+
<!-- Output nonce, action, and option_page fields for a settings page. -->
|
871 |
+
<?php settings_fields( 'iaff_settings_group' ); ?>
|
872 |
+
|
873 |
+
<!-- Basic Settings -->
|
874 |
+
<div id="iaff-basic" class="iaff-settings-tab">
|
875 |
+
<h2 class="showh2"><?php _e('Basic Settings', 'abl_iaff_td') ?></h2>
|
876 |
+
<p><?php _e('Automatically add Image attributes such as Image Title, Image Caption, Description And Alt Text from Image Filename for new uploads', 'abl_iaff_td') ?></p>
|
877 |
+
<?php do_settings_sections( 'iaff_basic_settings_section' ); ?>
|
878 |
+
<?php submit_button( __('Save Settings', 'abl_iaff_td') ); ?>
|
879 |
+
</div>
|
880 |
+
|
881 |
+
<!-- Advanced Settings -->
|
882 |
+
<div id="iaff-advanced" class="iaff-settings-tab">
|
883 |
+
|
884 |
+
<?php if( ! iaff_is_pro() ) { ?>
|
885 |
+
<div class="updated inline" style="margin-top: 20px;">
|
886 |
+
<p><strong><?php _e('This is a preview of the features included in Image Attributes Pro.', 'abl_iaff_td') ?></strong></p>
|
887 |
+
</div>
|
888 |
+
<?php } ?>
|
889 |
+
|
890 |
+
<h2 class="showh2"><?php _e('Advanced Settings', 'abl_iaff_td') ?></h2>
|
891 |
+
<p><?php _e('Advanced settings for new uploads.', 'abl_iaff_td') ?></p>
|
892 |
+
<?php do_settings_sections( 'iaff_advanced_settings_section' ); ?>
|
893 |
+
<?php if( iaff_is_pro() ) submit_button( __('Save Settings', 'abl_iaff_td') ); ?>
|
894 |
+
</div>
|
895 |
+
|
896 |
+
<!-- Bulk Updater Settings -->
|
897 |
+
<div id="iaff-bulk-updater-settings" class="iaff-settings-tab">
|
898 |
|
899 |
+
<?php if( ! iaff_is_pro() ) { ?>
|
900 |
+
<div class="updated inline" style="margin-top: 20px;">
|
901 |
+
<p><strong><?php _e('This is a preview of the features included in Image Attributes Pro.', 'abl_iaff_td') ?></strong></p>
|
902 |
+
</div>
|
903 |
+
<?php } ?>
|
904 |
|
905 |
+
<h2 class="showh2"><?php _e('Bulk Updater Settings', 'abl_iaff_td') ?></h2>
|
906 |
+
<p><?php _e('Options set here will be used while running the Bulk Updater.', 'abl_iaff_td') ?></p>
|
907 |
+
<?php do_settings_sections( 'iaff_bu_settings_section' ); ?>
|
908 |
+
<?php if( iaff_is_pro() ) submit_button( __('Save Settings', 'abl_iaff_td') ); ?>
|
909 |
</div>
|
910 |
+
|
911 |
+
</form>
|
912 |
+
|
913 |
+
<!-- Bulk Updater -->
|
914 |
+
<div id="iaff-bulk-updater" class="iaff-settings-tab">
|
915 |
+
|
916 |
+
<h2 class="showh2"><?php _e('Bulk Updater', 'abl_iaff_td') ?></h2>
|
917 |
+
|
918 |
+
<p><?php _e('Run this bulk updater to update Image Title, Caption, Description and Alt Text for all images.', 'abl_iaff_td') ?></p>
|
919 |
+
|
920 |
+
<div class="error inline">
|
921 |
+
<p class="hide-if-js"><strong><?php _e('It seems that JavasScript is disabled in your browser. Please enable JavasScript or use a different browser to use the bulk updater.', 'abl_iaff_td') ?></strong></p>
|
922 |
+
<p><strong><?php _e('IMPORTANT: Please backup your database before running the bulk updater.', 'abl_iaff_td') ?></strong></p>
|
923 |
+
<?php if( ! iaff_is_pro() ) { ?>
|
924 |
+
<p><strong><?php printf( __( 'If your image is named <em>a-lot-like_love.jpg</em>, your Image Title, Caption, Description and Alt Text will be: <em>a lot like love</em>. <a href="%s" target="_blank">Upgrade to Pro</a> for more options.', 'abl_iaff_td' ), 'https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=bulk-updater-notice' ); ?></strong></p>
|
925 |
+
<?php } ?>
|
926 |
+
</div>
|
927 |
+
|
928 |
+
<p class="submit">
|
929 |
+
<input class="button-primary iaff-bulk-updater-buttons iaff_run_bulk_updater_button" type="submit" name="Run Bulk Updater" value="<?php esc_attr_e( 'Run Bulk Updater' ); ?>" />
|
930 |
+
|
931 |
+
<input class="button-secondary iaff-bulk-updater-buttons iaff_test_bulk_updater_button" type="submit" name="Test Bulk Updater" value="<?php esc_attr_e( 'Test Bulk Updater' ); ?>" />
|
932 |
+
|
933 |
+
<input class="button-secondary iaff-bulk-updater-buttons iaff_stop_bulk_updater_button" type="submit" name="Run Bulk Updater" value="<?php esc_attr_e( 'Stop Bulk Updater' ); ?>" disabled />
|
934 |
+
</p>
|
935 |
+
|
936 |
+
<h2 class="showh2"><?php _e('Reset Counter', 'abl_iaff_td') ?></h2>
|
937 |
+
|
938 |
+
<p><?php _e('To restart processing images from the beginning (the oldest upload first), reset the counter.', 'abl_iaff_td') ?></p>
|
939 |
+
|
940 |
+
<span class="reset-counter-button">
|
941 |
+
<?php submit_button( __('Reset Counter', 'abl_iaff_td'), 'iaff_reset_counter_button' ); ?>
|
942 |
+
</span>
|
943 |
+
|
944 |
+
<!-- Event log -->
|
945 |
+
<div id="bulk-updater-results">
|
946 |
+
<fieldset id="bulk-updater-log-wrapper">
|
947 |
+
<legend><span class="dashicons dashicons-welcome-write-blog"></span> <strong>Event Log</strong> <div class="iaff-spinner is-active" style="margin-top:0px;"></div></legend>
|
948 |
+
|
949 |
+
<div id="bulk-updater-log">
|
950 |
+
<p id="iaff_remaining_images_text"><?php _e('Number of Images Remaining: ', 'abl_iaff_td') ?><?php echo iaff_count_remaining_images(); ?></p>
|
951 |
+
|
952 |
+
<p><?php _e('Number of Images Updated: ', 'abl_iaff_td') ?><?php echo iaff_number_of_images_updated(); ?></p>
|
953 |
+
</div>
|
954 |
+
</fieldset>
|
955 |
+
</div>
|
956 |
+
|
957 |
+
<!-- Dialogs -->
|
958 |
+
<div class="hidden-dialogs" style="display:none;">
|
959 |
+
|
960 |
+
<!-- Run Bulk Updater Confirmation Dialog -->
|
961 |
+
<div id="iaff-confirm-run-dialog" title="Run Bulk Updater">
|
962 |
+
<p>You are about to run the bulk updater. This will update all images and cannot be undone. Please make a database backup before you proceed. Press OK to confirm.</p>
|
963 |
+
</div>
|
964 |
+
|
965 |
+
<!-- Test Bulk Updater Dialog -->
|
966 |
+
<div id="iaff-test-run-dialog" title="Test Bulk Updater">
|
967 |
+
<p>The bulk updater will do a test run by updating one image. Note that this is a live test and actual values will be updated in the database. Please make a database backup before you proceed. Press Ok to confirm.</p>
|
968 |
+
</div>
|
969 |
+
|
970 |
+
<!-- Bulk Updater Reset Counter Dialog -->
|
971 |
+
<div id="iaff-reset-counter-dialog" title="Reset Counter">
|
972 |
+
<p>You are about to reset the bulk updater counter. The bulk updater will start from scratch in the next run. Press Ok to confirm.</p>
|
973 |
+
</div>
|
974 |
+
|
975 |
+
</div>
|
976 |
+
|
977 |
+
</div><!-- Bulk Updater ends -->
|
978 |
|
979 |
+
<!-- Support Tab -->
|
980 |
+
<div id="iaff-support" class="iaff-settings-tab">
|
981 |
+
|
982 |
+
<h2 class="showh2"><?php _e('Support And Documentation', 'abl_iaff_td') ?></h2>
|
983 |
+
|
984 |
+
<p><?php _e('Looking for help? Here are the available options.', 'abl_iaff_td') ?></p>
|
985 |
+
|
986 |
+
<!-- Free Support -->
|
987 |
+
<div class="iaff-support-block">
|
988 |
+
<div class="iaff-support-block-inner">
|
989 |
+
<h2 class="patua showh2">Free Support</h2>
|
990 |
+
<ul>
|
991 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://imageattributespro.com/docs?utm_source=iaff-basic&utm_medium=support-tab">Documentation</a></li>
|
992 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://wordpress.org/plugins/auto-image-attributes-from-filename-with-bulk-updater/">Read the FAQ</a></li>
|
993 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://wordpress.org/support/plugin/auto-image-attributes-from-filename-with-bulk-updater">Free Support Forum</a></li>
|
994 |
+
</ul>
|
995 |
+
</div>
|
996 |
+
</div><!-- .iaff-support-block -->
|
997 |
+
|
998 |
+
<!-- Premium Support -->
|
999 |
+
<?php if ( iaff_is_pro() ) { ?>
|
1000 |
+
<div class="iaff-support-block">
|
1001 |
+
<div class="iaff-support-block-inner">
|
1002 |
+
<h2 class="patua showh2">Premium Support</h2>
|
1003 |
+
<ul>
|
1004 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://imageattributespro.com/docs?utm_source=iap&utm_medium=support-tab">Documentation</a></li>
|
1005 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://millionclues.net/?utm_source=iap&utm_medium=support-tab">Priority Support Forum</a></li>
|
1006 |
+
<li><span class="dashicons dashicons-yes"></span><a target="_blank" href="https://imageattributespro.com/contact/?utm_source=iap&utm_medium=support-tab">Contact Support</a></li>
|
1007 |
+
|
1008 |
+
</ul>
|
1009 |
+
</div>
|
1010 |
+
</div><!-- .iaff-support-block -->
|
1011 |
+
<?php } ?>
|
1012 |
+
|
1013 |
+
<!-- Upgrade for Premium Support -->
|
1014 |
+
<?php if ( ! iaff_is_pro() ) { ?>
|
1015 |
+
<div class="iaff-support-block">
|
1016 |
+
<div class="iaff-support-block-inner">
|
1017 |
+
<a target="_blank" href="https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=support-tab">
|
1018 |
+
<h2 class="patua showh2">Upgrade to Pro</h2>
|
1019 |
+
<ul>
|
1020 |
+
<li><span class="dashicons dashicons-yes"></span>Priority support</li>
|
1021 |
+
<li><span class="dashicons dashicons-yes"></span>Advanced features</li>
|
1022 |
+
<li><span class="dashicons dashicons-yes"></span>Support ongoing development</li>
|
1023 |
+
</ul>
|
1024 |
+
</a>
|
1025 |
+
</div>
|
1026 |
+
</div><!-- .iaff-support-block -->
|
1027 |
+
<?php } ?>
|
1028 |
+
|
1029 |
+
</div>
|
1030 |
+
</div><!-- .iaff-admin-options-main -->
|
1031 |
|
1032 |
+
<!-- Upgrade to pro sidebar -->
|
1033 |
+
<?php if ( ! iaff_is_pro() ) { ?>
|
1034 |
+
<div class="iaff-admin-options-sidebar">
|
1035 |
+
|
1036 |
+
<div class="iaff-upgrade-header">
|
1037 |
+
<a href="https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=coupon-sidebar" target="_blank">
|
1038 |
+
<div class="iaff-icon"></div>
|
1039 |
+
<h1 class="patua">Upgrade to Pro</h1>
|
1040 |
+
<ul>
|
1041 |
+
<li><span class="dashicons dashicons-yes"></span>Advanced formatting options</li>
|
1042 |
+
<li><span class="dashicons dashicons-yes"></span>Use post titles as attributes</li>
|
1043 |
+
<li><span class="dashicons dashicons-yes"></span>Fine tune bulk updater settings</li>
|
1044 |
+
</ul>
|
1045 |
+
</a>
|
1046 |
+
</div><!-- .iaff-upgrade-header -->
|
1047 |
+
|
1048 |
+
<div class="iaff-upgrade-form">
|
1049 |
+
|
1050 |
+
<form method="post" action="https://imageattributespro.com/coupons/" target="_blank">
|
1051 |
+
|
1052 |
+
<h1 class="patua">20% Coupon</h1>
|
1053 |
+
|
1054 |
+
<?php $user = wp_get_current_user(); ?>
|
1055 |
+
|
1056 |
+
<p>Submit your name and email to receive 20% off when you upgrade to the pro version.</p>
|
1057 |
+
|
1058 |
+
<fieldset>
|
1059 |
+
|
1060 |
+
<input type="text" name="first_name" value="<?php echo esc_attr( trim( $user->first_name ) ); ?>" placeholder="First Name"/>
|
1061 |
+
|
1062 |
+
<input type="email" name="email" value="<?php echo esc_attr( $user->user_email ); ?>" placeholder="Your Email"/>
|
1063 |
+
|
1064 |
+
<input type="hidden" name="source" value="IAFF" />
|
1065 |
+
<input type="hidden" name="submitted" id="submitted" value="true" />
|
1066 |
+
|
1067 |
+
<input type="submit" class="button" value="Send me the coupon"/>
|
1068 |
+
|
1069 |
+
</fieldset>
|
1070 |
+
|
1071 |
+
<p class="opacity-75">Your email will be kept private and will not be shared or spammed.</p>
|
1072 |
+
</form>
|
1073 |
+
|
1074 |
+
<hr>
|
1075 |
+
|
1076 |
+
<div class="iaff-upgrade-review">
|
1077 |
+
<div class="iaff-upgrade-review-stars">
|
1078 |
+
<h3>"Fast & Simple Time Saver"</h3>
|
1079 |
+
<?php echo str_repeat('<span class="dashicons dashicons-star-filled"></span>', 5); ?>
|
1080 |
+
</div>
|
1081 |
+
<div class="iaff-upgrade-review-detail">
|
1082 |
+
<div class="iaff-upgrade-review-detail-left">
|
1083 |
+
<img class="iaff-upgrade-review-avatar" src="<?php echo IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_URL . 'admin/img/checkerboardflyer.jpeg'; ?>" />
|
1084 |
+
</div>
|
1085 |
+
<div class="iaff-upgrade-review-detail-right">
|
1086 |
+
<p>"This plugin will save me a LOT of time! Great plugin!" <br><a target="_blank" href="https://wordpress.org/support/topic/fast-simple-time-saver/">@checkerboardflyer</a></p>
|
1087 |
+
</div>
|
1088 |
+
</div>
|
1089 |
+
</div>
|
1090 |
+
</div><!-- .iaff-upgrade-form -->
|
1091 |
+
</div><!-- .iaff-admin-options-sidebar -->
|
1092 |
+
<?php } ?>
|
1093 |
+
|
1094 |
+
</div><!-- .iaff-admin-options -->
|
1095 |
+
</div><!-- #iaff-pro .wrap -->
|
1096 |
<?php
|
1097 |
+
}
|
|
|
|
admin/iaff_image-attributes-from-filename-basic-setup.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
|
14 |
|
15 |
// Exit if accessed directly
|
16 |
-
if ( !defined('ABSPATH') ) exit;
|
17 |
|
18 |
|
19 |
/**
|
@@ -33,7 +33,7 @@ function iaff_activate_plugin() {
|
|
33 |
* @since 1.0
|
34 |
*/
|
35 |
function iaff_load_plugin_textdomain() {
|
36 |
-
load_plugin_textdomain( 'abl_iaff_td', FALSE,
|
37 |
}
|
38 |
add_action( 'plugins_loaded', 'iaff_load_plugin_textdomain' );
|
39 |
|
@@ -51,7 +51,7 @@ function iaff_settings_link( $links ) {
|
|
51 |
$links
|
52 |
);
|
53 |
}
|
54 |
-
add_filter( 'plugin_action_links_' .
|
55 |
|
56 |
|
57 |
/**
|
@@ -60,13 +60,18 @@ add_filter( 'plugin_action_links_' . IAFF_STARTER_PLUGIN . '/iaff_image-attribut
|
|
60 |
* @since 1.0
|
61 |
*/
|
62 |
function iaff_plugin_row_meta( $links, $file ) {
|
|
|
|
|
|
|
|
|
|
|
63 |
if ( strpos( $file, 'iaff_image-attributes-from-filename.php' ) !== false ) {
|
64 |
$new_links = array(
|
65 |
-
'
|
66 |
-
'hireme' => '<a href="http://millionclues.com/portfolio/" target="_blank">Hire Me For A Project</a>',
|
67 |
);
|
68 |
$links = array_merge( $links, $new_links );
|
69 |
}
|
|
|
70 |
return $links;
|
71 |
}
|
72 |
add_filter( 'plugin_row_meta', 'iaff_plugin_row_meta', 10, 2 );
|
@@ -88,10 +93,14 @@ function iaff_footer_text($default) {
|
|
88 |
return $default;
|
89 |
}
|
90 |
|
91 |
-
$iaff_footer_text = sprintf( __( 'If you like this plugin, please <a href="%s" target="_blank">
|
92 |
-
'
|
93 |
'https://wordpress.org/support/plugin/auto-image-attributes-from-filename-with-bulk-updater/reviews/?rate=5#new-post'
|
94 |
);
|
|
|
|
|
|
|
|
|
95 |
|
96 |
return $iaff_footer_text;
|
97 |
}
|
@@ -112,6 +121,4 @@ function iaff_footer_version($default) {
|
|
112 |
|
113 |
return 'Plugin version ' . IAFF_VERSION_NUM;
|
114 |
}
|
115 |
-
add_filter( 'update_footer', 'iaff_footer_version', 11 );
|
116 |
-
|
117 |
-
?>
|
13 |
|
14 |
|
15 |
// Exit if accessed directly
|
16 |
+
if ( ! defined('ABSPATH') ) exit;
|
17 |
|
18 |
|
19 |
/**
|
33 |
* @since 1.0
|
34 |
*/
|
35 |
function iaff_load_plugin_textdomain() {
|
36 |
+
load_plugin_textdomain( 'abl_iaff_td', FALSE, IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/languages/' );
|
37 |
}
|
38 |
add_action( 'plugins_loaded', 'iaff_load_plugin_textdomain' );
|
39 |
|
51 |
$links
|
52 |
);
|
53 |
}
|
54 |
+
add_filter( 'plugin_action_links_' . IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME . '/iaff_image-attributes-from-filename.php', 'iaff_settings_link' );
|
55 |
|
56 |
|
57 |
/**
|
60 |
* @since 1.0
|
61 |
*/
|
62 |
function iaff_plugin_row_meta( $links, $file ) {
|
63 |
+
|
64 |
+
if ( iaff_is_pro() ) {
|
65 |
+
return $links;
|
66 |
+
}
|
67 |
+
|
68 |
if ( strpos( $file, 'iaff_image-attributes-from-filename.php' ) !== false ) {
|
69 |
$new_links = array(
|
70 |
+
'upgrade' => '<a href="https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=plugins-list" target="_blank">Upgrade To Image Attributes Pro</a>',
|
|
|
71 |
);
|
72 |
$links = array_merge( $links, $new_links );
|
73 |
}
|
74 |
+
|
75 |
return $links;
|
76 |
}
|
77 |
add_filter( 'plugin_row_meta', 'iaff_plugin_row_meta', 10, 2 );
|
93 |
return $default;
|
94 |
}
|
95 |
|
96 |
+
$iaff_footer_text = sprintf( __( 'If you like this plugin, please <a href="%s" target="_blank">upgrade to pro</a> or leave a <a href="%s" target="_blank">★★★★★</a> rating to support continued development. Thanks a bunch!', 'abl_iaff_td' ),
|
97 |
+
'https://imageattributespro.com/?utm_source=iaff-basic&utm_medium=footer',
|
98 |
'https://wordpress.org/support/plugin/auto-image-attributes-from-filename-with-bulk-updater/reviews/?rate=5#new-post'
|
99 |
);
|
100 |
+
|
101 |
+
if( iaff_is_pro() ) {
|
102 |
+
$iaff_footer_text = __( 'Thank you for choosing Image Attributes Pro! Use the support tab if you have any questions or feedback.', 'abl_iaff_td' );
|
103 |
+
}
|
104 |
|
105 |
return $iaff_footer_text;
|
106 |
}
|
121 |
|
122 |
return 'Plugin version ' . IAFF_VERSION_NUM;
|
123 |
}
|
124 |
+
add_filter( 'update_footer', 'iaff_footer_version', 11 );
|
|
|
|
admin/iaff_image-attributes-from-filename-do.php
CHANGED
@@ -9,87 +9,58 @@
|
|
9 |
* @function iaff_total_number_of_images() Count total number of images in the database
|
10 |
* @function iaff_count_remaining_images() Count remaining number of images to process
|
11 |
* @function iaff_reset_bulk_updater_counter() Reset counter to zero so that bulk updating starts from scratch
|
|
|
|
|
12 |
* @function iaff_image_bulk_updater() Bulk Updater Ajax
|
13 |
* @function iaff_lcb_restore_image_title() Insert Image Title Into Post HTML
|
14 |
-
* @function
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
|
17 |
-
|
18 |
// Exit if accessed directly
|
19 |
-
if ( !defined('ABSPATH') ) exit;
|
20 |
-
|
21 |
|
22 |
/**
|
23 |
* Auto add image attributes from image filename for new uploads
|
24 |
*
|
25 |
* @since 1.0
|
26 |
*/
|
27 |
-
function iaff_auto_image_attributes( $
|
28 |
-
|
29 |
-
// Default Values For Settings
|
30 |
-
global $defaults;
|
31 |
|
32 |
// Get Settings
|
33 |
-
$settings =
|
34 |
-
|
35 |
-
$attachment = get_post( $post_ID );
|
36 |
|
37 |
-
//
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
$filter_chars = array();
|
42 |
-
|
43 |
-
if ( isset( $settings['hyphens'] ) && boolval($settings['hyphens']) ) {
|
44 |
-
$filter_chars[] = '-'; // Hypen
|
45 |
-
}
|
46 |
-
if ( isset( $settings['under_score'] ) && boolval($settings['under_score']) ) {
|
47 |
-
$filter_chars[] = '_'; // Underscore
|
48 |
-
}
|
49 |
-
if ( isset( $settings['full_stop'] ) && boolval($settings['full_stop']) ) {
|
50 |
-
$filter_chars[] = '.'; // Full stops
|
51 |
-
}
|
52 |
-
if ( isset( $settings['commas'] ) && boolval($settings['commas']) ) {
|
53 |
-
$filter_chars[] = '-_-'; // WordPress removes commas during file upload. iaff_upload_comma_prefilter() replaces commas with -_- so that we can process commas here.
|
54 |
-
}
|
55 |
-
|
56 |
-
// Remove characters
|
57 |
-
if ( !empty($filter_chars) ) {
|
58 |
-
$attachment_title = str_replace( $filter_chars, ' ', $attachment_title );
|
59 |
-
}
|
60 |
-
|
61 |
-
// Remove all numbers
|
62 |
-
if ( isset( $settings['all_numbers'] ) && boolval($settings['all_numbers']) ) {
|
63 |
-
$attachment_title = preg_replace('/[0-9]+/', '', $attachment_title);
|
64 |
-
}
|
65 |
|
66 |
-
//
|
67 |
-
|
68 |
-
|
69 |
-
$attachment_title = ucwords( $attachment_title ); // Capitalize First Word
|
70 |
|
71 |
-
|
72 |
-
$
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
}
|
86 |
-
|
87 |
-
wp_update_post( $uploaded_image );
|
88 |
-
|
89 |
}
|
90 |
add_action( 'add_attachment', 'iaff_auto_image_attributes' );
|
91 |
|
92 |
-
|
93 |
/**
|
94 |
* Auto add image attributes from image filename for existing uploads
|
95 |
*
|
@@ -105,40 +76,39 @@ function iaff_rename_old_image() {
|
|
105 |
$counter = intval ($counter);
|
106 |
|
107 |
global $wpdb;
|
108 |
-
$image = $wpdb->get_row("SELECT ID,
|
109 |
|
110 |
-
// Die
|
111 |
if ($image === NULL) {
|
112 |
wp_die();
|
113 |
}
|
114 |
|
115 |
-
//
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
'post_content' => $image_name, // Image Description
|
130 |
-
);
|
131 |
-
wp_update_post( $updated_image );
|
132 |
-
|
133 |
-
// Update Image Alt Text (stored in post_meta table)
|
134 |
-
update_post_meta( $image->ID, '_wp_attachment_image_alt', $image_name ); // Image Alt Text
|
135 |
|
136 |
-
// Increment
|
137 |
$counter++;
|
138 |
update_option( 'iaff_bulk_updater_counter', $counter );
|
139 |
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
add_action( 'wp_ajax_iaff_rename_old_image', 'iaff_rename_old_image' );
|
144 |
|
@@ -163,7 +133,7 @@ function iaff_number_of_images_updated() {
|
|
163 |
function iaff_total_number_of_images() {
|
164 |
|
165 |
global $wpdb;
|
166 |
-
$total_no_of_images = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->prefix}posts WHERE post_type='attachment'");
|
167 |
|
168 |
return $total_no_of_images;
|
169 |
}
|
@@ -182,7 +152,7 @@ function iaff_count_remaining_images( $force_return = false ) {
|
|
182 |
$no_of_images_processed = get_option('iaff_bulk_updater_counter');
|
183 |
$no_of_images_processed = intval ($no_of_images_processed);
|
184 |
|
185 |
-
$reamining_images = $total_no_of_images - $no_of_images_processed;
|
186 |
|
187 |
// If called from Ajax echo the result. Else return as an integer.
|
188 |
// :TODO: Calling iaff_count_remaining_images() from Ajax for ignores the default value of $force_return for some reason. When I set if ( wp_doing_ajax() && $force_return === false ) this does not work even though they are logically equivalent. If you know why it is so, please email me - arunbasillal@gmail.com
|
@@ -216,6 +186,33 @@ function iaff_reset_bulk_updater_counter() {
|
|
216 |
}
|
217 |
add_action( 'wp_ajax_iaff_reset_bulk_updater_counter', 'iaff_reset_bulk_updater_counter' );
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
/**
|
221 |
* Bulk Updater Ajax
|
@@ -231,75 +228,179 @@ function iaff_image_bulk_updater() {
|
|
231 |
}?>
|
232 |
|
233 |
<script type="text/javascript" >
|
234 |
-
jQuery(document).ready(function($) {
|
235 |
-
// Reset Bulk Updater Counter
|
236 |
-
$('.iaff_reset_counter_button').click(function() {
|
237 |
-
data = {
|
238 |
-
action: 'iaff_reset_bulk_updater_counter',
|
239 |
-
security: '<?php echo wp_create_nonce( "iaff_reset_counter_nonce" ); ?>'
|
240 |
-
};
|
241 |
-
|
242 |
-
$.post(ajaxurl, data, function (response) {
|
243 |
-
$('#bulk-updater-log').append('<p>Number of Images Remaining: ' + response.remaining_images + '</p>');
|
244 |
-
$('#bulk-updater-log').append('<p>Number of Images Updated: 0</p>');
|
245 |
-
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
246 |
-
alert(response.message);
|
247 |
-
});
|
248 |
-
});
|
249 |
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
// Notice to the user
|
261 |
-
$('#bulk-updater-log').append('<p class="iaff-green">Initializing bulk updater.
|
262 |
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
263 |
|
264 |
// Count Remaining Images To Process
|
265 |
data = {
|
266 |
action: 'iaff_count_remaining_images',
|
267 |
-
};
|
268 |
-
|
269 |
-
var remaining_images = null;
|
270 |
-
|
271 |
var reamining_images_count = $.post(ajaxurl, data, function (response) {
|
272 |
remaining_images = response;
|
273 |
console.log(remaining_images);
|
274 |
});
|
275 |
|
276 |
-
//
|
277 |
-
reamining_images_count.done(function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
$(
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
rename_image.done(function() {
|
293 |
-
remaining_images--;
|
294 |
-
iaff_rename_image();
|
295 |
-
});
|
296 |
}
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
301 |
});
|
|
|
302 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
});
|
304 |
</script> <?php
|
305 |
}
|
@@ -316,44 +417,210 @@ add_action( 'admin_footer', 'iaff_image_bulk_updater' );
|
|
316 |
* @refer https://wordpress.org/plugins/restore-image-title/
|
317 |
*/
|
318 |
function iaff_lcb_restore_image_title( $html, $id ) {
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
|
|
325 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
|
|
|
|
327 |
function iaff_lcb_restore_title_to_gallery( $content, $id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
$thumb_title = get_the_title($id);
|
|
|
329 |
return str_replace('<a', '<a title="' . esc_attr($thumb_title) . '" ', $content);
|
330 |
}
|
331 |
-
|
332 |
-
// Insert image title to post HTML only if it is enabled in the settings. Disabled by default.
|
333 |
-
$settings = get_option('iaff_settings');
|
334 |
-
if ( isset($settings['image_title_to_html']) && ($settings['image_title_to_html'] == 1) ) {
|
335 |
-
add_filter( 'media_send_to_editor', 'iaff_lcb_restore_image_title', 15, 2 );
|
336 |
-
add_filter('wp_get_attachment_link', 'iaff_lcb_restore_title_to_gallery', 10, 4);
|
337 |
-
}
|
338 |
-
|
339 |
|
340 |
/**
|
341 |
-
* Replace commas in filename with
|
342 |
*
|
343 |
-
* WordPress removes commas during file upload. This function replaces commas with
|
344 |
* @since 1.3
|
345 |
* @refer https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter
|
346 |
*/
|
347 |
-
function
|
348 |
-
|
|
|
|
|
|
|
349 |
|
350 |
-
|
351 |
-
|
352 |
return $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
} else {
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
}
|
357 |
-
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* @function iaff_total_number_of_images() Count total number of images in the database
|
10 |
* @function iaff_count_remaining_images() Count remaining number of images to process
|
11 |
* @function iaff_reset_bulk_updater_counter() Reset counter to zero so that bulk updating starts from scratch
|
12 |
+
* @function iaff_before_bulk_updater() Wrapper for functions to run before running bulk updater
|
13 |
+
* @function iaff_after_bulk_updater() Wrapper for functions to run after running bulk updater
|
14 |
* @function iaff_image_bulk_updater() Bulk Updater Ajax
|
15 |
* @function iaff_lcb_restore_image_title() Insert Image Title Into Post HTML
|
16 |
+
* @function iaff_clean_filename() Replace commas in filename with -
|
17 |
+
* @function iaff_image_name_from_filename() Extract, format and return image name from filename
|
18 |
+
* @function iaff_update_image() Update Image Attributes in database
|
19 |
+
* @function boolval() Get the boolean value of a variable
|
20 |
+
* @function iaff_is_pro() Check if IAFF Pro is installed
|
21 |
*/
|
22 |
|
|
|
23 |
// Exit if accessed directly
|
24 |
+
if ( ! defined('ABSPATH') ) exit;
|
|
|
25 |
|
26 |
/**
|
27 |
* Auto add image attributes from image filename for new uploads
|
28 |
*
|
29 |
* @since 1.0
|
30 |
*/
|
31 |
+
function iaff_auto_image_attributes( $post_id ) {
|
|
|
|
|
|
|
32 |
|
33 |
// Get Settings
|
34 |
+
$settings = iaff_get_settings();
|
|
|
|
|
35 |
|
36 |
+
// Return if attachment is not an image
|
37 |
+
if( ! wp_attachment_is_image($post_id) )
|
38 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
// Return if Global switch is turned off
|
41 |
+
if ( ! ( isset( $settings['global_switch'] ) && boolval($settings['global_switch']) ) )
|
42 |
+
return;
|
|
|
43 |
|
44 |
+
// Retrieve image object from its ID
|
45 |
+
$image = get_post( $post_id );
|
46 |
|
47 |
+
// Image Attributes Pro
|
48 |
+
if ( iaff_is_pro() ) {
|
49 |
+
|
50 |
+
// Running the pro module
|
51 |
+
iaffpro_auto_image_attributes_pro($image);
|
52 |
+
|
53 |
+
} else {
|
54 |
+
|
55 |
+
// Get the image name from filename
|
56 |
+
$image_name = iaff_image_name_from_filename($image->ID);
|
57 |
+
|
58 |
+
// Update image attributes
|
59 |
+
iaff_update_image($image->ID, $image_name);
|
60 |
}
|
|
|
|
|
|
|
61 |
}
|
62 |
add_action( 'add_attachment', 'iaff_auto_image_attributes' );
|
63 |
|
|
|
64 |
/**
|
65 |
* Auto add image attributes from image filename for existing uploads
|
66 |
*
|
76 |
$counter = intval ($counter);
|
77 |
|
78 |
global $wpdb;
|
79 |
+
$image = $wpdb->get_row("SELECT ID, post_parent FROM {$wpdb->prefix}posts WHERE post_type='attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date LIMIT 1 OFFSET {$counter}");
|
80 |
|
81 |
+
// Die if no image
|
82 |
if ($image === NULL) {
|
83 |
wp_die();
|
84 |
}
|
85 |
|
86 |
+
// Image Attributes Pro
|
87 |
+
if ( iaff_is_pro() ) {
|
88 |
+
|
89 |
+
// Running the pro module
|
90 |
+
iaffpro_auto_image_attributes_pro($image, true);
|
91 |
+
|
92 |
+
} else {
|
93 |
+
|
94 |
+
// Get the image name from filename
|
95 |
+
$image_name = iaff_image_name_from_filename($image->ID, true);
|
96 |
+
|
97 |
+
// Update image attributes
|
98 |
+
iaff_update_image($image->ID, $image_name, true);
|
99 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
+
// Increment counter and update it
|
102 |
$counter++;
|
103 |
update_option( 'iaff_bulk_updater_counter', $counter );
|
104 |
|
105 |
+
// Extract the image url
|
106 |
+
$image_url = wp_get_attachment_url($image->ID);
|
107 |
+
|
108 |
+
// Update Event log
|
109 |
+
echo __('Image attributes updated for: ', 'abl_iaff_td') . '<a href="'. get_edit_post_link($image->ID) .'">'. $image_url .'</a>';
|
110 |
+
|
111 |
+
wp_die();
|
112 |
}
|
113 |
add_action( 'wp_ajax_iaff_rename_old_image', 'iaff_rename_old_image' );
|
114 |
|
133 |
function iaff_total_number_of_images() {
|
134 |
|
135 |
global $wpdb;
|
136 |
+
$total_no_of_images = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->prefix}posts WHERE post_type='attachment' AND post_mime_type LIKE 'image%'");
|
137 |
|
138 |
return $total_no_of_images;
|
139 |
}
|
152 |
$no_of_images_processed = get_option('iaff_bulk_updater_counter');
|
153 |
$no_of_images_processed = intval ($no_of_images_processed);
|
154 |
|
155 |
+
$reamining_images = max($total_no_of_images - $no_of_images_processed, 0);
|
156 |
|
157 |
// If called from Ajax echo the result. Else return as an integer.
|
158 |
// :TODO: Calling iaff_count_remaining_images() from Ajax for ignores the default value of $force_return for some reason. When I set if ( wp_doing_ajax() && $force_return === false ) this does not work even though they are logically equivalent. If you know why it is so, please email me - arunbasillal@gmail.com
|
186 |
}
|
187 |
add_action( 'wp_ajax_iaff_reset_bulk_updater_counter', 'iaff_reset_bulk_updater_counter' );
|
188 |
|
189 |
+
/**
|
190 |
+
* Wrapper for functions to run before running bulk updater
|
191 |
+
*
|
192 |
+
* @since 1.4
|
193 |
+
*/
|
194 |
+
function iaff_before_bulk_updater() {
|
195 |
+
|
196 |
+
// Security Check
|
197 |
+
check_ajax_referer( 'iaff_before_bulk_updater_nonce', 'security' );
|
198 |
+
|
199 |
+
do_action('iaff_before_bulk_updater');
|
200 |
+
}
|
201 |
+
add_action( 'wp_ajax_iaff_before_bulk_updater', 'iaff_before_bulk_updater' );
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Wrapper for functions to run after running bulk updater
|
205 |
+
*
|
206 |
+
* @since 1.4
|
207 |
+
*/
|
208 |
+
function iaff_after_bulk_updater() {
|
209 |
+
|
210 |
+
// Security Check
|
211 |
+
check_ajax_referer( 'iaff_after_bulk_updater_nonce', 'security' );
|
212 |
+
|
213 |
+
do_action('iaff_after_bulk_updater');
|
214 |
+
}
|
215 |
+
add_action( 'wp_ajax_iaff_after_bulk_updater', 'iaff_after_bulk_updater');
|
216 |
|
217 |
/**
|
218 |
* Bulk Updater Ajax
|
228 |
}?>
|
229 |
|
230 |
<script type="text/javascript" >
|
231 |
+
jQuery(document).ready(function($) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
+
var iaff_stop = false;
|
234 |
+
|
235 |
+
// Bulk Updater
|
236 |
+
function iaff_do_bulk_updater(iaff_test=false) {
|
237 |
+
|
238 |
+
iaff_stop = false;
|
239 |
+
var focused = true;
|
240 |
+
window.onfocus = function() {
|
241 |
+
focused = true;
|
242 |
+
};
|
243 |
+
window.onblur = function() {
|
244 |
+
focused = false;
|
245 |
+
};
|
246 |
+
$('.iaff-spinner').addClass("spinner"); // Turn spinner on
|
247 |
+
$('.iaff_stop_bulk_updater_button').prop('disabled', false); // Enable stop button
|
248 |
+
$('.iaff_stop_bulk_updater_button').removeClass("button-secondary");
|
249 |
+
$('.iaff_stop_bulk_updater_button').addClass("button-primary"); // Turn stop button primary
|
250 |
|
251 |
// Notice to the user
|
252 |
+
$('#bulk-updater-log').append('<p class="iaff-green"><span class="dashicons dashicons-controls-play"></span>Initializing bulk updater. Please be patient and do not close the browser while it\'s running. In case you do, you can always resume by returning to this page later.</p>');
|
253 |
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
254 |
|
255 |
// Count Remaining Images To Process
|
256 |
data = {
|
257 |
action: 'iaff_count_remaining_images',
|
258 |
+
};
|
259 |
+
var remaining_images = null;
|
|
|
|
|
260 |
var reamining_images_count = $.post(ajaxurl, data, function (response) {
|
261 |
remaining_images = response;
|
262 |
console.log(remaining_images);
|
263 |
});
|
264 |
|
265 |
+
// set remaining count as 1 when running in test mode
|
266 |
+
reamining_images_count.done(function() {
|
267 |
+
|
268 |
+
if((iaff_test===true)&&(remaining_images>1)) {
|
269 |
+
remaining_images = 1;
|
270 |
+
}
|
271 |
+
|
272 |
+
// Initialize pre run settings
|
273 |
+
data = {
|
274 |
+
action: 'iaff_before_bulk_updater',
|
275 |
+
security: '<?php echo wp_create_nonce( "iaff_before_bulk_updater_nonce" ); ?>'
|
276 |
+
};
|
277 |
+
var iaff_initializer = $.post(ajaxurl, data);
|
278 |
+
|
279 |
+
// Loop For Each Image And Update Its Attributes
|
280 |
+
iaff_initializer.done(function iaff_rename_image() {
|
281 |
+
|
282 |
+
if((remaining_images > 0)&&(iaff_stop===false)){
|
283 |
+
data = {
|
284 |
+
action: 'iaff_rename_old_image',
|
285 |
+
security: '<?php echo wp_create_nonce( "iaff_rename_old_image_nonce" ); ?>'
|
286 |
+
};
|
287 |
+
|
288 |
+
var rename_image = $.post(ajaxurl, data, function (response) {
|
289 |
+
$('#bulk-updater-log').append('<p>' + response + '</p>');
|
290 |
+
if(iaff_test===false) {
|
291 |
+
$('#bulk-updater-log').append('<p>Images remaining: ' + (remaining_images-1) + '</p>');
|
292 |
+
}
|
293 |
+
if( (($('#bulk-updater-log').prop('scrollHeight')-($('#bulk-updater-log').scrollTop()+$('#bulk-updater-log').height())) < 100) || (focused == false) ) {
|
294 |
+
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},100);
|
295 |
+
}
|
296 |
+
});
|
297 |
+
|
298 |
+
rename_image.done(function() {
|
299 |
+
remaining_images--;
|
300 |
+
iaff_rename_image();
|
301 |
+
});
|
302 |
+
} else {
|
303 |
+
// Post run stuff
|
304 |
+
data = {
|
305 |
+
action: 'iaff_after_bulk_updater',
|
306 |
+
security: '<?php echo wp_create_nonce( "iaff_after_bulk_updater_nonce" ); ?>'
|
307 |
+
};
|
308 |
+
$.post(ajaxurl, data);
|
309 |
+
|
310 |
+
if(iaff_stop===false) {
|
311 |
+
$('#bulk-updater-log').append('<p class="iaff-green"><span class="dashicons dashicons-yes"></span>All done!</p>');
|
312 |
+
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
313 |
+
} else {
|
314 |
+
$('#bulk-updater-log').append('<p class="iaff-red"><span class="dashicons dashicons-dismiss"></span>Operation aborted by user.</p>');
|
315 |
+
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
316 |
+
}
|
317 |
+
|
318 |
+
$('.iaff-spinner').removeClass('spinner'); // Turn spinner off
|
319 |
+
$('.iaff_stop_bulk_updater_button').removeClass("button-primary");
|
320 |
+
$('.iaff_stop_bulk_updater_button').addClass("button-secondary"); // Turn stop button secondary
|
321 |
+
$('.iaff_stop_bulk_updater_button').prop('disabled', true); // Disable stop button
|
322 |
+
}
|
323 |
+
});
|
324 |
+
});
|
325 |
+
}
|
326 |
+
|
327 |
+
// Run Bulk Updater
|
328 |
+
$('.iaff_run_bulk_updater_button').click(function() {
|
329 |
|
330 |
+
// Run Bulk Updater Dialog
|
331 |
+
$('#iaff-confirm-run-dialog').dialog({
|
332 |
+
autoOpen: false,
|
333 |
+
width: 600,
|
334 |
+
modal: true,
|
335 |
+
buttons: {
|
336 |
+
"Ok": function() {
|
337 |
+
$(this).dialog("close");
|
338 |
+
iaff_do_bulk_updater();
|
339 |
+
},
|
340 |
+
"Cancel": function() {
|
341 |
+
$(this).dialog("close");
|
342 |
+
}
|
|
|
|
|
|
|
|
|
343 |
}
|
344 |
+
});
|
345 |
+
$('#iaff-confirm-run-dialog').dialog('open');
|
346 |
+
});
|
347 |
+
|
348 |
+
// Test Bulk Updater
|
349 |
+
$('.iaff_test_bulk_updater_button').click(function() {
|
350 |
+
|
351 |
+
// Test Bulk Updater Dialog
|
352 |
+
$('#iaff-test-run-dialog').dialog({
|
353 |
+
autoOpen: false,
|
354 |
+
width: 600,
|
355 |
+
modal: true,
|
356 |
+
buttons: {
|
357 |
+
"Ok": function() {
|
358 |
+
$(this).dialog("close");
|
359 |
+
iaff_do_bulk_updater(true);
|
360 |
+
},
|
361 |
+
"Cancel": function() {
|
362 |
+
$(this).dialog("close");
|
363 |
+
}
|
364 |
}
|
365 |
});
|
366 |
+
$('#iaff-test-run-dialog').dialog('open');
|
367 |
});
|
368 |
+
|
369 |
+
// Stop Bulk Updater
|
370 |
+
$('.iaff_stop_bulk_updater_button').click(function() {
|
371 |
+
iaff_stop=true;
|
372 |
+
});
|
373 |
+
|
374 |
+
// Reset Bulk Updater Counter
|
375 |
+
$('.iaff_reset_counter_button').click(function() {
|
376 |
+
|
377 |
+
// Reset Counter Dialog
|
378 |
+
$('#iaff-reset-counter-dialog').dialog({
|
379 |
+
autoOpen: false,
|
380 |
+
width: 600,
|
381 |
+
modal: true,
|
382 |
+
buttons: {
|
383 |
+
"Ok": function() {
|
384 |
+
data = {
|
385 |
+
action: 'iaff_reset_bulk_updater_counter',
|
386 |
+
security: '<?php echo wp_create_nonce( "iaff_reset_counter_nonce" ); ?>'
|
387 |
+
};
|
388 |
+
$.post(ajaxurl, data, function (response) {
|
389 |
+
$('#bulk-updater-log').append('<p class="iaff-green"><span class="dashicons dashicons-yes"></span>' + response.message + '</p>');
|
390 |
+
$('#bulk-updater-log').append('<p>Number of Images Remaining: ' + response.remaining_images + '</p>');
|
391 |
+
$('#bulk-updater-log').append('<p>Number of Images Updated: 0</p>');
|
392 |
+
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
|
393 |
+
});
|
394 |
+
$(this).dialog("close");
|
395 |
+
},
|
396 |
+
"Cancel": function() {
|
397 |
+
$(this).dialog("close");
|
398 |
+
}
|
399 |
+
}
|
400 |
+
});
|
401 |
+
$('#iaff-reset-counter-dialog').dialog('open');
|
402 |
+
});
|
403 |
+
|
404 |
});
|
405 |
</script> <?php
|
406 |
}
|
417 |
* @refer https://wordpress.org/plugins/restore-image-title/
|
418 |
*/
|
419 |
function iaff_lcb_restore_image_title( $html, $id ) {
|
420 |
+
|
421 |
+
// Get Settings
|
422 |
+
$settings = iaff_get_settings();
|
423 |
+
|
424 |
+
// Return if disabled in settings
|
425 |
+
if ( isset($settings['image_title_to_html']) && ($settings['image_title_to_html'] == 0) ) {
|
426 |
+
return $html;
|
427 |
}
|
428 |
+
|
429 |
+
// If html already contains a title, do nothing
|
430 |
+
if ( strpos($html, "title=") !== false ) {
|
431 |
+
return $html;
|
432 |
+
}
|
433 |
+
|
434 |
+
$attachment = get_post($id);
|
435 |
+
$mytitle = esc_attr($attachment->post_title);
|
436 |
+
|
437 |
+
return str_replace('<img', '<img title="' . $mytitle . '" ' , $html);
|
438 |
}
|
439 |
+
add_filter( 'media_send_to_editor', 'iaff_lcb_restore_image_title', 15, 2 );
|
440 |
+
|
441 |
function iaff_lcb_restore_title_to_gallery( $content, $id ) {
|
442 |
+
|
443 |
+
// Get Settings
|
444 |
+
$settings = iaff_get_settings();
|
445 |
+
|
446 |
+
// Return if disabled in setings
|
447 |
+
if ( isset($settings['image_title_to_html']) && ( ! boolval($settings['image_title_to_html']) ) ) {
|
448 |
+
return $content;
|
449 |
+
}
|
450 |
+
|
451 |
$thumb_title = get_the_title($id);
|
452 |
+
|
453 |
return str_replace('<a', '<a title="' . esc_attr($thumb_title) . '" ', $content);
|
454 |
}
|
455 |
+
add_filter('wp_get_attachment_link', 'iaff_lcb_restore_title_to_gallery', 10, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
457 |
/**
|
458 |
+
* Replace commas in filename with hyphens
|
459 |
*
|
460 |
+
* WordPress removes commas during file upload. This function replaces commas with hyphens so that we can replace them later. Without this red,pill.jpg will become redpill.jpg and we cannot extract the word 'Red Pill' with the space out of it.
|
461 |
* @since 1.3
|
462 |
* @refer https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter
|
463 |
*/
|
464 |
+
function iaff_clean_filename( $file ) {
|
465 |
+
|
466 |
+
$image_extensions = array (
|
467 |
+
'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'ico'
|
468 |
+
);
|
469 |
|
470 |
+
// Return if file is not an image file
|
471 |
+
if ( ! in_array($file['type'],$image_extensions) )
|
472 |
return $file;
|
473 |
+
|
474 |
+
// Clean filename with IAFF Pro
|
475 |
+
if( iaff_is_pro() ) {
|
476 |
+
|
477 |
+
return iaffpro_clean_filename($file);
|
478 |
+
}
|
479 |
+
|
480 |
+
// Get Settings
|
481 |
+
$settings = iaff_get_settings();
|
482 |
+
|
483 |
+
if ( isset( $settings['commas'] ) && boolval($settings['commas']) ) {
|
484 |
+
$file['name'] = str_replace( ',', '-', $file['name'] );
|
485 |
+
}
|
486 |
+
|
487 |
+
return $file;
|
488 |
+
}
|
489 |
+
add_filter('wp_handle_upload_prefilter', 'iaff_clean_filename' );
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Extract, format and return image name from filename
|
493 |
+
*
|
494 |
+
* @since 1.4
|
495 |
+
* @param $image_id Integer ID of the image to work on
|
496 |
+
* @param $bulk Boolean True when called from the Bulk Updater. False by default
|
497 |
+
* @return String Name of the image extracted from filename
|
498 |
+
*/
|
499 |
+
function iaff_image_name_from_filename( $image_id, $bulk = false ) {
|
500 |
+
|
501 |
+
// Return if no image ID is passed
|
502 |
+
if( $image_id === NULL ) return;
|
503 |
+
|
504 |
+
// Get Settings
|
505 |
+
$settings = iaff_get_settings();
|
506 |
+
|
507 |
+
// Extract the image name from the image url
|
508 |
+
$image_url = wp_get_attachment_url($image_id);
|
509 |
+
$image_extension = pathinfo($image_url);
|
510 |
+
$image_name = basename($image_url, '.'.$image_extension['extension']);
|
511 |
+
|
512 |
+
if ( $bulk === true ) {
|
513 |
+
|
514 |
+
$image_name = str_replace( '-', ' ', $image_name ); // replace hyphens with spaces
|
515 |
+
$image_name = str_replace( '_', ' ', $image_name ); // replace underscores with spaces
|
516 |
+
return $image_name;
|
517 |
+
}
|
518 |
+
|
519 |
+
$filter_chars = array();
|
520 |
+
|
521 |
+
if ( isset( $settings['hyphens'] ) && boolval($settings['hyphens']) ) {
|
522 |
+
$filter_chars[] = '-'; // Hypen
|
523 |
+
}
|
524 |
+
if ( isset( $settings['under_score'] ) && boolval($settings['under_score']) ) {
|
525 |
+
$filter_chars[] = '_'; // Underscore
|
526 |
+
}
|
527 |
+
if ( isset( $settings['full_stop'] ) && boolval($settings['full_stop']) ) {
|
528 |
+
$filter_chars[] = '.'; // Full stops
|
529 |
+
}
|
530 |
+
|
531 |
+
// Remove characters
|
532 |
+
if ( !empty($filter_chars) ) {
|
533 |
+
$image_name = str_replace( $filter_chars, ' ', $image_name );
|
534 |
+
}
|
535 |
+
|
536 |
+
// Remove all numbers
|
537 |
+
if ( isset( $settings['all_numbers'] ) && boolval($settings['all_numbers']) ) {
|
538 |
+
$image_name = preg_replace('/[0-9]+/', '', $image_name);
|
539 |
+
}
|
540 |
+
|
541 |
+
// Final cleanup
|
542 |
+
$image_name = preg_replace('/\s\s+/', ' ', $image_name); // Replace multiple spaces with a single spaces
|
543 |
+
$image_name = trim($image_name); // Remove white spaces from both ends
|
544 |
+
|
545 |
+
return $image_name;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Update Image Attributes in database
|
550 |
+
*
|
551 |
+
* @since 1.4
|
552 |
+
* @param $image_id Integer ID of the image to work on
|
553 |
+
* @param $text String String to be used for Image Title, Caption, Description and Alt Text
|
554 |
+
* @param $bulk Boolean True when called from Bulk Updater. False by default
|
555 |
+
* @return True on success. False otherwise
|
556 |
+
*/
|
557 |
+
function iaff_update_image( $image_id, $text, $bulk = false ) {
|
558 |
+
|
559 |
+
// Return if no image ID is passed
|
560 |
+
if( $image_id === NULL ) return false;
|
561 |
+
|
562 |
+
// Get Settings
|
563 |
+
$settings = iaff_get_settings();
|
564 |
+
|
565 |
+
$image = array();
|
566 |
+
$image['ID'] = $image_id;
|
567 |
+
|
568 |
+
if ( $bulk == true ) {
|
569 |
+
|
570 |
+
$image['post_title'] = $text; // Image Title
|
571 |
+
$image['post_excerpt'] = $text; // Image Caption
|
572 |
+
$image['post_content'] = $text; // Image Description
|
573 |
+
|
574 |
+
// Update Image Alt Text (stored in post_meta table)
|
575 |
+
update_post_meta( $image_id, '_wp_attachment_image_alt', $text ); // Image Alt Text
|
576 |
} else {
|
577 |
+
|
578 |
+
if ( isset( $settings['image_title'] ) && boolval($settings['image_title']) ) {
|
579 |
+
$image['post_title'] = $text; // Image Title
|
580 |
+
}
|
581 |
+
if ( isset( $settings['image_caption'] ) && boolval($settings['image_caption']) ) {
|
582 |
+
$image['post_excerpt'] = $text; // Image Caption
|
583 |
+
}
|
584 |
+
if ( isset( $settings['image_description'] ) && boolval($settings['image_description']) ) {
|
585 |
+
$image['post_content'] = $text; // Image Description
|
586 |
+
}
|
587 |
+
if ( isset( $settings['image_alttext'] ) && boolval($settings['image_alttext']) ) {
|
588 |
+
update_post_meta( $image_id, '_wp_attachment_image_alt', $text ); // Image Alt Text
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
$return_id = wp_update_post( $image ); // Retruns the ID of the post if the post is successfully updated in the database. Otherwise returns 0.
|
593 |
+
|
594 |
+
if ( $return_id == 0 ) return false;
|
595 |
+
|
596 |
+
return true;
|
597 |
+
}
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Get the boolean value of a variable
|
601 |
+
*
|
602 |
+
* For backwards compatibility with pre PHP 5.5
|
603 |
+
* @param mixed The scalar value being converted to a boolean.
|
604 |
+
* @return boolean The boolean value of var.
|
605 |
+
* @refer https://millionclues.com/wordpress-tips/solved-fatal-error-call-to-undefined-function-boolval/
|
606 |
+
*/
|
607 |
+
if( !function_exists('boolval')) {
|
608 |
+
|
609 |
+
function boolval($var) {
|
610 |
+
return !! $var;
|
611 |
}
|
612 |
}
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Check if IAFF Pro is installed
|
616 |
+
*
|
617 |
+
* @since 1.4
|
618 |
+
* @return True if IAFF Pro is installed. False otherwise.
|
619 |
+
*/
|
620 |
+
function iaff_is_pro() {
|
621 |
+
|
622 |
+
if( function_exists('iaffpro_auto_image_attributes_pro') )
|
623 |
+
return true;
|
624 |
+
|
625 |
+
return false;
|
626 |
+
}
|
admin/iaff_image-attributes-from-filename-loader.php
CHANGED
@@ -2,24 +2,21 @@
|
|
2 |
/**
|
3 |
* Loads the plugin files
|
4 |
*
|
5 |
-
* @since
|
6 |
*/
|
7 |
|
8 |
|
9 |
// Exit if accessed directly
|
10 |
-
if ( !defined('ABSPATH') ) exit;
|
11 |
-
|
12 |
|
13 |
// Load basic setup. Plugin list links, text domain, footer links etc.
|
14 |
-
require_once(
|
15 |
|
16 |
// Load admin setup. Register menus and settings
|
17 |
-
require_once(
|
18 |
|
19 |
// Render Admin UI
|
20 |
-
require_once(
|
21 |
|
22 |
// Do plugin operations
|
23 |
-
require_once(
|
24 |
-
|
25 |
-
?>
|
2 |
/**
|
3 |
* Loads the plugin files
|
4 |
*
|
5 |
+
* @since 1.3
|
6 |
*/
|
7 |
|
8 |
|
9 |
// Exit if accessed directly
|
10 |
+
if ( ! defined('ABSPATH') ) exit;
|
|
|
11 |
|
12 |
// Load basic setup. Plugin list links, text domain, footer links etc.
|
13 |
+
require_once( IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/admin/iaff_image-attributes-from-filename-basic-setup.php');
|
14 |
|
15 |
// Load admin setup. Register menus and settings
|
16 |
+
require_once( IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/admin/iaff_image-attributes-from-filename-admin-setup.php');
|
17 |
|
18 |
// Render Admin UI
|
19 |
+
require_once( IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/admin/iaff_image-attributes-from-filename-admin-ui-render.php');
|
20 |
|
21 |
// Do plugin operations
|
22 |
+
require_once( IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/admin/iaff_image-attributes-from-filename-do.php');
|
|
|
|
admin/img/black-traingles.png
ADDED
Binary file
|
admin/img/checkerboardflyer.jpeg
ADDED
Binary file
|
admin/img/iaff-icon.png
ADDED
Binary file
|
admin/index.php
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
<?php
|
2 |
-
// Silence is golden
|
3 |
-
?>
|
1 |
<?php
|
2 |
+
// Silence is golden
|
|
admin/js/iaff-js.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( document ).ready( function($){
|
2 |
+
$('#iaff-pro .iaff-settings-tab').hide();
|
3 |
+
if (sessionStorage.getItem("iaffCurrentTab") !== null) {
|
4 |
+
tab = sessionStorage.getItem("iaffCurrentTab");
|
5 |
+
$(tab).show();
|
6 |
+
$('#iaff-pro a.nav-tab').removeClass('nav-tab-active');
|
7 |
+
$('#iaff-pro a[href="'+tab+'"].nav-tab').addClass('nav-tab-active');
|
8 |
+
} else {
|
9 |
+
$('#iaff-pro #iaff-basic').show();
|
10 |
+
$('#iaff-pro a[href="#iaff-basic"].nav-tab').addClass('nav-tab-active');
|
11 |
+
}
|
12 |
+
$('#iaff-pro .nav-tab').on( 'click', function(e){
|
13 |
+
e.preventDefault();
|
14 |
+
tab = $(this).attr( 'href' );
|
15 |
+
$('#iaff-pro .iaff-settings-tab').hide();
|
16 |
+
$(tab).show();
|
17 |
+
$('#iaff-pro a.nav-tab').removeClass('nav-tab-active');
|
18 |
+
$('#iaff-pro a[href="'+tab+'"].nav-tab').addClass('nav-tab-active');
|
19 |
+
if (typeof(Storage) !== "undefined") {
|
20 |
+
sessionStorage.setItem("iaffCurrentTab", tab); // Store current tab in sessionStorage object
|
21 |
+
}
|
22 |
+
});
|
23 |
+
});
|
iaff_image-attributes-from-filename.php
CHANGED
@@ -5,12 +5,11 @@
|
|
5 |
* Description: Automatically Add Image Title, Image Caption, Description And Alt Text From Image Filename. Since this plugin includes a bulk updater this can update both existing images in the Media Library and new images.
|
6 |
* Author: Arun Basil Lal
|
7 |
* Author URI: http://millionclues.com
|
8 |
-
* Version: 1.
|
9 |
* Text Domain: abl_iaff_td
|
10 |
* Domain Path: /languages
|
11 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
*/
|
13 |
-
|
14 |
|
15 |
/**
|
16 |
* This plugin was developed using the WordPress starter plugin template by Arun Basil Lal <arunbasillal@gmail.com>
|
@@ -18,7 +17,6 @@
|
|
18 |
* @Github https://github.com/arunbasillal/WordPress-Starter-Plugin
|
19 |
*/
|
20 |
|
21 |
-
|
22 |
/**
|
23 |
* ~ Directory Structure ~
|
24 |
*
|
@@ -33,31 +31,34 @@
|
|
33 |
* uninstall.php - Fired when the plugin is uninstalled.
|
34 |
*/
|
35 |
|
36 |
-
|
37 |
/**
|
38 |
* :TODO:
|
39 |
*
|
40 |
* - Update IAFF_VERSION_NUM in iaff_starter-plugin.php (keep this line for future updates)
|
41 |
*/
|
42 |
|
43 |
-
|
44 |
// Exit if accessed directly
|
45 |
-
if ( !defined('ABSPATH') ) exit;
|
46 |
-
|
47 |
|
48 |
/**
|
49 |
* Plugin name and directory constants
|
50 |
*
|
51 |
-
* @since
|
52 |
-
* @constant IAFF_STARTER_PLUGIN The name of the plugin - 'starter-plugin'
|
53 |
-
* @constant IAFF_STARTER_PLUGIN_DIR The absolute path to the plugin directory without the trailing slash - C:\xampp\htdocs\wp/wp-content/plugins/starter-plugin
|
54 |
*/
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
|
58 |
-
|
59 |
-
|
|
|
|
|
60 |
|
|
|
|
|
|
|
|
|
61 |
|
62 |
/**
|
63 |
* Add plugin version to database
|
@@ -67,14 +68,34 @@ if (!defined('IAFF_STARTER_PLUGIN_DIR'))
|
|
67 |
* @refer https://www.smashingmagazine.com/2011/03/ten-things-every-wordpress-plugin-developer-should-know/
|
68 |
*/
|
69 |
if (!defined('IAFF_VERSION_NUM'))
|
70 |
-
define('IAFF_VERSION_NUM', '1.
|
71 |
-
update_option('abl_iaff_version', IAFF_VERSION_NUM); // Change to add_option when we need to check installed version at some later point.
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
// Load everything
|
75 |
-
require_once(
|
76 |
|
77 |
// Register activation hook (this has to be in the main plugin file.)
|
78 |
-
register_activation_hook( __FILE__ , 'iaff_activate_plugin' );
|
79 |
-
|
80 |
-
?>
|
5 |
* Description: Automatically Add Image Title, Image Caption, Description And Alt Text From Image Filename. Since this plugin includes a bulk updater this can update both existing images in the Media Library and new images.
|
6 |
* Author: Arun Basil Lal
|
7 |
* Author URI: http://millionclues.com
|
8 |
+
* Version: 1.4
|
9 |
* Text Domain: abl_iaff_td
|
10 |
* Domain Path: /languages
|
11 |
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
*/
|
|
|
13 |
|
14 |
/**
|
15 |
* This plugin was developed using the WordPress starter plugin template by Arun Basil Lal <arunbasillal@gmail.com>
|
17 |
* @Github https://github.com/arunbasillal/WordPress-Starter-Plugin
|
18 |
*/
|
19 |
|
|
|
20 |
/**
|
21 |
* ~ Directory Structure ~
|
22 |
*
|
31 |
* uninstall.php - Fired when the plugin is uninstalled.
|
32 |
*/
|
33 |
|
|
|
34 |
/**
|
35 |
* :TODO:
|
36 |
*
|
37 |
* - Update IAFF_VERSION_NUM in iaff_starter-plugin.php (keep this line for future updates)
|
38 |
*/
|
39 |
|
|
|
40 |
// Exit if accessed directly
|
41 |
+
if ( ! defined('ABSPATH') ) exit;
|
|
|
42 |
|
43 |
/**
|
44 |
* Plugin name and directory constants
|
45 |
*
|
46 |
+
* @since 1.3
|
|
|
|
|
47 |
*/
|
48 |
+
// The name of the plugin
|
49 |
+
// 'auto-image-attributes-from-filename-with-bulk-updater'
|
50 |
+
if (!defined('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME'))
|
51 |
+
define('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME', trim(dirname(plugin_basename(__FILE__)), '/'));
|
52 |
|
53 |
+
// The absolute path to the plugin directory without the trailing slash. Useful for using with includes
|
54 |
+
// eg - C:\xampp\htdocs\wp/wp-content/plugins/auto-image-attributes-from-filename-with-bulk-updater
|
55 |
+
if (!defined('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR'))
|
56 |
+
define('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR', plugin_dir_path( __FILE__ ));
|
57 |
|
58 |
+
// The url to the plugin folder. Useful for referencing src
|
59 |
+
// eg - http://localhost/wp/wp-content/plugins/auto-image-attributes-from-filename-with-bulk-updater/
|
60 |
+
if (!defined('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_URL'))
|
61 |
+
define('IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_URL', plugin_dir_url( __FILE__ ));
|
62 |
|
63 |
/**
|
64 |
* Add plugin version to database
|
68 |
* @refer https://www.smashingmagazine.com/2011/03/ten-things-every-wordpress-plugin-developer-should-know/
|
69 |
*/
|
70 |
if (!defined('IAFF_VERSION_NUM'))
|
71 |
+
define('IAFF_VERSION_NUM', '1.4');
|
|
|
72 |
|
73 |
+
/**
|
74 |
+
* Upgrade database settings on update
|
75 |
+
*
|
76 |
+
* @since 1.4
|
77 |
+
*/
|
78 |
+
function iaff_upgrade_db_settings() {
|
79 |
+
|
80 |
+
$current_ver = get_option('abl_iaff_version');
|
81 |
+
|
82 |
+
if ( ($current_ver >= 1.4 ) ) {
|
83 |
+
return; // Version was added in 1.3. Return if version is above 1.3.
|
84 |
+
}
|
85 |
+
|
86 |
+
$settings = get_option('iaff_settings');
|
87 |
+
|
88 |
+
if ( $settings != false ) {
|
89 |
+
$settings['global_switch'] = 1; // Global switch was introduced in ver 1.4
|
90 |
+
update_option('iaff_settings', $settings);
|
91 |
+
}
|
92 |
+
|
93 |
+
update_option('abl_iaff_version', IAFF_VERSION_NUM);
|
94 |
+
}
|
95 |
+
add_action( 'plugins_loaded', 'iaff_upgrade_db_settings' );
|
96 |
|
97 |
// Load everything
|
98 |
+
require_once( IAFF_IMAGE_ATTRIBUTES_FROM_FILENAME_DIR . '/admin/iaff_image-attributes-from-filename-loader.php');
|
99 |
|
100 |
// Register activation hook (this has to be in the main plugin file.)
|
101 |
+
register_activation_hook( __FILE__ , 'iaff_activate_plugin' );
|
|
|
|
includes/index.php
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
<?php
|
2 |
-
// Silence is golden
|
3 |
-
?>
|
1 |
<?php
|
2 |
+
// Silence is golden
|
|
index.php
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
<?php
|
2 |
-
// Silence is golden
|
3 |
-
?>
|
1 |
<?php
|
2 |
+
// Silence is golden
|
|
public/index.php
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
<?php
|
2 |
-
// Silence is golden
|
3 |
-
?>
|
1 |
<?php
|
2 |
+
// Silence is golden
|
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Auto Image Attributes From Filename With Bulk Updater ===
|
2 |
Contributors: arunbasillal
|
3 |
Donate link: http://millionclues.com/donate/
|
4 |
-
Tags: image title, image caption, image description, alt text, bulk edit images, bulk rename images, auto image attributes, auto image alt text, remove underscores
|
5 |
Requires at least: 3.5.0
|
6 |
-
Tested up to: 4.
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -21,8 +21,8 @@ With this plugin you can:
|
|
21 |
* Set the image filename as the image Title.
|
22 |
* Set the image filename as the image Caption.
|
23 |
* Set the image filename as the image Description.
|
24 |
-
* Set the image filename as the image Alt Text. This was a default feature in WordPress before 4.7.
|
25 |
-
* Insert Image Title into post HTML. WordPress stopped adding Image Titles to images since WordPress 3.5.
|
26 |
* Remove hyphens from the image filename.
|
27 |
* Remove underscores from the image filename.
|
28 |
* Remove full stops from filename.
|
@@ -35,11 +35,49 @@ With the bulk updater you can:
|
|
35 |
* Set the image filename as image Title, Caption, Description and Alt Text after removing hyphens and underscores from the filename.
|
36 |
* Update any number of images in your Media Library in one click.
|
37 |
|
38 |
-
If your image filename is *
|
39 |
|
40 |
The plugin settings and bulk updater are in WordPress Admin > Settings > Image Attributes. Here you can choose which attributes to update for NEW uploads.
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
== Installation ==
|
45 |
|
@@ -57,20 +95,36 @@ Yes, the plugin will update image Title, Caption, Description And Alt Text from
|
|
57 |
|
58 |
= I need more features. Can I hire you? =
|
59 |
|
60 |
-
|
61 |
|
62 |
= This plugin saved me a lot of time, how can I show my appreciation? =
|
63 |
|
64 |
-
I am glad to hear that! You can either [
|
65 |
|
66 |
== Screenshots ==
|
67 |
|
68 |
1. The settings page in WordPress Admin > Settings > Image Attributes with default settings.
|
69 |
-
2.
|
|
|
|
|
70 |
|
71 |
== Changelog ==
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
= 1.3 =
|
|
|
74 |
* Improved the architecture of the plugin laying foundation for future updates. Utilizing my [starter plugin framework](http://millionclues.com/lab/wordpress-starter-plugin-a-framework-for-quick-plugin-development/)
|
75 |
* Bug fix: For images that had EXIF data, EXIF data was used instead of filename. Props to @mathieupellegrin for reporting this.
|
76 |
* NEW: Added option to Insert Image Title into HTML. WordPress stopped including image titles since 3.5. Code from [Restore Image Title](https://wordpress.org/plugins/restore-image-title/) plugin was used.
|
@@ -84,17 +138,33 @@ I am glad to hear that! You can either [make a donation](http://millionclues.com
|
|
84 |
* Tested on WordPress 4.8.1. Result = pass.
|
85 |
|
86 |
= 1.2 =
|
|
|
87 |
* Added: Character filter options. Plugin now removes hyphens and underscores.
|
88 |
* Bug Fix: Minor bug fix.
|
89 |
|
90 |
= 1.1 =
|
|
|
91 |
* Added: Options to choose individual image attributes for NEW uploads.
|
92 |
|
93 |
= 1.0 =
|
|
|
94 |
* First release of the plugin.
|
95 |
|
96 |
== Upgrade Notice ==
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
= 1.3 =
|
99 |
* Improved the architecture of the plugin laying foundation for future updates. Utilizing my [starter plugin framework](http://millionclues.com/lab/wordpress-starter-plugin-a-framework-for-quick-plugin-development/)
|
100 |
* Bug fix: For images that had EXIF data, EXIF data was used instead of filename. Props to @mathieupellegrin for reporting this.
|
1 |
=== Auto Image Attributes From Filename With Bulk Updater ===
|
2 |
Contributors: arunbasillal
|
3 |
Donate link: http://millionclues.com/donate/
|
4 |
+
Tags: image title, image caption, image description, alt text, bulk edit images, bulk rename images, auto image attributes, auto image alt text, remove underscores, image seo
|
5 |
Requires at least: 3.5.0
|
6 |
+
Tested up to: 4.9
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
21 |
* Set the image filename as the image Title.
|
22 |
* Set the image filename as the image Caption.
|
23 |
* Set the image filename as the image Description.
|
24 |
+
* Set the image filename as the image Alt Text. This was a default feature in WordPress before 4.7. The plugin restores this essential feature which is great for SEO.
|
25 |
+
* Insert Image Title into post HTML. WordPress stopped adding Image Titles to images since WordPress 3.5. The plugin restores it.
|
26 |
* Remove hyphens from the image filename.
|
27 |
* Remove underscores from the image filename.
|
28 |
* Remove full stops from filename.
|
35 |
* Set the image filename as image Title, Caption, Description and Alt Text after removing hyphens and underscores from the filename.
|
36 |
* Update any number of images in your Media Library in one click.
|
37 |
|
38 |
+
If your image filename is *My_image-name.jpg*, your Image Title, Caption, Description And Alt Text will be *My image name*.
|
39 |
|
40 |
The plugin settings and bulk updater are in WordPress Admin > Settings > Image Attributes. Here you can choose which attributes to update for NEW uploads.
|
41 |
|
42 |
+
Please remember to take a database backup before running the bulk updater. The bulk updater updates ALL attributes for existing images in the Media Library and ignores the settings set for NEW uploads.
|
43 |
+
|
44 |
+
**Image Attributes Pro**
|
45 |
+
|
46 |
+
A pro add-on is now available for the plugin. Check out [Image Attributes Pro](https://imageattributespro.com/?utm_source=wordpress&utm_medium=readme).
|
47 |
+
|
48 |
+
What the pro add-on you get these additional features:
|
49 |
+
|
50 |
+
* Remove apostrophe ( ' ) from filename
|
51 |
+
* Remove tilde ( ~ ) from filename
|
52 |
+
* Remove plus ( + ) from filename
|
53 |
+
* Remove pound ( # ) from filename
|
54 |
+
* Remove ampersand ( & ) from filename
|
55 |
+
* Remove round brackets ( ( ) ) from filename
|
56 |
+
* Remove square brackets ( [ ] ) from filename
|
57 |
+
* Remove curly brackets ( { } ) from filename
|
58 |
+
* Filter words or characters from filename
|
59 |
+
* Filter filename with regex
|
60 |
+
* convert image attributes to lowercase
|
61 |
+
* CONVERT IMAGE ATTRIBUTES TO UPPERCASE
|
62 |
+
* Use title casing for image attributes. First Letter Of Each Word Will Be Capitalized.
|
63 |
+
* Use sentence casing for image attributes. First letter of a sentence will be capitalized.
|
64 |
+
* Clean the actual image filename after upload.
|
65 |
+
* Use post title as title text. If image is not attached to a post, image filename will be used instead.
|
66 |
+
* Use post title as alt text. If image is not attached to a post, image filename will be used instead.
|
67 |
+
* Use post title as caption. If image is not attached to a post, image filename will be used instead.
|
68 |
+
* Use post title as description. If image is not attached to a post, image filename will be used instead.
|
69 |
+
* Choose to turn off any of the above mentioned features.
|
70 |
+
|
71 |
+
With the pro bulk updater you can:
|
72 |
+
|
73 |
+
* Update image title and alt text for images inserted into posts and custom post types.
|
74 |
+
* Fine tune all settings. Choose what to update.
|
75 |
+
* Update image titles / alt text in media library only. Image titles / alt text in existing posts will be left unchanged.
|
76 |
+
* Update image titles / alt text in media library and existing posts.
|
77 |
+
* Update image titles / alt text in existing posts only if no title / alt text is set. All image titles/ alt text in media library will be updated.
|
78 |
+
* Choose to turn off any of the above mentioned features.
|
79 |
+
|
80 |
+
For screenshots, FAQ and further details, please see the [product website](https://imageattributespro.com/?utm_source=wordpress&utm_medium=readme).
|
81 |
|
82 |
== Installation ==
|
83 |
|
95 |
|
96 |
= I need more features. Can I hire you? =
|
97 |
|
98 |
+
Please checkout the [Image Attributes Pro add-on](https://imageattributespro.com/?utm_source=wordpress&utm_medium=readme) to see if it suits your requirement. If not, please [get in touch via my contact form](http://millionclues.com/contact/) with a brief description of your requirement and budget for the project. I will be in touch shortly.
|
99 |
|
100 |
= This plugin saved me a lot of time, how can I show my appreciation? =
|
101 |
|
102 |
+
I am glad to hear that! You can either [upgrade to pro](https://imageattributespro.com/?utm_source=wordpress&utm_medium=readme) or leave a [rating](https://wordpress.org/support/plugin/auto-image-attributes-from-filename-with-bulk-updater/reviews/?rate=5#new-post) to motivate me to keep working on the plugin.
|
103 |
|
104 |
== Screenshots ==
|
105 |
|
106 |
1. The settings page in WordPress Admin > Settings > Image Attributes with default settings.
|
107 |
+
2. Preview of the Advanced settings screen. Seen only when the preview is enabled.
|
108 |
+
2. Preview of the Bulk Updater settings screen. Seen only when the preview is enabled.
|
109 |
+
4. Bulk Updater
|
110 |
|
111 |
== Changelog ==
|
112 |
|
113 |
+
= 1.4 =
|
114 |
+
* Date: 22.November.2017
|
115 |
+
* NEW: Global switch to enable or disable the plugin.
|
116 |
+
* NEW: Test button.
|
117 |
+
* NEW: Stop Bulk Updater button.
|
118 |
+
* NEW: Support tab.
|
119 |
+
* Improvement: Changed source of filename from guid to wp_get_attachment_url() to prevent conflicts with other plugins. GUID was being replaced by other plugins. Thanks to @niresh12495 for [bringing this up] (https://wordpress.org/support/topic/image-title-description-and-alt-tag-replaced-with-attachment-idnumber/).
|
120 |
+
* Impreovement: Added checks to check if attachment is image before processing.
|
121 |
+
* FIX: Added [boolval() function for backwards compatibility](https://millionclues.com/wordpress-tips/solved-fatal-error-call-to-undefined-function-boolval/) with servers with PHP older than PHP 5.5.
|
122 |
+
* Added preview of premium options that ship with [Image Attributes Pro](https://imageattributespro.com/docs?utm_source=wordpressorg&utm_medium=changelog)
|
123 |
+
* UI Improvements.
|
124 |
+
* Code improvements.
|
125 |
+
|
126 |
= 1.3 =
|
127 |
+
* Date: 17.August.2017
|
128 |
* Improved the architecture of the plugin laying foundation for future updates. Utilizing my [starter plugin framework](http://millionclues.com/lab/wordpress-starter-plugin-a-framework-for-quick-plugin-development/)
|
129 |
* Bug fix: For images that had EXIF data, EXIF data was used instead of filename. Props to @mathieupellegrin for reporting this.
|
130 |
* NEW: Added option to Insert Image Title into HTML. WordPress stopped including image titles since 3.5. Code from [Restore Image Title](https://wordpress.org/plugins/restore-image-title/) plugin was used.
|
138 |
* Tested on WordPress 4.8.1. Result = pass.
|
139 |
|
140 |
= 1.2 =
|
141 |
+
* Date: 15.July.2017
|
142 |
* Added: Character filter options. Plugin now removes hyphens and underscores.
|
143 |
* Bug Fix: Minor bug fix.
|
144 |
|
145 |
= 1.1 =
|
146 |
+
* Date: 4.July.2017
|
147 |
* Added: Options to choose individual image attributes for NEW uploads.
|
148 |
|
149 |
= 1.0 =
|
150 |
+
* Date: 4.July.2017
|
151 |
* First release of the plugin.
|
152 |
|
153 |
== Upgrade Notice ==
|
154 |
|
155 |
+
= 1.4 =
|
156 |
+
* Date: 22.November.2017
|
157 |
+
* NEW: Global switch to enable or disable the plugin.
|
158 |
+
* NEW: Test button.
|
159 |
+
* NEW: Stop Bulk Updater button.
|
160 |
+
* NEW: Support tab.
|
161 |
+
* Improvement: Changed source of filename from guid to wp_get_attachment_url() to prevent conflicts with other plugins. GUID was being replaced by other plugins. Thanks to @niresh12495 for [bringing this up] (https://wordpress.org/support/topic/image-title-description-and-alt-tag-replaced-with-attachment-idnumber/).
|
162 |
+
* Impreovement: Added checks to check if attachment is image before processing.
|
163 |
+
* FIX: Added [boolval() function for backwards compatibility](https://millionclues.com/wordpress-tips/solved-fatal-error-call-to-undefined-function-boolval/) with servers with PHP older than PHP 5.5.
|
164 |
+
* Added preview of premium options that ship with [Image Attributes Pro](https://imageattributespro.com/docs?utm_source=wordpressorg&utm_medium=changelog)
|
165 |
+
* UI Improvements.
|
166 |
+
* Code improvements.
|
167 |
+
|
168 |
= 1.3 =
|
169 |
* Improved the architecture of the plugin laying foundation for future updates. Utilizing my [starter plugin framework](http://millionclues.com/lab/wordpress-starter-plugin-a-framework-for-quick-plugin-development/)
|
170 |
* Bug fix: For images that had EXIF data, EXIF data was used instead of filename. Props to @mathieupellegrin for reporting this.
|
uninstall.php
CHANGED
@@ -6,13 +6,11 @@
|
|
6 |
* @since 1.3
|
7 |
*/
|
8 |
|
9 |
-
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined('ABSPATH') ) exit;
|
12 |
|
13 |
// If uninstall not called from WordPress, then die.
|
14 |
if ( !defined('WP_UNINSTALL_PLUGIN') ) die;
|
15 |
-
|
16 |
|
17 |
/**
|
18 |
* Delete database entries
|
@@ -21,6 +19,4 @@ if ( !defined('WP_UNINSTALL_PLUGIN') ) die;
|
|
21 |
*/
|
22 |
delete_option( 'iaff_settings' );
|
23 |
delete_option( 'iaff_bulk_updater_counter' );
|
24 |
-
delete_option( 'abl_iaff_version' );
|
25 |
-
|
26 |
-
?>
|
6 |
* @since 1.3
|
7 |
*/
|
8 |
|
|
|
9 |
// Exit if accessed directly
|
10 |
if ( !defined('ABSPATH') ) exit;
|
11 |
|
12 |
// If uninstall not called from WordPress, then die.
|
13 |
if ( !defined('WP_UNINSTALL_PLUGIN') ) die;
|
|
|
14 |
|
15 |
/**
|
16 |
* Delete database entries
|
19 |
*/
|
20 |
delete_option( 'iaff_settings' );
|
21 |
delete_option( 'iaff_bulk_updater_counter' );
|
22 |
+
delete_option( 'abl_iaff_version' );
|
|
|
|