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

nexxoz on "[HELP] Upload to MEDIA library"

$
0
0

Im currently working on a plugin to my project and i want users to be able to upload images to the media library the problem is that the code dosen't make a thumbnail image or add watermark by the Easy watermark plugin, help plz

if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' );
	$uploadedfile = $_FILES['myfile'];
	$upload_overrides = array( 'test_form' => false );
	$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );

		if ( $movefile ) {
		    $wp_filetype = $movefile['type'];
		    $filename = $movefile['file'];
		    $wp_upload_dir = wp_upload_dir();
		    $attachment = array(
		        'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
		        'post_mime_type' => $wp_filetype,
		        'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
		        'post_content' => '',
		        'post_status' => 'inherit'
		    );
		    $attach_id = wp_insert_attachment( $attachment, $filename);
		    $text = 'Image uploaded! Waiting to be accepted by admins';
		}

	}

	if(empty($text)){

	echo '<form role="form" method="post" enctype="multipart/form-data">';
	echo '  <div class="form-group">';
	echo '    <label for="exampleInputFile">Välj fil</label>';
	echo '    <input type="file" name="myfile">';
	echo '   <p class="help-block">Minst 250x250px</p>';
	echo '  </div>';
	echo ' <button type="submit" name="ch-upload" class="btn btn-default">Ladda upp</button>';
	echo '</form>';

	}else{
		echo $text;
	}

andy999 on "Sort users by meta_value_num"

$
0
0

Been trying some things to output some users and sort by a meta_value_num, but nothing I try works and I can't find anything online about it.

This one's a real challenge.

<?php
$args = array(
    'orderby' => 'meta_value_num',
    'meta_key ' => 'rank',
    'order' => 'DESC',
);

// The Query
$user_query = new WP_User_Query( $args );

// User Loop
if ( ! empty( $user_query->results ) ) {
    foreach ( $user_query->results as $user ) {
        echo '<p>' . $user->display_name . '</p>';
    }
} else {
    echo 'No users found.';
}
?>

I can get the meta value for each author on author.php easily enough but I can't get users to sort by the same meta value.

[Moderator Note: No bumping. If it's that urgent, consider hiring someone instead.]

MI on "WP Query - odd/even and post types"

$
0
0

Hi,

I want that odd and even posts would be different post types in one loop. How can i make it work? Here is the test query, which i think should work with getting odd and even ones, but how can i attach different post type here?

$args( 'post_type' => 'TYPE' );

$query = new WP_Query( $args );

<?php while (have_posts()): the_post() ?>
    <?php if ($wp_query->current_post % 2 == 0): ?>
        odd
    <?php else: ?>
        even
    <?php endif ?>
<?php endwhile ?>

Thanks

colinsp on "My get_results query not returning any results"

$
0
0

Anyone got any clues please? I expect I have done something stupid.

//Assign users to studies as authors
global $wpdb;
echo "Started";
$wpdb->show_errors();
// First get the profiles
$result = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE  post_type='name_profile'");
print_r ($result);
foreach ($result as $results){
$study_id = $results->id;
echo "Study ID= ". $study_id;
$study_name = $results->post_title;
echo $study_name;
/*$result1 = $wpdb->get_row("SELECT * FROM $wpdb->variants WHERE  study = $study_name");
$author = $result1->number;
$result2 = $wpdb->get_row("SELECT id FROM $wpdb->users WHERE  user_login = $author");
$author = $result2->id;
echo $author;
 $my_post = array(
      'ID'           => $study_id,
      'post_author' => $author
  );

// Update the post into the database
  wp_update_post( $my_post );*/

echo "Updated";
}

Sonyc-11 on "Customizing Add New Part"

$
0
0

I want to customize Add new post part where I want user to enter basic information based on my form and things like that, I also want to add JS there for validation and other purposes

P.S its urgent, Reply ASAP

Free269 on "What is the best way to improve in wordpress development"

$
0
0

Hi guys,

I'm new to Wordpress, working on a website for about 2 months. First built my own theme and learnt how things work from this level (file structure, basic functions, responsive mobile design, ect' ).

