Add upstream

This commit is contained in:
root
2019-10-24 00:12:05 +02:00
parent 85d41e4216
commit ac980f592c
3504 changed files with 1049983 additions and 29971 deletions

View File

@@ -0,0 +1,186 @@
/*
Colorbox Core Style:
The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
overflow: hidden;
}
#cboxOverlay {
position: fixed;
width: 100%;
height: 100%;
}
#cboxMiddleLeft, #cboxBottomLeft {
clear: left;
}
#cboxContent {
position: relative;
}
#cboxLoadedContent {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
#cboxTitle {
margin: 0;
display: none !important;
}
#cboxLoadingOverlay, #cboxLoadingGraphic {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
cursor: pointer;
}
.cboxPhoto {
float: left;
margin: auto;
border: 0;
display: block;
max-width: none;
-ms-interpolation-mode: bicubic;
}
.cboxIframe {
width: 100%;
height: 100%;
display: block;
border: 0;
}
#colorbox, #cboxContent, #cboxLoadedContent {
box-sizing: content-box;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
}
/*
User Style:
Change the following styles to modify the appearance of Colorbox. They are
ordered & tabbed in a way that represents the nesting of the generated HTML.
*/
#cboxOverlay {
background: #000;
}
#colorbox {
outline: 0;
}
#cboxContent {
margin-top: 20px;
background: #000;
}
.cboxIframe {
background: #fff;
}
#cboxError {
padding: 50px;
border: 1px solid #ccc;
}
#cboxLoadedContent {
border: 5px solid #000;
background: #fff;
}
#cboxTitle {
position: absolute;
top: -20px;
left: 0;
color: #ccc;
}
#cboxCurrent {
position: absolute;
top: -20px;
right: 0px;
color: #ccc;
}
#cboxLoadingGraphic {
background: url(../images/loading.gif) no-repeat center center;
}
/* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
#cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {
border: 0;
padding: 0;
margin: 0;
overflow: visible;
width: auto;
background: none;
}
/* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
#cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {
outline: 0;
}
#cboxSlideshow {
position: absolute;
top: -20px;
right: 90px;
color: #fff;
}
#cboxPrevious {
position: absolute;
top: 50%;
left: 5px;
margin-top: -32px;
background: url(../images/controls.png) no-repeat top left;
width: 28px;
height: 65px;
text-indent: -9999px;
}
#cboxPrevious:hover {
background-position: bottom left;
}
#cboxNext {
position: absolute;
top: 50%;
right: 5px;
margin-top: -32px;
background: url(../images/controls.png) no-repeat top right;
width: 28px;
height: 65px;
text-indent: -9999px;
}
#cboxNext:hover {
background-position: bottom right;
}
#cboxClose {
position: absolute;
top: 5px;
right: 5px;
display: block;
background: url(../images/controls.png) no-repeat top center;
width: 38px;
height: 19px;
text-indent: -9999px;
}
#cboxClose:hover {
background-position: bottom center;
}

View File

@@ -0,0 +1,274 @@
#vpxb_popup {
font-size: 13px !important;
font-family: "Helvetica", helvetica, arial, sans-serif !important;
color: #111 !important;
}
.vpxb_dashicons {
vertical-align: middle !important;
}
.vpxb_container {
width: 618px;
display: inline-block;
margin-top: 10px;
}
.vpxb_item {
position: relative;
display: inline-block;
width: 150px;
height: 150px;
text-align: center;
border: 1px solid #ddd;
float: left;
margin-right: 3px;
margin-bottom: 3px;
padding: 0;
background: #fff;
box-sizing: content-box !important;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.vpxb_item:nth-child(4n+0) {
margin-right: 0px !important;
}
.vpxb_input, .vpxb_select {
padding: 0 6px !important;
border-color: #DDD !important;
box-shadow: none !important;
border-radius: 2px !important;
border: 1px solid #DDD !important;
background-color: #fff !important;
color: #32373c !important;
float: left !important;
margin-right: 2px !important;
outline: none !important;
font-size: 13px !important;
line-height: 28px !important;
height: 28px !important;
}
.vpxb_input {
width: 100%;
}
.vpxb_input-small {
width: 60px !important;
}
.vpxb_input-normal {
width: 355px !important;
}
.vpxb_textarea {
padding: 6px !important;
border-color: #DDD !important;
box-shadow: none !important;
border-radius: 2px !important;
border: 1px solid #DDD !important;
background-color: #fff !important;
color: #32373c !important;
float: left !important;
margin-right: 2px !important;
outline: none !important;
font-size: 13px !important;
width: 100%;
}
.vpxb_button {
padding: 0 6px !important;
border-color: #00a0d2 !important;
box-shadow: none !important;
border-radius: 2px !important;
border: 1px solid #00a0d2 !important;
background-color: #00a0d2 !important;
color: #fff !important;
float: left !important;
margin-right: 2px !important;
cursor: pointer !important;
outline: none !important;
font-size: 13px !important;
line-height: 26px !important;
height: 28px !important;
}
.vpxb_button_disable {
padding: 0 6px !important;
border-color: #dedede !important;
box-shadow: none !important;
border-radius: 2px !important;
border: 1px solid #dedede !important;
background-color: #dedede !important;
color: #555 !important;
float: left !important;
margin-right: 2px !important;
cursor: pointer !important;
outline: none !important;
font-size: 13px !important;
line-height: 26px !important;
height: 28px !important;
}
.vpxb_table {
display: table !important;
border-collapse: separate !important;
border-spacing: 2px !important;
border-color: grey !important;
vertical-align: middle !important;
}
.vpxb_tr {
display: table-row !important;
vertical-align: middle !important;
border-color: inherit !important;
}
.vpxb_td {
display: table-cell !important;
vertical-align: middle !important;
}
.vpxb_checkbox {
border: 1px solid #DDDDDD;
background: #fff;
color: #32373c;
clear: none;
cursor: pointer;
display: inline-block;
line-height: 0;
height: 16px;
margin: -4px 4px 0 0;
outline: 0;
padding: 0 !important;
text-align: center;
vertical-align: middle;
width: 16px;
min-width: 16px;
border-radius: 2px !important;
-webkit-appearance: none;
box-shadow: none !important;
-webkit-transition: .05s border-color ease-in-out;
transition: .05s border-color ease-in-out;
}
.vpxb_check {
z-index: 995;
position: absolute;
top: 5px;
right: 8px;
}
.vpxb_check input {
margin: 0 !important;
padding: 0 !important;
}
.vpxb_button:hover {
opacity: 0.7;
}
.vpxb_item img {
max-width: 150px;
max-height: 150px;
}
.vpxb_use-image {
width: 100%;
display: none;
}
.vpxb_item span {
position: absolute;
bottom: 0;
right: 0;
padding: 0 4px;
color: #fff;
font-size: 10px;
background: rgba(0, 0, 0, 0.65);
z-index: 10;
}
.vpxb_page {
text-align: center;
}
.vpxb_item-overlay {
width: 150px;
height: 150px;
background: #000;
position: absolute;
top: 0px;
left: 0px;
z-index: 997;
opacity: 0.7;
filter: alpha(opacity=70);
display: none;
cursor: pointer;
}
.vpxb_item-link {
display: none;
position: absolute;
top: 50px;
width: 150px;
text-align: center;
z-index: 998;
}
.vpxb_item-link a {
display: inline-block;
background: #fff;
padding: 0 10px;
height: 24px;
line-height: 24px;
margin-bottom: 5px;
text-decoration: none;
width: 120px;
font-size: 12px;
outline: none !important;
}
#vpxb_view img {
max-width: 100%;
height: auto;
}
p.vpxb_p {
margin: 0 0 5px 0
}
.vpxb_item:hover > .vpxb_item-overlay {
display: block
}
.vpxb_item:hover > .vpxb_item-link {
display: block
}
.vpxb_item-single {
width: 100%;
height: auto;
text-align: center;
}
.vpxb_loading {
display: inline-block;
height: 28px;
line-height: 28px;
min-width: 20px;
background: url("../images/loading.gif") no-repeat;
background-position: center;
}
.vpxb_loading-text {
display: inline-block;
height: 20px;
line-height: 20px;
min-width: 20px;
background: url("../images/loading.gif") no-repeat;
padding-left: 30px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,395 @@
<?php
/*
Plugin Name: WP Pixabay
Plugin URI: https://wpclever.net
Description: This plugin help you search millions of free photos, vectors and art illustrations from https://pixabay.com then insert into content or set as featured image very quickly.
Version: 2.5
Author: WPclever
Author URI: https://wpclever.net/contact
*/
register_activation_hook( __FILE__, 'vpxb_activate' );
add_action( 'admin_init', 'vpxb_redirect' );
function vpxb_activate() {
add_option( 'vpxb_do_activation_redirect', true );
}
function vpxb_redirect() {
if ( get_option( 'vpxb_do_activation_redirect', false ) ) {
delete_option( 'vpxb_do_activation_redirect' );
wp_redirect( 'admin.php?page=vpxb' );
}
}
add_action( 'admin_menu', 'vpxb_menu' );
function vpxb_menu() {
add_menu_page( 'Pixabay', 'Pixabay', 'manage_options', 'vpxb', 'vpxb_menu_pages', 'dashicons-camera' );
}
function vpxb_menu_pages() {
$vpxb_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'settings';
?>
<div class="wrap vpxb_welcome">
<h1>Welcome to WP Pixabay</h1>
<div class="about-text">
This plugin help you search millions of free photos, vectors and art illustrations from <a
href="https://pixabay.com" target="_blank">https://pixabay.com</a> then insert into content
or set
as featured image very quickly.
</div>
<h2 class="nav-tab-wrapper">
<a href="?page=vpxb&amp;tab=settings"
class="nav-tab <?php echo $vpxb_active_tab == 'settings' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Settings' ); ?></a>
<a href="?page=vpxb&amp;tab=api"
class="nav-tab <?php echo $vpxb_active_tab == 'api' ? 'nav-tab-active' : ''; ?>"><?php _e( 'How to get Pixabay Username & Key?' ); ?></a>
<a href="?page=vpxb&amp;tab=about"
class="nav-tab <?php echo $vpxb_active_tab == 'about' ? 'nav-tab-active' : ''; ?>"><?php _e( 'How to use?' ); ?></a>
<a href="?page=vpxb&amp;tab=support"
class="nav-tab <?php echo $vpxb_active_tab == 'support' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Support' ); ?></a>
<a href="?page=vpxb&amp;tab=buy"
class="nav-tab <?php echo $vpxb_active_tab == 'buy' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Buy PRO version' ); ?></a>
</h2>
<br />
<?php if ( $vpxb_active_tab == 'api' ) { ?>
Step 1: Go to
<a href="https://pixabay.com" target="_blank">https://pixabay.com</a> and create new account (verify via email required).
<br /><br />
Step 2: Login with your account and go to
<a href="https://pixabay.com/api/docs/#api_key" target="_blank">https://pixabay.com/api/docs/#api_key</a>
then you can see the key.
<br /><br />
<img src="<?php echo plugin_dir_url( __FILE__ ); ?>/images/pixabay_key.jpg" />
<?php } elseif ( $vpxb_active_tab == 'about' ) { ?>
<iframe width="560" height="315" src="https://www.youtube.com/embed/nk40Ce06D4E" frameborder="0"
allowfullscreen></iframe>
<?php } elseif ( $vpxb_active_tab == 'settings' ) { ?>
<form method="post" action="options.php" novalidate="novalidate">
<?php wp_nonce_field( 'update-options' ) ?>
<table class="form-table">
<tr>
<th scope="row"><label for="vpxb_username">Pixabay Username</label></th>
<td>
<input name="vpxb_username" type="text" id="vpxb_username"
value="<?php echo get_option( 'vpxb_username' ); ?>" />
<p class="description"><a href="<?php echo admin_url( "admin.php?page=vpxb&tab=api" ); ?>">How
to get Pixabay Username & Key?</a></p>
</td>
</tr>
<tr>
<th scope="row"><label for="vpxb_key">Pixabay Key</label></th>
<td>
<input name="vpxb_key" type="text" id="vpxb_key"
value="<?php echo get_option( 'vpxb_key' ); ?>" />
<p class="description"><a href="<?php echo admin_url( "admin.php?page=vpxb&tab=api" ); ?>">How
to get Pixabay Username & Key?</a></p>
</td>
</tr>
<tr>
<th scope="row"><label for="vpxb_frontend">Front-end editor</label></th>
<td>
<input name="vpxb_frontend" type="checkbox" id="vpxb_frontend"
value="1" <?php checked( '1', get_option( 'vpxb_frontend' ) ); ?>/>
<p class="description">Check this option if you want use Pixabay for front-end
editor.</p>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options"
value="vpxb_username,vpxb_key,vpxb_frontend" />
<input type="submit" name="submit" id="submit" class="button button-primary"
value="Save Changes" />
</p>
</form>
<?php } elseif ( $vpxb_active_tab == 'support' ) { ?>
Thank you for choosing WP Pixabay,
<br /><strong>WPclever</strong>
<br />Email: cleverwp@gmail.com
<br />Website: <a href="https://wpclever.net" target="_blank">https://wpclever.net</a>
<?php } elseif ( $vpxb_active_tab == 'buy' ) { ?>
Buy PRO version with only $15 (Paypal) at
<a href="https://wpclever.net/downloads/wordpress-pixabay-search-and-insert">https://wpclever.net/downloads/wordpress-pixabay-search-and-insert</a>
<?php } ?>
</div>
<?php
}
function vpxb_load_scripts() {
if ( ( get_option( 'vpxb_username' ) != '' ) && ( get_option( 'vpxb_key' ) != '' ) ) {
$vpxb_username = get_option( 'vpxb_username' );
$vpxb_key = get_option( 'vpxb_key' );
} else {
$vpxb_username = 'dunghv';
$vpxb_key = '1498928-f190b376157b831824bdfb89b';
}
wp_enqueue_script( 'colorbox', plugin_dir_url( __FILE__ ) . 'js/jquery.colorbox.js', array( 'jquery' ) );
wp_enqueue_style( 'colorbox', plugin_dir_url( __FILE__ ) . 'css/colorbox.css' );
wp_enqueue_style( 'vpxb_css', plugin_dir_url( __FILE__ ) . 'css/vpxb.css' );
wp_enqueue_script( 'vpxb_js', plugin_dir_url( __FILE__ ) . 'js/vpxb.js', array( 'jquery' ), '1.0', true );
wp_localize_script( 'vpxb_js', 'vpxb_vars', array(
'vpxb_username' => $vpxb_username,
'vpxb_key' => $vpxb_key,
'vpxb_ajax_url' => admin_url( 'admin-ajax.php' ),
'vpxb_nonce' => wp_create_nonce( 'vpxb_nonce' )
) );
}
add_action( 'admin_enqueue_scripts', 'vpxb_load_scripts' );
if ( get_option( 'vpxb_frontend', 0 ) == 1 ) {
add_action( 'wp_enqueue_scripts', 'vpxb_load_scripts' );
}
function vpxb_add_button( $editor_id ) {
echo ' <a href="#vpxb_popup" id="vpxb_btn" data-editor="' . $editor_id . '" class="vpxb_btn button add_media" title="Pixabay"><span class="dashicons dashicons-camera vpxb_dashicons"></span> Pixabay</a><input type="hidden" id="vpxb_featured_url" name="vpxb_featured_url" value="" /> ';
}
add_action( 'media_buttons', 'vpxb_add_button' );
function vpxb_save_postdata( $post_id, $post ) {
if ( isset( $post->post_status ) && 'auto-draft' == $post->post_status ) {
return;
}
if ( wp_is_post_revision( $post_id ) ) {
return;
}
if ( ! empty( $_POST['vpxb_featured_url'] ) ) {
if ( strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post.php' ) ) {
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
} else {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
}
$vpxb_furl = sanitize_text_field( $_POST['vpxb_featured_url'] );
vpxb_save_featured( $vpxb_furl );
}
}
}
add_action( 'save_post', 'vpxb_save_postdata', 10, 3 );
function vpxb_save_to_media( $vurl, $vtitle, $vfilename, $vpid ) {
$thumbid = 0;
$filename = pathinfo( $vurl, PATHINFO_FILENAME );
if ( ( $vfilename == '1' ) && ( $vtitle != '' ) ) {
$filename = sanitize_title( $vtitle );
}
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
@set_time_limit( 300 );
if ( ! empty( $vurl ) ) {
$tmp = download_url( $vurl );
$ext = pathinfo( $vurl, PATHINFO_EXTENSION );
$file_array['name'] = $filename . '.' . $ext;
$file_array['tmp_name'] = $tmp;
if ( is_wp_error( $tmp ) ) {
@unlink( $file_array['tmp_name'] );
$file_array['tmp_name'] = '';
}
$thumbid = media_handle_sideload( $file_array, $vpid, $desc = null );
if ( is_wp_error( $thumbid ) ) {
@unlink( $file_array['tmp_name'] );
return $thumbid;
}
}
echo wp_get_attachment_url( $thumbid );
}
function vpxb_save_featured( $vurl ) {
global $post;
$filename = pathinfo( $vurl, PATHINFO_FILENAME );
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
@set_time_limit( 300 );
if ( ! empty( $vurl ) ) {
$tmp = download_url( $vurl );
$ext = pathinfo( $vurl, PATHINFO_EXTENSION );
$file_array['name'] = $filename . '.' . $ext;
$file_array['tmp_name'] = $tmp;
if ( is_wp_error( $tmp ) ) {
@unlink( $file_array['tmp_name'] );
$file_array['tmp_name'] = '';
}
$thumbid = media_handle_sideload( $file_array, $post->ID, $desc = null );
if ( is_wp_error( $thumbid ) ) {
@unlink( $file_array['tmp_name'] );
return $thumbid;
}
}
set_post_thumbnail( $post, $thumbid );
}
function vpxb_popup_content() {
?>
<div style='display:none'>
<div id="vpxb_popup" style="width: 920px; height: 440px; position: relative; overflow: hidden">
<table style="width: 100%; height: 100%; padding: 0; margin: 0; border-spacing: 0; vertical-align: top">
<tr>
<td style="width: 620px; vertical-align: top; padding: 10px">
<select name="vpxb_language" id="vpxb_language" class="vpxb_select">
<option value="en">Language</option>
<option value="en">en</option>
</select>
<select name="vpxb_type" id="vpxb_type" class="vpxb_select">
<option value="all">Type</option>
<option value="all">All</option>
<option value="photo">Photo</option>
<option value="illustration">Illustration</option>
<option value="vector">Vector</option>
</select>
<select name="vpxb_orientation" id="vpxb_orientation" class="vpxb_select">
<option value="all">Orientation</option>
<option value="horizontal">Horizontal</option>
<option value="vertical">Vertical</option>
</select>
<select name="vpxb_editorchoice" id="vpxb_editorchoice" class="vpxb_select">
<option value="false">EditorsChoice</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
<select name="vpxb_order" id="vpxb_order" class="vpxb_select">
<option value="popular">Order</option>
<option value="popular">Popular</option>
<option value="latest">Latest</option>
</select>
<div style="width:100%; display: inline-block; height:28px; line-height: 28px;">
<span style="float:left;">
<select name="vpxb_safesearch" id="vpxb_safesearch" class="vpxb_select">
<option value="false">SafeSearch</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
</span>
<input type="text" id="vpxb_input" name="vpxb_input" value=""
class="vpxb_input vpxb_input-normal" placeholder="keyword" />
<input type="button" id="vpxb_search" class="vpxb_button" value="Search" />
<span id="vpxb_spinner" style="display:none" class="vpxb_loading">&nbsp;</span>
</div>
<div id="vpxb_container" class="vpxb_container">
</div>
<div id="vpxb_page" class="vpxb_page"></div>
</td>
<td style="border-left: 1px solid #ddd; background: #fcfcfc; vertical-align: top; padding: 10px">
<div id="vpxb_use-image" class="vpxb_use-image">
<div class="vpxb_right" style="height: 370px; overflow-y: auto; overflow-x: hidden">
<table class="vpxb_table">
<tr class="vpxb_tr">
<td colspan="2" class="vpxb_td">
<div class="vpxb_item-single" id="vpxb_view"
style="margin-right: 20px;"></div>
</td>
</tr>
<tr class="vpxb_tr">
<td class="vpxb_td">Title</td>
<td class="vpxb_td"><input type="text" id="vpxb_title" value=""
class="vpxb_input"
placeholder="title" />
</td>
</tr>
<tr>
<td class="vpxb_td">Caption</td>
<td class="vpxb_td"><textarea id="vpxb_caption" name="vpxb_caption"
class="vpxb_textarea"></textarea>
</td>
</tr>
<tr>
<td class="vpxb_td">File name</td>
<td class="vpxb_td">
<select name="vpxb_filename" id="vpxb_filename" class="vpxb_select">
<option value="0">Keep original file name</option>
<option value="1">Generate from title</option>
</select>
</td>
</tr>
<tr>
<td class="vpxb_td">Size</td>
<td class="vpxb_td"><input type="number" id="vpxb_width" value="0"
class="vpxb_input vpxb_input-small"
placeholder="width" />
<input
type="number" id="vpxb_height" value="0"
class="vpxb_input vpxb_input-small"
placeholder="height" />
</td>
</tr>
<tr>
<td class="vpxb_td">Alignment</td>
<td class="vpxb_td">
<select name="vpxb_align" id="vpxb_align" class="vpxb_select">
<option value="alignnone">None</option>
<option value="alignleft">Left</option>
<option value="alignright">Right</option>
<option value="aligncenter">Center</option>
</select>
</td>
</tr>
<tr>
<td class="vpxb_td">Link to</td>
<td class="vpxb_td">
<select name="vpxb_link" id="vpxb_link" class="vpxb_select">
<option value="0">None</option>
<option value="1">Original site</option>
<option value="2">Original image</option>
</select>
</td>
</tr>
<tr>
<td class="vpxb_td">&nbsp;</td>
<td class="vpxb_td"><input name="vpxb_blank" id="vpxb_blank" type="checkbox"
class="vpxb_checkbox" /> Open
new
windows
</td>
</tr>
<tr>
<td class="vpxb_td">&nbsp;</td>
<td class="vpxb_td"><input name="vpxb_nofollow" id="vpxb_nofollow"
type="checkbox"
class="vpxb_checkbox" />
Rel
nofollow
</td>
</tr>
</table>
</div>
<p class="vpxb_p" style="margin-top: 10px; width: 100%; display: inline-block">
<input type="hidden" id="vpxb_site" value="" />
<input type="hidden" id="vpxb_url" value="" />
<input type="hidden" id="vpxb_eid" value="" />
<input type="button" id="vpxb_insert" class="vpxb_button" value="Insert" />
<a href="http://wpclever.net/downloads/wordpress-pixabay-search-and-insert"
target="_blank"
onclick="return confirm('This feature only available in PRO version!\nBuy it now?')">
<input type="button" id="vpxb_save" class="vpxb_button_disable" value="Save&Insert" />
</a>
<input type="button" id="vpxb_featured" class="vpxb_button" value="Featured" />
</p>
<div style="display:inline-block">
<span class="vpxb_loading-text" id="vpxb_note"
style="display:none">Saving image to Media Library...</span>
<span id="vpxb_error"></span>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
<?php
}
add_action( 'admin_footer', 'vpxb_popup_content' );
if ( get_option( 'vpxb_frontend', 0 ) == 1 ) {
add_action( 'wp_footer', 'vpxb_popup_content', 100 );
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,298 @@
var vpxb_imgs = {};
var vpxb_selected = new Array();
var vpxb_opened = false;
var vpxb_current = '';
function vpxb_insertatcaret(areaId, text) {
var txtarea = document.getElementById(areaId);
var scrollPos = txtarea.scrollTop;
var strPos = 0;
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
"ff" : (document.selection ? "ie" : false));
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();
range.moveStart('character', -txtarea.value.length);
strPos = range.text.length;
}
else if (br == "ff")
strPos = txtarea.selectionStart;
var front = (txtarea.value).substring(0, strPos);
var back = (txtarea.value).substring(strPos, txtarea.value.length);
txtarea.value = front + text + back;
strPos = strPos + text.length;
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();
range.moveStart('character', -txtarea.value.length);
range.moveStart('character', strPos);
range.moveEnd('character', 0);
range.select();
}
else if (br == "ff") {
txtarea.selectionStart = strPos;
txtarea.selectionEnd = strPos;
txtarea.focus();
}
txtarea.scrollTop = scrollPos;
}
function vpxb_escapehtml(html) {
var fn = function (tag) {
var charsToReplace = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&#34;'
};
return charsToReplace[tag] || tag;
}
return html.replace(/[&<>"]/g, fn);
}
jQuery("#vpxb_search").click(function () {
vpxb_showimages(1);
});
jQuery('.vpxb_btn').live('click', function () {
eid = jQuery(this).attr('data-editor');
jQuery('#vpxb_eid').val(eid)
});
jQuery(document).ready(function (jQuery) {
jQuery('.vpxb_btn').live('click', function () {
if (vpxb_opened) {
jQuery.colorbox({
width : "930px",
height : "460px",
inline : true,
href : "#vpxb_popup",
scrolling: false,
fixed : true
});
} else {
jQuery.colorbox({
width : "648px",
height : "460px",
inline : true,
href : "#vpxb_popup",
scrolling: false,
fixed : true
});
}
});
});
jQuery("#vpxb_page a").live("click", function () {
jQuery('#vpxb_page').html('');
vpxb_showimages(jQuery(this).attr("rel"));
});
jQuery("#vpxb_page-select").live("change", function () {
vpxb_showimages(jQuery(this).val());
});
jQuery("#vpxb_insert").live("click", function () {
for (var i = 0; i < vpxb_selected.length; i++) {
vinsert = '';
valign = '';
valign2 = '';
eid = jQuery('#vpxb_eid').val();
if (jQuery('#vpxb_align').val() != '') {
valign = ' align="' + vpxb_escapehtml(jQuery('#vpxb_align').val()) + '"';
valign2 = ' class="' + vpxb_escapehtml(jQuery('#vpxb_align').val()) + '"';
}
var cid = vpxb_selected[i];
if (vpxb_imgs[cid].img_caption != '') {
vinsert = '[caption id="" ' + valign + ']';
}
if (jQuery('#vpxb_link').val() == 1) {
vinsert += '<a href="' + vpxb_escapehtml(vpxb_imgs[cid].img_site) + '" title="' + vpxb_escapehtml(vpxb_imgs[cid].img_title) + '"';
}
if (jQuery('#vpxb_link').val() == 2) {
vinsert += '<a href="' + vpxb_escapehtml(vpxb_imgs[cid].img_full) + '" title="' + vpxb_escapehtml(vpxb_imgs[cid].img_title) + '"';
}
if (jQuery('#vpxb_blank').is(':checked')) {
vinsert += ' target="_blank"';
}
if (jQuery('#vpxb_nofollow').is(':checked')) {
vinsert += ' rel="nofollow"';
}
if (jQuery('#vpxb_link').val() != 0) {
vinsert += '>';
}
vinsert += '<img ' + valign2 + ' src="' + vpxb_escapehtml(vpxb_imgs[cid].img_full) + '" width="' + vpxb_escapehtml(vpxb_imgs[cid].img_width) + '" height="' + vpxb_escapehtml(vpxb_imgs[cid].img_height) + '" title="' + vpxb_escapehtml(vpxb_imgs[cid].img_title) + '" alt="' + vpxb_escapehtml(vpxb_imgs[cid].img_title) + '"/>';
if (jQuery('#vpxb_link').val() != 0) {
vinsert += '</a>';
}
if (vpxb_imgs[cid].img_caption != '') {
vinsert += ' ' + vpxb_escapehtml(vpxb_imgs[cid].img_caption) + '[/caption]';
}
vinsert += '\n';
if (!tinyMCE.activeEditor || tinyMCE.activeEditor.isHidden()) {
vpxb_insertatcaret(eid, vinsert);
} else {
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, vinsert);
}
}
jQuery.colorbox.close();
});
jQuery("#vpxb_featured").live("click", function () {
vffurl = jQuery('#vpxb_url').val();
jQuery('#vpxb_featured_url').val(vffurl);
jQuery('#postimagediv div.inside img').remove();
jQuery('#postimagediv div.inside').prepend('<img src="' + vffurl + '" width="270"/>');
jQuery.colorbox.close();
});
jQuery("#remove-post-thumbnail").live("click", function () {
jQuery('#vpxb_featured_url').val('');
});
jQuery(".vpxb_item-overlay").live("click", function (event) {
var checkbox = jQuery(this).parent().find(':checkbox');
var checkbox_id = jQuery(this).attr('rel');
jQuery.colorbox.resize({width: "930px", height: "460px"});
vpxb_opened = true;
vpxb_current = checkbox_id;
if (event.ctrlKey) {
if (!checkbox.is(':checked')) {
vpxb_selected.push(checkbox_id);
} else {
vpxb_selected.splice(vpxb_selected.indexOf(checkbox_id), 1);
}
checkbox.attr('checked', !checkbox.is(':checked'));
} else {
if (!checkbox.is(':checked')) {
vpxb_selected = [checkbox_id];
jQuery('#vpxb_popup').find('input:checkbox').removeAttr('checked');
checkbox.attr('checked', !checkbox.is(':checked'));
}
}
jQuery("#vpxb_use-image").show();
jQuery('#vpxb_title').val(vpxb_imgs[checkbox_id].img_title);
jQuery('#vpxb_caption').val(vpxb_imgs[checkbox_id].img_caption);
jQuery('#vpxb_width').val(vpxb_imgs[checkbox_id].img_width);
jQuery('#vpxb_height').val(vpxb_imgs[checkbox_id].img_height);
jQuery('#vpxb_site').val(vpxb_imgs[checkbox_id].img_site);
jQuery('#vpxb_url').val(vpxb_imgs[checkbox_id].img_full);
jQuery('#vpxb_view').html('<img src="' + vpxb_imgs[checkbox_id].img_full + '"/>');
jQuery('#vpxb_error').html('');
jQuery('#vpxb_insert').val('Insert (' + vpxb_selected.length + ')');
jQuery('#vpxb_save').val('Save&Insert (' + vpxb_selected.length + ')');
});
function vpxb_showimages(page) {
if (jQuery("#vpxb_input").val() == '') {
alert('Please enter keyword to search!');
} else {
jQuery('#vpxb_spinner').show();
jQuery('#vpxb_container').html("");
var USERNAME = vpxb_vars.vpxb_username;
var API_KEY = vpxb_vars.vpxb_key;
var PER_PAGE = 8;
var vurl = "https://pixabay.com/api/?username=" + USERNAME + "&key=" + API_KEY + "&lang=" + jQuery('#vpxb_language').val() + "&image_type=" + jQuery('#vpxb_type').val() + "&orientation=" + jQuery('#vpxb_orientation').val() + "&editors_choice=" + jQuery('#vpxb_editorchoice').val() + "&order=" + jQuery('#vpxb_order').val() + "&safesearch=" + jQuery('#vpxb_safesearch').val() + "&q=" + encodeURIComponent(jQuery('#vpxb_input').val()) + "&per_page=" + PER_PAGE + "&page=" + page;
jQuery.ajax({
url : vurl,
dataType: "jsonp",
success : function (data) {
if (data.totalHits > 0) {
jQuery('#vpxb_spinner').hide();
for (var i = 0; i < data.hits.length; i++) {
img_id = data.hits[i].id;
img_ext = data.hits[i].webformatURL.split('.').pop().toUpperCase().substring(0, 4);
img_site = data.hits[i].pageURL;
img_thumb = data.hits[i].previewURL;
img_full = data.hits[i].webformatURL;
img_width = data.hits[i].webformatWidth;
img_height = data.hits[i].webformatHeight;
img_title = String(data.hits[i].tags);
jQuery('#vpxb_container').append('<div class="vpxb_item" bg="' + img_thumb + '"><div class="vpxb_item-overlay" rel="' + img_id + '"></div><div class="vpxb_check"><input type="checkbox" value="' + img_id + '"/></div><span>' +
img_ext + ' | ' + img_width + 'x' + img_height + '</span></div>'
)
vpxb_imgs[img_id] = {
img_ext : img_ext,
img_site : img_site,
img_thumb : img_thumb,
img_full : img_full,
img_width : img_width,
img_height : img_height,
img_title : img_title,
img_caption: ''
};
}
jQuery('.vpxb_item').each(function () {
imageUrl = jQuery(this).attr('bg');
jQuery(this).css('background-image', 'url(' + imageUrl + ')');
});
var vpages = "About " + data.totalHits + " results / Pages: ";
if ((data.totalHits / PER_PAGE + 1) < 10) {
for (var j = 1; j < data.totalHits / PER_PAGE + 1; j++) {
vpages += '<a href="javascript: void (0);" rel="' + j + '" title="Page ' + j + '">' + j + '</a> ';
}
} else {
vpages += '<select id="vpxb_page-select" class="vpxb_page-select">';
for (var j = 1; j < data.totalHits / PER_PAGE + 1; j++) {
vpages += '<option value="' + j + '"';
if (j == page) {
vpages += ' selected';
}
vpages += '>' + j + '</option> ';
}
vpages += '</select>';
}
jQuery('#vpxb_page').html(vpages);
} else {
jQuery('#vpxb_spinner').hide();
jQuery('#vpxb_container').html('No result! Please try again!');
jQuery('#vpxb_page').html('');
}
}
});
}
}
function vpxb_escapehtml(html) {
return html;
}
function vpxb_isurl(str) {
var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|' + // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
return pattern.test(str);
}
//change value
function vpxb_change_value(img_id, img_field, img_value) {
vpxb_imgs[img_id][img_field] = img_value;
}
jQuery("#vpxb_title").change(function () {
vpxb_change_value(vpxb_current, 'img_title', jQuery(this).val());
});
jQuery("#vpxb_caption").change(function () {
vpxb_change_value(vpxb_current, 'img_caption', jQuery(this).val());
});
jQuery("#vpxb_width").change(function () {
vpxb_change_value(vpxb_current, 'img_width', jQuery(this).val());
});
jQuery("#vpxb_height").change(function () {
vpxb_change_value(vpxb_current, 'img_height', jQuery(this).val());
});

