• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wl_write_log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wl_write_log函数的典型用法代码示例。如果您正苦于以下问题:PHP wl_write_log函数的具体用法?PHP wl_write_log怎么用?PHP wl_write_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wl_write_log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wl_core_install_create_relation_instance_table

/**
 * Install known types in WordPress.
 */
function wl_core_install_create_relation_instance_table()
{
    global $wpdb;
    // global $wl_db_version;
    $installed_version = get_option("wl_db_version");
    if ($installed_version != WL_DB_VERSION) {
        $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
        $charset_collate = $wpdb->get_charset_collate();
        // Sql statement for the relation instances custom table
        $sql = <<<EOF
\t\t\tCREATE TABLE {$table_name} (
  \t\t\t\tid int(11) NOT NULL AUTO_INCREMENT,
  \t\t\t\tsubject_id int(11) NOT NULL,
  \t\t\t\tpredicate char(10) NOT NULL,
  \t\t\t\tobject_id int(11) NOT NULL,
  \t\t\t\tUNIQUE KEY id (id),
  \t\t\t\tKEY subject_id_index (subject_id),
  \t\t\t\tKEY object_id_index (object_id)
\t\t\t) {$charset_collate};
EOF;
        // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        $results = dbDelta($sql);
        wl_write_log($results);
        update_option("wl_db_version", WL_DB_VERSION);
    }
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:30,代码来源:wordlift_core_install.php


示例2: wordlift_ajax_related_posts

function wordlift_ajax_related_posts($http_raw_data = null)
{
    // Extract filtering conditions
    if (!isset($_GET["post_id"]) || !is_numeric($_GET["post_id"])) {
        wp_die('Post id missing or invalid!');
        return;
    }
    $post_id = $_GET["post_id"];
    // Get the current post
    $post = get_post($post_id);
    wl_write_log("Going to find posts related to current with post id: {$post_id} ...");
    // Extract filtering conditions
    $filtering_entity_uris = null == $http_raw_data ? file_get_contents("php://input") : $http_raw_data;
    $filtering_entity_uris = json_decode($filtering_entity_uris);
    $filtering_entity_ids = wl_get_entity_post_ids_by_uris($filtering_entity_uris);
    $related_posts = array();
    // If the current post is an antity
    // related posts to the current entity are returned
    if (Wordlift_Entity_Service::TYPE_NAME == $post->post_type) {
        $filtering_entity_ids = array($post_id);
    }
    if (!empty($filtering_entity_ids)) {
        $related_posts = wl_core_get_posts(array('get' => 'posts', 'related_to__in' => $filtering_entity_ids, 'post__not_in' => array($post_id), 'post_type' => 'post', 'post_status' => 'publish', 'as' => 'subject'));
        foreach ($related_posts as $post_obj) {
            $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post_obj->ID, 'thumbnail'));
            $post_obj->thumbnail = $thumbnail ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH;
            $post_obj->link = get_edit_post_link($post_obj->ID, 'none');
            $post_obj->permalink = get_post_permalink($post_obj->ID);
        }
    }
    wl_core_send_json($related_posts);
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:32,代码来源:wordlift_admin_ajax_related_posts.php


示例3: rl_execute_sparql_update_query

/**
 * Execute a query on Redlink.
 *
 * @since 3.0.0
 *
 * @uses wl_queue_sparql_update_query() to queue a query if query buffering is on.
 *
 * @param string $query The query to execute.
 * @param bool $queue Whether to queue the update.
 *
 * @return bool True if successful otherwise false.
 */
