0) { $message = sprintf(esc_html__( 'aimojo: %s ' , 'aimojo'), $af_errors); } af_update_url(); update_option("af_post_type_posts", "true"); //setting default to turn on affinitomics for pages update_option("af_post_type_pages", "true"); //setting default to turn on affinitomics for posts update_option("af_post_type_products", "true"); //setting default to turn on affinitomics for posts } if (strlen($message) > 0) { bail_on_activation( $message ); } } function plugin_deactivation( ) { //TODO: } function days_since_activation() { if( !get_option( "af_install_date" ) ) { //setup the install date option update_option("af_install_date", current_time( 'timestamp' )); } $install_time = get_option("af_install_date"); $days = current_time( 'timestamp' ) - $install_time; $days = floor($days / 86400); //how many days since first installed return $days; } function check_registration_remaining() { $elapsed = days_since_activation(); if ($elapsed >= 30) { $af_key = af_verify_key(); $af_cloud_url = af_verify_provider(); $status_request = curl_request($af_cloud_url . "/api/account_status?user_key=" . $af_key); $status_response = json_decode($status_request, true); $account_status_type = $status_response['data']['account_type']; if($account_status_type == 'Anonymous') { return false; } } return true; } function bail_on_activation( $message, $deactivate = true ) { ?>
$plugin ) { if ( $plugin === $akismet ) { $plugins[$i] = false; $update = true; } } if ( $update ) { update_option( 'active_plugins', array_filter( $plugins ) ); } } exit; } function my_script_enqueuer() { wp_enqueue_script( 'jquery' ); $plugins_ajax_script_url = plugins_url( 'affinitomics_ajax_script.js', __FILE__ ); wp_register_script( "affinitomics_ajax_script", $plugins_ajax_script_url, array('jquery') ); wp_localize_script( 'affinitomics_ajax_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ))); wp_enqueue_script( 'affinitomics_ajax_script' ); } function custom_restore_function($post_ID) { $the_key = af_verify_key(); $af_cloud_url = af_verify_provider(); $url = get_permalink($post_ID); $request = curl_request($af_cloud_url . "/api/restore_resource?user_key=" . $the_key . '&uid=' . $post_ID . '&url=' . $url); } add_action('untrash_post', 'custom_restore_function'); /* Ensure pages have category IDs for server compatability. We'll want to document in the help file that we have this effect on a person's wordpress install. */ function add_categories_to_pages() { register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'add_categories_to_pages' ); /* Page Types to Apply Affinitomics */ $screens = array(); // if (get_option('af_post_type_affinitomics','true') == 'true') $screens[] = 'archetype'; if (get_option('af_post_type_posts','false') == 'true') $screens[] = 'post'; if (get_option('af_post_type_pages','false') == 'true') $screens[] = 'page'; if (get_option('af_post_type_products','false') == 'true') $screens[] = 'product'; if (get_option('af_post_type_projects','false') == 'true') $screens[] = 'project'; if (get_option('af_post_type_listings','false') == 'true') $screens[] = 'listing'; add_action('admin_menu', 'remove_extra_submenu_items'); function remove_extra_submenu_items() { global $submenu; unset($submenu["edit.php?post_type=archetype"][10]); unset($submenu["edit.php?post_type=archetype"][5]); } function af_verify_key() { $af_key = get_option('af_key'); if (!isset($af_key) || $af_key == "") { $af_cloud_url = af_verify_provider(); $request = curl_request($af_cloud_url . "/api/anon_key"); $response = json_decode($request, true); $af_key = $response['data']['anon_key']; update_option( 'af_key' , $af_key ); } return $af_key; } function af_check_for_errors(){ $the_key = af_verify_key(); $af_cloud_url = af_verify_provider(); $request = curl_request($af_cloud_url . "/check_for_errors?user_key=" . $the_key); $response = json_decode($request, true); update_option( 'af_errors' , $response['data']['af_errors'] ); update_option( 'af_error_code' , $response['data']['af_error_code'] ); } function af_verify_provider() { $af_cloud_url = get_option('af_cloud_url', ''); if (!isset($af_cloud_url) || $af_cloud_url == "") { $af_cloud_url = 'www.affinitomics.com'; // $af_cloud_url = 'localhost:3000'; //TODO: this is just for testing update_option( 'af_cloud_url' , $af_cloud_url ); } return $af_cloud_url; } function af_update_url() { $affinitomics = array( 'url' => get_site_url(), 'title' => '', 'descriptors' => '', 'draws' => '', 'distances' => '', 'key' => af_verify_key(), 'uid' => '', 'category' => '', 'status' => '' ); if ($afid) $affinitomics['afid'] = $afid; $af_cloudify_url = get_option('af_cloud_url') . '/api/affinitomics/cloudify/' . af_verify_key() . '/'; $request = curl_request($af_cloudify_url, $affinitomics); } /* Save Custom DATA */ function afpost_save_postdata() { af_verify_key(); af_verify_provider(); $post_ID = get_the_id(); $post_status = get_post_status($post_ID); // Collect descriptor terms from the post $these_descriptors = wp_get_post_terms( $post_ID, "descriptor" ); $descriptor_terms = array(); foreach ($these_descriptors as $descriptor) { array_push($descriptor_terms, $descriptor->name); } // Collect draw terms from the post $these_draws = wp_get_post_terms( $post_ID, "draw" ); $draw_terms = array(); foreach ($these_draws as $draw) { array_push($draw_terms, $draw->name); } // Collect distance terms from the post $these_distances = wp_get_post_terms( $post_ID, "distance" ); $distance_terms = array(); foreach ($these_distances as $distance) { array_push($distance_terms, $distance->name); } // implode the data $afpost_descriptors = implode(",", $descriptor_terms); $afpost_draw = implode(",", $draw_terms); $afpost_distance = implode(",", $distance_terms); // Save Meta DATA add_post_meta($post_ID, '_afpost_descriptors', $afpost_descriptors, true) or update_post_meta($post_ID, '_afpost_descriptors', $afpost_descriptors); add_post_meta($post_ID, '_afpost_draw', $afpost_draw, true) or update_post_meta($post_ID, '_afpost_draw', $afpost_draw); add_post_meta($post_ID, '_afpost_distance', $afpost_distance, true) or update_post_meta($post_ID, '_afpost_distance', $afpost_distance); // Affinitomic ID $afid = get_post_meta($post_ID, 'afid', true); // Categories String $cat_string = ''; // Save Data To Prefrent Cloud global $af_flag; if ($af_flag == 0) { $cat_string = ''; $categories = get_the_category($id); if ($categories) { $cats = array(); foreach($categories as $cat) { $cats[] = $cat->term_id; } $cat_string = implode(",", $cats); } $affinitomics = array( 'url' => get_permalink($post_ID), 'title' => get_the_title($post_ID), 'descriptors' => $afpost_descriptors, 'draws' => $afpost_draw, 'distances' => $afpost_distance, 'key' => af_verify_key(), 'uid' => $post_ID, 'category' => $cat_string, 'status' => $post_status ); if ($afid) $affinitomics['afid'] = $afid; $af_cloudify_url = get_option('af_cloud_url') . '/api/affinitomics/cloudify/' . af_verify_key() . '/'; $request = curl_request($af_cloudify_url, $affinitomics); $af = json_decode($request, true); if (isset($af['data']['objectId'])) { update_post_meta($post_ID, 'afid', $af['data']['objectId']); } } $af_flag = 1; } /* ---------------------------------------------------------------------- CUSTOM TAXONOMY ---------------------------------------------------------------------- */ // Register Custom Taxonomy Descriptor function descriptor_taxonomy() { $labels = array( 'name' => _x( 'Descriptors', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Descriptor', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'Descriptor', 'text_domain' ), 'all_items' => __( 'All Descriptors', 'text_domain' ), 'parent_item' => __( 'Parent Descriptor', 'text_domain' ), 'parent_item_colon' => __( 'Parent Descriptor:', 'text_domain' ), 'new_item_name' => __( 'New Descriptor', 'text_domain' ), 'add_new_item' => __( 'Add New Descriptor', 'text_domain' ), 'edit_item' => __( 'Edit Descriptor', 'text_domain' ), 'update_item' => __( 'Update Descriptor', 'text_domain' ), 'separate_items_with_commas' => __( 'Descriptors are similar to Categories in Wordpress. Separate each Descriptor with commas. e.g. Summer Activities, Hobbies', 'text_domain' ), 'search_items' => __( 'Search descriptors', 'affinitomics' ), 'add_or_remove_items' => __( 'Add or remove descriptors', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used Descriptors', 'text_domain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, 'show_in_menu' => true, ); global $screens; register_taxonomy( 'descriptor', $screens, $args ); } // Hook into the 'init' action add_action( 'init', 'descriptor_taxonomy', 0 ); register_taxonomy_for_object_type( 'item', 'product' ); // Register Custom Taxonomy Draw function draw_taxonomy() { $labels = array( 'name' => _x( 'Positive Relationships (Draws)', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Draw', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'Draw', 'text_domain' ), 'all_items' => __( 'All Draws', 'text_domain' ), 'parent_item' => __( 'Parent Draw', 'text_domain' ), 'parent_item_colon' => __( 'Parent Draw:', 'text_domain' ), 'new_item_name' => __( 'New Draw', 'text_domain' ), 'add_new_item' => __( 'Add New Draw', 'text_domain' ), 'edit_item' => __( 'Edit Draw', 'text_domain' ), 'update_item' => __( 'Update Draw', 'text_domain' ), 'separate_items_with_commas' => __( 'Syntax: Draws can have a magnitude from 1 to 5 written as a suffix, with each draw separated by a comma. If a magnitude is not present, a magnitude of one will be assumed. e.g. Cats5, Laser Pointer2', 'text_domain' ), 'search_items' => __( 'Search draws', 'affinitomics' ), 'add_or_remove_items' => __( 'Add or remove draws', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used Draws', 'text_domain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, ); global $screens; register_taxonomy( 'draw', $screens, $args ); } // Hook into the 'init' action add_action( 'init', 'draw_taxonomy', 0 ); register_taxonomy_for_object_type( 'item', 'product' ); // Register Custom Taxonomy Distance function distance_taxonomy() { $labels = array( 'name' => _x( 'Negative Relationships (Distances)', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Distance', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'Distance', 'text_domain' ), 'all_items' => __( 'All Distances', 'text_domain' ), 'parent_item' => __( 'Parent Distance', 'text_domain' ), 'parent_item_colon' => __( 'Parent Distance:', 'text_domain' ), 'new_item_name' => __( 'New Distance', 'text_domain' ), 'add_new_item' => __( 'Add New Distance', 'text_domain' ), 'edit_item' => __( 'Edit Distance', 'text_domain' ), 'update_item' => __( 'Update Distance', 'text_domain' ), 'separate_items_with_commas' => __( 'Syntax: Distances can have a magnitude of 1 to 5, written as a suffix, with each distance separated by a comma. If a magnitude is not present, a magnitude of one will be assumed. e.g. Nickelback5, Canada2', 'text_domain' ), 'search_items' => __( 'Search distances', 'affinitomics' ), 'add_or_remove_items' => __( 'Add or remove Distance', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used Distances', 'text_domain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, ); global $screens; register_taxonomy( 'distance', $screens, $args ); } // Hook into the 'init' action add_action( 'init', 'distance_taxonomy', 0 ); register_taxonomy_for_object_type( 'item', 'product' ); /* ---------------------------------------------------------------------- Register "Archetype" post type ---------------------------------------------------------------------- */ // Register Custom Post Type function arche_type() { $labels = array( 'name' => __( 'Archetypes', 'Post Type General Name', 'text_domain' ), 'singular_name' => __( 'Archetype', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Affinitomics™', 'text_domain' ), 'parent_item_colon' => __( 'Parent Archetype:', 'text_domain' ), 'all_items' => __( 'All Archetypes', 'text_domain' ), 'view_item' => __( 'View Archetype', 'text_domain' ), 'add_new_item' => __( 'Add New Archetype', 'text_domain' ), 'add_new' => __( 'New Archetype', 'text_domain' ), 'edit_item' => __( 'Edit Archetype', 'text_domain' ), 'update_item' => __( 'Update Archetype', 'text_domain' ), 'search_items' => __( 'Search Archetypes', 'text_domain' ), 'not_found' => __( 'No archetypes found', 'text_domain' ), 'not_found_in_trash' => __( 'No archetypes found in Trash', 'text_domain' ), ); $args = array( 'label' => __( 'archetype', 'text_domain' ), 'description' => __( 'Archetype information pages', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'post-formats', ), 'taxonomies' => array( 'descriptor', 'draw', 'distance' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'menu_icon' => plugins_url( 'affinitomics-favicon.svg', __FILE__ ), 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', ); register_post_type( 'archetype', $args ); } // // Hook into the 'init' action add_action( 'init', 'arche_type', 0 ); /* ---------------------------------------------------------------------- RELATED POSTS SHORTCODE Examples: [afview], [afview limit="4"], [afview category_filter="50"] [afview limit=1 display_title="false"] ---------------------------------------------------------------------- */ //register shortcode add_shortcode("afview", "afview_handler"); //handle shortcode function afview_handler( $atts, $content = null ) { $afview_output = afview_function($atts); return $afview_output; } //process shortcode function afview_function($atts) { af_verify_key(); af_verify_provider(); global $screens; extract( shortcode_atts( array( 'affinitomics' => null, 'display_title' => 'true', 'limit' => 10, 'category_filter' => '', 'title' => '' ), $atts ) ); // Start output // $afview_output = 'Your Affinitomics are saved in the cloud each time you publish a page or post so that our servers can do the heavy computation lift, leaving yours free to serve web pages as fast as possible. You only need to export your Affinitomics to the cloud if:
Again, pages, posts and custom post types ( those specified in the "settings" tab ) added or edited individually after ai•mojo was installed automatically save their Affinitomic elements to the cloud when published.
This is where you tell your Wordpress install how to talk to our system. Once set, we can do the heavy lifting when it comes to measuring relationships within your site – meaning that you can maintain a lightweight, fast site with the power of a much more robust intelligent system. Once these settings are made, archetypes will be created and saved in the Affinitomics I.Q. cloud whenever you save information containing Affinitomics on your site.
Legacy Data and the Export Function
Legacy data (stuff you already had saved before you installed ai•mojo) will not automatically become Affinitomic Archetypes. You will have to tell ai•mojo to do that for you. Once you’ve turned your legacy data into Affinitomic archetypes, you will need to export the data to the cloud (see export tab).
Learn how you can find related posts, and display them to your users, by '; $pointer_content .= 'adding draws, distances, and descriptors.
'; ?> Set up a post with aimojo!'; // Title should beAdd descriptors, draws, and distances to setup relationships with other posts.
'; $pointer_content .= 'Then add the [afview] shortcode to find and display related post links to your users.
'; ?> Add aimojo relationships!'; // Title should beAdd the shortcode [afview] in your post to view other related posts.
'; $pointer_content .= 'Be sure to scroll down on the right side of the page'; $pointer_content .= ' to add draws, distances, and descriptors to your posts.
'; ?> aimojo tip: add descriptors'; // Title should beAdd terms that describe your post.
'; $pointer_content .= 'A post about cars might include the descriptors: cars, automobiles.
'; ?> aimojo tip: add draws'; // Title should beAdd draws that are related to your descriptors.
'; $pointer_content .= 'For example, a post about cars might include the draws: horsepower, nascar, racing, ferrari.
'; ?> aimojo tip: add distances'; // Title should beAdd distances that are things opposite to the draws and descriptors.
"; $pointer_content .= 'For example, a post about cars might include the distances: bicycle, boat, rain.
'; ?>Getting Started!
In a few short minutes, your site will be able to Match, Rank, and Relate information in posts, pages, and custom post-types better than ever before. You'll experience "stickier" sites that convert better and faster, while providing rich and relevant links for SEO.
aimojo-crash-course from Prefrent on Vimeo.
|
||
|
Jump Search
Jump Search combines Google CSE and Affinitomics for incredibly contextual searches. Requires a free Google API key, can be configured in less than five minutes. |
||
| Archetype | Any page or post-type (any piece of information really) that contains one or more descriptors, draws, or distances such that the information can be intelligently compared to other archetypes. |
| Descriptor | A descriptor is similar to a tag, but is used to describe whatever it is attached to. It's not uncommon for a page to have a descriptor of "web page." A page about cars might include the descriptors "page, cars, automobiles." |
| Draw | A draw is also similar to a tag, but is used to record what the descriptors are related to, or co-occur with. A page about cars might include the draws "horsepower, nascar, racing, gear-head." |
| Distance | These are the opposites of draws and indicate things that oppose the descriptors or draws attached to an archetype. A page about cars might include the distances "bicycle, boat, rain." |
| Smart List | A list created with [afview] shortcode, displaying Affinitomic relationships sorted by contextual match. |
| The first thing you'll want to do, is make sure your "permalinks" are set how you want them. aimojo exports to the cloud with a URI based on your permalinks. If they change, your Affinitomic™ links will be broken. Resetting them currently requires registering a new account. |
|
[afview] has an available selector:
This page will have a form that allows the user to control certain CSS and layout elements