Delete
';
echo '';
endforeach; ?>
',
'gllr_nonce_name',
wp_create_nonce( plugin_basename(__FILE__) )
);
}
}
if ( ! function_exists ( 'gllr_save_postdata' ) ) {
function gllr_save_postdata( $post_id, $post ) {
global $post, $wpdb;
$key = "gllr_image_text";
if( isset( $_REQUEST['undefined'] ) && ! empty( $_REQUEST['undefined'] ) ) {
$array_file_name = $_REQUEST['undefined'];
$uploadFile = array();
$newthumb = array();
$time = current_time('mysql');
$uploadDir = wp_upload_dir( $time );
while( list( $key, $val ) = each( $array_file_name ) ) {
$imagename = $val;
$uploadFile[] = $uploadDir["path"] ."/" . $imagename;
}
reset( $array_file_name );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
while( list( $key, $val ) = each( $array_file_name ) ) {
$file_name = $val;
if( file_exists( $uploadFile[$key] ) ){
$uploadFile[$key] = $uploadDir["path"] ."/" . pathinfo($uploadFile[$key], PATHINFO_FILENAME ).uniqid().".".pathinfo($uploadFile[$key], PATHINFO_EXTENSION );
}
if ( copy ( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/".$file_name, $uploadFile[$key] ) ) {
unlink( ABSPATH ."wp-content/plugins/gallery-plugin/upload/files/".$file_name );
$overrides = array('test_form' => false );
$file = $uploadFile[$key];
$filename = basename( $file );
$wp_filetype = wp_check_filetype( $filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => $filename,
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $file );
$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
wp_update_attachment_metadata( $attach_id, $attach_data );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE ID = %d", $post->ID, $attach_id ) );
}
}
}
if( isset( $_REQUEST['delete_images'] ) ) {
foreach( $_REQUEST['delete_images'] as $delete_id ) {
delete_post_meta( $delete_id, $key );
wp_delete_attachment( $delete_id );
}
}
if( isset( $_REQUEST['gllr_image_text'] ) ) {
$posts = get_posts(array(
"showposts" => -1,
"what_to_show" => "posts",
"post_status" => "inherit",
"post_type" => "attachment",
"orderby" => "menu_order",
"order" => "ASC",
"post_mime_type"=> "image/jpeg,image/gif,image/jpg,image/png",
"post_parent" => $post->ID));
foreach ( $posts as $page ) {
if( isset( $_REQUEST['gllr_image_text'][$page->ID] ) ) {
$value = $_REQUEST['gllr_image_text'][$page->ID];
if( get_post_meta( $page->ID, $key, FALSE ) && $value ) {
// Custom field has a value and this custom field exists in database
update_post_meta( $page->ID, $key, $value );
}
elseif($value) {
// Custom field has a value, but this custom field does not exist in database
add_post_meta( $page->ID, $key, $value );
}
}
}
}
}
}
if ( ! function_exists ( 'gllr_plugin_init' ) ) {
function gllr_plugin_init() {
// Internationalization, first(!)
load_plugin_textdomain( 'gallery', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
if( ! function_exists( 'gllr_custom_permalinks' ) ) {
function gllr_custom_permalinks() {
global $wp_rewrite;
global $wpdb;
$parent = $wpdb->get_var("SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id");
if( ! empty( $parent ) ) {
$wp_rewrite->add_rule( '(.+)/'.$parent.'/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[2]&posts_per_page=-1', 'top' );
$wp_rewrite->add_rule( ''.$parent.'/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[1]&posts_per_page=-1', 'top' );
$wp_rewrite->add_rule( ''.$parent.'/page/([^/]+)/?$', 'index.php?pagename='.$parent.'&paged=$matches[1]', 'top' );
$wp_rewrite->add_rule( ''.$parent.'/page/([^/]+)?$', 'index.php?pagename='.$parent.'&paged=$matches[1]', 'top' );
}
else {
$wp_rewrite->add_rule( '(.+)/gallery/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[2]&posts_per_page=-1', 'top' );
$wp_rewrite->add_rule( 'gallery/([^/]+)/?$', 'index.php?post_type=gallery&title=$matches[1]&posts_per_page=-1', 'top' );
$wp_rewrite->add_rule( 'gallery/page/([^/]+)/?$', 'index.php?pagename=gallery&paged=$matches[1]', 'top' );
$wp_rewrite->add_rule( 'gallery/page/([^/]+)?$', 'index.php?pagename=gallery&paged=$matches[1]', 'top' );
}
$wp_rewrite->flush_rules();
}
}
if ( ! function_exists( 'gllr_template_redirect' ) ) {
function gllr_template_redirect() {
global $wp_query, $post, $posts;
if( 'gallery' == get_post_type() && "" == $wp_query->query_vars["s"] ) {
include( STYLESHEETPATH . '/gallery-single-template.php' );
exit();
}
}
}
// Change the columns for the edit CPT screen
if ( ! function_exists( 'gllr_change_columns' ) ) {
function gllr_change_columns( $cols ) {
$cols = array(
'cb' => '
',
'title' => __( 'Title', 'gallery' ),
'autor' => __( 'Author', 'gallery' ),
'gallery' => __( 'Photo\'s', 'gallery' ),
'status' => __( 'Public', 'gallery' ),
'dates' => __( 'Date', 'gallery' )
);
return $cols;
}
}
if ( ! function_exists( 'gllr_custom_columns' ) ) {
function gllr_custom_columns( $column, $post_id ) {
global $wpdb;
$post = get_post( $post_id );
$row = $wpdb->get_results( "SELECT *
FROM $wpdb->posts
WHERE $wpdb->posts.post_parent = $post_id
AND $wpdb->posts.post_type = 'attachment'
AND (
$wpdb->posts.post_status = 'inherit'
)
ORDER BY $wpdb->posts.post_title ASC" );
switch ( $column ) {
//case "category":
case "autor":
$author_id=$post->post_author;
echo '
'.get_the_author_meta( 'user_nicename' , $author_id ).' ';
break;
case "gallery":
echo count($row);
break;
case "status":
if( $post->post_status == 'publish' )
echo '
Yes ';
else
echo '
No ';
break;
case "dates":
echo strtolower( __( date( "F", strtotime( $post->post_date ) ), 'kerksite' ) )." ".date( "j Y", strtotime( $post->post_date ) );
break;
}
}
}
if ( ! function_exists( 'get_ID_by_slug' ) ) {
function get_ID_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
}
else {
return null;
}
}
}
if( ! function_exists( 'the_excerpt_max_charlength' ) ) {
function the_excerpt_max_charlength( $charlength ) {
$excerpt = get_the_excerpt();
$charlength ++;
if( strlen( $excerpt ) > $charlength ) {
$subex = substr( $excerpt, 0, $charlength-5 );
$exwords = explode( " ", $subex );
$excut = - ( strlen ( $exwords [ count( $exwords ) - 1 ] ) );
if( $excut < 0 ) {
echo substr( $subex, 0, $excut );
}
else {
echo $subex;
}
echo "...";
}
else {
echo $excerpt;
}
}
}
if( ! function_exists( 'gllr_page_css_class' ) ) {
function gllr_page_css_class( $classes, $item ) {
global $wpdb;
$post_type = get_query_var( 'post_type' );
$parent_id = 0;
if( $post_type == "gallery" ) {
$parent_id = $wpdb->get_var( "SELECT $wpdb->posts.ID FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'gallery-template.php' AND post_status = 'publish' AND $wpdb->posts.ID = $wpdb->postmeta.post_id" );
while ( $parent_id ) {
$page = get_page( $parent_id );
if( $page->post_parent > 0 )
$parent_id = $page->post_parent;
else
break;
}
wp_reset_query();
}
if ( $item->ID == $parent_id ) {
array_push( $classes, 'current_page_item' );
}
return $classes;
}
}
if( ! function_exists( 'bws_add_menu_render' ) ) {
function bws_add_menu_render() {
global $title;
$active_plugins = get_option('active_plugins');
$all_plugins = get_plugins();
$array_activate = array();
$array_install = array();
$array_recomend = array();
$count_activate = $count_install = $count_recomend = 0;
$array_plugins = array(
array( 'captcha\/captcha.php', 'Captcha', 'http://wordpress.org/extend/plugins/captcha/', 'http://bestwebsoft.com/plugin/captcha-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Captcha+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=captcha.php' ),
array( 'contact-form-plugin\/contact_form.php', 'Contact Form', 'http://wordpress.org/extend/plugins/contact-form-plugin/', 'http://bestwebsoft.com/plugin/contact-form/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Contact+Form+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=contact_form.php' ),
array( 'facebook-button-plugin\/facebook-button-plugin.php', 'Facebook Like Button Plugin', 'http://wordpress.org/extend/plugins/facebook-button-plugin/', 'http://bestwebsoft.com/plugin/facebook-like-button-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Facebook+Like+Button+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=facebook-button-plugin.php' ),
array( 'twitter-plugin\/twitter.php', 'Twitter Plugin', 'http://wordpress.org/extend/plugins/twitter-plugin/', 'http://bestwebsoft.com/plugin/twitter-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Twitter+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=twitter.php' ),
array( 'portfolio\/portfolio.php', 'Portfolio', 'http://wordpress.org/extend/plugins/portfolio/', 'http://bestwebsoft.com/plugin/portfolio-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Portfolio+bestwebsoft&plugin-search-input=Search+Plugins', '' ),
array( 'gallery-plugin\/gallery-plugin.php', 'Gallery', 'http://wordpress.org/extend/plugins/gallery-plugin/', 'http://bestwebsoft.com/plugin/gallery-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Gallery+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', '' ),
array( 'adsense-plugin\/adsense-plugin.php', 'Google AdSense Plugin', 'http://wordpress.org/extend/plugins/adsense-plugin/', 'http://bestwebsoft.com/plugin/google-adsense-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Adsense+Plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=adsense-plugin.php' ),
array( 'custom-search-plugin\/custom-search-plugin.php', 'Custom Search Plugin', 'http://wordpress.org/extend/plugins/custom-search-plugin/', 'http://bestwebsoft.com/plugin/custom-search-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Custom+Search+plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=custom_search.php' ),
array( 'quotes-and-tips\/quotes-and-tips.php', 'Quotes and Tips', 'http://wordpress.org/extend/plugins/quotes-and-tips/', 'http://bestwebsoft.com/plugin/quotes-and-tips/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Quotes+and+Tips+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=quotes-and-tips.php' ),
array( 'google-sitemap-plugin\/google-sitemap-plugin.php', 'Google sitemap plugin', 'http://wordpress.org/extend/plugins/google-sitemap-plugin/', 'http://bestwebsoft.com/plugin/google-sitemap-plugin/', '/wp-admin/plugin-install.php?tab=search&type=term&s=Google+sitemap+plugin+bestwebsoft&plugin-search-input=Search+Plugins', 'admin.php?page=google-sitemap-plugin.php' )
);
foreach($array_plugins as $plugins) {
if( 0 < count( preg_grep( "/".$plugins[0]."/", $active_plugins ) ) ) {
$array_activate[$count_activate]['title'] = $plugins[1];
$array_activate[$count_activate]['link'] = $plugins[2];
$array_activate[$count_activate]['href'] = $plugins[3];
$array_activate[$count_activate]['url'] = $plugins[5];
$count_activate++;
}
else if( array_key_exists(str_replace("\\", "", $plugins[0]), $all_plugins) ) {
$array_install[$count_install]['title'] = $plugins[1];
$array_install[$count_install]['link'] = $plugins[2];
$array_install[$count_install]['href'] = $plugins[3];
$count_install++;
}
else {
$array_recomend[$count_recomend]['title'] = $plugins[1];
$array_recomend[$count_recomend]['link'] = $plugins[2];
$array_recomend[$count_recomend]['href'] = $plugins[3];
$array_recomend[$count_recomend]['slug'] = $plugins[4];
$count_recomend++;
}
}
?>
array( 'album-thumb', 'photo-thumb' ),
'gllr_custom_size_px' => array( array(120, 80), array(160, 120) ),
'custom_image_row_count' => 3,
'start_slideshow' => 0,
'slideshow_interval' => 2000,
'order_by' => 'menu_order',
'order' => 'ASC',
'return_link' => 0,
'return_link_text' => 'Return to all albums',
'return_link_shortcode' => 0
);
// install the option defaults
if ( 1 == $wpmu ) {
if( ! get_site_option( 'gllr_options' ) ) {
add_site_option( 'gllr_options', $gllr_option_defaults, '', 'yes' );
}
}
else {
if( ! get_option( 'gllr_options' ) )
add_option( 'gllr_options', $gllr_option_defaults, '', 'yes' );
}
// get options from the database
if ( 1 == $wpmu )
$gllr_options = get_site_option( 'gllr_options' ); // get options from the database
else
$gllr_options = get_option( 'gllr_options' );// get options from the database
// array merge incase this version has added new options
$gllr_options = array_merge( $gllr_option_defaults, $gllr_options );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'album-thumb', $gllr_options['gllr_custom_size_px'][0][0], $gllr_options['gllr_custom_size_px'][0][1], true );
add_image_size( 'photo-thumb', $gllr_options['gllr_custom_size_px'][1][0], $gllr_options['gllr_custom_size_px'][1][1], true );
}
}
}
if( ! function_exists( 'gllr_settings_page' ) ) {
function gllr_settings_page() {
global $gllr_options;
$error = "";
// Save data for settings page
if( isset( $_REQUEST['gllr_form_submit'] ) ) {
$gllr_request_options = array();
$gllr_request_options["gllr_custom_size_name"] = $gllr_options["gllr_custom_size_name"];
$gllr_request_options["gllr_custom_size_px"] = array(
array( intval( trim( $_REQUEST['custom_image_size_w_album'] ) ), intval( trim($_REQUEST['custom_image_size_h_album'] ) ) ),
array( intval( trim( $_REQUEST['custom_image_size_w_photo'] ) ), intval( trim($_REQUEST['custom_image_size_h_photo'] ) ) )
);
$gllr_request_options["custom_image_row_count"] = intval( trim( $_REQUEST['custom_image_row_count'] ) );
if( $gllr_request_options["custom_image_row_count"] == "" || $gllr_request_options["custom_image_row_count"] < 1 )
$gllr_request_options["custom_image_row_count"] = 1;
if( isset( $_REQUEST['start_slideshow'] ) )
$gllr_request_options["start_slideshow"] = 1;
else
$gllr_request_options["start_slideshow"] = 0;
$gllr_request_options["slideshow_interval"] = $_REQUEST['slideshow_interval'];
$gllr_request_options["order_by"] = $_REQUEST['order_by'];
$gllr_request_options["order"] = $_REQUEST['order'];
if( isset( $_REQUEST['return_link'] ) )
$gllr_request_options["return_link"] = 1;
else
$gllr_request_options["return_link"] = 0;
if( isset( $_REQUEST['return_link_shortcode'] ) )
$gllr_request_options["return_link_shortcode"] = 1;
else
$gllr_request_options["return_link_shortcode"] = 0;
$gllr_request_options["return_link_text"] = $_REQUEST['return_link_text'];
// array merge incase this version has added new options
$gllr_options = array_merge( $gllr_options, $gllr_request_options );
// Check select one point in the blocks Arithmetic actions and Difficulty on settings page
update_option( 'gllr_options', $gllr_options, '', 'yes' );
$message = __( "Options saved.", 'gallery' );
}
if ( ! file_exists( get_stylesheet_directory() .'/gallery-template.php' ) || ! file_exists( get_stylesheet_directory() .'/gallery-single-template.php' ) ) {
$error .= __( 'The following files "gallery-template.php" and "gallery-single-template.php" were not found in the directory of your theme. Please copy them from the directory `/wp-content/plugins/gallery-plugin/template/` to the directory of your theme for the correct work of the Gallery plugin', 'gallery' );
}
// Display form on the setting page
?>
[print_gllr id=Your_gallery_id]
' . __( 'Settings', 'gallery' ) . '';
$links[] = '
' . __( 'FAQ', 'gallery' ) . ' ';
$links[] = '
' . __( 'Support', 'gallery' ) . ' ';
}
return $links;
}
}
if( ! function_exists( 'gllr_plugin_action_links' ) ) {
function gllr_plugin_action_links( $links, $file ) {
//Static so we don't call plugin_basename on every plugin row.
static $this_plugin;
if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
if ( $file == $this_plugin ){
$settings_link = '
' . __( 'Settings', 'gallery' ) . ' ';
array_unshift( $links, $settings_link );
}
return $links;
} // end function gllr_plugin_action_links
}
if( ! function_exists( 'gllr_add_script' ) ){
function gllr_add_script() { ?>
''
), $attr )
);
$args = array(
'post_type' => 'gallery',
'post_status' => 'publish',
'p' => $id,
'posts_per_page' => 1
);
$second_query = new WP_Query( $args );
$gllr_options = get_option( 'gllr_options' );
if ($second_query->have_posts()) :
while ($second_query->have_posts()) :
global $post;
$second_query->the_post(); ?>
-1,
"what_to_show" => "posts",
"post_status" => "inherit",
"post_type" => "attachment",
"orderby" => $gllr_options['order_by'],
"order" => $gllr_options['order'],
"post_mime_type"=> "image/jpeg,image/gif,image/jpg,image/png",
"post_parent" => $post->ID
));
if( count( $posts ) > 0 ) {
$count_image_block = 0; ?>
ID, 'photo-thumb' );
$image_attributes_large = wp_get_attachment_image_src( $attachment->ID, 'large' );
if( $count_image_block % $gllr_options['custom_image_row_count'] == 0 ) { ?>
ID, $key, true ); ?>
0 && $count_image_block%$gllr_options['custom_image_row_count'] != 0) { ?>