function rl_execute_sparql_update_query($query, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING)
{
    // Get the calling function for debug purposes.
    $callers = debug_backtrace();
    $calling_function = $callers[1]['function'];
    wl_write_log("[ calling function :: {$calling_function} ][ queue :: " . ($queue ? 'true' : 'false') . ' ]');
    // Queue the update query.
    if ($queue) {
        wl_queue_sparql_update_query($query);
        return true;
    }
    // Get the update end-point.
    $url = wl_configuration_get_query_update_url();
    // Prepare the request.
    $args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array('method' => 'POST', 'headers' => array('Accept' => 'application/json', 'Content-type' => 'application/sparql-update; charset=utf-8'), 'body' => $query));
    // Send the request.
    $response = wp_remote_post($url, $args);
    // If an error has been raised, return the error.
    if (is_wp_error($response) || 200 !== (int) $response['response']['code']) {
        $body = is_wp_error($response) ? $response->get_error_message() : $response['body'];
        wl_write_log("rl_execute_sparql_update_query : error [ url :: {$url} ][ args :: ");
        wl_write_log("\n" . var_export($args, true));
        wl_write_log("[ response :: ");
        wl_write_log("\n" . var_export($response, true));
        wl_write_log("][ body :: ");
        wl_write_log("\n" . $body);
        wl_write_log("]");
        return false;
    }
    wl_write_log("rl_execute_sparql_query [ url :: {$url} ][ response code :: " . $response['response']['code'] . " ][ query :: ");
    wl_write_log("\n" . $query);
    wl_write_log("]");
    return true;
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:46,代码来源:wordlift_redlink.php


示例4: wl_shortcode_timeline_get_events

/**
 * Retrieve timeline events.
 *
 * @uses wl_core_get_related_entity_ids() to retrieve the entities referenced by the specified post.
 *
 * @param int $post_id The post ID.
 * @return array An array of event posts.
 */
function wl_shortcode_timeline_get_events($post_id = null)
{
    // Build list of event-entities.
    if (is_null($post_id) || !is_numeric($post_id)) {
        // Global timeline. Get entities from the latest posts.
        $latest_posts_ids = get_posts(array('numberposts' => 50, 'fields' => 'ids', 'post_type' => 'post', 'post_status' => 'publish'));
        if (empty($latest_posts_ids)) {
            // There are no posts.
            return array();
        }
        // Collect entities related to latest posts
        $entity_ids = array();
        foreach ($latest_posts_ids as $id) {
            $entity_ids = array_merge($entity_ids, wl_core_get_related_entity_ids($id, array('status' => 'publish')));
        }
        if (empty($entity_ids)) {
            return array();
        }
    } else {
        // Post-specific timeline. Search for entities in the post itself.
        $entity_ids = wl_core_get_related_entity_ids($post_id);
    }
    wl_write_log("wl_shortcode_timeline_get_events [ entity IDs :: " . join(', ', $entity_ids) . " ]");
    return get_posts(array('post__in' => $entity_ids, 'post_type' => WL_ENTITY_TYPE_NAME, 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => WL_CUSTOM_FIELD_CAL_DATE_START, 'value' => null, 'compare' => '!='), array('key' => WL_CUSTOM_FIELD_CAL_DATE_END, 'value' => null, 'compare' => '!='))));
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:33,代码来源:wordlift_shortcode_timeline.php


示例5: rl_execute_sparql_update_query

/**
 * Execute a query on Redlink.
 *
 * @since 3.0.0
 *
 * @uses wl_queue_sparql_update_query() to queue a query if query buffering is on.
 *
 * @param string $query The query to execute.
 * @param bool $queue Whether to queue the update.
 *
 * @return bool True if successful otherwise false.
 */
