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

filipstefansson on "Tag picker for attachments"

$
0
0

I've added a taxonomy to use tags for attachments like so:

$args = array(/*..*/)
register_taxonomy( 'tags', array('attachment'), $args );

It works fine on the attachment page, but not in the media popup where there's just a basic input field instead of the picker you would expect.

Is this a WordPress bug or am I missing something?


LuciferIAm on "When a post is published, immediately update it after."

$
0
0

This may sound strange to some but how would I set some code so that right after a new post is created (via remote publishing, although that part doesn't matter) Wordpress tells the new post to update itself again. I would think using wp_update_post() must be the way to go about this but beyond that I don't know how. I don't even want nor need to update information in the post, I simply want it to go through the process of updating.

To put it as simply as possible it'd be akin to going to a post that was just published and pressing 'Update' without doing anything else. I realize it might sound strange to some but it's likely the solution to a problem I have not been able to solve nor get help with any where I've looked. So I'd really appreciate a little help :).

Thanks.

iq2002b31 on "Website backend file get deleted even when permission set to read only"

$
0
0

Our company website is constantly get hacked by "UmiTeaSets DoMiTea", they have always posted spam on our website. If we deleted the spam or changed the backend file to read only permission. They will delete all our files and code. And recently they have posted this on our website "UmiTeaSets DoMiTea If you delete it again, will destroy your website!!!!

Can someone to tell me how to stop this?

Ehsan-Hosseini on "security issue in wordpress"

aaron_th on "save_post action not triggering on post meta update"

$
0
0

Hi.

Looks like save_post action is not firing when updating any post meta (e.g. tags, custom fields, categories).

Its only firing when title or post body is updated.

Is there any action which is triggered when post meta is updated?

I'm doing a plugin which broadcasts posts via XMLRPC to other WP blogs. Transfer function is hooked to save_post action and it is working perfectly when creating post or updating title or post body. But its not triggered when one updates tags, custom field or category.

moccc on "How to upload custom field images to wordpress automatically?"

$
0
0

