function get_shortcode_id_from_content($shortcode_name) {
$post = get_post();
$post_content = $post->post_content;
// регулярка для поиска id
$pattern = sprintf('/\[%s[^\]]*id\s*=\s*[\'"]?(\d+)[\'"]?\]/', preg_quote($shortcode_name, '/'));
// ищем id, указанный в шорткоде
if (preg_match($pattern, $post_content, $matches)) {
return $matches[1]; // если найден
}
return false;
}
$id_from_shortcode = get_shortcode_id_from_content($shortcode_name);
on:
pull_request:
branches:
- master
types:
- closed
permissions:
pull-requests: read
contents: read
packages: write
jobs:
build:
name: Build and Deploy
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer
- name: Install PHP dependencies
run: composer install