WordPress.org

Plugin Directory

Changeset 530018


Ignore:
Timestamp:
04/11/12 18:28:51 (2 years ago)
Author:
ldebrouwer
Message:

Version 0.3.3. Added the Add New Feed Wizard

Location:
affiliate-press
Files:
8 added
3 edited
7 copied

Legend:

Unmodified
Added
Removed
  • affiliate-press/tags/0.3.3/affiliate-press.php

    r529401 r530018  
    22/** 
    33 * @package Affiliate_Press 
    4  * @version 0.3.2 
     4 * @version 0.3.3 
    55 */ 
    66/* 
     
    99Description: Affiliate Press allows you to set up an affiliate website based on product feeds as easy as 1-2-3. 
    1010Author: ldebrouwer 
    11 Version: 0.3.2 
     11Version: 0.3.3 
    1212Author URI: http://lucdebrouwer.nl/ 
    1313*/ 
     
    3131function AP_activation() { 
    3232    include( LDB_AP_PATH . 'affiliate-press-upgrade.php' ); 
    33     update_option( 'LDB_Affiliate_Press_Version', '0.3.2' ); 
     33    update_option( 'LDB_Affiliate_Press_Version', '0.3.3' ); 
    3434    wp_schedule_event( time(), 'hourly', 'AP_cronjob' ); 
    3535} 
  • affiliate-press/tags/0.3.3/includes/class-affiliate-press.php

    r529401 r530018  
    2929            $pages[] = add_submenu_page( 'affiliate_press', __( 'Feeds', 'LDB_AP' ), __( 'Feeds', 'LDB_AP' ), 'manage_options', 'affiliate_press_feeds', array( &$this, 'AP_feeds' ) ); 
    3030            $pages[] = add_submenu_page( 'affiliate_press', __( 'Add New Feed', 'LDB_AP' ), __( 'Add New Feed', 'LDB_AP' ), 'manage_options', 'affiliate_press_add', array( &$this, 'AP_addFeed' ) ); 
     31            $pages[] = add_submenu_page( 'affiliate_press', __( 'Add New Feed Wizard', 'LDB_AP' ), __( 'Add New Feed Wizard', 'LDB_AP' ), 'manage_options', 'affiliate_press_add_wizard', array( &$this, 'AP_addFeedWizard' ) ); 
    3132            foreach( $pages as $page ) 
    3233                add_action( 'admin_print_styles-' . $page, array( &$this, 'AP_loadStyle' ) ); 
     
    5657        } 
    5758 
     59        /* Function to change the title on hidden pages */ 
    5860        function AP_changeTitle( $admin_title, $title ) { 
    5961            if( isset( $_GET['page'] ) && isset( $this->titles[ $_GET['page'] ] ) ) 
     
    128130        } 
    129131 
     132        /* Function that determines the sortable columns on the products index page. */ 
    130133        function AP_sortableColumns() { 
    131134            return array( 
     
    285288        } 
    286289 
     290        /* Function that shows the add feed page. */ 
     291        function AP_addFeedWizard() { 
     292            $step = 1; 
     293            if( isset( $_POST['step'] ) ) { 
     294                $step = $_POST['step'] + 1; 
     295            } 
     296            if( $step === 2 ) { 
     297                if( $this->AP_issetAndNotEmpty( $_POST, array( 'title', 'currency', 'url' ) ) ) { 
     298                    $nodes = $this->AP_fetchNodesWithChildren( $_POST['url'] ); 
     299                    $item_xpath = $this->AP_buildSelect( 'item_xpath', $nodes, false, true ); 
     300                } else { 
     301                    $this->AP_setMessage( __( "You didn't fill out all the required fields.", 'LDB_AP' ), 'warning' ); 
     302                    $step = 1; 
     303                } 
     304            } else if( $step === 3 ) { 
     305                if( $this->AP_issetAndNotEmpty( $_POST, array( 'title', 'currency', 'url', 'item_xpath' ) ) ) { 
     306                    $xpath = array(); 
     307                    $fields = array( 'name', 'image', 'price', 'link', 'identifier' ); 
     308                    $nodes = $this->AP_fetchChildNodes( $_POST['url'], $_POST['item_xpath'] ); 
     309                    foreach( $fields as $field ) { 
     310                        $xpath[ $field ] = $this->AP_buildSelect( $field . '_xpath', $nodes, false, true ); 
     311                    } 
     312                    $matches = $this->AP_buildSelect( 'matches', $this->AP_getCustomFields() ); 
     313                } else { 
     314                    $nodes = $this->AP_fetchNodesWithChildren( $_POST['url'] ); 
     315                    $item_xpath = $this->AP_buildSelect( 'item_xpath', $nodes, false, true ); 
     316                    $this->AP_setMessage( __( "You didn't fill out all the required fields.", 'LDB_AP' ), 'warning' ); 
     317                    $step = 2; 
     318                } 
     319            } 
     320            include( LDB_AP_VIEW_PATH . 'feed-add-wizard-step' . $step . '.php' ); 
     321        } 
     322 
     323        /* Function that check if the data in an array is set and not empty */ 
     324        function AP_issetAndNotEmpty( $var, $keys ) { 
     325            $check = true; 
     326            foreach( $keys as $key ) { 
     327                if( !isset( $var[ $key ] ) || empty( $var[ $key ] ) ) 
     328                    $check = false; 
     329 
     330            } 
     331            return $check; 
     332        } 
     333 
     334        /* Function that fetches all XPath nodes that have children and occur multiple times. */ 
     335        function AP_fetchNodesWithChildren( $url ) { 
     336            $nodes = array(); 
     337            $temp = array(); 
     338            $data = wp_remote_get( $url ); 
     339            $body = new DOMDocument(); 
     340            @$body->loadXML( $data['body'] ); 
     341            $xpath = new DOMXPath( $body ); 
     342            $items = $xpath->query( '//*[count(*)>0]' ); 
     343            foreach( $items as $item ) { 
     344                if( in_array( $item->nodeName, $temp ) && !in_array( $item->nodeName, $nodes ) ) { 
     345                    $nodes['//' . $item->nodeName] = '//' .$item->nodeName; 
     346                } 
     347                $temp[] = $item->nodeName; 
     348            } 
     349            return $nodes; 
     350        } 
     351 
     352        /* Function that fetches the childnodes for the first occurence of a certain node. */ 
     353        function AP_fetchChildNodes( $url, $item_xpath ) { 
     354            $nodes = array(); 
     355            $data = wp_remote_get( $url ); 
     356            $body = new DOMDocument(); 
     357            @$body->loadXML( $data['body'] ); 
     358            $xpath = new DOMXPath( $body ); 
     359            $query = $item_xpath . '[1]/*'; 
     360            $items = $xpath->query( $item_xpath . '[1]/*' ); 
     361            foreach( $items as $item ) { 
     362                if( !in_array( $item->nodeName, $nodes ) ) { 
     363                    $nodes['.//' . $item->nodeName] = './/' .$item->nodeName; 
     364                } 
     365            } 
     366            return $nodes; 
     367        } 
     368 
    287369        /* Function that shows the edit feed page. */ 
    288370        function AP_editFeed() { 
     
    305387            if( isset( $_GET['post'] ) ) { 
    306388                $postinfo = get_post( $_GET['post'] ); 
    307                 $this->AP_setMessage( sprintf( __( 'The draft for %s was created succesfully.', 'LDB_AP' ), $postinfo->post_title ), 'success' ); 
     389                $this->AP_setMessage( sprintf( __( 'The draft for %s was created successfully.', 'LDB_AP' ), $postinfo->post_title ), 'success' ); 
    308390            } else if( isset( $_GET['linkto'] ) ) { 
    309391                $postinfo = get_post( $_GET['linkto'] ); 
  • affiliate-press/tags/0.3.3/readme.txt

    r529401 r530018  
    22Contributors: ldebrouwer 
    33Donate link: http://luc.me/40 
    4 Tags: affiliate, affiliates, product, products, product feed, product feeds 
     4Tags: affiliate, affiliates, product, products, product feed, product feeds, feed, feeds 
    55Requires at least: 3.3 
    66Tested up to: 3.4 
    7 Stable tag: 0.3.2 
     7Stable tag: 0.3.3 
    88 
    99Affiliate Press allows you to set up an affiliate website based on product feeds as easy as 1-2-3. 
     
    1313Affiliate Press is a plugin that allows you to create products ( as a custom post type ) based on product feeds. It also collects other data for these products, such as prices and affiliate links, which are shown on the product pages in the front end, effectively allowing you to set up your own affiliate website as easy as 1-2-3. 
    1414 
     15Affiliate Press was specifically developed to be compatible with multiple affiliate programs and networks, aiming to support a broader range of feeds and therefor more competitive prices for your visitor. 
     16 
     17Currently I'm looking for people who are willing to send me examples of their product feeds so I can improve this plugin further. Please send your XML product feeds as attachment to [affiliatepress@lucdebrouwer.nl](mailto:affiliatepress@lucdebrouwer.nl). 
     18 
    1519Follow Luc De Brouwer on [Facebook](https://www.facebook.com/lucdebrouwernl) & [Twitter](http://twitter.com/ldebrouwer). 
    1620 
     
    1822 
    19231. Upload the `affiliate-press` folder to the `/wp-content/plugins/` directory 
    20 1. Activate the Affiliate Press plugin through the `Plugins` menu in WordPress 
     241. Activate the Affiliate Press plugin through the 'Plugins' menu in WordPress 
    21251. Configure the plugin by going to the `Affiliate Press` menu that appears in your admin menu 
    2226 
     
    5256 
    5357== Changelog == 
     58 
     59= 0.3.3 = 
     60* Added the 'Add New Feed Wizard'. It's still rudimentary and feedback would be highly appreciated. Should work like a charm with Daisycon feeds. 
    5461 
    5562= 0.3.2 = 
  • affiliate-press/trunk/affiliate-press.php

    r529401 r530018  
    22/** 
    33 * @package Affiliate_Press 
    4  * @version 0.3.2 
     4 * @version 0.3.3 
    55 */ 
    66/* 
     
    99Description: Affiliate Press allows you to set up an affiliate website based on product feeds as easy as 1-2-3. 
    1010Author: ldebrouwer 
    11 Version: 0.3.2 
     11Version: 0.3.3 
    1212Author URI: http://lucdebrouwer.nl/ 
    1313*/ 
     
    3131function AP_activation() { 
    3232    include( LDB_AP_PATH . 'affiliate-press-upgrade.php' ); 
    33     update_option( 'LDB_Affiliate_Press_Version', '0.3.2' ); 
     33    update_option( 'LDB_Affiliate_Press_Version', '0.3.3' ); 
    3434    wp_schedule_event( time(), 'hourly', 'AP_cronjob' ); 
    3535} 
  • affiliate-press/trunk/includes/class-affiliate-press.php

    r529401 r530018  
    2929            $pages[] = add_submenu_page( 'affiliate_press', __( 'Feeds', 'LDB_AP' ), __( 'Feeds', 'LDB_AP' ), 'manage_options', 'affiliate_press_feeds', array( &$this, 'AP_feeds' ) ); 
    3030            $pages[] = add_submenu_page( 'affiliate_press', __( 'Add New Feed', 'LDB_AP' ), __( 'Add New Feed', 'LDB_AP' ), 'manage_options', 'affiliate_press_add', array( &$this, 'AP_addFeed' ) ); 
     31            $pages[] = add_submenu_page( 'affiliate_press', __( 'Add New Feed Wizard', 'LDB_AP' ), __( 'Add New Feed Wizard', 'LDB_AP' ), 'manage_options', 'affiliate_press_add_wizard', array( &$this, 'AP_addFeedWizard' ) ); 
    3132            foreach( $pages as $page ) 
    3233                add_action( 'admin_print_styles-' . $page, array( &$this, 'AP_loadStyle' ) ); 
     
    5657        } 
    5758 
     59        /* Function to change the title on hidden pages */ 
    5860        function AP_changeTitle( $admin_title, $title ) { 
    5961            if( isset( $_GET['page'] ) && isset( $this->titles[ $_GET['page'] ] ) ) 
     
    128130        } 
    129131 
     132        /* Function that determines the sortable columns on the products index page. */ 
    130133        function AP_sortableColumns() { 
    131134            return array( 
     
    285288        } 
    286289 
     290        /* Function that shows the add feed page. */ 
     291        function AP_addFeedWizard() { 
     292            $step = 1; 
     293            if( isset( $_POST['step'] ) ) { 
     294                $step = $_POST['step'] + 1; 
     295            } 
     296            if( $step === 2 ) { 
     297                if( $this->AP_issetAndNotEmpty( $_POST, array( 'title', 'currency', 'url' ) ) ) { 
     298                    $nodes = $this->AP_fetchNodesWithChildren( $_POST['url'] ); 
     299                    $item_xpath = $this->AP_buildSelect( 'item_xpath', $nodes, false, true ); 
     300                } else { 
     301                    $this->AP_setMessage( __( "You didn't fill out all the required fields.", 'LDB_AP' ), 'warning' ); 
     302                    $step = 1; 
     303                } 
     304            } else if( $step === 3 ) { 
     305                if( $this->AP_issetAndNotEmpty( $_POST, array( 'title', 'currency', 'url', 'item_xpath' ) ) ) { 
     306                    $xpath = array(); 
     307                    $fields = array( 'name', 'image', 'price', 'link', 'identifier' ); 
     308                    $nodes = $this->AP_fetchChildNodes( $_POST['url'], $_POST['item_xpath'] ); 
     309                    foreach( $fields as $field ) { 
     310                        $xpath[ $field ] = $this->AP_buildSelect( $field . '_xpath', $nodes, false, true ); 
     311                    } 
     312                    $matches = $this->AP_buildSelect( 'matches', $this->AP_getCustomFields() ); 
     313                } else { 
     314                    $nodes = $this->AP_fetchNodesWithChildren( $_POST['url'] ); 
     315                    $item_xpath = $this->AP_buildSelect( 'item_xpath', $nodes, false, true ); 
     316                    $this->AP_setMessage( __( "You didn't fill out all the required fields.", 'LDB_AP' ), 'warning' ); 
     317                    $step = 2; 
     318                } 
     319            } 
     320            include( LDB_AP_VIEW_PATH . 'feed-add-wizard-step' . $step . '.php' ); 
     321        } 
     322 
     323        /* Function that check if the data in an array is set and not empty */ 
     324        function AP_issetAndNotEmpty( $var, $keys ) { 
     325            $check = true; 
     326            foreach( $keys as $key ) { 
     327                if( !isset( $var[ $key ] ) || empty( $var[ $key ] ) ) 
     328                    $check = false; 
     329 
     330            } 
     331            return $check; 
     332        } 
     333 
     334        /* Function that fetches all XPath nodes that have children and occur multiple times. */ 
     335        function AP_fetchNodesWithChildren( $url ) { 
     336            $nodes = array(); 
     337            $temp = array(); 
     338            $data = wp_remote_get( $url ); 
     339            $body = new DOMDocument(); 
     340            @$body->loadXML( $data['body'] ); 
     341            $xpath = new DOMXPath( $body ); 
     342            $items = $xpath->query( '//*[count(*)>0]' ); 
     343            foreach( $items as $item ) { 
     344                if( in_array( $item->nodeName, $temp ) && !in_array( $item->nodeName, $nodes ) ) { 
     345                    $nodes['//' . $item->nodeName] = '//' .$item->nodeName; 
     346                } 
     347                $temp[] = $item->nodeName; 
     348            } 
     349            return $nodes; 
     350        } 
     351 
     352        /* Function that fetches the childnodes for the first occurence of a certain node. */ 
     353        function AP_fetchChildNodes( $url, $item_xpath ) { 
     354            $nodes = array(); 
     355            $data = wp_remote_get( $url ); 
     356            $body = new DOMDocument(); 
     357            @$body->loadXML( $data['body'] ); 
     358            $xpath = new DOMXPath( $body ); 
     359            $query = $item_xpath . '[1]/*'; 
     360            $items = $xpath->query( $item_xpath . '[1]/*' ); 
     361            foreach( $items as $item ) { 
     362                if( !in_array( $item->nodeName, $nodes ) ) { 
     363                    $nodes['.//' . $item->nodeName] = './/' .$item->nodeName; 
     364                } 
     365            } 
     366            return $nodes; 
     367        } 
     368 
    287369        /* Function that shows the edit feed page. */ 
    288370        function AP_editFeed() { 
     
    305387            if( isset( $_GET['post'] ) ) { 
    306388                $postinfo = get_post( $_GET['post'] ); 
    307                 $this->AP_setMessage( sprintf( __( 'The draft for %s was created succesfully.', 'LDB_AP' ), $postinfo->post_title ), 'success' ); 
     389                $this->AP_setMessage( sprintf( __( 'The draft for %s was created successfully.', 'LDB_AP' ), $postinfo->post_title ), 'success' ); 
    308390            } else if( isset( $_GET['linkto'] ) ) { 
    309391                $postinfo = get_post( $_GET['linkto'] ); 
  • affiliate-press/trunk/readme.txt

    r529401 r530018  
    22Contributors: ldebrouwer 
    33Donate link: http://luc.me/40 
    4 Tags: affiliate, affiliates, product, products, product feed, product feeds 
     4Tags: affiliate, affiliates, product, products, product feed, product feeds, feed, feeds 
    55Requires at least: 3.3 
    66Tested up to: 3.4 
    7 Stable tag: 0.3.2 
     7Stable tag: 0.3.3 
    88 
    99Affiliate Press allows you to set up an affiliate website based on product feeds as easy as 1-2-3. 
     
    1313Affiliate Press is a plugin that allows you to create products ( as a custom post type ) based on product feeds. It also collects other data for these products, such as prices and affiliate links, which are shown on the product pages in the front end, effectively allowing you to set up your own affiliate website as easy as 1-2-3. 
    1414 
     15Affiliate Press was specifically developed to be compatible with multiple affiliate programs and networks, aiming to support a broader range of feeds and therefor more competitive prices for your visitor. 
     16 
     17Currently I'm looking for people who are willing to send me examples of their product feeds so I can improve this plugin further. Please send your XML product feeds as attachment to [affiliatepress@lucdebrouwer.nl](mailto:affiliatepress@lucdebrouwer.nl). 
     18 
    1519Follow Luc De Brouwer on [Facebook](https://www.facebook.com/lucdebrouwernl) & [Twitter](http://twitter.com/ldebrouwer). 
    1620 
     
    1822 
    19231. Upload the `affiliate-press` folder to the `/wp-content/plugins/` directory 
    20 1. Activate the Affiliate Press plugin through the `Plugins` menu in WordPress 
     241. Activate the Affiliate Press plugin through the 'Plugins' menu in WordPress 
    21251. Configure the plugin by going to the `Affiliate Press` menu that appears in your admin menu 
    2226 
     
    5256 
    5357== Changelog == 
     58 
     59= 0.3.3 = 
     60* Added the 'Add New Feed Wizard'. It's still rudimentary and feedback would be highly appreciated. Should work like a charm with Daisycon feeds. 
    5461 
    5562= 0.3.2 = 
Note: See TracChangeset for help on using the changeset viewer.