Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Themer ACF get_row_index();
생성일
3년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
0 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
174 행
복사
13 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
183 행
복사
<?php
<?php
/**
/**
* ACF repeater and flexible content shortcode
* ACF repeater and flexible content shortcode
* support for the theme builder.
* support for the theme builder.
*
*
* @since 1.1.2
* @since 1.1.2
*/
*/
final class FLThemeBuilderACFRepeater {
final class FLThemeBuilderACFRepeater {
/**
/**
* Shortcode tags for ACF repeater fields.
* Shortcode tags for ACF repeater fields.
*
*
* @since 1.1.2
* @since 1.1.2
* @var array $repeater_shortcodes
* @var array $repeater_shortcodes
*/
*/
static private $repeater_shortcodes = array(
static private $repeater_shortcodes = array(
'wpbb-acf-flex',
'wpbb-acf-flex',
'wpbb-acf-repeater',
'wpbb-acf-repeater',
);
);
/**
/**
* Shortcode tags for ACF repeater field content.
* Shortcode tags for ACF repeater field content.
*
*
* @since 1.1.2
* @since 1.1.2
* @var array $content_shortcodes
* @var array $content_shortcodes
*/
*/
static private $content_shortcodes = array(
static private $content_shortcodes = array(
'wpbb',
'wpbb',
'wpbb-if',
'wpbb-if',
'wpbb-acf-layout',
'wpbb-acf-layout',
);
);
/**
/**
* All shortcode tags for ACF repeaters.
* All shortcode tags for ACF repeaters.
*
*
* @since 1.1.2
* @since 1.1.2
* @var array $all_shortcodes
* @var array $all_shortcodes
*/
*/
static private $all_shortcodes = array(
static private $all_shortcodes = array(
'wpbb-acf-flex',
'wpbb-acf-flex',
'wpbb-acf-repeater',
'wpbb-acf-repeater',
'wpbb',
'wpbb',
'wpbb-if',
'wpbb-if',
'wpbb-acf-layout',
'wpbb-acf-layout',
);
);
/**
/**
* @since 1.1.2
* @since 1.1.2
* @return void
* @return void
*/
*/
static public function init() {
static public function init() {
add_filter( 'fl_builder_before_render_shortcodes', __CLASS__ . '::parse_shortcodes', 1 );
add_filter( 'fl_builder_before_render_shortcodes', __CLASS__ . '::parse_shortcodes', 1 );
add_filter( 'fl_theme_builder_custom_post_grid_html', __CLASS__ . '::parse_shortcodes', 1 );
add_filter( 'fl_theme_builder_custom_post_grid_html', __CLASS__ . '::parse_shortcodes', 1 );
add_shortcode( 'wpbb-acf-repeater', __CLASS__ . '::parse_shortcode' );
add_shortcode( 'wpbb-acf-repeater', __CLASS__ . '::parse_shortcode' );
add_shortcode( 'wpbb-acf-flex', __CLASS__ . '::parse_shortcode' );
add_shortcode( 'wpbb-acf-flex', __CLASS__ . '::parse_shortcode' );
add_shortcode( 'wpbb-acf-layout', __CLASS__ . '::parse_layout_shortcode' );
add_shortcode( 'wpbb-acf-layout', __CLASS__ . '::parse_layout_shortcode' );
복사
복사됨
복사
복사됨
// New Index Shortcode
add_shortcode( 'wpbb-acf-repeater-index', __CLASS__ . '::parse_index_shortcode' );
}
}
복사
복사됨
복사
복사됨
/**
/**
* Parse the repeater shortcode here instead of
* Parse the repeater shortcode here instead of
* relying on do_shortcode to make sure it's parsed
* relying on do_shortcode to make sure it's parsed
* before other wpbb shortcodes.
* before other wpbb shortcodes.
*
*
* @since 1.1.2
* @since 1.1.2
* @param string $content
* @param string $content
* @return string
* @return string
*/
*/
static public function parse_shortcodes( $content ) {
static public function parse_shortcodes( $content ) {
return FLThemeBuilderFieldConnections::parse_shortcodes(
return FLThemeBuilderFieldConnections::parse_shortcodes(
$content,
$content,
self::$repeater_shortcodes
self::$repeater_shortcodes
);
);
}
}
/**
/**
* Parses the ACF repeater and flex shortcodes.
* Parses the ACF repeater and flex shortcodes.
*
*
* @since 1.1.2
* @since 1.1.2
* @param array $attrs
* @param array $attrs
* @param string $content
* @param string $content
* @return string
* @return string
*/
*/
static public function parse_shortcode( $attrs, $content = '' ) {
static public function parse_shortcode( $attrs, $content = '' ) {
if ( ! isset( $attrs['name'] ) ) {
if ( ! isset( $attrs['name'] ) ) {
return '';
return '';
}
}
// Yoast will throw a fatal error if shortcodes are found in regular wp content.
// Yoast will throw a fatal error if shortcodes are found in regular wp content.
if ( ! class_exists( 'FLPageDataACF' ) ) {
if ( ! class_exists( 'FLPageDataACF' ) ) {
return '';
return '';
}
}
$name = trim( $attrs['name'] );
$name = trim( $attrs['name'] );
$type = isset( $attrs['type'] ) ? $attrs['type'] : 'post';
$type = isset( $attrs['type'] ) ? $attrs['type'] : 'post';
$id = FLPageDataACF::get_object_id_by_type( $type );
$id = FLPageDataACF::get_object_id_by_type( $type );
$parsed = '';
$parsed = '';
if ( have_rows( $name, $id ) ) {
if ( have_rows( $name, $id ) ) {
while ( have_rows( $name, $id ) ) {
while ( have_rows( $name, $id ) ) {
the_row();
the_row();
$content = self::escape_nested_shortcodes( $content );
$content = self::escape_nested_shortcodes( $content );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes );
$row = self::unescape_nested_shortcodes( $row );
$row = self::unescape_nested_shortcodes( $row );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes );
복사
복사됨
복사
복사됨
$parsed .=
$row
;
$parsed .=
do_shortcode(
$row
)
;
}
}
} else {
} else {
$content = self::escape_nested_shortcodes( $content );
$content = self::escape_nested_shortcodes( $content );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes );
$row = self::unescape_nested_shortcodes( $row );
$row = self::unescape_nested_shortcodes( $row );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes );
$row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes );
복사
복사됨
복사
복사됨
$parsed .=
$row
;
$parsed .=
do_shortcode(
$row
)
;
}
}
return $parsed;
return $parsed;
}
}
복사
복사됨
복사
복사됨
static public function parse_index_shortcode() {
$index = get_row_index();
return "$index";
}
/**
/**
* Parses the ACF layout shortcode for flexible content.
* Parses the ACF layout shortcode for flexible content.
*
*
* @since 1.1.2
* @since 1.1.2
* @param array $attrs
* @param array $attrs
* @param string $content
* @param string $content
* @return string
* @return string
*/
*/
static public function parse_layout_shortcode( $attrs, $content = '' ) {
static public function parse_layout_shortcode( $attrs, $content = '' ) {
if ( ! isset( $attrs['name'] ) || get_row_layout() !== $attrs['name'] ) {
if ( ! isset( $attrs['name'] ) || get_row_layout() !== $attrs['name'] ) {
return '';
return '';
}
}
return FLThemeBuilderFieldConnections::parse_shortcodes(
return FLThemeBuilderFieldConnections::parse_shortcodes(
$content,
$content,
self::$all_shortcodes
self::$all_shortcodes
);
);
}
}
/**
/**
* Escapes nested wpbb shortcodes so they are not parsed
* Escapes nested wpbb shortcodes so they are not parsed
* when the parent repeater is.
* when the parent repeater is.
*
*
* @since 1.1.2
* @since 1.1.2
* @param string $content
* @param string $content
* @return string
* @return string
*/
*/
static public function escape_nested_shortcodes( $content ) {
static public function escape_nested_shortcodes( $content ) {
$pattern = '/\[wpbb-acf-nested-repeater.*?\][\d\D]*?\[\/wpbb-acf-nested-repeater\]/i';
$pattern = '/\[wpbb-acf-nested-repeater.*?\][\d\D]*?\[\/wpbb-acf-nested-repeater\]/i';
preg_match_all( $pattern, $content, $matches );
preg_match_all( $pattern, $content, $matches );
foreach ( $matches as $match ) {
foreach ( $matches as $match ) {
$content = str_replace( $match, str_replace( 'wpbb', 'wpbb-nested', $match ), $content );
$content = str_replace( $match, str_replace( 'wpbb', 'wpbb-nested', $match ), $content );
}
}
return $content;
return $content;
}
}
/**
/**
* Unescapes nested shortcodes so they can be parsed.
* Unescapes nested shortcodes so they can be parsed.
*
*
* @since 1.1.2
* @since 1.1.2
* @param string $content
* @param string $content
* @return string
* @return string
*/
*/
static public function unescape_nested_shortcodes( $content ) {
static public function unescape_nested_shortcodes( $content ) {
$content = str_replace( 'wpbb-nested', 'wpbb', $content );
$content = str_replace( 'wpbb-nested', 'wpbb', $content );
$content = str_replace( 'wpbb-acf-nested-repeater', 'wpbb-acf-repeater', $content );
$content = str_replace( 'wpbb-acf-nested-repeater', 'wpbb-acf-repeater', $content );
return $content;
return $content;
}
}
}
}
FLThemeBuilderACFRepeater::init();
FLThemeBuilderACFRepeater::init();
저장된 비교 결과
원본
파일 열기
<?php /** * ACF repeater and flexible content shortcode * support for the theme builder. * * @since 1.1.2 */ final class FLThemeBuilderACFRepeater { /** * Shortcode tags for ACF repeater fields. * * @since 1.1.2 * @var array $repeater_shortcodes */ static private $repeater_shortcodes = array( 'wpbb-acf-flex', 'wpbb-acf-repeater', ); /** * Shortcode tags for ACF repeater field content. * * @since 1.1.2 * @var array $content_shortcodes */ static private $content_shortcodes = array( 'wpbb', 'wpbb-if', 'wpbb-acf-layout', ); /** * All shortcode tags for ACF repeaters. * * @since 1.1.2 * @var array $all_shortcodes */ static private $all_shortcodes = array( 'wpbb-acf-flex', 'wpbb-acf-repeater', 'wpbb', 'wpbb-if', 'wpbb-acf-layout', ); /** * @since 1.1.2 * @return void */ static public function init() { add_filter( 'fl_builder_before_render_shortcodes', __CLASS__ . '::parse_shortcodes', 1 ); add_filter( 'fl_theme_builder_custom_post_grid_html', __CLASS__ . '::parse_shortcodes', 1 ); add_shortcode( 'wpbb-acf-repeater', __CLASS__ . '::parse_shortcode' ); add_shortcode( 'wpbb-acf-flex', __CLASS__ . '::parse_shortcode' ); add_shortcode( 'wpbb-acf-layout', __CLASS__ . '::parse_layout_shortcode' ); } /** * Parse the repeater shortcode here instead of * relying on do_shortcode to make sure it's parsed * before other wpbb shortcodes. * * @since 1.1.2 * @param string $content * @return string */ static public function parse_shortcodes( $content ) { return FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$repeater_shortcodes ); } /** * Parses the ACF repeater and flex shortcodes. * * @since 1.1.2 * @param array $attrs * @param string $content * @return string */ static public function parse_shortcode( $attrs, $content = '' ) { if ( ! isset( $attrs['name'] ) ) { return ''; } // Yoast will throw a fatal error if shortcodes are found in regular wp content. if ( ! class_exists( 'FLPageDataACF' ) ) { return ''; } $name = trim( $attrs['name'] ); $type = isset( $attrs['type'] ) ? $attrs['type'] : 'post'; $id = FLPageDataACF::get_object_id_by_type( $type ); $parsed = ''; if ( have_rows( $name, $id ) ) { while ( have_rows( $name, $id ) ) { the_row(); $content = self::escape_nested_shortcodes( $content ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); $row = self::unescape_nested_shortcodes( $row ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes ); $parsed .= $row; } } else { $content = self::escape_nested_shortcodes( $content ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); $row = self::unescape_nested_shortcodes( $row ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes ); $parsed .= $row; } return $parsed; } /** * Parses the ACF layout shortcode for flexible content. * * @since 1.1.2 * @param array $attrs * @param string $content * @return string */ static public function parse_layout_shortcode( $attrs, $content = '' ) { if ( ! isset( $attrs['name'] ) || get_row_layout() !== $attrs['name'] ) { return ''; } return FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); } /** * Escapes nested wpbb shortcodes so they are not parsed * when the parent repeater is. * * @since 1.1.2 * @param string $content * @return string */ static public function escape_nested_shortcodes( $content ) { $pattern = '/\[wpbb-acf-nested-repeater.*?\][\d\D]*?\[\/wpbb-acf-nested-repeater\]/i'; preg_match_all( $pattern, $content, $matches ); foreach ( $matches as $match ) { $content = str_replace( $match, str_replace( 'wpbb', 'wpbb-nested', $match ), $content ); } return $content; } /** * Unescapes nested shortcodes so they can be parsed. * * @since 1.1.2 * @param string $content * @return string */ static public function unescape_nested_shortcodes( $content ) { $content = str_replace( 'wpbb-nested', 'wpbb', $content ); $content = str_replace( 'wpbb-acf-nested-repeater', 'wpbb-acf-repeater', $content ); return $content; } } FLThemeBuilderACFRepeater::init();
수정본
파일 열기
<?php /** * ACF repeater and flexible content shortcode * support for the theme builder. * * @since 1.1.2 */ final class FLThemeBuilderACFRepeater { /** * Shortcode tags for ACF repeater fields. * * @since 1.1.2 * @var array $repeater_shortcodes */ static private $repeater_shortcodes = array( 'wpbb-acf-flex', 'wpbb-acf-repeater', ); /** * Shortcode tags for ACF repeater field content. * * @since 1.1.2 * @var array $content_shortcodes */ static private $content_shortcodes = array( 'wpbb', 'wpbb-if', 'wpbb-acf-layout', ); /** * All shortcode tags for ACF repeaters. * * @since 1.1.2 * @var array $all_shortcodes */ static private $all_shortcodes = array( 'wpbb-acf-flex', 'wpbb-acf-repeater', 'wpbb', 'wpbb-if', 'wpbb-acf-layout', ); /** * @since 1.1.2 * @return void */ static public function init() { add_filter( 'fl_builder_before_render_shortcodes', __CLASS__ . '::parse_shortcodes', 1 ); add_filter( 'fl_theme_builder_custom_post_grid_html', __CLASS__ . '::parse_shortcodes', 1 ); add_shortcode( 'wpbb-acf-repeater', __CLASS__ . '::parse_shortcode' ); add_shortcode( 'wpbb-acf-flex', __CLASS__ . '::parse_shortcode' ); add_shortcode( 'wpbb-acf-layout', __CLASS__ . '::parse_layout_shortcode' ); // New Index Shortcode add_shortcode( 'wpbb-acf-repeater-index', __CLASS__ . '::parse_index_shortcode' ); } /** * Parse the repeater shortcode here instead of * relying on do_shortcode to make sure it's parsed * before other wpbb shortcodes. * * @since 1.1.2 * @param string $content * @return string */ static public function parse_shortcodes( $content ) { return FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$repeater_shortcodes ); } /** * Parses the ACF repeater and flex shortcodes. * * @since 1.1.2 * @param array $attrs * @param string $content * @return string */ static public function parse_shortcode( $attrs, $content = '' ) { if ( ! isset( $attrs['name'] ) ) { return ''; } // Yoast will throw a fatal error if shortcodes are found in regular wp content. if ( ! class_exists( 'FLPageDataACF' ) ) { return ''; } $name = trim( $attrs['name'] ); $type = isset( $attrs['type'] ) ? $attrs['type'] : 'post'; $id = FLPageDataACF::get_object_id_by_type( $type ); $parsed = ''; if ( have_rows( $name, $id ) ) { while ( have_rows( $name, $id ) ) { the_row(); $content = self::escape_nested_shortcodes( $content ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); $row = self::unescape_nested_shortcodes( $row ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes ); $parsed .= do_shortcode( $row ); } } else { $content = self::escape_nested_shortcodes( $content ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); $row = self::unescape_nested_shortcodes( $row ); $row = FLThemeBuilderFieldConnections::parse_shortcodes( $row, self::$repeater_shortcodes ); $parsed .= do_shortcode( $row ); } return $parsed; } static public function parse_index_shortcode() { $index = get_row_index(); return "$index"; } /** * Parses the ACF layout shortcode for flexible content. * * @since 1.1.2 * @param array $attrs * @param string $content * @return string */ static public function parse_layout_shortcode( $attrs, $content = '' ) { if ( ! isset( $attrs['name'] ) || get_row_layout() !== $attrs['name'] ) { return ''; } return FLThemeBuilderFieldConnections::parse_shortcodes( $content, self::$all_shortcodes ); } /** * Escapes nested wpbb shortcodes so they are not parsed * when the parent repeater is. * * @since 1.1.2 * @param string $content * @return string */ static public function escape_nested_shortcodes( $content ) { $pattern = '/\[wpbb-acf-nested-repeater.*?\][\d\D]*?\[\/wpbb-acf-nested-repeater\]/i'; preg_match_all( $pattern, $content, $matches ); foreach ( $matches as $match ) { $content = str_replace( $match, str_replace( 'wpbb', 'wpbb-nested', $match ), $content ); } return $content; } /** * Unescapes nested shortcodes so they can be parsed. * * @since 1.1.2 * @param string $content * @return string */ static public function unescape_nested_shortcodes( $content ) { $content = str_replace( 'wpbb-nested', 'wpbb', $content ); $content = str_replace( 'wpbb-acf-nested-repeater', 'wpbb-acf-repeater', $content ); return $content; } } FLThemeBuilderACFRepeater::init();
비교하기