Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

Meitar on "$network_wide argument on plugin activate hook in multisite always empty string?"

$
0
0

I'm seeing strange behavior contrary to the WordPress documentation as well as contradicting this WP StackExchange answer regarding the value of the $network_wide argument for plugin activation hooks. Specifically, no matter when/where I test the value of $network_wide, the value is always an empty string. Example code/test case:

<?php
/**
 * A test plugin for the network_wide argument.
 *
 * WordPress plugin header information:
 *
 * * Plugin Name: Test Plugin
 * * Plugin URI: http://example.com/
 * * Description: This plugin tests whether or not the network_wide argument is correctly passed.
 * * Version: 0.1
 * * Author: Meitar <meitarm+wordpress.org@gmail.com>
 * * Author URI: https://maymay.net/
 * * License: GPL-3
 * * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
 */

function test_plugin_activate($network_wide) {
    var_dump($network_wide);
    exit();
}
register_activation_hook(__FILE__, 'test_plugin_activate');

When activated on a subdomain-based multisite install, this code produces an error:

Plugin could not be activated because it triggered a fatal error.

string(0) ""

My first instinct is to assume I have done something wrong. I am using a VVV multisite development environment and still get this error.

I have searched Core Trac but the only ticket that seems relevant (ticket:14170) seems to have been closed years ago.

Am I missing something obvious or is this a regression?

P.S. I asked this over on StackExchange, too.


Kevin on "Unzipping files immediately after upload"

$
0
0

So I thought I had this working but now am having some issues.

Basically, I'm trying to automatically unzip files when they are being uploaded within posts belonging to the CPT "publications". The trouble I am having is with the following lines of code:

// Unzip the file after upload
function sbh_after_upload( $file ) {

  $upload_dir = wp_upload_dir();
  $pub_dir = $upload_dir['basedir'] . '/publications';
  $extension = substr( strrchr( $file['file'], '.' ), 1 );

  if( $extension == 'zip' ) {

    require_once( ABSPATH .'/wp-admin/includes/file.php' );

    WP_Filesystem();

    $unzip = unzip_file( $file['file'], $pub_dir );

    if( !$unzip ) {
        echo 'There was a problem unzipping the file.';
    }
  }
  return $file;
}
add_filter( 'wp_handle_upload', 'sbh_after_upload' );

The issue seems to be with the unzip function itself. I've done some troubleshooting, and for some reason nothing is being generated in the /publications directory. I've tried using the php's zipArchive class which doesn't seem to work either.

Chris Huff on "Query posts of a certain category AND all pages"

$
0
0

Is it possible to query posts only of a certain category AND ALSO all pages? As soon as I add the cat => '1' parameter, it only queries posts (obviously, as expected). But I want pages included as well, which don't have categories assigned. Is this possible?

$args = array(
    'post_type' => array('any'),
    'post_type' => $post_types,
    'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
    'order' => 'DESC',
    'orderby' => 'id',
    'meta_query' => array(
        array(
            'key' => '_thumbnail_id',
            'value' => '?',
            'compare' => 'NOT EXISTS'
            )
        ),
    <strong>if(is_single()){echo 'cat' => '1',}</strong>
    'posts_per_page' => 5,
    );

That doesn't work (and I wouldn't expect it to), but is there something like that which does?

modparlor on "How do I create a custom post type upon plugin activation?"

$
0
0

Hoi.

I'm currently building a plugin for WP (my first) and would like to create a custom post type when the plugin is activated. Is it possible to do that and if so, which functions would I use? ...I also need a function to somehow list all custom content types in the related WP installation in order to check if the custom post type i want to create already exists.

Thanks for any help.

MidouCloud on "Custom plugin permissions"

$
0
0

Im making my own plugin and i looking for a plugin or a way to create custom permissions for different options on the plugin. Someone can help me?

gotmedia on "How to remove core rotate image feature?"

$
0
0

Hi there,

Is there a way to remove the rotate image feature when someone goes to Edit Image?

Guido on "Pagination in sidebar widget"

$
0
0

Hi,

I'm the developer of the VSEL plugin. It contains a widget to list events in a sidebar. Today an user told me the pagination (next/prev post) doesn't work in the widget. Did not know this but now understand why because the event list isn't displayed on a page.

Is there an alternative available for the pagination feature?

Guido

byronpk on "Editing existing pre-created menus in PHP"

$
0
0