I've about 5000 posts in my wordpress-based blog. All these blog posts contain a custom field named : "Screenshots"
This custom field contains several remote image links which doesn't have any extensions by default. (It's google play apps screenshots image links).
Image links in this custom field are separated with a ; character .
How can I upload these images to my own wordpress media library and then change the image link values to the new ones automatically ?
A sample post's screenshots custom field value :
https://lh3.googleusercontent.com/66dpQlA5aHuLURg8zFt4MT3UmB4wnw99pNaKu6gO3ker3M44Q_6egy5cBzXYXf8MSjg;https://lh3.googleusercontent.com/WZrmkq2nee2f4r6X_uOe8crhoh0iF4WDA0RL1YJdu0R3Ez4EebAsbCn6fZt6c3aPGLo;https://lh3.googleusercontent.com/1khQ51c9y_v1ZugrA6dYkJ6UUuJ3AWsNhTGrAzD_lc5TnRHCOCt6Ka8RvSsmhxRtlg;https://lh3.googleusercontent.com/2Tg4U7ixeldgl4KzyYcO9MabgbhHGqehyUWK-1y3RpnRFwMo-t9LTfJD9SfAXBv1rT8;https://lh3.googleusercontent.com/heS9QejeNhhw0gO1Cx0-AGZZcuzbTVr3k8HGB6QXX1ADZp8qtpH9DMn4ybFVGrHhIC4;https://lh3.googleusercontent.com/saos8uQ1eaynxYDH04ZpZCTzkXIeSaXlJd74zEMmDs-pvkxnjCWwIBWx1ukxi0-T1w;https://lh3.googleusercontent.com/mWWFF4dGhTLO5a8WGoiPoD0zx_ge8fEDZej--8aw1fFkFBZkhv1QAmizhicF3-yxAH0;https://lh3.googleusercontent.com/r3bcAKJyROutXMQUtG9TX7xyM3925aPXGpwm1KJIzNE6nM8Rz4XmzgEzM6nymDDXN-g;https://lh3.googleusercontent.com/Y5s4ASDTy00kY6ka2goYrfo5Gz7fTwN0RM7wfXtxfalQfR10-VF0ewUH7yMl6_inPVr6;https://lh3.googleusercontent.com/6HpVi0AWg0s0uWFczyzS_zjYCbfmaECgbpPTgKqjSjhVOF0B8uAKWF07E9sZLjHzCKuW;https://lh3.googleusercontent.com/frvVe94alyYjX-x4ifT6Za1DFKWgjJ5nkQO0xayC3fWjk0bZ252YlJwXC1oG3xcemA;https://lh3.googleusercontent.com/gvTUf_wzfcwKw7m1zqg6Ei5_7OfXqB86zCiGOlGnXc7QOZ01sIuk2RZP6Nf0pa-rzg;https://lh3.googleusercontent.com/66dpQlA5aHuLURg8zFt4MT3UmB4wnw99pNaKu6gO3ker3M44Q_6egy5cBzXYXf8MSjg;https://lh3.googleusercontent.com/WZrmkq2nee2f4r6X_uOe8crhoh0iF4WDA0RL1YJdu0R3Ez4EebAsbCn6fZt6c3aPGLo;https://lh3.googleusercontent.com/1khQ51c9y_v1ZugrA6dYkJ6UUuJ3AWsNhTGrAzD_lc5TnRHCOCt6Ka8RvSsmhxRtlg;https://lh3.googleusercontent.com/2Tg4U7ixeldgl4KzyYcO9MabgbhHGqehyUWK-1y3RpnRFwMo-t9LTfJD9SfAXBv1rT8;https://lh3.googleusercontent.com/heS9QejeNhhw0gO1Cx0-AGZZcuzbTVr3k8HGB6QXX1ADZp8qtpH9DMn4ybFVGrHhIC4;https://lh3.googleusercontent.com/saos8uQ1eaynxYDH04ZpZCTzkXIeSaXlJd74zEMmDs-pvkxnjCWwIBWx1ukxi0-T1w;https://lh3.googleusercontent.com/mWWFF4dGhTLO5a8WGoiPoD0zx_ge8fEDZej--8aw1fFkFBZkhv1QAmizhicF3-yxAH0;https://lh3.googleusercontent.com/r3bcAKJyROutXMQUtG9TX7xyM3925aPXGpwm1KJIzNE6nM8Rz4XmzgEzM6nymDDXN-g;https://lh3.googleusercontent.com/Y5s4ASDTy00kY6ka2goYrfo5Gz7fTwN0RM7wfXtxfalQfR10-VF0ewUH7yMl6_inPVr6;https://lh3.googleusercontent.com/6HpVi0AWg0s0uWFczyzS_zjYCbfmaECgbpPTgKqjSjhVOF0B8uAKWF07E9sZLjHzCKuW;https://lh3.googleusercontent.com/frvVe94alyYjX-x4ifT6Za1DFKWgjJ5nkQO0xayC3fWjk0bZ252YlJwXC1oG3xcemA;https://lh3.googleusercontent.com/gvTUf_wzfcwKw7m1zqg6Ei5_7OfXqB86zCiGOlGnXc7QOZ01sIuk2RZP6Nf0pa-rzg
I want a bulk process for mass number of posts (If it's possible)
Thank you.

grincho on "Copy data into table / multidimensional array"

$
0
0

Hello again,

Scenery: I want to copy data from "wp_users" to another table "user".
SQL
INSERT INTO user(wpUserId, email) SELECT ID, user_email FROM {$wpdb->users} GROUP BY ID;
woulde be sooo easy. So it's software development and it's never "easy" and wpdb has query and insert.

query combined with prepare reports an error, it's about quoting.

$results = $wpdb->get_results(
			$wpdb->prepare(
			"
			INSERT INTO %s ( 'wpUserId', 'email' )
			SELECT ID, user_email FROM {$wpdb->users} GROUP BY ID;
			", $tabname
			)
	);

For the insert I have to split the sql up. So started to get the info

$results = $wpdb->get_results(
			"
			SELECT ID as wpUserId, user_email as email FROM {$wpdb->users} GROUP BY ID;
			", ARRAY_A
);

which results in

Array
	(
	    [0] => Array
	        (
	            [wpUserId] => 1
	            [email] => test@mail.com
	        )

	    [1] => Array
	        (
	            [wpUserId] => 2
	            [email] => anothertest@mail.com
	        )
	)

How to transform that in a key => value array for the insert?
Or is there an easier way which I overlooked?

mbansak on "Hide page sections based on user role in Visual Composer"

$
0
0

I am trying to hide certain page sections based on user role in Visual Composer by adding Custom Content Shortcode in two text blocks. The first text block is at the top of the content I want to hide to all but admins and contains:

[is role=administrator]

The second text block, at the bottom of the content I want to hide, contains the closing tag,

[/is]

This is doing what it's supposed to and hiding the content, however, Visual Composer doesn't seem to like it, VC shortcode winds up getting outputted to the page for logged-in admins, i.e. [/vc_column]. I can't get it to not display the VC shortcode. It's strange too that it only outputs the shortcode for admins.

If there is a different or better way to do what I'm trying to accomplish, I'm open to any solutions! I just want certain page sections to only be visible to admins. Thanks in advance!


atxelin on "WooCommerce multiple select a variation?"

craigcmurray on "Custom Post types assistance"

$
0
0

I am working on a plugin using Custom Post types. These custom post types will be events. people will be registered (not from front end right now) for an event by an administrator and assigned to a specific age group for that event. I have the custom post type created and have added all the custom fields i need. I have the list and detail pages working. The next step is to show all people registered for the event organized by age groups. Would it be best to create users in wordpress (as ultimately at a later date i will have them login and register themselves).? How would i add on the admin side the ability to assign a user to a an age group within an event? how would i show the list of users assigned to each age group on the front end?

thank you in advance for your assistance.

tompoezie on "Custom theme with less"

$
0
0

Hi,

I made an empty base-theme for theme development. I would like to use less instead of css. WordPress requires a file style.css in the theme folder (/wp-admin/themes.php -> "Stylesheet is missing."). Is there a way to bypass this check, or change the check to style.less? (Without modifying core files of course)

Kind regards,
Tom

aliuskon on "Shortcode issue with less-than sign"

$
0
0

Let say I write:

\( a<c \)

[caption ...]<img ...> My figure[/caption]

Caption shortcode is not processed. But if I change the code to:

\( a>c \)

[caption ...]<img ...> My figure[/caption]

Caption shortcode is processed as usual. The only difference is that I have changed < to >.

A similar problem occurs if I just use: [latex]a<c[/latex]. WP sees that as a single "empty" shortcode (just [latex]) and some unrelated text (namely the a<c[/latex] part) afterwards. Changing < to > once again "solves" the issue.

So I believe there are some problems with HTML cleanup and Shortcode API. I believe these problems might be related to fixes of Shortcode API done in 4.2.3.

So far I can bypass the problem by changing < into <, but this is not proper LaTeX.

elliottjb7 on "Conditional image based on post date range"

$
0
0

Hi I'm trying to output a image based on the age of a post.

For instance with the loop, I want to say: IF the post's date is younger than 3 days, display the premium icon next to the post, ELSE, IF the post is older than 3 days, display the general icon next to the post.

Thank you in advance for any help.

[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

<?php global $wp_query;
query_posts( array(
	'post_type' => 'job_listing' ,
	'showposts' => 5 )
); ?>
<?php if ( have_posts() ): ?>
<div class="shortcode post archive grid two-column">
	<div class="grid-row linearise">

		<div class="grid-item">
			<article class="unboxed">
				<div class="content">
					<div class="typography">
					<table style="width:100%">
						<tr>
							<th>STATUS</th>
							<th>JOB TITLE</th>
							<th>LOCATION</th>
							<th>POSTED</th>
						</tr>

<?php while ( have_posts() ) : the_post(); ?>
						<tr>
							<td class="status">
							<?php if ( $postDate < $todaysDate || $postDate == $todaysDate ) { ?>
							<img src="<?php bloginfo('template_directory');?>-child/images/icon-premium.png"/>
							<?php else: ?>
							<img src="<?php bloginfo('template_directory');?>-child/images/icon-general.png"/>
							<?php endif; ?>
							*</td>
<?php endwhile; ?>
							<td><a>"><?php the_title(); ?></a></td>
							<td><?php the_job_location( false ); ?></td>
							<td><span class="datetime"><?php echo get_the_date( "d/m/Y" ); ?></span></td>
						</tr>
					</table>
					<p>*Premium jobs are jobs between 1-3 days old. You can view all of our other jobs at any time.</p>
					</div>
				</div>
			</article>
		</div>
<?php if ( have_posts() ): ?>
	</div>
</div>
<p><a>/jobs" target="_self" class="button small">See all of our jobs</a></p>
<?php endif; ?>
<?php else: ?>
<article class="unboxed">
	<div class="content">
		<div class="typography">
			<p>Alternative Content</p>
		</div>
	</div>
</article>
<?php endif; ?>

eljass on "Custom wordpress dashboard"

$
0
0

Hey,

I want to change look of the wordpress admin dashboard and I know how to add own widgets on it. But the way I'm trying to customize it is different.

Let's say that I have html template of beautiful dashboard and I would love to make wp dashboard page look like it. So I go and redirect dashboard page to that template's file and all works except that I need that html file to be hidden behind wp login, so that nobody could access that throught the url. Is there any possible way to ensure that user is logged in before entering a page which isn't inside wordpress? Or is there some other way to fully customize that dashboard page (get rid of the widgets and fully redesign it

Thanks,
Eljas

darksith on "pdf upload to media library using php script"

$
0
0

Hello,

I thought i could use media_sideload_image to upload a pdf file via php, the same way it works for images but i could not succeed. And could not find any sample allowing to do it.

The pdf is stored via an external process on a server temp dir , and just need to include in the media library the same way or close the media_sideload_image does it.

If someone have the solution could be great.

Thks in advance

Rgds

Ps : pretty new on this site, apologies if question was already submitted


Pol0023 on "iframe video gallery"

$
0
0

Hi I'm making a personal website for a porn Actor. He want insert videos using iframe codes from the producer companies.
I can insert it just pasting the iframe code in the text editor but no gallery plugin accepts it. They show me nothing or just don't recognize the video.
I want to make a video gallery, someone know how could I fix it?

Just if someone wants try it:
EXPLICIT CONTENT---
</iframe>">Video iframe code

masonify on "Custom meta data for taxonomy's not saving"

$
0
0

Created a CPT ("officers"), and registered a custom taxonomy ("officerspos") for that CPT. I have excluded the CPT code below as there is no problem with it.

The custom meta data field shows up fine on both the add and edit screens (I'm wanting to use it for sorting purposes)

I can't however seem to get the values to save and retrieve.

Codes as follows:

Register taxonomy

//Register custom taxonomy' (3 of them below) NOTE: hierarchical true makes them select boxes
    register_taxonomy("officerspos", array("officers"),
        array("hierarchical" => true,
            "label" => "Officer Positions",
            "singular_label" => "Officer Position",
            "rewrite" => true,
            ));

Add sort field to add taxonomy screen

function officers_taxonomy_meta_field() {
    // this will add the custom meta field Sorting Order to the Add new taxonomy page for officers postions
    ?>
    <div class="form-field">
        <label for="sort_meta[custom_sort_meta]">Sorting Order</label>
        <input type="text" name="sort_meta[custom_sort_meta]" id="sort_meta[custom_sort_meta]" value="">
        <p class="description">Numeric Value 1 to 1000, 1 being the top of the sort order.</p>
    </div>
    <?php
}
add_action( 'officerspos_add_form_fields', 'officers_taxonomy_meta_field', 10, 2 );

Add sort field to edit taxonomy screen

function officers_taxonomy_edit_meta_field($sort) {

    // put the sort ID into a variable
    $s_id = $sort->sort_id;

    // retrieve the existing value(s) for this meta field. This returns an array
    $sort_meta = get_option( "taxonomy_$s_id" ); ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="sort_meta[custom_sort_meta]">Sorting Order</label></th>
        <td>
            <input type="text" name="sort_meta[custom_sort_meta]" id="sort_meta[custom_sort_meta]" value="<?php echo esc_attr( $sort_meta['custom_sort_meta'] ) ? esc_attr( $sort_meta['custom_sort_meta'] ) : ''; ?>">
            <p class="description">Numeric Value 1 to 1000, 1 being the top of the sort order.</p>
        </td>
    </tr>
    <?php
}
add_action( 'officerspos_edit_form_fields', 'officers_taxonomy_edit_meta_field', 10, 2 );

Save taxonomy fields callback function

function save_taxonomy_custom_meta( $sort_id ) {
    if ( isset( $_POST['sort_meta'] ) ) {
        $s_id = $sort_id;
        $sort_meta = get_option( "taxonomy_$s_id" );
        $cat_keys = array_keys( $_POST['sort_meta'] );
        foreach ( $cat_keys as $key ) {
            if ( isset ( $_POST['sort_meta'][$key] ) ) {
                $sort_meta[$key] = $_POST['sort_meta'][$key];
            }
        }
        // Save the option array.
        update_option( "taxonomy_$s_id", $sort_meta );
    }
}
add_action( 'edited_officerspos', 'save_taxonomy_custom_meta', 10, 2 );
add_action( 'create_officerspos', 'save_taxonomy_custom_meta', 10, 2 );

any help on why this won't save and recall would be greatly appreciated.

masonify on "Populate custom taxonomy with data/content"

$
0
0

Have a number of custom taxonomy's associated with Custom Post types. Although they need the ability to be edited, I would like the plugin to auto-populate a starting set of values in these taxonomy's

For instance If I had a taxonomy that allowed the user to pick Mr. or Mrs. Miss etc... I would like the plugin to include the popular ones when installed.

What's the best way of achieving this?

Grigory Volochiy on "Receive data from remote server and save it in data base by plugin"

$
0
0

I'm writing a plugin, which should be able receive data from remote server and save data to the site Data Base.

The main problam is that if I try to send request from remote server to the .php file that uses native WordPress functions - the WP ignores this request and the script does not receive any data.

The solution which I found is the next:
I receive the data (from remote server) by using .php file that saves this data in the .txt file. After that, I invoke .php file that use native WP functions and save data from this file to the Data Base. I understand that this is like a cheat the WP security.

But I need to know: is here a way to receive data from remote server and directly save to the Data Base using native WP classes for working with Data Base, without using extra file like that .txt file.

Also, using native WP function with DataBase makes the work more safe.

I already used the "Plugin API/Action Reference/admin post (action)". But it allows to receive data as logged site admin (like from my own admin page). I need to receive data from remote server by the plugin without admin access, and I can take the risk on myself, but I want to use the native WP functions to receive that request and work with DataBase.

Is it possible?

MaleneHansen on "Make shortcode return shortcode?"

$
0
0

Can I make a shortcode in functions.php that returns a shortcode?

I have tried to make my shortcode return a string with the shortcode and also to return a string with some html and the shortcode. But it just prints the shortcode as text.

Viewing all 8245 articles
Browse latest View live




Latest Images