-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscloader-options.php
More file actions
184 lines (145 loc) · 5.56 KB
/
scloader-options.php
File metadata and controls
184 lines (145 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
//common slag scloader_
// add option page to the admin menu
function scloader_option_admin_menu() {
add_options_page( 'SC loader Options', 'Loader Options', 'manage_options', 'scloader_options.php', 'scloader_main_callbk_function' );
//Activating custom setting
add_action( 'admin_init', 'scloader_custom_settings' );
}
add_action( 'admin_menu', 'scloader_option_admin_menu' );
// custom setting callback function
function scloader_custom_settings(){
//registering settings with group-id
register_setting( 'scloader-settings-group', 'select-loader');
//settings sections
add_settings_section( 'scloader-genarel-section', 'General Options', 'genarel_section_callback', 'scloader_options.php' );
//adding setting fields
add_settings_field( 'scloader-loader-selection', 'Select a loader', 'loader_selection_callback', 'scloader_options.php', 'scloader-genarel-section' );
}
// section callbacks
function genarel_section_callback(){
echo 'customize the loader';
}
// option fields callback
function loader_selection_callback(){
$selectLoader = get_option( 'select-loader' );
?>
<div class="loader_selection_div">
<?php for ($x = 1; $x <= 24; $x++) { ?>
<label>
<input onchange="loaderselectionChange(this.value)" type="radio" name="select-loader" value="<?php echo $x; ?>" <?php echo checked( $x, $selectLoader, false); ?>> <img src="<?php echo plugins_url( '/loaders/Preloader_'.$x.'.gif', __FILE__ ); ?>" alt="">
</label>
<?php } ?>
</div>
<?php }
// callback function
function scloader_main_callbk_function(){ ?>
<div class="wrap">
<!-- Inline style for Live View and Options -->
<style>
#scloader_live_view {
align-items: center;
background: #fff none repeat scroll 0 0;
border: 2px solid #ddd;
display: flex;
height: 300px;
justify-content: center;
max-width: 600px;
min-width: 300px;
position: relative;
}
#scloader_live_view .frame {
background: #ddd none repeat scroll 0 0;
display: block;
height: 18px;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
#scloader_live_view span {
background-color: #eee;
border: 1px solid #dadada;
border-radius: 8px;
float: left;
height: 8px;
margin: 3px 0 0 4px;
width: 8px;
}
.loader_selection_div {
max-width: 560px;
}
.loader_selection_div > label > input {
display: none;
}
.loader_selection_div > label > img {
border: 2px solid transparent;
cursor: pointer;
max-width: 60px;
}
.loader_selection_div > label > input:checked + img {
border: 2px solid #ddd;
}
/*Author credit*/
.scauthor_credit {
margin: 10px 0;
}
.scauthor_credit h2 {
font-size: 16px;
margin: 0;
line-height: 18px;
}
.scauthor_credit a {
text-decoration: none;
color: #1b1dfc;
}
.scauthor_credit a > span {
border: 1px solid #649e7d;
color: #232a36;
font-weight: normal;
padding: 1px 10px;
text-transform: uppercase;
font-size: 14px;
}
.scauthor_credit a:hover span {
background: #649e7d;
color: #fff;
}
.scauthor_credit > p {
font-size: 14px;
color: #5d5e5f;
border-left: 5px solid #ddd;
padding-left: 10px;
margin: 0;
}
</style>
<!-- Line Script for live view -->
<script>
function loaderselectionChange(value) {
var liveLoaderImage = document.getElementById("scloader_live_view_img");
liveLoaderImage.src = "<?php echo plugins_url( '/loaders/Preloader_" + value + ".gif', __FILE__ ); ?>";
}
</script>
<!-- Live viw for admin -->
<div id="scloader_live_view">
<div class="frame">
<span></span>
<span></span>
<span></span>
</div>
<img id="scloader_live_view_img" src="<?php echo plugins_url( '/loaders/Preloader_'. get_option( 'select-loader' ) .'.gif', __FILE__ ); ?>">
</div>
<!-- Options -->
<h1 class="title">SC Loader Options</h1>
<?php settings_errors('scloader_options.php'); ?>
<form method="post" action="options.php">
<?php settings_fields( 'scloader-settings-group' ); ?>
<div class="scauthor_credit">
<h2>Developed by <a href="#">Mashiur Rahman <span>Hire Now!</span></a></h2>
<p>Available for freelance work!</p>
</div>
<?php do_settings_sections( 'scloader_options.php' ); ?>
<?php submit_button(); ?>
</form>
</div>
<?php }