So I started to do things more advanced like writing a code to get random posts on the sidebar, and that too, used scripts that are already written, what help to interduce me to new functions that I didn't know of.
after trying to write stuff on wordpress, I noticed that I have a block that I really want to overcome.
I code in PHP, JS, CSS, jQuery, HMTL in a basic level, and I want to start writing plugins myself, to build over the current wordpress code in the best efficient way myself, to know how it works, and learn it in the best and fastest way.
I noticed that when I wanted to create a "load more posts" button in the end of the homepage, when I realized that I know to work in ajax and php, but just cant manage to apply it on my WP website.

So, I know that there is a lot of the documentation on the website, but everything is very unorganized. there is no specific way to learn it.
I would like to hear what you guys thing about this, and maybe tell me how you become experts with wordpress. If you have any recommendations for good books that you know will help me, or online courses..

Thank you guys.

joaoimai on "Hide a specific category from page navigation"

$
0
0

Hello.

I have a category that I wanted parallel from the main blog.
So I didn't want it to appear on the page navigation buttons. Only when it is at the category page.

Anyone know the easiest to do it?

I would need to exclude the category from the main navigation, and have a parallel page navigation exclusive for the hidden category. Is that right?

(If possible, the option for "recent posts" list too)

Thank you very much!

tojihi.com on "how add custom feild in metabox quickedite in wordpress admin panel"

$
0
0

hi
all of my website post have four coustom feild like price,pages,size and year
and i have edit all this ... and i want to edit all in quickedit section...

is has a sulotion...!!!?


nicgios on "plugin dependencies and configuration"

$
0
0

Hello,

I'm writing a plugin that create some pages with custom templates in a private area and deals with Custom Post Types. Trying not to reinvent the wheel I've found plenty of standard plugins that integrate mine and perfectly and do the job. The questions are:

1]
is there an efficient way to install plugins dependencies?

