2020-12-17 14:35:39 +01:00
< ? php
class wp_lightbox_2_general_settings_page {
2026-03-31 11:30:59 +02:00
2020-12-17 14:35:39 +01:00
private $databese_settings ;
public $initial_values ;
2025-02-28 08:42:11 +01:00
2025-06-09 09:58:01 +02:00
protected $plugin_url = '' ;
protected $plugin_path = '' ;
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
public function __construct ( $params = array () ) {
2020-12-17 14:35:39 +01:00
// set plugin url
2026-03-31 11:30:59 +02:00
if ( isset ( $params [ 'plugin_url' ] ) ) {
$this -> plugin_url = $params [ 'plugin_url' ];
} else {
$this -> plugin_url = trailingslashit ( dirname ( plugins_url ( '' , __FILE__ )));
}
2020-12-17 14:35:39 +01:00
// set plugin path
2026-03-31 11:30:59 +02:00
if ( isset ( $params [ 'plugin_path' ] ) ) {
$this -> plugin_path = $params [ 'plugin_path' ];
} else {
$this -> plugin_path = trailingslashit ( dirname ( plugin_dir_path ( '' , __FILE__ )));
}
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
$this -> databese_settings = $params [ 'databese_settings' ];
2025-02-28 08:42:11 +01:00
2020-12-17 14:35:39 +01:00
/*ajax parametrs*/
2026-03-31 11:30:59 +02:00
add_action ( 'wp_ajax_save_in_databese_lightbox2' , array ( $this , 'save_parametrs' ) );
2020-12-17 14:35:39 +01:00
}
2026-03-31 11:30:59 +02:00
public function save_parametrs () {
$initial_values = $this -> databese_settings ;
$kk = 1 ;
if ( ! current_user_can ( 'manage_options' ) || ! wp_doing_ajax () ) {
die ( 'Authorization Problem' );
}
if ( isset ( $_POST [ 'wp_lightbox_2_general_settings_page' ] ) && wp_verify_nonce ( $_POST [ 'wp_lightbox_2_general_settings_page' ], 'wp_lightbox_2_general_settings_page' ) ) {
foreach ( $initial_values as $key => $value ) {
if ( isset ( $_POST [ $key ] ) ) {
update_option ( $key , stripslashes ( $_POST [ $key ] ) );
} else {
$kk = 0 ;
printf ( 'error saving %s <br>' , $key );
2020-12-17 14:35:39 +01:00
}
2025-02-28 08:42:11 +01:00
}
2026-03-31 11:30:59 +02:00
} else {
die ( 'Authorization Problem' );
2020-12-17 14:35:39 +01:00
}
2026-03-31 11:30:59 +02:00
if ( empty ( $kk ) ) {
2020-12-17 14:35:39 +01:00
exit ;
}
2026-03-31 11:30:59 +02:00
2020-12-17 14:35:39 +01:00
die ( 'sax_normala' );
}
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
public function controller_page () {
$this -> display_table_list_answers ();
2020-12-17 14:35:39 +01:00
}
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
private function display_table_list_answers () {
2020-12-17 14:35:39 +01:00
2026-03-31 11:30:59 +02:00
$initial_values = $this -> databese_settings ;
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
// Allow
extract ( $initial_values );
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
// jQuery settings
$jquery_settings = '' ;
$keys = array_keys ( $initial_values );
foreach ( $keys as $key ) {
$jquery_settings .= $key . ':jQuery("#' . $key . '").val(),' ;
2020-12-17 14:35:39 +01:00
}
2026-03-31 11:30:59 +02:00
?>
< h2 > Lightbox General Settings </ h2 >
< div class = " main_yutube_plus_params " >
< table class = " wp-list-table widefat fixed posts wp_lightbox2_settings_table " style = " width: 900px; min-width:320px !important;table-layout: fixed; " >
< thead >
< tr >
< th width = " 50% " >
< span > Lightbox General Settings </ span >
</ th >
< th width = " 50% " >
& nbsp ;
</ th >
</ tr >
</ thead >
< tbody >
< tr class = " parametr_chechbox " >
< td >
Use Lightbox for all image links : < span title = " Enable or disable the lightbox. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " checkbox " name = " jqlb_automate_checkbox " id = " jqlb_automate_checkbox " < ? php checked ( $jqlb_automate , '1' ); ?> value="1">
< input type = " hidden " name = " jqlb_automate " id = " jqlb_automate " value = " <?php echo esc_attr( $jqlb_automate ); ?> " >
</ td >
</ tr >
< tr class = " parametr_chechbox " >
< td >
Enable lightbox in comments : < span title = " This feature will enable lightbox for your comments. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " checkbox " name = " jqlb_comments_checkbox " id = " jqlb_comments_checkbox " < ? php checked ( $jqlb_comments , '1' ); ?> value="1">
< input type = " hidden " name = " jqlb_comments " id = " jqlb_comments " value = " <?php echo esc_attr( $jqlb_comments ); ?> " >
</ td >
</ tr >
< tr class = " parametr_chechbox " >
< td >
Show download link : < span title = " You can display download link. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " checkbox " name = " jqlb_show_download_checkbox " id = " jqlb_show_download_checkbox " < ? php checked ( $jqlb_show_download , '1' ); ?> value="1">
< input type = " hidden " name = " jqlb_show_download " id = " jqlb_show_download " value = " <?php echo esc_attr( $jqlb_show_download ); ?> " >
</ td >
</ tr >
< tr >
< td >
Overlay opacity : < span title = " Set overlay opacity for lightbox. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " number " min = " 0 " max = " 100 " step = " 1 " name = " jqlb_overlay_opacity " id = " jqlb_overlay_opacity " value = " <?php echo esc_attr( $jqlb_overlay_opacity ); ?> " >< span class = " befor_input_small_desc " >%</ span >
</ td >
</ tr >
< tr class = " parametr_chechbox " >
< td >
Show image info on top : < span title = " Choose image info position. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " checkbox " name = " jqlb_navbarOnTop_checkbox " id = " jqlb_navbarOnTop_checkbox " < ? php checked ( $jqlb_navbarOnTop , '1' ); ?> value="1">
< input type = " hidden " name = " jqlb_navbarOnTop " id = " jqlb_navbarOnTop " value = " <?php echo esc_attr( $jqlb_navbarOnTop ); ?> " >
</ td >
</ tr >
< tr class = " parametr_chechbox " >
< td >
Reduce large images to fit smaller screens : < span title = " We recommend to enable this option, it will reduce large images to fit smaller screens. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " checkbox " name = " jqlb_resize_on_demand_checkbox " id = " jqlb_resize_on_demand_checkbox " < ? php checked ( $jqlb_resize_on_demand , '1' ); ?> value="1">
< input type = " hidden " name = " jqlb_resize_on_demand " id = " jqlb_resize_on_demand " value = " <?php echo esc_attr( $jqlb_resize_on_demand ); ?> " >
</ td >
</ tr >
< tr >
< td >
Minimum margin from top : < span title = " You can change image position from top. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " number " min = " 0 " max = " 999 " step = " 1 " name = " jqlb_margin_size " id = " jqlb_margin_size " value = " <?php echo esc_attr( $jqlb_margin_size ); ?> " >< span class = " befor_input_small_desc " > ( default : 0 ) </ span >
</ td >
</ tr >
< tr >
< td >
Lightbox Animation duration : < span title = " Animation duration for lightbox. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " number " min = " 0 " max = " 9999999 " step = " 1 " name = " jqlb_resize_speed " id = " jqlb_resize_speed " value = " <?php echo esc_attr( $jqlb_resize_speed ); ?> " >< span class = " befor_input_small_desc " > ( milliseconds ) </ span >
</ td >
</ tr >
< tr >
< td >
Additional text below image info : < span title = " Text only (no HTML) that will appear below images. " class = " desription_class " > ? </ span >
</ td >
< td >
< input type = " text " name = " jqlb_help_text " id = " jqlb_help_text " value = " <?php echo esc_attr( $jqlb_help_text ); ?> " >< span class = " befor_input_small_desc " > ( default : none ) </ span >
</ td >
</ tr >
</ tbody >
< tfoot >
< tr >
< th colspan = " 2 " width = " 100% " >
< button type = " button " id = " save_button_general " class = " save_button button button-primary " >
< span class = " save_button_span " > Save Settings </ span >
< span class = " saving_in_progress " ></ span >
< span class = " sucsses_save " ></ span >
< span class = " error_in_saving " ></ span >
</ button >
</ th >
</ tr >
</ tfoot >
2020-12-17 14:35:39 +01:00
</ table >
2026-03-31 11:30:59 +02:00
2025-02-28 08:42:11 +01:00
< ol >
2026-03-31 11:30:59 +02:00
< li > You can use WordPress image galleries and have them grouped and auto - lightboxed : < a href = " https://codex.wordpress.org/Gallery_Shortcode " >< code > [ gallery link = " file " ] </ code ></ a ></ li >
< li > You can also add a < code > rel = " lightbox " </ code > attribute to any link tag to activate the lightbox . For example :
< pre >& lt ; a href =& quot ; images / image - 1. jpg & quot ; rel =& quot ; lightbox & quot ; title =& quot ; my caption & quot ; & gt ; image #1</a></pre>
< em > Optional :</ em > Use the < code > title </ code > attribute if you want to show a caption .
</ li >
< li > If you have a set of related images that you would like to group , simply include a group name in the rel attribute . For example :
< pre >& lt ; a href =& quot ; images / image - 1. jpg & quot ; rel =& quot ; lightbox [ roadtrip ] & quot ; & gt ; image #1</a>
& lt ; a href =& quot ; images / image - 2. jpg & quot ; rel =& quot ; lightbox [ roadtrip ] & quot ; & gt ; image #2</a>
& lt ; a href =& quot ; images / image - 3. jpg & quot ; rel =& quot ; lightbox [ roadtrip ] & quot ; & gt ; image #3</a></pre>
No limits to the number of image sets per page or how many images are allowed in each set . Go nuts !
</ li >
< li > To < strong > disable </ strong > lightboxing of an image link , just set any other rel - attribute : < code > rel = " nobox " </ code ></ li >
</ ol >
< ? php wp_nonce_field ( 'wp_lightbox_2_general_settings_page' , 'wp_lightbox_2_general_settings_page' ); ?>
</ div >
< br />< br />< span class = " error_massage " ></ span >
< script >
jQuery ( document ) . ready ( function () {
jQuery ( '#save_button_general' ) . click ( function (){
jQuery ( '#save_button_general' ) . addClass ( 'padding_loading' );
jQuery ( " #save_button_general " ) . prop ( 'disabled' , true );
jQuery ( '.saving_in_progress' ) . css ( 'display' , 'inline-block' );
generete_checkbox ( 'parametr_chechbox' );
jQuery . ajax ({
type : 'POST' ,
url : " <?php echo admin_url( 'admin-ajax.php?action=save_in_databese_lightbox2' ); ?> " ,
data : {
wp_lightbox_2_general_settings_page : jQuery ( '#wp_lightbox_2_general_settings_page' ) . val (),
< ? php echo $jquery_settings ; ?>
}
}) . done ( function ( date ) {
if ( date === 'sax_normala' ){
2020-12-17 14:35:39 +01:00
jQuery ( '.saving_in_progress' ) . css ( 'display' , 'none' );
jQuery ( '.sucsses_save' ) . css ( 'display' , 'inline-block' );
2026-03-31 11:30:59 +02:00
setTimeout ( function () {
jQuery ( '.sucsses_save' ) . css ( 'display' , 'none' );
jQuery ( '#save_button_general' ) . removeClass ( 'padding_loading' );
jQuery ( " #save_button_general " ) . prop ( 'disabled' , false );
}, 2500 );
} else {
jQuery ( '.saving_in_progress' ) . css ( 'display' , 'none' );
jQuery ( '.error_in_saving' ) . css ( 'display' , 'inline-block' );
jQuery ( '.error_massage' ) . css ( 'display' , 'inline-block' );
jQuery ( '.error_massage' ) . html ( date );
setTimeout ( function () {
jQuery ( '#save_button_general' ) . removeClass ( 'padding_loading' );
jQuery ( " #save_button_general " ) . prop ( 'disabled' , false );
}, 5000 );
}
2020-12-17 14:35:39 +01:00
});
2026-03-31 11:30:59 +02:00
});
function generete_checkbox ( checkbox_class ){
jQuery ( '.' + checkbox_class ) . each ( function ( index , element ) {
if ( jQuery ( this ) . find ( 'input[type=checkbox]' ) . prop ( 'checked' ))
jQuery ( this ) . find ( 'input[type=hidden]' ) . val ( jQuery ( this ) . find ( 'input[type=checkbox]:checked' ) . val ());
else
jQuery ( this ) . find ( 'input[type=hidden]' ) . val ( 0 );
});
}
2020-12-17 14:35:39 +01:00
});
2025-02-28 08:42:11 +01:00
2026-03-31 11:30:59 +02:00
</ script >
2020-12-17 14:35:39 +01:00
< ? php
2025-02-28 08:42:11 +01:00
}
2020-12-17 14:35:39 +01:00
}