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


Showcase


Channel Catalog


Channel Description:

WordPress › Support

older | 1 | .... | 337 | 338 | (Page 339) | 340 | 341 | .... | 413 | newer

    0 0

    I have a problem with ajax and plugin in WordPress.
    In the plugin (frontend) I call ajax by clicking on a link and it works correctly. You can see this here http://goo.gl/RFda1O in the bottom page: if you click in menù "servizi offerti" ajax works and you can see "detail Service".

    Now, in each row, that is "detail service", I would add a link visible for only admin. Because I can remove, editing, add, the service.
    but, this second ajax in this link is not working!

    In the main file:

    `..

    function run_class() {

    $servizio = new diocesi_class();
    add_action("init",array ($servizio,"run"));
    add_action("wp_footer",array ($servizio,'load_script'));
    add_action( 'wp_ajax_ajaxx', array ($servizio, 'prefix_ajaxx' ));
    add_action( 'wp_ajax_nopriv_ajaxx', array ($servizio, 'prefix_ajaxx' ));

    //second call for ajax. Use this after the first call.

    add_action( 'wp_ajax_ajaxx2', array ($servizio, 'prefix_ajaxx2' ));
    add_action( 'wp_ajax_nopriv_ajaxx2', array ($servizio, 'prefix_ajaxx2' ));

    }

    run_class();

    ?>`

    In diocesi_class:

    ` class diocesi_class {

    ...

    public function __construct() {
    add_shortcode("servizi", array ($this,"run"));

    }

    public function run($atts, $content = null) {

    ....
    ....

    ob_start(); ?>
    <strong>Servizi offerti</strong><br/>
    <div id="servizi_offerti"><div id="menu_servizi">
    <?php
    //create menu
    foreach ($servizi_disp as $servizi) {
    //menu for first call ajax and it's working!
    echo "<a class='ajaxLoad' data-diocesi='".$this->content."' data-servizi='".$servizi->id."' href='#' >".$servizi->nome." </a> |";

    } ?>
    </div>

    <p class="info">Per i dettagli selezionare dall'elenco il tipo di servizio</p>
    <div id="informazioni_servizi"></div>
    <a href="#" id="ritorna" >Ritorna su <?php echo get_the_title(); ?></a>
    </div> <?php

    //For testing. It's working, but not needed here!Look in the function prefix_ajaxx()
    if (current_user_can('edit_plugins'))
    {

    $link = plugin_dir_url(__FILE__) .'admin_servizi.php';
    echo "<a class='carica_admin' data-diocesi='".$this->content."' data-servizi='".$servizi->id."' href='#' > Modifica Servizi </a>";

    }

    return ob_get_clean();

    }

    }

    //register script
    public function load_script(){

    wp_enqueue_script( 'jquery' );

    wp_register_style('servizi', plugin_dir_url(__FILE__) . 'servizi.css',array());
    wp_enqueue_style('servizi');

    wp_register_script('ajaxx', plugin_dir_url(__FILE__) . 'ajax.js',array('jquery'));
    wp_localize_script('ajaxx', 'ajax_params', array('ajax_url' => admin_url( 'admin-ajax.php' ) ));
    wp_enqueue_script('ajaxx');

    //caricamento per admin
    // mostra la parte admin

    if (current_user_can('edit_plugins')) {
    wp_register_script('ajaxx2', plugin_dir_url(__FILE__) . 'ajax2.js',array('jquery'));
    wp_localize_script('ajaxx2', 'ajax_params', array('ajax_url' => admin_url( 'admin-ajax.php' ) ));
    wp_enqueue_script('ajaxx2');

    }

    }

    //first ajax response
    public function prefix_ajaxx() {

    // return details services. Create table and rows.
    ...
    ...
    ...

    // ****************Event jquery NOT WORKING! ***********
    if (current_user_can('edit_plugins'))
    {

    echo "<a class='carica_admin' data-diocesi='".$this->content."' data-servizi='".$servizi->id."' href='#' > Modifica Servizi </a>";

    }

    wp_die();
    }

    public function prefix_ajaxx2()
    {
    // response for second call ajax
    // edit row or single services (after click carica_admin)

    }
    else
    {
    echo "non si hanno i permessi!";
    }
    wp_die();
    }`

    ajax2.js:

    `jQuery("#ritorna").hide();
    jQuery("a.carica_admin").click(function(){

    //var querystring = $(this).attr('href');
    var diocesi = jQuery(this).data('diocesi');
    var servizi = jQuery(this).data('servizi');

    jQuery.ajax({

    url:ajax_params.ajax_url,
    type: "GET",
    data:{
    action: 'ajaxx2',
    diocesi : diocesi,
    servizi : servizi
    },
    success: function(data) {
    jQuery('#menu_servizi').hide();
    jQuery('p.info').hide();
    jQuery("#informazioni_servizi").html(data);

    }
    });
    return false;
    });

    ajax.js
    jQuery(document).ready(function(){
    jQuery("#ritorna").hide();
    jQuery("a.ajaxLoad").click(function(){

    //var querystring = $(this).attr('href');
    var diocesi = jQuery(this).data('diocesi');
    var servizi = jQuery(this).data('servizi');
    jQuery.ajax({

    url:ajax_params.ajax_url,
    type: "GET",
    data:{
    action: 'ajaxx',
    diocesi : diocesi,
    servizi : servizi
    },
    success: function(data) {

    jQuery("#informazioni_servizi").html(data);
    jQuery("#ritorna").show();

    }
    });
    return false;
    });

    jQuery("#ritorna").click(function() {
    jQuery("#informazioni_servizi").empty();
    jQuery("#ritorna").hide();

    });

    });`

    Important! the problem is only out of public function run, for example in prefix_ajax where event jQuery click not work!

    Thanks!


    0 0

    i made plugin which auto generate database if not exist. same way i want to generate table under generated database. For Example

    • I generate database with codes like ABCD
    • Now next i want generate DEF table under ABCD database

    I try these codes

    function plugin_name_activation() {
    	require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
    	global $wpdb;
    	$db_table_name = $wpdb->prefix . 'table_name';
    	if( $wpdb->get_var( "SHOW TABLES LIKE '$db_table_name'" ) != $db_table_name ) {
    		if ( ! empty( $wpdb->charset ) )
    			$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    		if ( ! empty( $wpdb->collate ) )
    			$charset_collate .= " COLLATE $wpdb->collate";
    
    		$sql = "CREATE TABLE " . $db_table_name . " (
    			<code>id</code> bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    			<code>type</code> varchar(100) NOT NULL DEFAULT '',
    			<code>extra</code> longtext NOT NULL,
    			<code>date_time</code> datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    			PRIMARY KEY (<code>id</code>)
    		) $charset_collate;";
    		dbDelta( $sql );
    	}
    }
    register_activation_hook(__FILE__, 'plugin_name_activation');

    http://web-profile.com.ua/wordpress/dev/create-table-on-plugin-activation/


    0 0

    Hello,

    I want to delete all posts of a specific post type (in this case "vfb_entry") that are older than 60 days. The cron job should run once a day.

    I have the following code and would like to ask you guys if it is correct:

    // Cron Job to Delete VFB Entries older than 60 days
    if(!wp_next_scheduled( 'remove_old_vfb_entries')){
        wp_schedule_event(time(), 'daily', 'remove_old_vfb_entries');
    }
    add_action('remove_old_vfb_entries', 'myd_remove_old_vfb_entries');
    
    // Build the function
    function myd_remove_old_vfb_entries(){
    global $wpdb;
    // Set max post date and post_type name
    $date = date("Y-m-d H:i:s", strtotime('-60 days'));
    $post_type = 'vfb_entry';
    
    // Query post type
    $query = "
        SELECT ID FROM $wpdb->posts
        WHERE post_type = '$post_type'
        AND post_status = 'publish'
        AND post_author = '1'
        AND post_date < '$date'
        ORDER BY post_modified DESC
    ";
    $results = $wpdb->get_results($query);
                foreach($results as $post){
                    // Let the WordPress API clean up the entire post trails
                    wp_delete_post( $post->ID, true);
              }
    }

    Thank you!


    0 0

    Hi all !

    I cant figure why I get a 404 error.
    I started my project two days ago, and I'm not use to work with WP, but I did some javascript with node and angular. I have to make something who look like that.

    I took Grid, and begin to work on the grid for the index. As I dont know WP, I dont know if chosing this theme was the right decision. The infinit scroll dont work after my changes so I managed to write my own with a tutorial, all was going well before this error. So, my script do a get request on the next page, and, on success, display all the article. It work for the firsts pages.
    But, for the lasts pages, even if the content is display (as I can see when I enter the url directly in my browser), the 404 ruins everything.

    I readed a lot about this issues and I already try some solutions;
    -switch permalink's setting and save in order to refresh it
    -I activated rewrite_module on my Apache setting (I'm in local with Wamp 2.5)

    How can I fix this ?
    Should I swith to another theme for my project ?

    Really sorry for my terrible english, I'm french, and thank you for you time !


    0 0

    Hi,

    Does anyone know if it's possible to create a shortcode for the following function: <?php comments_template(); ?> ?

    I would add this code to a shortcode plugin or something if that's possible.

    Thanks everyone for your help!


    0 0

    I am trying to extend the archives widget.

    By default WordPress will allow me from its archives widget to select a month from the drop down and display only posts from that month.

    I want the same functionality but I want to list the months on a page not have them contained within the widget. I also want to list images for each month and not URL's.

    I have thought about this and considered storing a custom image against every month and then looping through and displaying these within a page. But I am not sure I could create custom fields associated with meta data such as the post month.

    Does this make sense to do it this way or could you suggest a better way?

    Thanks!


    0 0

    Here's the use case.

    The user is on the edit post page and he/she makes some changes to the title, content, may be tags, categories, featured image etc.

    I need to pass this modified content to a custom action/function.
    get_post( $post_id ); - will only return the currently saved data and not this modified data.

    Is there a way to invoke the WordPress autosave functionality and get the updated post contents?


    0 0

    I've been trying for the life of me to figure out how to change the default "thumbtack" icon of the "Posts" menu on the backend to something else. Unfortunately, when searching Google for this, all I get is how to do it with Custom Post Types—not the default/existing "post" post-type. I know with a Custom Post Type you use 'menu_icon' in your args when registering the Custom Post Type, but I can't figure out how to do it with 'post'.


    0 0

    Isn't it supposed to?


    0 0

    Hi

    I need of some help please! Would be much appreciated as I am battling with this one.

    See links below along with the scenario.

    Test Site: <a
    http://www.ileaddesign.co.za/scw/
    Brand Link:
    http://www.ileaddesign.co.za/scw/product-brand/brands/fullvision/

    This is what I have have:

    CPT: products
    2 x Taxonomies: product_categories / product_brands

    You add a product and allocate the product to a category (product_categories) and allocate it to a brand (product_brands).

    Under the products page (taxonomy-product_categories.php) you drill down through the different categories till you reach the single product. On the single product you will see that the brand is displayed. I used this tutorial to get this result. The idea is to keep navigating through the categories - http://code.tutsplus.com/articles/create-a-product-listing-with-infinite-categories-using-custom-post-types--wp-23447

    I created another template (taxonomy-product_brands.php) to display the brands title, brands description...and the idea is to do exactly as the (taxonomy-product_categories.php) but display the categories related to that specific brand?

    I am I correct in doing it the way I have done it? By creating another taxonomy called brand_categories?

    <?php
      get_header();
    
      $slug_products = get_query_var( 'term' );
      $term_products = get_term_by( 'slug', $slug_products, 'product_categories' );
      $term_id_products = $term_products->term_id;
    
      $slug_brands = get_query_var( 'term' );
      $term_brands = get_term_by( 'slug', $slug_brands, 'product_brands' );
      $term_id_brands = $term_brands->term_id;
    ?>
    
    <?php // get_template_part( 'parts/featured-image' ); ?>
    
    <div class="row" style="padding-bottom: 40px;">
    
      <?php get_sidebar( 'left' ); ?>
    
      <div class="small-12 large-8 columns right" role="main">
      <?php do_action( 'foundationpress_before_content' ); ?>
    
        <article <?php post_class() ?>>
          <?php do_action( 'foundationpress_page_before_entry_content' ); ?>
    
          <div class="entry-content">
    
            <header><h2 class="entry-title"><?php echo $term_brands->name; ?></h2></header>
    
            <?php
              if ( function_exists('yoast_breadcrumb') ) {
                yoast_breadcrumb('<div id="breadcrumbs">','</div>');
              }
            ?>
    
            <p><?php echo $term_brands->description; ?></p>
    
            <?php
              $args=array(
                'post_type' => 'products',
    
                'tax_query' => array(
                  'relation' => 'AND',
    
                  array(
                    'taxonomy'      => 'product_categories',
                    'hide_empty'    => 0,
                    'parent'        => $term_id_products,
                    'terms'         => $term_products,
                    'field'         => 'slug',
                  ),
    
                  array(
                    'taxonomy'      => 'product_brands',
                    'hide_empty'    => 0,
                    'parent'        => $term_id_brands,
                    'terms'         => $term_brands,
                    'field'         => 'slug',
                  )
                )
              );
    
              $categories=get_categories($args);
    
              if(!$categories){
    
              //get the product category name
              echo "<h3>' .$term_brands->name. ' Products</h3>";
    
              $args = array(
                'posts_per_page' => 50, //remember posts per page should be less or more that what's set in general settings
                'paged' => $paged,
                'order' => 'ASC',
                'tax_query' => array(
                  'relation' => 'AND',
    
                  array(
                    'taxonomy'      => 'product_categories',
                    'hide_empty'    => 0,
                    'parent'        => $term_id_products,
                    'terms'         => $term_products,
                    'field'         => 'slug',
                  ),
    
                  array(
                    'taxonomy'      => 'product_brands',
                    'hide_empty'    => 0,
                    'parent'        => $term_id_brands,
                    'terms'         => $term_brands,
                    'field'         => 'slug',
                  )
                )
              );
            ?>
    
            <!-- if there are no subcategories output current product category's products -->
            <?php
              $products_query = new WP_Query($args);
              if (have_posts()) : while($products_query->have_posts()) : $products_query->the_post();
    
              $thumb_url = get_option('taxonomy_image_plugin');
            ?>
    
            <div class="large-4 column product-cat end" onclick="location.href='<?php echo get_permalink(); ?>';">
              <div class="panel" data-equalizer-watch>
                <div class="prod-img">
    
                  <?php
                    if ( has_post_thumbnail( $post->ID ) ) :
                      $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
                      $image = $image[0];
                      echo '<img src=" ' . $image . ' " />';
                    endif;
                  ?>
    
                </div>
              </div>
    
              <a class="cat-title" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
            </div>
    
            <?php endwhile; endif; ?>
    
            <?php } else {
    
              //output current category name - MOST OF THE ACTION IS HERE
              echo '<h3>'.$term_brands->name.' Products</h3>';
    
              foreach($categories as $category) {
                $product_cat_url = get_term_link( $category->slug, 'product_categories' );
                // $product_cat_url = get_term_link( $term_products, 'product_categories' );
    
                $thumb_url = get_option('taxonomy_image_plugin');
            ?>
    
            <div class="large-4 medium-4 column product-cat" onclick="location.href='<?php echo $product_cat_url ; ?>';">
              <div class="panel" data-equalizer-watch>
                <div class="prod-img"><img src="<?php echo wp_get_attachment_url( $thumb_url[$category->term_id]); ?>" /></div>
              </div>
    
              <a class="cat-title" href="<?php echo $product_cat_url ; ?>"><?php echo $category->name; ?></a>
            </div>
    
          <?php } } ?>
    
          </div> <!--end of entry-->
    
        </article>
    
      <?php do_action( 'foundationpress_after_content' ); ?>
      </div><!-- large-8 -->
    
    </div><!-- outer row -->
    <?php get_footer(); ?>

    0 0

    I do not want to the_modified_time changed when admin change something.

    If I as an admin wants to make small changes in post I do not want to the_modified_time be changed, is it possible?


    0 0

    I will do my best to ask this question in English.

    If I write a answer to a question from Advanced Custom Field.
    Can I use it as a alternativ in a different question?

    Can an title in a custom post type be an option in a question of Advanced custom field?

    Can a category / taxonomy become an option in the advanced custom field?


    0 0

    Hi there,

    I created a template page to implement a purchase order. So in this page, i have my form and then my "controller" send the purchase order to me. But now, I want to create a pdf and link it to the mail.

    I tried html2pdf but I need composer to install dependencies, i'm on shared server so i don't know if i can do that, and i don't know how to.

    Is there any other solution ?

    My english sucks, I know and i'm sorry, I hope you will understand what's my problem.


    0 0

    Theme: 2012

    Trying to make my own plugin using a tutorial in a book I have and the data is not saving. Not sure why or where to begin. Any pointers would be helpful.

    Note: I've kept getting an illegal offset warning but I have since turned debugging off.

    Code is over 100 lines and is located at a Pastebin:
    http://pastebin.com/Q34iMYPk


    0 0

    Hi! I'm trying to add this bit of code into visual editor but it doesn't show the image:

    bg-img{
    background-image:url('imagefile.jpg');
    width:100%;
    }
    <bg-img></bg-img>

    Do you know why it doesn't work?
    I could use the wordpress background image feature but I can't get it to be responsive. I really need the background image to keep a width of 100% while resizing.

    Thanks for your help!


    0 0

    Hello,
    i've used PHP inside the Sidebar to show a Message.

    <?php $HKS_geschlossen = TRUE; ?>
    <?php if ( $HKS_geschlossen): ?>
    TEXT
    <?php endif ;?>

    My problem now is, that I have some more People using that Site, who have to change the Value of $HKS_geschlossen. Is there a Way to create sth like a Checkbox in the Admin-Bar where people with rights can change the Value? Thats what I thought is easy to use for "non-coders". If that doesn't work, does sb. know another way to simply change a Value to display/not display a part in the sidebar?

    Site is: blog.schwimm-club.de

    Martin


    0 0

    Hi there,

    I'm new to WordPress, and developing a plugin. Now, what I have is a plugin with a shortcode, and I added it to a page ("/mypage") like so:

    [my_shortcode]

    All works fine. When visiting "/mypage". Shortcode works.

    Now, in my shortcode callback function I want to be able to use an URL segment to show certain data. E.g. "/mypage/foo" or "mypage/bar".

    But when I visit "/mypage/foo" or "/mypage/bar", I get a 404 page since that page does not exist. How can I prevent this 404 from happening?

    What I want is that the page "/mypage/foo" is simply handled by "/mypage", where my shortcode is on.

    Can I do this somehow?


    0 0

    Hello every one, i recently made all links in my website clickable using this code
    add_filter('the_content', 'make_clickable');

    i have a lot of unclickable links so this solved the problem but i would like them to sent to external tabs. Can some pliz help me with a code to enable that.


    0 0

    Hie,

    So I managed to get my infinite scroll work, but my following jquery doesn't work on new loaded elements.

    $(".projects").click(function (e) {
    e.preventDefault();
    //Do things
    });

    How do I fix that ?
    Thanks all !


    0 0

    Hi,

    I am creating my own widget, which is displaying some information stored in the backend - just as all the "examples" on creating your own custom widget works.

    I now would like to create a page, where I also display some of this information. My idea was to use a shortcode to display the output. In my plugin code I have done the following:

    class GM_Server_Status extends WP_Widget {
    (...)
        public function display_gm_status($atts) {
            extract(shortcode_atts(
                            array(
                'gm' => '',
                            ), $atts)
            );
        }
    }
    add_shortcode('gmstatus', array('GM_Server_Status', 'display_gm_status'));

    I would like to be able to get the $instance values inside the display_gm_status function... But how? Is it possible?


older | 1 | .... | 337 | 338 | (Page 339) | 340 | 341 | .... | 413 | newer