View File

@@ -0,0 +1,76 @@
=== WP Pixabay ===
Contributors: wpclever
Donate link: https://wpclever.net/downloads/wordpress-pixabay-search-and-insert
Tags: pixabay, pixabay api, pixabay photos, pixabay image, pixabay images, pixabay search
Requires at least: 4.0
Tested up to: 4.7.1
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
This plugin helps you search millions of free photos, vectors and art illustrations from pixabay.com then insert into content or set as featured image very quickly.
== Description ==
This plugin helps you search millions of free photos, vectors and art illustrations from https://pixabay.com then insert into content or set as featured image very quickly.
= Video =
Let's see how the plugin works in this video
https://www.youtube.com/watch?v=nk40Ce06D4E
= Features =
- Search images with powerful filters
- Quick insert image with original URL into content
- Upload image to Media Library then inserts into content (PRO version)
- Use image as featured image
- Multiple select support (NEW)
= Need support? =
Visit [plugin documentation website](https://wpclever.net "plugin documentation")
== Installation ==
1. Unzip the wp-pixabay-search-and-insert.zip
2. Copy wp-pixabay-search-and-insert folder to wp-content/plugins
3. Go to Installed Plugins, find WP Pixabay and click Active
4. Enjoy!
== Screenshots ==
1. "Pixabay" button
1. Search images with powerfull options
1. User searched image with many purposes
== Changelog ==
= 2.5 =
* Compatible with WordPress 4.7.1
= 2.4 =
* Compatible with WordPress 4.6.1
= 2.3 =
* Compatible with WordPress 4.6
= 2.2 =
* Compatible with WordPress 4.5.3
= 2.1 =
* Compatible with WordPress 4.5.2
= 2.0 =
* Added multiple select support
* Compatible with WordPress 4.5.1
= 1.2 =
* Compatible with WordPress 4.5
= 1.1 =
* Compatible with WordPress 4.4.1
= 1.0 =
* Released