2]
Is there an efficient way to configure them automatically? (I'd like the user install my plugin and the others are just installed and configured automatically without any issue for the user).

Thanks a lot for your help

plasmax on "Smooth Scrolling"

$
0
0

Hey guys, hope to be in the right section.

I'm building a wordpress based website, all the theme is nice, responsive and modern, but I don't like when I scroll down with the mouse wheel because it's not fluid.

I would like some script or something similar to increase the frame rate when scrolling up and down, something fluid instead of jumping 30/40 pixels for every snap I do with the wheel.

I'm not sure you understand what I mean, in that case I'm really sorry!

thank you!

chalax212 on "Problem in wtiting custom wifget"

$
0
0

hello..
i'm jay, i currently learn how to develop website using wordpress.
i really love wordpress with tons of plugin and theme available out there, i just learn how to write my own custom widget.
my widget is work fine when i include it on my theme function. its show on backend and also on frontend just like another widget.
the only problem i got, when i add/create another widgets, the widgets(all widgets) start act wierd. when i add the widget(s) to widget area it show the options(form) but then option suddently dissapear. when i try to refresh the page (widget.php) on admin area the options on that widget appear normal and i can modify the value on that widget and save it just like normal widget.
this behavior affect the other functionality in my admin area such ass add image thumbnail is wierd(i can add thumbnail image, but image not shows on the thumbnail section on editor page.
and also with the other functionality, for example when i add new post it show on blank page when i hit save, also the same condition for adding category, page, menu, or anything that say add new. even on saving my theme options it direct me to blank page after i hit save.

this is the widget code.

<?php

class chalax_try_widget extends WP_Widget {

	/**
	 * Register widget with WordPress.
	 */
	function __construct() {
		parent::__construct(
			'chalax_try_widget', // Base ID
			__('Chalax try List', 'text_domain'), // Name
			array( 'description' => __( 'Widget untuk menampilkan daftar artikel/berita tertentu', 'text_domain' ), ) // Args
		);
	}

	/**
	 * Front-end display of widget.
	 *
	 * @see WP_Widget::widget()
	 *
	 * @param array $args     Widget arguments.
	 * @param array $instance Saved values from database.
	 */
	public function widget( $args, $instance ) {
		echo $args['before_widget'];
		echo $args['before_title'].$instance['title1'].$args['after_title'];
		echo "string";
		echo $args['after_widget'];
	}

	/**
	 * Back-end widget form.
	 *
	 * @see WP_Widget::form()
	 *
	 * @param array $instance Previously saved values from database.
	 */
	public function form( $instance ) {
		if (isset($instance['title1'])) {
			# code...
			$title1=$instance['title1'];
		}else{
			$title1="jajal";
		}
		?>
			<input id="<?php echo $this->get_field_id( 'title1' ); ?>" name="<?php echo $this->get_field_name( 'title1' ); ?>" value="<?php echo $title1 ;?>">
		<?php
	}

	/**
	 * Sanitize widget form values as they are saved.
	 *
	 * @see WP_Widget::update()
	 *
	 * @param array $new_instance Values just sent to be saved.
	 * @param array $old_instance Previously saved values from database.
	 *
	 * @return array Updated safe values to be saved.
	 */
	public function update( $new_instance, $old_instance ) {
		$instance  = array();
		$instance['title1'] = ( ! empty( $new_instance['title1'] ) ) ? strip_tags( $new_instance['title1'] ) : '';
		return $instance;
	}

} // class Foo_Widget

?>

and the other widget.

<?php

class chalax_try2_widget extends WP_Widget {

	/**
	 * Register widget with WordPress.
	 */
	function __construct() {
		parent::__construct(
			'chalax_try2_widget', // Base ID
			__('Chalax try2 List', 'text_domain'), // Name
			array( 'description' => __( 'Widget untuk menampilkan daftar artikel/berita tertentu', 'text_domain' ), ) // Args
		);
	}

	/**
	 * Front-end display of widget.
	 *
	 * @see WP_Widget::widget()
	 *
	 * @param array $args     Widget arguments.
	 * @param array $instance Saved values from database.
	 */
	public function widget( $args, $instance ) {
		echo $args['before_widget'];
		echo $args['before_title'].$instance['title'].$args['after_title'];
		echo "string";
		echo $args['after_widget'];
	}

	/**
	 * Back-end widget form.
	 *
	 * @see WP_Widget::form()
	 *
	 * @param array $instance Previously saved values from database.
	 */
	public function form( $instance ) {
		if (isset($instance['title'])) {
			# code...
			$title=$instance['title'];
		}else{
			$title="jajal";
		}
		?>
			<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $title ;?>">
		<?php
	}

	/**
	 * Sanitize widget form values as they are saved.
	 *
	 * @see WP_Widget::update()
	 *
	 * @param array $new_instance Values just sent to be saved.
	 * @param array $old_instance Previously saved values from database.
	 *
	 * @return array Updated safe values to be saved.
	 */
	public function update( $new_instance, $old_instance ) {
		$instance  = array();
		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
		return $instance;
	}

} // class Foo_Widget

?>

Chrisago on "Display specific category items."

$
0
0

Hi all,

Any suggestions on how to display specific category items from the portfolio?
Instead of 4 random items from the whole portfolio I would like to post 4 related portfolio items with the main portfolio item the user views.

Something like 4 "related products" with the main product.

The code excludes 3 items which don't want to show and displays all portfolio items:

// Create a new WP_Query() object
$wpcust = new WP_Query(
array(
'post_type' => array('portfolio'),
'post__not_in' => array(1366, 1359, 1353),
'orderby' => 'rand',
'showposts' => '4' )
);

Any help is really appreciated!

erpatton on "Active Directory - Grant/Restrict Access to Content"

$
0
0

Hello WordPress gurus! We have a client who is wanting to be able to restrict/grant access to pages on a WordPress site for certain groups in their Active Directory. Do you know of any plugins that already do this or a combination that can be used as a base to piece together functionality for this? I've worked with WordPress a few times before, but I mostly get .NET and Umbraco project requests from clients, so I'm not as familiar with what can be done in WordPress.

BrutaTroN on "PHP Coding Help"

$
0
0

For some some reason i can't get this code to work on my site. It works fine on my other site and i checked and the widget is accepting PHP coding. Can anyone help me out? I person made this code for me a long time ago and though the years i modified it, its to view online and offline steams from twitch.tv

<?php 

define("SHOW_OFFLINE_STREAMS", true);

$streams = array(

        new streamer("Believe", "gm", "p", "iambelieve"),
        new streamer("Legend", "gm", "t", "EliteLegend"),
        new streamer("WinD", "gm", "z", "neomaestro"),
        new streamer("dheinzen", "d", "z", "dheinzen13"),
        new streamer("MyaurA", "d", "z", "myaurasc2"),
        new streamer("PingPang", "d", "t", "stephen_c"),
	);

class streamer
{
	private $name;
        private $league;
	private $race;
	private $streamID;
	private $online; 

	public function __construct($nName, $nLeague, $nRace, $nStreamID) {
		$this->name = $nName;
                $this->league = strtolower($nLeague);
		$this->race = strtolower($nRace);
		$this->streamID = strtolower($nStreamID);
		$this->online = false;
	}

	public function isOnline() {return $this->online;}
	public function setOnline($bool) {$this->online = $bool;}

	public function getStreamID() {return $this->streamID;}

	private function onlineStatusImage() {
		if($this->online) {
			return "<img src='http://stratk.com/wp-content/uploads/2014/06/online.png'/>";
		} else {
			return "<img src='http://stratk.com/wp-content/uploads/2014/05/OfflineIcon1.png'/>";
		}
	}

	private function streamLeagueImage() {
		switch($this->league) {
			case "gm":
				return "<img src='http://stratk.com/wp-content/uploads/2014/06/grade1.png'/>";
			case "m":
				return "<img src='http://stratk.com/wp-content/uploads/2014/06/masterS.png'/>";
			case "d":
				return "<img src='http://stratk.com/wp-content/uploads/2014/06/diamondS.png'/>";
			case "p":
				return "<img src='http://stratk.com/wp-content/uploads/2014/06/diamondS.png'/>";
			case "g":
				return "<img src='http://stratk.com/wp-content/uploads/2014/05/Gold.png'/>";
			case "s":
				return "<img src='http://stratk.com/wp-content/uploads/2014/05/Silver.png'/>";
			case "b":
				return "<img src='http://stratk.com/wp-content/uploads/2014/05/Bronze.png'/>";

			default:
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
		}
	}

	private function streamRaceImage() {
		switch($this->race) {
			case "t":
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Ticon_small.png'/>";
			case "p":
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Picon_small.png'/>";
			case "z":
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Zicon_small.png'/>";
			case "r":
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
			default:
				return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
		}
	}

	private function streamLink() {
		return "<a>streamID."'>".$this->name."</a>";
	}

	public function linkTextLine() {
		return $this->onlineStatusImage().$this->streamLeagueImage().$this->streamRaceImage().$this->streamLink();
	}
}

$nameArray = array();
foreach($streams as $stream) {$nameArray[] = $stream->getStreamID();}

$json_file = file_get_contents("http://api.justin.tv/api/stream/list.json?channel=".implode(',',$nameArray), 0, null, null);
		$json_array = json_decode($json_file, true); 

foreach($streams as $stream) {
	foreach($json_array as $api) {
		if ($api['name'] == "live_user_{$stream->getStreamID()}") {
			$stream->setOnline(true);
		}
	}
}

echo "<ul style='list-style-type:none !important'>";
foreach($streams as $stream) {
	if(SHOW_OFFLINE_STREAMS) {
		echo "<li style='list-style:none !important;'>".$stream->linkTextLine()."\n";
	} else {
		if($stream->isOnline()) {
			echo "<li style='list-style:none !important;'>".$stream->linkTextLine()."\n";
		}
	}
}
echo "";
?>

[Moderator Note: Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged by the forum's parser.]

sjbmaine on "Limit user registration to a fixed time limit"

$
0
0

I need to set-up Subscribers to only have access to the site for four days from the time they registered. Can anyone advise how I might do this? I am using the WP-Members plugin to limit access to the pages on the site.


David on "Wordpress Media Manager 3.9 - default Create Gallery"

$
0
0

Sorry for my English.

Media Manager.

I need that in the admin edit page, when the user clicks on “add Media”, the default in the new frame will be “Create Gallery” and not “Insert Media”.

I think, that the script for it is in the media-editor.js in wp/inclodes/js.

There, if I change line 1009 - “state: 'insert’,” into “state: ‘gallery,”, and do the same in the media-editor.min.js, it works, and the frame is opened with “Create Galley”.

Well, the question: how can I do the same using actions or filters in the function.php?

Thanks

PearlsMedia on "Disable other back-end plugin's javascript files?"

$
0
0

It seems that wordpress is loading always Javascript resources of all plugins, despite I am only opening a specific back-end plugin. That leads to quite some trouble as some Javascript is colliding or incompatible or its simply bad to load them all together. Just imagine 2 different configured Dojo applications with different requirejs configs or similar commonjs scenarios. In top it makes no sense to load all plugins Javascript resources in every back-end component.

How do I prevent that other Javascript files from being loaded in my back-end plugin ? Do I need to 'de-queue' them manually?

Thanks from a Wordpress newbee.

otti.steinhauer on "How to send a SMS"

$
0
0

Hello,
at my plugin I'm already sending automatic mails with wp_mail() function. Now I want to send SMS and I don't know how to do that.
I have got via a form the number of a mobile phone and I can create the message via code. So what is the best way to send the message as SMS to the number?

Thanks

Ottilie

Elli_K on "Allow basic html formatting in custom user profile fields"

xymalf on "Syntax error"

$
0
0
//  Then you actually have to declare the functions that will generate the pages/page content.
function boj_menuexample_settings_page() {

  echo "<h1>Settings Page</h1>";

}
function boj_menuexample_about_page() {

  echo "<h1>APPLICATION</h1>";

function displayBook ($resultItems)
{
foreach ($resultItems AS $item)
{
$title = $item['ProductName'];
$url = $item['Url'];
$image = $item['ImageUrlSmall'];
$authorList = implode($item['Authors'], ", ");
$price = $item['ListPrice'];
if ($url != "") echo "<img src=\"$image\" align=\"left\">";
echo "<a href=\"$url\" title=\" Learn More at Amazon.com\">$title<a><br>";
echo "Author(s): ". $authorList. "<br>";
echo "List Price:" . $price;
echo "<br>";
}
}

function runSearchQuery($client, $keywords, $page, $mode , $type='lite')

{
$params = array(
'keyword' => $keywords,
'page' => $page,
'mode' => $mode,
'tag' => 'xymalfsentert-20',
'type' => $type,
'devtag' => 'AKIAIQ2ZQ6JWDC5LOJLA',

);

$namespace = 'http://soap.amazon.com';
$action = 'http://soap.amazon.com';
$method = "KeywordSearchRequest";
$result = $client->call($methos, array('KeywordSearchRequest' =>$params),
$namespace, $action);

return $result;

}

<form action="./soap.search.php" method ="get"> ## syntax error #
<input type="text" name="query">
<input type="hidden" name="page" value="1">
<select name="mode">

$modes = array();
$modes[] = "books";

foreach ($modes as $mode)
{
echo "<option value =\"$mode\">$mode</option>";
}
</select>
<input type="submit">
</form> #syntax error ##

$resultItems = $result['Details'];

switch ($mode)
{
case "books":
displayBook($resultItems);
break;
}
if ($result['TotalPages'] > $page)
{
$page++;
echo "<a href=\"soap.search.php?query&mode&page=$page\"> Next 10 Results</a>";
}

}
function boj_menuexample_uninstall_page() {

  echo "<h1>Uninstall Page</h1>";

}

?>

getting syntax errors also would like the amazon tags on my setting page and be able to get variables into my app.

Viewing all 8245 articles
Browse latest View live




Latest Images