Hi y'all!

Here's my pickle. I'm using a script to automatically create a fully pledged WordPress site. In this process new pages, etc are created automatically. I now need a way to add the newly created page(s) to an existing menu on site from the script (this menu was created automatically by the theme I us and is pre-filled with links to some demo pages).

The script has full access to all WordPress functions, but I cannot use hooks (since this is all run before the site is even up). Is there a way to pull an existing menu into the script and change it's contents?

Thanks in advance! :)


Advanced SEO on "How to compress original image during upload?"

$
0
0

WordPress will compress scaled thumbnails of picture during upload, but, original image will be is same quality.

I am trying to compress original image too. I wish to make image in original resolution available for users, but to compress it and save disk space. For example original 16 MP, hi resolution image can be 5 MB, but after applying 85% compression filter it can be 2-3 MB without noticeable quality loss.

Also I need to preserve image EXIF data.

Solution (need tweak):

This function will compress original photo too, but it will strip EXIF/IPTC data too.

function wt_handle_upload_callback( $data ) {
    $image_quality = 85; // 85% commpresion of original image
    $file_path = $data['file'];
    $image = false;

    switch ( $data['type'] ) {
        case 'image/jpeg': {
            $image = imagecreatefromjpeg( $file_path );
            imagejpeg( $image, $file_path, $image_quality );
            break;
        }

        case 'image/png': {
            $image = imagecreatefrompng( $file_path );
            imagepng( $image, $file_path, $image_quality );
            break;
        }

        case 'image/gif': {
            // No 'image quality' option
            break;
        }
    }

    return $data;
}
add_filter( 'wp_handle_upload', 'wt_handle_upload_callback' )

How to preserve EXIF data, and to compress original image?

cyrilledefrance on "Random article on gridsby theme"

$
0
0

Hello
Wordpress 4.4.2
Theme Gridsby
Modele page: home page.

i want to have a lot of random article in my home page but the code orderby=> rand doesn't work correctly.....

if i write this code, i have a probleme:

Article Everything is good in the disorder, but link too.....

<?php else :

global $post;

// Set the photo length
if ( get_theme_mod( 'photos_length' ) ) :

if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) :

// Set Ascending
$args = array( 'post_type' => 'post', 'posts_per_page' => get_theme_mod( 'photos_length', '20' ), 'order' => 'ASC', 'tax_query' =>
array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-image',
)));

else :

// Set Descending
$args = array( 'post_type' => 'post', 'posts_per_page' => get_theme_mod( 'photos_length', '20' ), 'tax_query' =>
array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-image',
)));

endif;

else :

if ( 'option1' == gridsby_sanitize_index_content( get_theme_mod( 'gridsby_post_time_method' ) ) ) :

// Set Ascending
$args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'order' => 'ASC', 'tax_query' =>
array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-image',
)));

else :

// Set Descending
$args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'tax_query' =>
array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-image',
)));

endif;

endif;

$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>

<?php get_template_part( 'content', 'pf-image' ); // Post Format Image ?>

<?php endforeach; ?>

<?php endif; ?>

denburt on "Trying to list my childpages properly ordered"

$
0
0

I used the following line of code in a function so I can display the child pages as links and it works great however the links are being returned in the order that the pages were created and not like the menu, I must have missed something somewhere. If I change the order numbers that will work but who wants to do that. I structured the menu so they are alphabetical but iot may not stay that way. I just want my function to follow the menu.

'$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );'

perthmetro on "query_posts is preventing viewing page2"

$
0
0

I have a very normal loop inside my index.php I am using for my home page. I also have <?php query_posts( 'order=asc' ); ?> above this loop... like so,

<?php query_posts( 'order=asc' ); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>

Now whenever I try to click on page 2 it keeps me on page 1Any ay to fix this so I don't need to change my loop code.

davidrivera on "How can I turn this into a Shortcode?"

$
0
0

I am pulling images from a custom post type, and really need to know how to turn the following into a shortcode:

<img src="<?php echo get_post_meta($post->ID, 'productcms_wp_image_url_0', true) ?>"/>

Any help would be greatly appreciated!

IslandWoman on "My site have been been hacked"

$
0
0

Recently all of my 17 wordpress sites have been hacked.

