如何使这个WordPress插件更优雅,更快?

时间:2019-12-18 12:21:22

标签: php wordpress performance pagespeed

我编写了以下插件,该插件将字段添加到媒体/附件条目中,并以一个Shortcode返回所有信息。此解决方案有效,但是,可用的条目越多,速度就越慢。

我知道问题出在while循环中。但是,我包含了整个代码,以便查看我要实现的目标:

import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';

describe('#updateFilter()', () => {

    let fixture: ComponentFixture<FilterComponent>;
    let component: FilterComponent;
    let inputElement: HTMLInputElement;

    beforeEach(() => {
        TestBed.configureTestingModule({
            declarations: [FilterComponent]
        });
        fixture = TestBed.createComponent(FilterComponent);
        fixture.detectChanges();
        component = fixture.componentInstance;
        inputElement = <HTMLInputElement> fixture.debugElement.nativeElement.querySelector('INPUT');
        fixture.detectChanges();
    });

    it('format input string to lowercase', fakeAsync(() => {

        //given
        component.t = ?; // no idea what this member is made of
        inputElement.value = 'abC'; 
        const event = new KeyboardEvent('keydown', { key: 'C' });

        // when            
        inputElement.dispatchEvent(event);
        tick();

        // then
        expect(component.data).toBe(?); // define expected value here
    });

    ...
});

先谢谢了。感谢您的努力!

0 个答案:

没有答案