function rl_execute_sparql_update_query($query, $queue = WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING)
{
    // Queue the update query.
    if ($queue) {
        if (WP_DEBUG) {
            global $wl_logger;
            $wl_logger->trace("Buffering a query [ query :: {$query} ]");
        }
        wl_queue_sparql_update_query($query);
        return true;
    }
    // Get the update end-point.
    $url = wl_configuration_get_query_update_url();
    // Prepare the request.
    $args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array('method' => 'POST', 'headers' => array('Accept' => 'application/json', 'Content-type' => 'application/sparql-update; charset=utf-8'), 'body' => $query));
    // Send the request.
    $response = wp_remote_post($url, $args);
    // If an error has been raised, return the error.
    if (is_wp_error($response) || 200 !== (int) $response['response']['code']) {
        $body = is_wp_error($response) ? $response->get_error_message() : $response['body'];
        wl_write_log("rl_execute_sparql_update_query : error [ url :: {$url} ][ args :: ");
        wl_write_log("\n" . var_export($args, true));
        wl_write_log("[ response :: ");
        wl_write_log("\n" . var_export($response, true));
        wl_write_log("][ body :: ");
        wl_write_log("\n" . $body);
        wl_write_log("]");
        return false;
    }
    if (WP_DEBUG) {
        global $wl_logger;
        $wl_logger->trace("Query executed successfully [ query :: {$query} ]");
    }
    return true;
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:47,代码来源:wordlift_redlink.php


示例6: wordlift_shortcode_navigator_populate