This is the sequence I have just gone though to clean up the sites:
1.updated all usernames and passwords including databases and FTP
2.Backup all contents and wp-config.php for each site and delted all other files.
3. downloade a fresh copy of wordpress 4.4.2 zip and manually reinstalled to all website.
4. installed Wordfence and Sucuri plugins and activated.
5. Scans results came out clean for all.

So now I am thing all is well.
Two hours later this file wp-check.php appeared on all the cleaned websites. I deleted it.

wp-check.php keeps reappering with this code in it:
[removed]

Can anyone tell if this is a malicious code? And how this file keeps reapping?

sharkonda on "Use Custom Fields as thumbnails"

$
0
0

Hi, I'm using SimplePress theme with an epanel slider.
I'm not very proficient with PHP, so I hope someone can point me in the right direction: The site is thebellevuelocksmith.com and as you can see, the thumbs under the slider are generated with print_thumbnail and are the same as the slider images - what I want to do is call on each page's Custom Field named 'Thumbnail' which contains an url to the custom icon i would like displayed for each slider.
Here's the current code for the lower area:

<?php for ($i = 1; $i <= $featured_num; $i++) { ?>
       	  <div class="item">
              <div class="wrap <?php if($i == 1) echo('active'); ?>">
               	  <span class="image" style="background-image: url(<?php print_thumbnail($arr[$i]["thumb_small"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"], $width_small, $height_small, '', true, true); ?>);"><img src="<?php bloginfo('template_directory'); ?>/images/slider-thumb-overlay.png" alt="" /></span>
                  <div class="hover">
                      <span><?php echo esc_html($arr[$i]["fulltitle"]); ?></span>
                      <br class="clear" />
                      <?php echo($arr[$i]["excerpt_small"]); ?>
                  </div>
              </div>
          </div>
          <?php }; ?>

Hope someone can help, thanks in advance.


gunnerman1 on "Elements that utilize ::before and ::after behavior in php"

$
0
0

I am having a problem with how my template is handling html code that utilizes the :before and :after css properties. It seems the evaluation of the html and css is out of sync when parsed in the php file.

Background:
My header.php has the code:

<p class="top-message">
<?php
    if ($pagename === 'PageA') {
        echo converio_sanitize_text_decode('Some simple html');
    } elseif ($pagename === 'PageB') {
        echo converio_sanitize_text_decode('Some simple html');
    } elseif ($top_header_msg <> '') {
        echo converio_sanitize_text_decode($top_header_msg);
    }
?>
</p>

I should note the functions converio_sanitize_text_decode is theme code and is not mine but it is pretty trivial so I will post it and is defined as:

function converio_stripslashes( $string ) {
    if(get_magic_quotes_gpc()) {
        return stripslashes($string);
    } else {
        return $string;
    }
}

function converio_sanitize_text_decode( $string ) {
	return converio_stripslashes(htmlspecialchars_decode($string));
}

This problem lies in the last else if where $top_header_msg =

<a class="call_button" href="tel:+1-505-555-5555" role="button">
	<span class="cb">call us: (505) 555-5555</span>
	<div class="ci">
		<i class="fa fa-phone"></i>
		<i class="fa fa-check"></i>
	</div>
</a>

The css:

.call_button {
  display: block;
  background-color: #820024;
  width: 300px;
  height: 40px;
  line-height: 40px;
  margin: auto;
  color: #fff;
  position: relative;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  cursor: pointer;
  overflow: hidden;
  border-radius: 5px;
  box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.3);
  -webkit-transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
  transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
}
.call_button span.cb, .call_button .ci {
  display: block;
  height: 100%;
  text-align: center;
  position: absolute;
  top: 0;
}
.call_button span.cb {
  width: 84%;
  line-height: inherit;
  font-size: 22px;
  text-transform: uppercase;
  left: 0;
  -webkit-transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
  transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
}
.call_button span.cb:after {
  content: '';
  background-color: #66001B;
  width: 2px;
  height: 70%;
  position: absolute;
  top: 15%;
  right: -5px;
}
.call_button .ci {
  width: 16%;
  right: 0;
  -webkit-transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
  transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4);
}
.call_button .ci .fa {
  font-size: 30px;
  vertical-align: middle;
  -webkit-transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4), height 0.25s ease;
  transition: all 0.25s cubic-bezier(0.31, -0.105, 0.43, 1.4), height 0.25s ease;
}
.call_button .ci .fa-phone {
  height: 30px;
}
.call_button .ci .fa-check {
  display: none;
}
.call_button.success span.cb, .call_button:hover span.cb {
  left: -72%;
  opacity: 0;
}
.call_button.success .ci, .call_button:hover .ci {
  width: 100%;
}
.call_button.success .ci .fa, .call_button:hover .ci .fa {
  font-size: 40px;
}
.call_button.success {
  background-color: #27ae60;
}
.call_button.success .ci .fa-phone {
  display: none;
}
.call_button.success .ci .fa-check {
  display: inline-block;
}
.call_button:hover {
  opacity: .9;
}
.call_button:hover .ci .fa-phone {
  height: 40px;
}
.call_button:active {
  opacity: 1;
}

