百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

KayueWordpressBundle

> 编程语言
开源

一个 Symfony 2 组件,用于提供 WordPress 仓库和验证用户(登录)。

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个 Symfony 2 组件,用于提供 WordPress 仓库和验证用户(登录)。

KayueWordpressBundle

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.

Features

  • WordPress authentication (v1.0.0)
  • Custom table prefix (v1.0.1)
  • WordPress entities (v1.0.2)
  • Multisite support (v1.1.0)
  • Twig extension (v1.1.0)
  • WordPress style shortcode (v1.1.0)
  • Major code update. (v2.0.0)
  • Support Symfony 4, new cache configuration (v4.0.0)

Todo

  • Unit test (please help!)

Installation

Composer

composer require kayue/kayue-wordpress-bundle

Register the bundle

…

Twig Extension

This bundle comes with the following Twig extensions.

Functions

  • 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_post
  • wp_find_featured_image - equivalent to WordPress's get_the_post_thumbnail method.
  • wp_get_attachment_url($post)
  • wp_get_post_format
  • wp_find_terms_by_post
  • wp_find_categories_by_post - equivalent to WordPress's get_categories() method.
  • wp_find_tags_by_post - equivalent to WordPress's get_tags() method.

Filters

  • wp_autop - Wrap paragraph with tag. Needed for post formatting.
  • wp_texturize - Texturize. Needed for post formatting
  • wp_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

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.

php
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);
}

WordPress Authentication

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.

…

Shortcode

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

  1. extends ShortcodeInterface
  2. tag it with kayue_wordpress.shortcode
php
<?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
";
    }
}
}
yaml
services:
    acme_demo_bundle.wordpress.shortcode.gallery:
        class: Acme\DemoBundle\Wordpress\Shortcode\GalleryShortcode
        tags:
            - { name: kayue_wordpress.shortcode }

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言