/**
* Get list of posts that will populate the navigator.
* 
* @param int $post_id Id of the post.
* 
* @return Array List of tuples organized in this way:
*      Array(
*          [0] => Array(
*              [0] => related post Object
*              [1] => related entity Object (main post and the post above are related via this entity)
*          )
*          [1] => another tuple
           [2] => ...
*      )
*/
function wordlift_shortcode_navigator_populate($post_id)
{
    // prepare structures to memorize other related posts
    $related_posts_ids = array();
    $related_posts = array();
    // get the related entities, ordered by WHO-WHAT-WHERE-WHEN (as established the 29/7/2015 12:45 in the grottino)
    // TODO: should be a single query
    $related_entities = wl_core_get_related_entities($post_id, array('predicate' => WL_WHO_RELATION, 'status' => 'publish'));
    $related_entities = array_merge($related_entities, wl_core_get_related_entities($post_id, array('predicate' => WL_WHAT_RELATION, 'status' => 'publish')));
    $related_entities = array_merge($related_entities, wl_core_get_related_entities($post_id, array('predicate' => WL_WHERE_RELATION, 'status' => 'publish')));
    $related_entities = array_merge($related_entities, wl_core_get_related_entities($post_id, array('predicate' => WL_WHEN_RELATION, 'status' => 'publish')));
    foreach ($related_entities as $rel_entity) {
        wl_write_log("Looking for posts related to entity {$rel_entity->ID}");
        // take the id of posts referencing the entity
        $referencing_posts = wl_core_get_related_posts($rel_entity->ID, array('status' => 'publish'));
        // loop over them and take the first one which is not already in the $related_posts
        foreach ($referencing_posts as $referencing_post) {
            if (!in_array($referencing_post->ID, $related_posts_ids) && $referencing_post->ID != $post_id) {
                $related_posts_ids[] = $referencing_post->ID;
                $related_posts[] = array($referencing_post, $rel_entity);
            }
        }
    }
    wl_write_log("Related posts for {$post_id}");
    wl_write_log($related_posts);
    return $related_posts;
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:42,代码来源:wordlift_shortcode_navigator.php


示例7: wl_admin_sync_to_redlink

/**
 * Sync the site to Redlink triple store and print out the post title being processed.
 */
function wl_admin_sync_to_redlink()
{
    $posts = get_posts(array('post_type' => 'any', 'posts_per_page' => -1));
    wl_write_log("wl_admin_sync_to_redlink [ post count :: " . sizeof($posts) . " ]");
    foreach ($posts as $post) {
        echo esc_html($post->post_title) . '<br/>';
        wl_linked_data_push_to_redlink($post->ID);
    }
    // Schedule the execution of SPARQL.
    wl_shutdown();
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:14,代码来源:wordlift_admin_sync.php


示例8: wl_entity_type_taxonomy_save_custom_meta

/**
 * Save extra taxonomy fields callback function.
 */
function wl_entity_type_taxonomy_save_custom_meta($term_id)
{
    if (isset($_POST['term_meta'])) {
        // Get the values for the term.
        $css_class = $_POST['term_meta']['css_class'];
        $uri = $_POST['term_meta']['uri'];
        $same_as = !empty($_POST['term_meta']['same_as']) ? preg_split("/\\r\\n|\\r|\\n/", $_POST['term_meta']['same_as']) : array();
        // Update the term data.
        wl_entity_type_taxonomy_update_term($term_id, $css_class, $uri, $same_as);
        wl_write_log("wl_entity_type_save_taxonomy_custom_meta [ term id :: {$term_id} ]");
    }
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:15,代码来源:wordlift_admin_entity_type_taxonomy.php


示例9: wl_save_image

/**
 * Save the image with the specified URL locally. To the local filename a uniqe serial is appended to ensure its uniqueness.
 *
 * @param string $url The image remote URL.
 *
 * @return array An array with information about the saved image (*path*: the local path to the image, *url*: the local
 * url, *content_type*: the image content type)
 */
function wl_save_image($url)
{
    $parts = parse_url($url);
    $path = $parts['path'];
    // Get the bare filename (filename w/o the extension).
    // Sanitize filename before saving the current image as attachment
    // See https://codex.wordpress.org/Function_Reference/sanitize_file_name
    $basename = sanitize_file_name(pathinfo($path, PATHINFO_FILENAME) . '-' . uniqid(date('YmdH-')));
    // Chunk the bare name to get a subpath.
    $chunks = chunk_split(strtolower($basename), 3, DIRECTORY_SEPARATOR);
    // Get the base dir.
    $wp_upload_dir = wp_upload_dir();
    $base_dir = $wp_upload_dir['basedir'];
    $base_url = $wp_upload_dir['baseurl'];
    // Get the full path to the local filename.
    $image_path = '/' . $chunks;
    $image_full_path = $base_dir . $image_path;
    $image_full_url = $base_url . $image_path;
    // Create the folders.
    if (!(file_exists($image_full_path) && is_dir($image_full_path))) {
        if (false === mkdir($image_full_path, 0777, true)) {
            wl_write_log("wl_save_image : failed creating dir [ image full path :: {$image_full_path} ]\n");
        }
    }
    // Request the remote file.
    $response = wp_remote_get($url);
    $content_type = wp_remote_retrieve_header($response, 'content-type');
    switch ($content_type) {
        case 'image/jpeg':
        case 'image/jpg':
            $extension = ".jpg";
            break;
        case 'image/svg+xml':
            $extension = ".svg";
            break;
        case 'image/gif':
            $extension = ".gif";
            break;
        case 'image/png':
            $extension = ".png";
            break;
        default:
            $extension = '';
    }
    // Complete the local filename.
    $image_full_path .= $basename . $extension;
    $image_full_url .= $basename . $extension;
    // Store the data locally.
    file_put_contents($image_full_path, wp_remote_retrieve_body($response));
    // wl_write_log( "wl_save_image [ url :: $url ][ content type :: $content_type ][ image full path :: $image_full_path ][ image full url :: $image_full_url ]\n" );
    // Return the path.
    return array('path' => $image_full_path, 'url' => $image_full_url, 'content_type' => $content_type);
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:61,代码来源:wordlift_linked_data_images.php


示例10: wl_remove_text_annotations

/**
 * Removes empty text annotations from the post content.
 *
 * @since 1.0.0
 *
 * @param array $data The post data.
 *
 * @return array mixed The post data array.
 */
function wl_remove_text_annotations($data)
{
    //    <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">
    //    $pattern = '/<span class=\\\"textannotation\\\" id=\\\"[^\"]+\\\">([^<]+)<\/span>/i';
    $pattern = '/<(\\w+)[^>]*\\sclass=\\\\"textannotation\\\\"[^>]*>([^<]+)<\\/\\1>/im';
    wl_write_log("Removing text annotations [ pattern :: {$pattern} ]");
    // Remove the pattern while it is found (match nested annotations).
    while (1 === preg_match($pattern, $data['post_content'])) {
        $data['post_content'] = preg_replace($pattern, '$2', $data['post_content'], -1, $count);
    }
    return $data;
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:21,代码来源:wordlift_admin.php


示例11: wl_core_delete_relation_instance

/**
* Remove a given relation instance 
* @uses $wpdb->delete() to perform the query
*
* @param int $subject_id The post ID | The entity post ID.
* @param string $predicate Name of the relation: 'what' | 'where' | 'when' | 'who'
* @param int $object_id The entity post ID.
*
* @return (boolean) False for failure. True for success.
*/
function wl_core_delete_relation_instance($subject_id, $predicate, $object_id)
{
    // Checks on subject and object
    if (!is_numeric($subject_id) || !is_numeric($object_id)) {
        return false;
    }
    // Checks on the given relation
    if (!wl_core_check_relation_predicate_is_supported($predicate)) {
        return false;
    }
    // Prepare interaction with db
    global $wpdb;
    wl_write_log("Going to delete relation instace [ subject_id :: {$subject_id} ] [ object_id :: {$object_id} ] [ predicate :: {$predicate} ]");
    // @see ttps://codex.wordpress.org/it:Riferimento_classi/wpdb#DELETE_di_righe
    $wpdb->delete(wl_core_get_relation_instances_table_name(), array('subject_id' => $subject_id, 'predicate' => $predicate, 'object_id' => $object_id), array('%d', '%s', '%d'));
    return true;
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:27,代码来源:wordlift_core_post_entity_relations.php


示例12: wl_build_entity_uri

/**
 * Build the entity URI given the entity's post.
 *
 * @uses wl_sanitize_uri_path() to sanitize the post title.
 * @uses wl_configuration_get_redlink_dataset_uri() to get the dataset base URI.
 *
 * @param int $post_id The post ID
 *
 * @return string The URI of the entity
 */
function wl_build_entity_uri($post_id)
{
    // Get the post.
    $post = get_post($post_id);
    if (null === $post) {
        wl_write_log("wl_build_entity_uri : error [ post ID :: {$post_id} ][ post :: null ]");
        return null;
    }
    // Create an ID given the title.
    $path = wl_sanitize_uri_path($post->post_title);
    // If the path is empty, i.e. there's no title, use the post ID as path.
    if (empty($path)) {
        $path = "id/{$post->ID}";
    }
    // Create the URL (dataset base URI has a trailing slash).
    $url = sprintf('%s/%s/%s', wl_configuration_get_redlink_dataset_uri(), $post->post_type, $path);
    // wl_write_log( "wl_build_entity_uri [ post_id :: $post->ID ][ type :: $post->post_type ][ title :: $post->post_title ][ url :: $url ]" );
    return $url;
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:29,代码来源:wordlift_entity_functions.php


示例13: wl_content_embed_item_microdata

/**
 * Embed the entity properties as microdata in the content.
 *
 * @param string $content A content.
 * @param string $uri An entity URI.
 * @param string $itemprop Specifies which property this entity is for another entity. Useful for recursive markup.
 *
 * @return string The content with embedded microdata.
 */
function wl_content_embed_item_microdata($content, $uri, $itemprop = null, $recursion_level = 0)
{
    if ($recursion_level > wl_config_get_recursion_depth()) {
        wl_write_log("recursion depth limit exceeded [ level :: {$recursion_level} ][ max :: " . wl_config_get_recursion_depth() . " ]");
        return '';
    }
    $post = wl_get_entity_post_by_uri($uri);
    // Entity not found or not published. Delete <span> tags but leave their content on page.
    if (null === $post || $post->post_status !== 'publish') {
        // wl_write_log( "wl_content_embed_item_microdata : entity not found or not published [ uri :: $uri ]" );
        // Replace the original tagging with the new tagging.
        $regex = wl_content_embed_build_regex_from_uri($uri);
        $content = preg_replace($regex, '$2', $content);
        return $content;
    }
    // Get the entity URI and its escaped version for the regex.
    $entity_uri = wl_get_entity_uri($post->ID);
    // Get the main type.
    $main_type = wl_entity_type_taxonomy_get_type($post->ID);
    // Set the item type if available.
    $item_type = null === $main_type ? '' : ' itemtype="' . esc_attr($main_type['uri']) . '"';
    // Define attribute itemprop if this entity is nested.
    if (!is_null($itemprop)) {
        $itemprop = ' itemprop="' . $itemprop . '"';
    }
    // Get additional properties (this may imply a recursion of this method on a sub-entity).
    $additional_properties = wl_content_embed_compile_microdata_template($post->ID, $main_type, $recursion_level);
    $same_as = '';
    // Get the array of sameAs uris.
    $same_as_uris = wl_schema_get_value($post->ID, 'sameAs');
    // Prepare the sameAs fragment.
    foreach ($same_as_uris as $same_as_uri) {
        $same_as .= "<link itemprop=\"sameAs\" href=\"{$same_as_uri}\">";
    }
    // Get the entity URL.
    $permalink = get_permalink($post->ID);
    $url = '<link itemprop="url" href="' . $permalink . '" />';
    // Replace the original tagging with the new tagging.
    $regex = wl_content_embed_build_regex_from_uri($uri);
    $content = preg_replace($regex, '<$1' . $itemprop . ' itemscope' . $item_type . ' itemid="' . esc_attr($entity_uri) . '">' . $same_as . $additional_properties . $url . '<a class="wl-entity-page-link" href="' . $permalink . '" itemprop="name" content="' . $post->post_title . '">' . (is_null($itemprop) ? '$2' : '') . '</a></$1>', $content);
    // wl_write_log( "wl_content_embed_item_microdata [ uri :: $uri ][ regex :: $regex ]" );
    return $content;
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:52,代码来源:wordlift_content_filter.php


示例14: test_shortcode_chord_ajax

 public function test_shortcode_chord_ajax()
 {
     // TODO: fix content-type tests.
     $this->markTestSkipped('Content Type tests are failing, needs fix');
     if (!function_exists('xdebug_get_headers')) {
         $this->markTestSkipped('xdebug is required for this test');
     }
     $post_id = wl_create_post('This is Post 1', 'post-1', 'Post 1', 'publish');
     $entity_1_id = wl_create_post('This is Entity 1', 'entity-1', 'Entity 1', 'publish', 'entity');
     wl_set_entity_main_type($entity_1_id, 'http://schema.org/Thing');
     $entity_2_id = wl_create_post('This is Entity 2', 'entity-2', 'Entity 2', 'publish', 'entity');
     wl_set_entity_main_type($entity_2_id, 'http://schema.org/Thing');
     wl_core_add_relation_instances($post_id, WL_WHAT_RELATION, array($entity_1_id, $entity_2_id));
     $_REQUEST['post_id'] = $post_id;
     $_REQUEST['depth'] = 3;
     ob_start();
     wl_shortcode_chord_ajax();
     $headers = xdebug_get_headers();
     ob_end_clean();
     wl_write_log($headers);
     $this->assertTrue(in_array('Content-Type: application/json', $headers));
 }
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:22,代码来源:test-ajax.php


示例15: wl_analyze_content

/**
 * Analyze the provided content. The analysis will make use of the method *wl_ajax_analyze_action*
 * provided by the WordLift plugin.
 *
 * @since 1.0.0
 *
 * @uses wl_configuration_get_analyzer_url() to get the API for the analysis.
 *
 * @param string $content The content to analyze.
 *
 * @return string Returns null on failure, or the WP_Error, or a WP_Response with the response.
 */
function wl_analyze_content($content)
{
    // Get the analyzer URL.
    $url = wl_configuration_get_analyzer_url();
    // Prepare the request.
    $args = array_merge_recursive(unserialize(WL_REDLINK_API_HTTP_OPTIONS), array('method' => 'POST', 'headers' => array('Accept' => 'application/json', 'Content-type' => 'text/plain'), 'httpversion' => '1.0', 'body' => $content));
    $response = wp_remote_post($url, $args);
    // If an error has been raised, return the error.
    if (is_wp_error($response) || 200 !== (int) $response['response']['code']) {
        $body = is_wp_error($response) ? $response->get_error_message() : $response['body'];
        wl_write_log("error [ url :: {$url} ][ args :: ");
        wl_write_log(var_export($args, true));
        wl_write_log('][ response :: ');
        wl_write_log("\n" . var_export($response, true));
        wl_write_log("][ body :: ");
        wl_write_log("\n" . $body);
        wl_write_log("]");
        return null;
    }
    wl_write_log("[ url :: {$url} ][ response code :: " . $response['response']['code'] . " ]");
    return $response['body'];
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:34,代码来源:wordlift_analyzer.php


示例16: prepareFakeGlobalPostArrayFromFile

 function prepareFakeGlobalPostArrayFromFile($fileName)
 {
     $json_data = file_get_contents(dirname(__FILE__) . $fileName);
     $json_data = preg_replace('/{{REDLINK_ENDPOINT}}/', wl_configuration_get_redlink_dataset_uri(), $json_data);
     wl_write_log($json_data);
     $data = json_decode($json_data, true);
     return $data;
 }
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:8,代码来源:test-entity-creation-via-post-creation.php


示例17: rl_sparql_select

/**
 * Execute the provided query against the SPARQL SELECT Redlink end-point and return the response.
 *
 * @param string $query A SPARQL query.
 * @param string $accept The mime type for the response format (default = 'text/csv').
 *
 * @return WP_Response|WP_Error A WP_Response instance in successful otherwise a WP_Error.
 */
function rl_sparql_select($query)
{
    // Prepare the SPARQL statement by prepending the default namespaces.
    $sparql = rl_sparql_prefixes() . "\n" . $query;
    // Get the SPARQL SELECT URL.
    $url = wl_configuration_get_query_select_url('csv') . urlencode($sparql);
    // Prepare the request.
    $args = unserialize(WL_REDLINK_API_HTTP_OPTIONS);
    // Send the request.
    wl_write_log("SPARQL Select [ sparql :: {$sparql} ][ url :: {$url} ][ args :: " . var_export($args, true) . " ]");
    return wp_remote_get($url, $args);
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:20,代码来源:functions.php


示例18: wl_shortcode_chord_get_graph

/**
 * Optimize and convert retrieved content to JSON.
 *
 * @used-by wl_shortcode_chord_ajax
 *
 * @param $data
 * @return mixed|string|void
 */
function wl_shortcode_chord_get_graph($data)
{
    // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
    array_walk($data['entities'], function (&$item) {
        $post = get_post($item);
        // Skip non-existing posts.
        if (is_null($post)) {
            wl_write_log("wl_shortcode_chord_get_graph : post not found [ post id :: {$item} ]");
            return $item;
        }
        // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
        $term = wl_entity_type_taxonomy_get_type($item);
        wl_write_log("wl_shortcode_chord_get_graph [ post id :: {$post->ID} ][ term :: " . var_export($term, true) . " ]");
        $entity = array('uri' => wl_get_entity_uri($item), 'url' => get_permalink($item), 'label' => $post->post_title, 'type' => $post->post_type, 'thumbnails' => wl_get_image_urls($post->ID), 'css_class' => isset($term['css_class']) ? $term['css_class'] : '');
        $item = $entity;
    });
    // Refactor the relations.
    array_walk($data['relations'], function (&$item) {
        $relation = array('s' => wl_get_entity_uri($item[0]), 'o' => wl_get_entity_uri($item[1]));
        $item = $relation;
    });
    // Return the JSON representation.
    return $data;
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:32,代码来源:wordlift_shortcode_chord.php


示例19: wl_entities_box_content

/**
 * Displays the meta box contents (called by *add_meta_box* callback).
 *
 * @param WP_Post $post The current post.
 */
function wl_entities_box_content($post)
{
    wl_write_log("wl_entities_box_content [ post id :: {$post->ID} ]");
    // Angularjs edit-post widget wrapper
    echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
    // Angularjs edit-post widget classification boxes configuration
    $classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
    // Array to store all related entities ids
    $all_referenced_entities_ids = array();
    // Add selected entities to classification_boxes
    foreach ($classification_boxes as $i => $box) {
        // Build the proper relation name
        $relation_name = $box['id'];
        wl_write_log("Going to related of {$relation_name}");
        // Get entity ids related to the current post for the given relation name (both draft and published entities)
        $draft_entity_ids = wl_core_get_related_entity_ids($post->ID, array('predicate' => $relation_name, 'status' => 'draft'));
        $publish_entity_ids = wl_core_get_related_entity_ids($post->ID, array('predicate' => $relation_name, 'status' => 'publish'));
        $entity_ids = array_unique(array_merge($draft_entity_ids, $publish_entity_ids));
        // Store the entity ids for all the 4W
        $all_referenced_entities_ids = array_merge($all_referenced_entities_ids, $entity_ids);
        // Transform entity ids array in entity uris array
        array_walk($entity_ids, function (&$entity_id) {
            // Retrieve the entity uri for the given entity id
            $entity_id = wl_get_entity_uri($entity_id);
        });
        // Enhance current box selected entities
        $classification_boxes[$i]['selectedEntities'] = $entity_ids;
    }
    // Json encoding for classification boxes structure
    $classification_boxes = json_encode($classification_boxes);
    // Ensure there are no repetitions of the referenced entities
    $all_referenced_entities_ids = array_unique($all_referenced_entities_ids);
    // Build the entity storage object
    $referenced_entities_obj = array();
    foreach ($all_referenced_entities_ids as $referenced_entity) {
        $entity = wl_serialize_entity($referenced_entity);
        $referenced_entities_obj[$entity['id']] = $entity;
    }
    $referenced_entities_obj = empty($referenced_entities_obj) ? '{}' : json_encode($referenced_entities_obj);
    $default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
    echo <<<EOF
    <script type="text/javascript">
        jQuery( function() {
        \tif ('undefined' == typeof window.wordlift) {
            \twindow.wordlift = {}
            \twindow.wordlift.entities = {}  \t\t
        \t}

        \twindow.wordlift.classificationBoxes = {$classification_boxes};
        \twindow.wordlift.entities = {$referenced_entities_obj};
        \twindow.wordlift.currentPostId = {$post->ID};
\t\t\twindow.wordlift.defaultThumbnailPath = '{$default_thumbnail_path}';


        });
    </script>
EOF;
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:63,代码来源:wordlift_admin_meta_box_entities.php


示例20: wl_caching_get_filename

/**
 * Get the cache filename. If a file is found but is expired, it is deleted and false is returned.
 *
 * @since 3.0.0
 *
 * @uses wl_caching_get_temp_path() to get the base cache filename.
 * @uses wl_caching_delete_file() to delete the cached file.
 *
 * @param string $hash The hash.
 * @return string|false The cache filename or false if not found.
 */
function wl_caching_get_filename($hash)
{
    $files = glob(wl_caching_get_temp_path($hash) . '_*');
    if (!is_array($files) || 0 === sizeof($files)) {
        return false;
    }
    // Get the filename.
    $filename = $files[0];
    // Return false if the filename doesn't conform.
    $matches = array();
    if (1 !== preg_match('/_(\\d+)$/', $filename, $matches)) {
        return false;
    }
    // echo 'time: ' . time() . ' > expires at: ' . (int)$matches[1] . "\n";
    // Delete the file and return false if it's expired.
    if (time() >= (int) $matches[1]) {
        wl_caching_delete_file($filename);
        return false;
    }
    wl_write_log("[ wl_caching ] Found a cached response [ filename :: {$filename} ]");
    return $filename;
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:33,代码来源:wordlift_caching.php



注:本文中的wl_write_log函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wlm_arrval函数代码示例发布时间:2022-05-23
下一篇:
PHP wl_configure_wordpress_test函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap