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 | .... | 360 | 361 | (Page 362) | 363 | 364 | .... | 413 | newer

    0 0

    I am trying to implement custom-type validation using JQuery.
    My HTML is

    <form id="register-form" method="post">
    			 <div class="register-body">
    
    				<div class="form-group">
    					<label for="phnumber">Contact number</label>
    					<input type="text" class="form-control" required="" name="phnumber" id="phnumber" value="" required>
    					<span class="help-block">Please include office contact number.</span>
    					<div id="phone-error" class="error-box" style="color:#ff0000"></div>
    				</div>
    
    			</div>
    
    			<div class="register-footer">
    			     <div class="row">
    				<div class="col-sm-6 col-sm-offset-3">
    					<input type="submit" name="submit" id="submit" tabindex="4" class="form-control btn btn-login" value="Create My Account" >
    				</div>
    			     </div>
    			</div>
    		</form>

    I have a script in my footer.php to validate as

    <footer>
    
    		</footer>
    		<script>
                            $(document).ready(function() {
    			     $('#phnumber').validate({
    			        if (validatePhone('txtPhone')) {
    			            $('#phone-error').html('Please enter valid phone number');
    			        }
    			        else {
    			            $('#phone-error').html('');
    			        }
    			    });
    			});
    
    			function validatePhone(txtPhone) {
    			    var a = document.getElementById(txtPhone).value;
    			    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
    			    if (filter.test(a)) {
    			        return true;
    			    }
    			    else {
    			        return false;
    			    }
    			}
                    </script>
    		<?php wp_footer() ?>
    
            </body>
    </html>

    I have JQuery in my functions.php

    function tourism_script_enqueue() {
    
    		wp_enqueue_script('jquery');
    
    	}
    	add_action( 'wp_enqueue_scripts', 'tourism_script_enqueue');

    When I click the submit button, I am expecting the message at my Form as Please enter valid phone number. But nothing comes out and all the input texts in the form disappeared.


    0 0

    My hosting company quarantined a file local.php. I looked on my other wordpress sites and this file is not any of the others. Do I need this file? I installed with quickinstall and don't do local server hosting. Now I can't get to my wp-admin because I get a 404. Did this affect my .htaccess?


    0 0

    Hi guys,

    So here's the thing : I was recently hired as a Wordpress trainer for students who have never used it. I accepted the job because the training program felt entirely under my scope of skills.

    But when I met the students, I learned that there's a mandatory part of the training that I have no idea how to deal with :

    On a Wordpress based subdomain, they need to connect to an external database which is linked to a Joomla install, to gather and display data from this external database.

    Again, this is way out of my scope of skills, so I'd definately like some insights from you guys. (detailed if possible)

    Please forgive me if this sounds like I want you to make my job, but since my employer here seems to see my incapacity in this field in an infavourable light, some help would be awesome.

    Thanks !


    0 0

    I having a trouble to connect multiple databases to pull search results, could you please help me to connect multiple databases for wordpress search, i'm testing this on local server.

    - My databases names are: connect1, connect2, connect3, and every db has different username and password.
    - I'm trying to pull all the posts and pages data from each db, so my posts goes into "wp_posts" and pages "wp_pages".
    - And can i have custom "table_prefix" in wp-config file like instead of 'wp_' something like 'xyz_123" for each database?
    - wordpress theme is 2016, (i guess you might need to know that).

    Please also describe which code goes where like in what file etc.
    many thanks!


    0 0

    (crossposting from stoackexchange: http://stackoverflow.com/questions/13936080/pre-select-images-when-opening-wordpress-3-5-media-manager)

    I'm trying to create a tinymce plugin that generates a shortcode containing two image ids:

    [image-fade old="xx" new="yy"]

    I would like to let users select images directly from the media selector frame, but haven't figured out how to do this. I am able to allow the users to enter the ID in an alert box, but can't do better than that. This is what I have so far:

    ( function() {
        var open_media_window = function () {
            var first={};
    
            var window = wp.media({
                title: 'Insert a media',
                library: {type: 'image'},
                multiple: false,
                button: {text: 'Insert'}
            });
            window.on('select', function(){
                var files = window.state().get('selection').toArray();
                first = files[0].toJSON();
                console.log ("first is: " + first);
                return first.id;
            });
            window.open();
            return first.id;
    
        };
        tinymce.create( 'tinymce.plugins.hhImage', {
        init: function( ed, url ) {
            ed.addButton( 'hh_image', {
            title: 'Insert Historical Image Overlay',
            image: 'http://matttest.hackinghistory.ca/wp-content/plugins/custom-content-type-manager/js/plugins/../../images/wrench.png',
            onclick: function() {
                //old = prompt( "Enter id of old photo", "" );
                old = open_media_window();
                //newImage = prompt( "Enter id of new photo", "" );
                newImage = open_media_window();
                ed.execCommand( 'mceInsertContent', false, '[image-fade old="' + old + '" new="' + newImage + '"]' );
            }
            });
        },
        createControl: function( n, cm ) { return null; },
        });
        tinymce.PluginManager.add( 'hh_image', tinymce.plugins.hhImage );
    })();

    The media selector window will open, and I can select two images, but nothing gets logged to the javascript console and the shortcode produced is:

    [image-fade old="undefined" new="undefined"]

    What am I doing wrong here? Thanks for the help! Matt


    0 0

    Hi,

    I created a custom taxonomy called Games
    Under it I have a term to list all the games on the website called Games
    Also I have a term for each game
    Games taxonomy, GTA term and so on.
    In my child theme I use taxonomy.php to know which game to view, or shall I view a list of games.
    I want to view the list of games like this
    site.com/games/ and not site.com/games/games
    So I did this working rewrite rule
    $new_rules = "games/?$" => "index.php?games=games";
    The problem is the game term's page is still recognized as site.com/games/games/ by other plugins like polylang for example.
    I want to force word press to accept site.com/games/ only to reach the term games in taxonomy games.

    Any help is greatly appreciated.


    0 0

    Hello everybody,

    I already know that many of you will beat me hard for this, BUT please after beating me try to help.

    I hacked the wordpress password generator to automatically generate ALWAYS THE SAME DEFAULT password. That is, let's say, "hello" (no quotes).

    I need to keep it like that, and I won't consider ANY solution that advise me to alter this condition.

    Having done that, I need to close all the backdoors that hackers may use.

    To protect subscribers, I disabled the profile page, and they have to contact me to access their data.

    But most important, I needed to disable the "Lost your password" function from wp-login.php.

    WHAT A PAIN! All the plugins and hacks that I tried were just removing the link to the password reset form, (i.e. the link to /wp-login.php?action=lostpassword) but I was still able to reach it by manually typing:

    mysite.com/wp-login.php?action=lostpassword

    The big problem here is, the same function used to generate a random password, that I altered to always output "hello", is used ALSO to generate the random password reset key. So the random password reset key is ALWAYS hello.

    Now, let's assume that the administrator, nickname John, has a super complicated password.

    If somebody gets the admin username or email (easy), they just type:

    mysite.com/wp-login.php?action=lostpassword

    Enter the admin username or email and send the form. Now the password reset key "hello" is active.

    Then they type:

    mysite.com/wp-login.php?action=rp&key=hello&login=John

    Here they set their own password: they are in and John's OUT!

    I found several methods to prevent the password reset for specific users, using the hook allow_password_reset from user.php but, probably due to my limited php competences, none of them was working.

    All I could get was hiding the link from wp-login.php to wp-login.php?action=lostpassword .

    To quickly patch this big hole I just prevented user.php from generating ANY password reset key.

    line 1947
    // $key = wp_generate_password( 20, true );

    (please note the EXTREMELY elegant // solution)

    Thanks to this, there is no password reset key and none of the following link appears to be valid

    mysite.com/wp-login.php?action=rp&key=&login=John

    mysite.com/wp-login.php?action=rp&key=hello&login=John

    So two questions:

    1- Can I do it in a different way??

    2- Is there any other backdoor that I'm leaving open for hackers?

    Thanks a lot for your help

    Nick

    PS: If you are going to answer that having such a password generator is dangerous for me, for the users and for the world, without providing me with a solution to my questions, or that "YES, the holes are huge and cannot be enumerated", please refrain from asnwering. I'll appreciate your silence


    0 0

    Everywhere on the net i was searching, no one is mentioning which one goes first and is it possible to use one hook theme activation for both roles and capabilities. They both are saved in database and as i see although they are linked with each other, they are not linked in database as foreign keys, they are even in same option saved.

    So my question is as both codex guides references that roles and capabilities should be added or removed on theme/plugin activation, they use different approach.

    In add capabilities codex page suggest to run on theme page and check if it's activated, otherwise remove capability.

    add_action( 'load-themes.php', 'add_theme_caps' );

    And in roles codex page they suggest register activation hook, which is basically used for plugin activations

    register_activation_hook( __FILE__, 'add_roles_on_plugin_activation' );

    So which one would be correct? can i use one hook on theme activation to add both new roles and new capabilities. My point is that i want to add a few roles

    Confirmed poster
    Unconfirmed poster
    Blocked poster

    And a few capabilities hooked to those roles like

    create_new_listing
    edit_own_listing
    delete_own_listing
    send_private_message
    edit_own_profile

    On top of that "listings" are custom post type so should i also add capabilities to that custom post type too?

    register_post_type(
    'listings',
    array(
       'public' => true,
       'capability_type' => 'listings',
       'capabilities' => array(
       'publish_posts' => 'create_new_listing',
       'edit_posts' => 'edit_own_listings',
       'edit_others_posts' => 'edit_others_listing',
       'read_private_posts' => 'read_private_listing',
       'edit_post' => 'edit_listing',
       'delete_post' => 'delete_listing',
       'read_post' => 'read_listing',
    ),
    )
    );

    So which order goes on activation and adding custom roles and capabilities?


    0 0

    I'm having hard time customising the posted ago in hours: It works fine with round up of hours but I want to display the posted ago hours:mins both. Can anyone help me?
    FYI instead of using $since = sprintf( _n( 'ཆུ་ཚོད་ %s སྔོན་ལ།', 'ཆུ་ཚོད་ %s སྔོན་ལ།', $hours ), $hours ); I tried with $since = 'ཆུ་ཚོད་' . $hours . '/' . $mins . 'སྔོན་ལ།'; somehow my values are crazy.

    function human_time_diff_custom( $from, $to = '' ) {
            if ( empty( $to ) )
                    $to = time();
            $diff = (int) abs( $to - $from );
            if ( $diff <= HOUR_IN_SECONDS ) {
                    $mins = round( $diff / MINUTE_IN_SECONDS );
                    if ( $mins <= 1 ) {
                            $mins = 1;
                    }
                    /* translators: min=minute */
                    $since = sprintf( _n( 'སྐར་མདའ། %s སྔོན་ལ།', 'སྐར་མདའ། %s སྔོན་ལ།', $mins ), $mins );
            } elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) {
                    $mins = round( $diff / MINUTE_IN_SECONDS );
                    if ( $mins <= 1 ) {
                            $mins = 1;
                    }
    
                    $hours = round( $diff / HOUR_IN_SECONDS );
                    if ( $hours <= 1 ) {
                            $hours = 1;
                    }
    
                    //$since = sprintf( _n( 'ཆུ་ཚོད་ %s སྔོན་ལ།', 'ཆུ་ཚོད་ %s སྔོན་ལ།', $hours ), $hours );
                    $since = 'ཆུ་ཚོད་' . $hours . '/' . $mins . 'སྔོན་ལ།';
    
            } elseif ( $diff >= DAY_IN_SECONDS ) {
                    $days = round( $diff / DAY_IN_SECONDS );
                    if ( $days <= 1 ) {
                            $days = 1;
                    }
                    $since = sprintf( _n( '%s ཉིན་སྔོན་ལ།', '%s ཉིན་སྔོན་ལ།', $days ), $days );
            }
            return $since;
    }

    Thanks!


    0 0

    Hello,

    I'm developing my first plugin and I'd like to add a link tag inside head to call a CSS file to style my options page.

    My plugin has the follow code (all my code, except the license coments)

    if( !defined( 'ABSPATH' ) ) exit;

    define( 'EASYDM_VERSION', '1.0' );

    define( 'EASYDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    define( 'EASYDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

    define( 'EASYDM_SETTINGS_URL', plugin_dir_url( __FILE__ ).'settings/' );
    define( 'EASYDM_SETTINGS_DIR', plugin_dir_path( __FILE__ ).'settings/' );
    define( 'EASYDM_SETTINGS_PATH', 'settings/' );

    define( 'EASYDM_IMAGES_URL', plugin_dir_url( __FILE__ ).'images/' );
    define( 'EASYDM_IMAGES_DIR', plugin_dir_path( __FILE__ ).'images/' );
    define( 'EASYDM_IMAGES_PATH', 'images/' );

    define( 'EASYDM_CSS_URL', plugin_dir_url( __FILE__ ).'css/' );
    define( 'EASYDM_CSS_DIR', plugin_dir_path( __FILE__ ).'css/' );
    define( 'EASYDM_CSS_PATH', 'css/' );

    define( 'EASYDM_INCLUDES_URL', plugin_dir_url( __FILE__ ).'includes/' );
    define( 'EASYDM_INCLUDES_DIR', plugin_dir_path( __FILE__ ).'includes/' );
    define( 'EASYDM_INCLUDES_PATH', 'includes/' );

    require_once EASYDM_SETTINGS_PATH.'easydm-functions.php';

    //add_filter( 'wp_head','easydm_add_link_tag_to_head' );
    add_action( 'wp_head', 'easydm_add_link_tag_to_head' );
    //do_action( 'wp_head' );

    add_action( 'admin_menu', 'easydm_top_level_menu' );

    From the constants is possible to conclude the directories structure of the plugin. Another directories are actually empty.
    The 'easydm-functions.php' has the follow function:

    function easydm_add_link_tag_to_head() {
    $path = __DIR__.'/../css/';
    echo '<link rel="stylesheet" type="text/css" href="'.$path.'style.css" />';
    }

    I expected to find this link tag in the source code but I can't. The tag doesn't appear there.

    Reading many tutorials and forums questions about this, no much is different from this.

    I'm developing in localhost, apache2, Ubuntu 14.04 LTS.

    Some help?

    Thanks


    0 0

    Hi All

    I have a custom theme with custom taxonomies (people and groups) added to Media Attachments.

    When I search in WP Admin on the Media Library page, the search includes custom taxonomies (I use the plugin Search Everything and some custom code).

    When I am in a post, and edit a gallery, and click on Add To Gallery and then search the images in the library using the search box in this panel, the search does not appear to include the custom taxonomies.

    I have tried adding this code in my functions.php file:

    function michaelputland_admin_search_by_tax_filter ( $query ) {
    	if ( $query->is_search && is_admin() ) {
    		$query->set( 'taxonomy', 'people, groups' );
    	}
    }
    add_action( 'parse_query', 'michaelputland_admin_search_by_tax_filter' );

    it does not help.

    Any pointers, thoughts, gratefully appreciated.

    Regards
    Mike


    0 0

    Hi,

    I have a field in my user profile for every author eg. restaurant, plumber, mechanic.

    Users can submit posts but I want them to only submit to the associated categories that I have created with the similar name eg. food, plumbing, mechanical.

    Is there a way to auto populate or do this in a dynamic fashion so when a user submits a post they can only post to their category ie.
    users with field "restaurant" = "food" category
    users with field "plumber" = "plumbing" category
    etc.


    0 0

    Hi, I need some help making a simple hit counter that take the jetpack visitor stats and display them in the body of the page as text. There are many plugins that takes the jetpack stats and displays as a plugins but I need it in the actual body of the page as a number only.

    Any one know if this is even possible?

    Thanks.


    0 0
  • 03/07/16--09:12: Chrisago on "Shortcode"
  • Hi all,

    I am trying to make a shortcode which will display specific posts based on the "id" of the post. I have found a shortcode example below which displays the most recent posts of "category1".

    Any thoughts on what should i do in order to make this work.

    [recent_work limit="4" orderby="title" filters="category1"][/recent_work]

    function pp_recent_work($atts, $content ) {
     extract(shortcode_atts(array(
        'limit'=>'4',
        'title' => 'Recent Work',
        'orderby'=> 'date',
        'order'=> 'DESC',
        'filters' => '',
        'carousel' => 'yes'
        ), $atts));
        $output = '';
        if($filters){
            $filterstemparray = explode(',', $filters);
            if (count($filterstemparray)>1) {
                $filtersarray = $filterstemparray;
    
            } else {
                $filtersarray = $filterstemparray[0];
            }
        };
        if($filters=="all" || empty($filters)) {
             $wp_query = new WP_Query(
                array(
                    'post_type' => array('portfolio'),
                    'showposts' => $limit,
                    'orderby' => $orderby,
                    'order' => $order
                    ));
        } else {
           $wp_query = new WP_Query(
            array(
                'post_type' => array('portfolio'),
                'showposts' => $limit,
                'orderby' => $orderby,
                'order' => $order,
                'tax_query' => array(
                    array(
                        'taxonomy' => 'filters',
                        'field' => 'slug',
                        'terms' => $filtersarray
                        )
                    ),
                )
                );
        }

    0 0

    I'm testing some code using PHPUnit, and when my code uses
    wp_die(new WP_Error('errorCode', 'errorMessage'));
    I get the error:
    Error: Wrong parameters for WPDieException([string $message [, long $code [, Throwable $previous = NULL]]])
    If I change my code to:
    wp_die('errorMessage');
    Then it works correctly (I get WPDieException: errorMessage).


    0 0

    Is there anywhere I can find the code for a form that updates input fields to the usermeta table. I would like to put the form on a plugin admin page.

    thank you


    0 0

    I am trying to add an options page using https://developer.wordpress.org/reference/functions/add_menu_page/ and then below that menu item I want to add a custom post type. The problem I'm running into is that when I add the custom post type and specify the parent menu item for it as my options page the link for the option page is replaced and goes to the custom post type page instead. Can anyone point me to how I can accomplish this?


    0 0

    Hi,

    I put the following code inside my activation hook function:

    function easydm_create_table_in_wpdb(){
    	global $wpdb;
    
    	$table_name = $wpdb->prefix.'easy_downloader_manager';
    
    	$charset_collate = $wpdb->get_charset_collate();
    	echo '<script type="text/javascript">alert('.$charset_collate.');</script>';
    
    	$sql = "CREATE TABLE $table_name (
    		name varchar(20) NOT NULL,
    		level int(1) NOT NULL,
    		url varchar(55) DEFAULT '' NOT NULL
    	) $charset_collate;";
    
    	require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
    	dbDelta( $sql, true );
    }

    and

    function easydm_activation() {
    	$path = WP_CONTENT_DIR.'/easydm-uploads';
    	if( !file_exists( $path ) ){
    		mkdir( $path );
    	}
    
    	easydm_create_table_in_wpdb();
    }

    When the plugin is activated, it creates a directory and a table in wp db. I'm in ubuntu 14.04 and keep my file manager opened to see the directory appear (no problem here). It's weird, when I insert the function to create the table, because I keep phpMyAdmin opened to see the table creation (and it is created in all activation) even the following message appears to me:

    The plugin generated 104 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    what should I do? How to debugger correctly? I wanna publish my plugins (this first and future ones) in WordPress repository


    0 0

    I have a site that uses a few cron jobs to take care of regular tasks. These cron jobs need to access data that is stored in posts that are only accessible by certain users. An addon, like WP Force Login, is used to keep unregistered users out.

    This requires the cron to be run as a logged in user to succeed. How can I accomplish this? Or, perhaps there is a more elegant solution I am overlooking?

    Thank you in advance!


    0 0

    (crossposting from stoackexchange: http://stackoverflow.com/questions/13936080/pre-select-images-when-opening-wordpress-3-5-media-manager)

    I'm trying to create a tinymce plugin that generates a shortcode containing two image ids:

    [image-fade old="xx" new="yy"]

    I would like to let users select images directly from the media selector frame, but haven't figured out how to do this. I am able to allow the users to enter the ID in an alert box, but can't do better than that. This is what I have so far:

    ( function() {
        var open_media_window = function () {
            var first={};
    
            var window = wp.media({
                title: 'Insert a media',
                library: {type: 'image'},
                multiple: false,
                button: {text: 'Insert'}
            });
            window.on('select', function(){
                var files = window.state().get('selection').toArray();
                first = files[0].toJSON();
                console.log ("first is: " + first);
                return first.id;
            });
            window.open();
            return first.id;
    
        };
        tinymce.create( 'tinymce.plugins.hhImage', {
        init: function( ed, url ) {
            ed.addButton( 'hh_image', {
            title: 'Insert Historical Image Overlay',
            image: 'http://matttest.hackinghistory.ca/wp-content/plugins/custom-content-type-manager/js/plugins/../../images/wrench.png',
            onclick: function() {
                //old = prompt( "Enter id of old photo", "" );
                old = open_media_window();
                //newImage = prompt( "Enter id of new photo", "" );
                newImage = open_media_window();
                ed.execCommand( 'mceInsertContent', false, '[image-fade old="' + old + '" new="' + newImage + '"]' );
            }
            });
        },
        createControl: function( n, cm ) { return null; },
        });
        tinymce.PluginManager.add( 'hh_image', tinymce.plugins.hhImage );
    })();

    The media selector window will open, and I can select two images, but nothing gets logged to the javascript console and the shortcode produced is:

    [image-fade old="undefined" new="undefined"]

    What am I doing wrong here? Thanks for the help! Matt


older | 1 | .... | 360 | 361 | (Page 362) | 363 | 364 | .... | 413 | newer