一个 Symfony 2 组件,用于提供 WordPress 仓库和验证用户(登录)。
Improved version of the original WordpressBundle. The biggest different is this new KayueWordpressBundle won't load the entire WordPress core, thus all the WordPress template funtions won't be available in your Symfony app. This is also the goal of the bundle; do everything in Symfony's way.
I started that bundle two years ago and the original repository grew somewhat chaotically, so I decided to start fresh with new repositories.
composer require kayue/kayue-wordpress-bundle…This bundle comes with the following Twig extensions.
wp_switch_blog - equivalent to WordPress's switch_to_blog() method.wp_find_option_by - equivalent to WordPress's get_option() method.wp_find_post_by - Get post by ID or slug.wp_find_post_metas_by($post, $key) - equivalent to WordPress's get_post_meta() method.wp_find_post_metas_by({'post': $post, 'key': $key}) - Same as above, accept array as argument.wp_find_comments_by_post($post) - return all approved comments in a post.wp_find_attachments_by_post($post)wp_find_attachment_by_id($id)wp_find_thumbnail($post) - alias of wp_find_featured_image_by_postwp_find_featured_image - equivalent to WordPress's get_the_post_thumbnail method.wp_get_attachment_url($post)wp_get_post_formatwp_find_terms_by_postwp_find_categories_by_post - equivalent to WordPress's get_categories() method.wp_find_tags_by_post - equivalent to WordPress's get_tags() method.wp_autop - Wrap paragraph with tag. Needed for post formatting.wp_texturize - Texturize. Needed for post formattingwp_shortcode - equivalent to WordPress's do_shortcode() method.To transform extra content like video links or social network links, you can use the Essence Bundle
Multisite is a feature of WordPress that allows multiple virtual sites to share a single WordPress installation. In this bundle, each blog (site) has its own entity manager. You need to use blog manager to retrive the blog and then the entity manager.
The following example shows you how to display the latest 10 posts in blog 2.
get('kayue_wordpress')->getManager();
$blogManager->setCurrentBlogId(2);
$this->getRepository('KayueWordpressBundle:Post')->findOnePostById(1);
// Method 2: Use entity manager if you don't want to switch the entire blog.
// This won't change the current blog ID.
$blogId = 3;
$anotherBlog = $this->get('kayue_wordpress')->getManager($blogId);
$posts = $anotherBlog->getRepository('KayueWordpressBundle:Post')->findOneById(1);
}This bundle allow you to create a WordPress login form in Symfony. All you have to do is to configure the WordPress firewall in your security.yml.
The following example demonstrates how to turn AcmeDemoBundle's login form into a WordPress login form.
…WordpressBundle support WordPress style shortcode. At the moment the bundle only come with the [caption] and [gallery] shortcode.
Pull request is welcome.
To create new shortcode, you need to
ShortcodeInterfacekayue_wordpress.shortcode<?php
use Kayue\WordpressBundle\Wordpress\Shortcode\ShortcodeInterface;
class GalleryShortcode implements ShortcodeInterface
{
public function getName()
{
return 'gallery';
}
public function($attr, $content = null)
{
// do your things...
return "
Return HTML
";
}
}
}services:
acme_demo_bundle.wordpress.shortcode.gallery:
class: Acme\DemoBundle\Wordpress\Shortcode\GalleryShortcode
tags:
- { name: kayue_wordpress.shortcode }暂无开放 Issues,或尚未同步最近议题。