定制 kyosifov/carbon-fields-urlpicker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kyosifov/carbon-fields-urlpicker

Composer 安装命令:

composer require kyosifov/carbon-fields-urlpicker

包简介

Carbon Fields extension, that adds a URL picker field type.

README 文档

README

(this is an extension of Carbon Fields plugin)

Adds a urlpicker field type to Carbon Fields. Install using composer:

composer require kyosfiov/carbon-fields-urlpicker

(first, make sure you have "minimum-stability": "dev" set in composer.json)

Or by installing as a WP plugin (composer is recommended though; installing as a plugin may throw an error).

Return values:

The field will return an associative array with the following values:

url: the actual URL
anchor: the text anchor (might be blank)
blank: wether the link should open in a new window or not

Example

Registering A Field

This goes in your functions.php as with other Carbon Fields fields. The only difference is that the type is urlpicker.

use Carbon_Fields\Container;
use Carbon_Fields\Field;

add_action( 'carbon_fields_register_fields', 'crb_url_picker_test' );

function crb_url_picker_test() {
  Container::make( 'post_meta', 'URL Picker Test' )
    ->add_fields( array(
      Field::make( 'urlpicker', 'crb_my_link', 'URL Picker Test' )
      	->set_help_text( "This is a test of the URL picker." )
    ));
}

Using Field Values

<?php $my_link = carbon_get_the_post_meta( 'crb_my_link' ); ?>
<a href="<?php $my_link[url] ?>"<?php ( $my_link[blank] ? ' target="_blank"' : '') ?>><?php $my_link[anchor] ?></a>

Note that the anchor field will return 0 or 1, depending on whether the checkbox is ticked next to "Open link in a new tab".

Gutenberg Integration

use Carbon_Fields\Block;

Block::make( __( 'My Shiny Gutenberg Block' ) )
    ->add_fields( array(
        Field::make( 'urlpicker', 'url_data', __( 'Link' ) ),
        Field::make( 'image', 'image', __( 'Block Image' ) ),
        Field::make( 'rich_text', 'content', __( 'Block Content' ) ),
    ) )
    ->set_render_callback( function ( $block ) {
        ?>

        <div class="block">
            <div class="block__heading">
            	<?php
            	$link_data = $block['url_data'];
            	?>
            	<a href="<?php $link_data['url'] ?>"<?php ( $link_data['blank'] ? ' target="_blank"' : '') ?>><?php $link_data['anchor'] ?></a>
            </div><!-- /.block__heading -->

            <div class="block__image">
                <?php echo wp_get_attachment_image( $block['image'], 'full' ); ?>
            </div><!-- /.block__image -->

            <div class="block__content">
                <?php echo apply_filters( 'the_content', $block['content'] ); ?>
            </div><!-- /.block__content -->
        </div><!-- /.block -->

        <?php
    } );

kyosifov/carbon-fields-urlpicker 适用场景与选型建议

kyosifov/carbon-fields-urlpicker 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 655 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 「carbon-field」 「carbon-fields-urlpicker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kyosifov/carbon-fields-urlpicker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kyosifov/carbon-fields-urlpicker 我们能提供哪些服务?
定制开发 / 二次开发

基于 kyosifov/carbon-fields-urlpicker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 655
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 18
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2019-01-30