Plugin Directory

Changeset 707277


Ignore:
Timestamp:
05/03/2013 06:02:59 AM (13 years ago)
Author:
DanielTulp
Message:

working, but with wrong method, shortcut builder

Location:
cross-network-posts/trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • cross-network-posts/trunk/cnp.php

    r706376 r707277  
    113113
    114114  //append the icon
    115   $context .= "<a class='thickbox' title='{$title}'
    116     href='#TB_inline?width=400&inlineId={$container_id}'>
     115  $context .= "<a class='button thickbox' title='{$title}'
     116    href='#TB_inline?width=100%&inlineId={$container_id}'>
    117117    CNP</a>";
    118118 
     
    156156        $result = get_categories( $args );
    157157    }
     158    if($type == 'post'){
     159        $args = array(
     160        'posts_per_page'  => -1,
     161        'category'        => '',
     162        'orderby'         => 'post_date',
     163        'order'           => 'DESC',
     164        'include'         => '',
     165        'exclude'         => '',
     166        'meta_key'        => '',
     167        'meta_value'      => '',
     168        'post_type'       => 'post',
     169        'post_mime_type'  => '',
     170        'post_parent'     => '',
     171        'post_status'     => 'publish',
     172        'suppress_filters' => true);
     173        $result = get_posts( $args );
     174    }
    158175    if(ms_is_switched()){
    159176        if( function_exists('restore_current_blog')){ restore_current_blog();}
     
    168185function add_cnp_inline_popup_content() {
    169186?>
     187<style>
     188    fieldset{
     189        width:49%;
     190        float:left;
     191    }
     192    fieldset#result{
     193        width: 100%;
     194    }
     195</style>
    170196<div id="cnp_popup_container" style="display:none;">
    171197  <form method="post" action="">
     198  <fieldset name="content" title="Content" class="cnp-content-field">
    172199    <h4>Choose type of content</h4>
    173200    <input type="radio" name="cnp-type" value="post" class="cnp-type" id="cnp-type-post" /><label for="cnp-type-post">Single post</label><br />
    174     <input type="radio" name="cnp-type" value="category" class="cnp-type" id="cnp-type-category" /><label for="cnp-type-category">Posts from category</label>
    175     <h4>Choose which blog you want to get the content from</h4>
     201    <input type="radio" name="cnp-type" value="category" class="cnp-type" id="cnp-type-category"/><label for="cnp-type-category">Posts from category</label>
     202    <h4>Select the website and content</h4>
    176203    <?php
    177204        foreach(cnp_get_blogs() as $blog):
    178205        ?>
    179206            <input type="radio" name="cnp-blogid" value="<?php echo $blog['blog_id'];?>" class="cnp-blogid" id="cnp-type-blogid-<?php echo $blog['blog_id'];?>" /><label for="cnp-type-blogid-<?php echo $blog['blog_id'];?>"><?php echo $blog['path'];?></label><br />
    180             <select name="cnp-categoryid" class="cnp-categoryid">
     207            <select style="display:none;" name="cnp-categoryid" class="cnp-categories cnp-categoryid-<?php echo $blog['blog_id'];?>">
    181208            <?php
    182209            foreach(cnp_get_content($blog['blog_id'],'cat') as $category):?>
     
    184211                <?php
    185212            endforeach;
    186             ?></select><br />
     213            ?></select>
     214            <select style="display:none;" name="cnp-postid" class="cnp-posts cnp-postid-<?php echo $blog['blog_id'];?>">
     215            <?php
     216            foreach(cnp_get_content($blog['blog_id'],'post') as $post):?>
     217                <option value="<?php echo $post->ID;?>"/><?php echo $post->post_title;?></option>
     218                <?php
     219            endforeach;
     220            ?></select>
     221            <br />
    187222            <?php
    188223        endforeach;
    189224    ?>
    190     <div class="cnpwizard"></div>
     225    </fieldset>
     226    <fieldset name="attributes" title="Optional attributes" class="cnp-attribute-field">
     227    <h4>Optional attributes</h4>
     228        <input type="checkbox" name="excerpt" id="cnp-excerpt" value="false" /><label for="cnp-excerpt">Only show excerpts (default is full post)</label><br />
     229        <label for="header">Header numer (default: 2)</label><input type="text" maxlength="1" name="header" id="header" /><br />
     230        <label for="numberofposts">Number of posts (default: 5)</label><input type="text" name="numberofposts" id="numberofposts" /><br />
     231        <label for="titlelink">Do not link post title (default: has a link)</label><input type="checkbox" maxlength="1" name="numberofposts" id="titlelink" value="false" />
     232    </fieldset>
     233   
     234    <fieldset name="result" id="result">
     235    <input type="button" value="Build shortcode" class="cnp-build-schortcode"/>
     236    <h3>The shortcode is:</h3>
     237    <div class="cnp-shortcode"></div>
     238    </fieldset>
    191239  </form>
    192240 
    193241  <script type="text/javascript">
     242    jQuery('.cnp-type').on('click',function(){
     243        if(jQuery('.cnp-type:checked').val() == 'post'){
     244            jQuery('.cnp-categories').hide();
     245            jQuery('.cnp-posts').show();
     246        }else if(jQuery('.cnp-type:checked').val() == 'category'){
     247            jQuery('.cnp-categories').show();
     248            jQuery('.cnp-posts').hide();
     249        }
     250    });
     251    jQuery('.cnp-build-schortcode').on('click', function(){
     252        jQuery('.cnp-shortcode').text('Loading, please wait...');
     253        var _type = jQuery('.cnp-type:checked').val();
     254        var _blogid = jQuery('.cnp-blogid:checked').val();
     255        var _postid = jQuery('.cnp-postid-'+_blogid+' option:selected').val();
     256        var _catid = jQuery('.cnp-categoryid-'+_blogid+' option:selected').val();
     257        var _excerpt = jQuery('#cnp-excerpt:checked').val();
     258        var _titlelink = jQuery('#titlelink:checked').val();
     259        var _numberofposts = jQuery('#numberofposts').val();
     260        if(_numberofposts == ""){
     261            _numberofposts = null;
     262        }
     263        var _header = jQuery('#header').val();
     264        if(_header == ""){
     265            _header = null;
     266        }
     267       
     268        jQuery.ajax({
     269            type: "POST",
     270            url: "<?php echo plugins_url("cnp-build-shortcode.php" , __FILE__ );?>",
     271            data: { type: _type, blogid: _blogid, postid: _postid, catid: _catid, excerpt: _excerpt, titlelink: _titlelink, numberofposts: _numberofposts, header: _header }
     272        }).done(function(data){
     273            jQuery('.cnp-shortcode').text(data);
     274        });
     275    });
    194276    // jQuery('.cnp-blogid').on('click',function(){
    195277        // jQuery.getJSON('<?php echo plugins_url("cnp-get-blogs.php" , __FILE__ );?>', function(data) {
Note: See TracChangeset for help on using the changeset viewer.