The problem is it seems to be closing <p class="top-message"> before the html contained in $top_header_msg is fully evaluated. The end result is:

<p class="top-message">
    <a class="call_button" href="tel:+1-505-555-5555" role="button">
        <span class="cb">call us: (505) 555-5555::after</span>
    </a>
</p>
<div class="ci">
    <a class="call_button" href="tel:+1-505-555-5555" role="button">
        <i class="fa fa-phone">::before</i>
        <i class="fa fa-check">::before</i>
    </a>
</div>
<a class="call_button" href="tel:+1-505-555-5555" role="button"></a>

You can see the </p> tag is entered prematurely and produces undesired results. What I need to happen:

<p class="top-message">
	<a class="call_button" href="tel:+1-505-555-5555" role="button">
	<span class="cb">call us: (505) 555-5555 ::after</span>
	<div class="ci">
		<i class="fa fa-phone">::before</i>
		<i class="fa fa-check"></i>
	</div>
        </a>
</p>

I only get this behavior in the html here when ::before and ::after properties are utilized. I have tried searching for how to resolve this but to be honest am not quite sure what to search for and have been unsuccessful in finding any info.

Would greatly appreciate any insight.
Thanks

simbaclaws on "Is there a hook for user passwords during registration?"

$
0
0

I would like to know whether I'ts possible to get the user password at registration and store it inside a different database with different encryption. I'm about to create a plugin that is for a gameserver where I want users that register on my wordpress site to automatically have an account for the gameserver with the same username and password with which they've registered with.

If there is no hook to it, I would have to hack the core of wordpress. Which honestly I think is not such a good idea and I would like it to be modular so that it works on any wordpress site like with plugins and not just one single modified wordpress installation.

If it's only possible to get the encrypted password then I'll have to change the encryption of the gameserver passwords itself, which is quite a hard task and not a good one because when upgrading to newer versions of that server it will cause it to reset it to the encryption that they are using...

Another solution would be to change the registration form of wordpress to have 2 passwords, one for the site and one for the game server. But it's not an ideal solution...

Any ideas?

Also sorry for posting my question on the wrong forum previously.

madaboutu on "wp-check.php Should it be there?"

$
0
0

Hey there, I seem to have a file in the root of my WP which looks like it may be bad. the name is wp-check.php

I found this along with wp-tmp.php across a few sites infact and so deleted them in each. Thing is the wp-check.php file seems to come back an hour or so later.

There isn't anything at this moment wrong with the sites that I can see - but I'd love to know if anyone can shed any light on this or have experience the exact same?

here are the contents of the file

[removed]

I did also notice that one or two files which came back had been apended with .suspected on the end of it

csleh on "have 2 category pages - 1 with sub-category listing, 1 with all posts"

$
0
0

I currently have a category page that lists subcategories with a link to see all posts in just that sub-category. At the bottom of the page is a list of all posts, regardless of sub-category. This works but is inelegant and not particularly user friendly.

Is there a way to have a link to show all posts in a separate page(s)? I thought about creating a new post and setting up a custom template but it seems like extra work for something that is probably easy to do.

sunnydar on "Grab search terms from wordpress search"

$
0
0

I have two different search methods on my site. My theme (enfold) has a built-in ajax search that's pretty good). I also use the plugin, sabai directory, which has it's own directory search. unfortunately, sabai directory doesn't use custom taxonomies/post types in any normal way, so no search plugins can find any of the pages sabai directory creates.

Is it possible, to grab the search keywords from the theme search and show results from both the theme search and the directory search on the same page?

As a side note, I've tried using plugins like relevanssi and wpsearch to improve search, but they can't find the sabai directory pages/listings either.

Viewing all 8245 articles
Browse latest View live




Latest Images